[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strtok_r in glibc 2.0.7 bugginess
In message <email@example.com>, Assar Westerlund writes:
| "Brandon S. Allbery KF8NH" <firstname.lastname@example.org> writes:
| > strtok() and strtok_r() are really pre-ANSI and in my experience are best
| > avoided.
| strtok() is ANSI but not reentrant, but I find strtok_r useful quite
| often. What do you use instead? strsep?
It was imported into ANSI because it was commonly used, but it predates ANSI
(it came from System III).
I generally write my own code in place to do such parsing, because most
often I find myself needing to special case something --- formerly, needing
a token separator which requires a special action (e.g. parsing "foo:bar" as
two tokens but associating the result, but "foo : bar" has to mean something
different) but more often these days because I end up needing to handle
Even in the quick-and-dirty cases like this one (deconstructing a
parameter), I usually prefer to do it manually so I can provide better error
checking/reporting. Too many cases of quick'n'dirty coming back to haunt
brandon s. allbery [os/2][linux][solaris][japh] email@example.com
system administrator [WAY too many hats] firstname.lastname@example.org
carnegie mellon / electrical and computer engineering KF8NH
We are Linux. Resistance is an indication that you missed the point.