Skip to contentSkip to conversation

bug in strtok_r(3) man page

DISCUSSION Michael Kerrisk (man-pages) 1 participant 1 message Sep 23, 2019 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hello,

Quoted 10 lines · eponymous alias

The 2019-03-06 strtok_r(3) man page says:

On the first call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored.

Uh, no. That would make saveptr totally useless. A quick fix would be:

On the first call to strtok_r(), str should point to the string to be parsed, and the value of *saveptr is ignored.

Thanks. I applied the patch below.

Michael

man3/strtok.3 +2 -2
index 32552534e..9efb18a8d 100644
@@ -146,12 +146,12 @@ On the first call to
 .BR strtok_r (),
 .I str
 should point to the string to be parsed, and the value of
-.I saveptr
+.I *saveptr
 is ignored.
 In subsequent calls,
 .I str
 should be NULL, and
-.I saveptr
+.I *saveptr
 should be unchanged since the previous call.
 .PP
 Different strings may be parsed concurrently using sequences of calls to
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/