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;
|
||||
|
||||
tofree = string = strdup("abc,def,ghi");
|
||||
if (string != NULL)
|
||||
while ((token = strsep(&string, ",")) != NULL)
|
||||
printf("%s\en", token);
|
||||
if (string == NULL)
|
||||
err(1, "strdup");
|
||||
while ((token = strsep(&string, ",")) != NULL)
|
||||
printf("%s\en", token);
|
||||
|
||||
free(tofree);
|
||||
.Ed
|
||||
|
Loading…
Reference in New Issue
Block a user