Sujet : Re: Buffer contents well-defined after fgets() reaches EOF ?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 16. Feb 2025, 08:37:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250215233538.938@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-02-16, James Kuyper <
jameskuyper@alumni.caltech.edu> wrote:
No. What makes strtok() problematic can come up without any use of
threads. Consider for the moment a bug I had to investigate. A function
that was looping through strtok() calls to parse a string called a
utility function during each pass through the loop. The utility function
also called strtok() in a loop to parse an entirely different string for
a different purpose. Exercise for the student: figure out what the
consequences were.
Moreover, if strtok is thread-safe thanks to using thread-specific
storage for the context, that will not make it recursion-safe. It will
make the bug behave predictably for the same inputs, no matter how other
threads use strtok.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca