if (last_lr && (*last_lr + 1) != '\0')
count++;
strncat(cell->contents, buf, MSL);
strncat(cell->contents, buf, MSL - 1);
int count = 0;
char *last_lr = null;
…
/*
* For text such as
* 1) "line nr 1" and
* 2) "line nr 1\nline nr 2"
* add one to count.
* But not:
* 3) "line nr 1\nline nr 2\n"
*/
if (!last_lr || *(last_lr + 1) != '\0')
count++;
**
I downloaded Davion's grid code, compiled and used his example which crashed on first try. GDB indicated that crashing line was " if ((*last_lr + 1) != '\0')". As I can see in GDB, the cell passed in didn't have a "\n" in the contents so *last_lr never got set therefore accessing it and caused the crash.
To fix, I set the "int count = 1" (assuming that everyone has 1 line if I'm calling this).
My question for anyone who has used this, do you see any issues with my fix? I have not broken it thus far and it seems to work as expected now.
Crashed:
My fix which appears to work:
Also, love the end result, cool code Davion.