readtokens: avoid core dumps with unusual calling patterns
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 6 Mar 2012 23:19:24 +0000 (15:19 -0800)
committerJim Meyering <meyering@redhat.com>
Wed, 7 Mar 2012 12:32:34 +0000 (13:32 +0100)
commitcdf7ddacd56d8d31fb9a23b94a8b8f317a8a1066
tree55d47e9b30f055dcea54e67bb542f27f9a8d492e
parenta527a9487c50b607b06a9a57709ca2f3d6affe68
readtokens: avoid core dumps with unusual calling patterns

Reported by Xu Zhongxing in <http://debbugs.gnu.org/10953>.
* lib/readtokens.c: Include limits.h.
(word, bits_per_word, get_nth_bit, set_nth_bit): New.
(readtoken): Don't cache the delimiters; the cache code was buggy
if !delim && saved_delim, or if the new n_delim differs from the old.
Also, it wasn't thread-safe.
ChangeLog
lib/readtokens.c