strsep.3: don't silently ignore errors
Reported by: bde MFC with: r334275
This commit is contained in:
parent
5bd0cf6dc8
commit
0eff530775
@ -86,9 +86,10 @@ to parse a string, and prints each token in separate line:
|
|||||||
char *token, *string, *tofree;
|
char *token, *string, *tofree;
|
||||||
|
|
||||||
tofree = string = strdup("abc,def,ghi");
|
tofree = string = strdup("abc,def,ghi");
|
||||||
if (string != NULL)
|
if (string == NULL)
|
||||||
while ((token = strsep(&string, ",")) != NULL)
|
err(1, "strdup");
|
||||||
printf("%s\en", token);
|
while ((token = strsep(&string, ",")) != NULL)
|
||||||
|
printf("%s\en", token);
|
||||||
|
|
||||||
free(tofree);
|
free(tofree);
|
||||||
.Ed
|
.Ed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user