parent
5118881e6c
commit
6b87e46e00
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
|
|
||||||
const char *BLANKS = " \t";
|
const char *BLANKS = " \t";
|
||||||
const char *TEXT = " hi there fr [ ie]nd";
|
const char *TEXT = "hi there fr [[] ie]nd] [] 23 ";
|
||||||
/* 01234567890123456789
|
/* 01234567890123456789
|
||||||
^ ^
|
^ ^
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,10 +32,9 @@ main(void)
|
||||||
while (NULL != rest) {
|
while (NULL != rest) {
|
||||||
/* How many chars have we got? */
|
/* How many chars have we got? */
|
||||||
diff = rest - text;
|
diff = rest - text;
|
||||||
/*printf("%ld\n", diff);*/
|
|
||||||
|
|
||||||
if (diff) {
|
if (diff) {
|
||||||
/* Allocate and copy out the substring. */
|
/* Allocate space and copy out the substring. */
|
||||||
snip = (char *)GC_malloc(diff + 1);
|
snip = (char *)GC_malloc(diff + 1);
|
||||||
strncat(snip, text, diff);
|
strncat(snip, text, diff);
|
||||||
printf("%s\n", snip);
|
printf("%s\n", snip);
|
||||||
|
|
@ -49,7 +48,11 @@ main(void)
|
||||||
/* */
|
/* */
|
||||||
text = trim_leading_blanks(++rest);
|
text = trim_leading_blanks(++rest);
|
||||||
/*printf(">>>%s\n\n", text);*/
|
/*printf(">>>%s\n\n", text);*/
|
||||||
rest = strpbrk(text, " []");
|
|
||||||
|
/* calling strpbrk on NULL caused segfault! */
|
||||||
|
rest = (NULL != text) ? strpbrk(text, " []") : text;
|
||||||
}
|
}
|
||||||
printf("%s\n", text);
|
if (text) {
|
||||||
|
printf("%s\n", text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue