From 7cf6336f44640e772242831f5d2ef0247215886b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 19 Nov 2004 13:46:41 +0000 Subject: [PATCH] Move comments from strtok_r.c to strtok_r.h. --- lib/ChangeLog | 5 +++++ lib/strtok_r.c | 11 ----------- lib/strtok_r.h | 27 +++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index a31078e3c0..1cce5054bf 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2004-11-19 Bruno Haible + + * strtok_r.c: Move comments from here... + * strtok_r.h: ... to here. + 2004-11-17 Paul Eggert * realloc.c (rpl_realloc): Call 'free' if n==0, since realloc diff --git a/lib/strtok_r.c b/lib/strtok_r.c index e9c143e588..6b380832ad 100644 --- a/lib/strtok_r.c +++ b/lib/strtok_r.c @@ -41,17 +41,6 @@ x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL x = strtok_r(NULL, "=", &sp); // x = NULL // s = "abc\0-def\0" - - For the POSIX documentation for this function, see: - http://www.opengroup.org/onlinepubs/009695399/functions/strtok.html - - Caveat: It modifies the original string. - Caveat: These functions cannot be used on constant strings. - Caveat: The identity of the delimiting character is lost. - Caveat: It doesn't work with multibyte strings unless all of the delimiter - characters are ASCII characters < 0x30. - - See also strsep(). */ char * __strtok_r (char *s, const char *delim, char **save_ptr) diff --git a/lib/strtok_r.h b/lib/strtok_r.h index 1535209283..36ae7dbc42 100644 --- a/lib/strtok_r.h +++ b/lib/strtok_r.h @@ -22,9 +22,32 @@ /* Get strtok_r declaration, if available. */ #include +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" + + This is a variant of strtok() that is multithread-safe. + + For the POSIX documentation for this function, see: + http://www.opengroup.org/onlinepubs/009695399/functions/strtok.html + + Caveat: It modifies the original string. + Caveat: These functions cannot be used on constant strings. + Caveat: The identity of the delimiting character is lost. + Caveat: It doesn't work with multibyte strings unless all of the delimiter + characters are ASCII characters < 0x30. + + See also strsep(). +*/ #if defined HAVE_DECL_STRTOK_R && !HAVE_DECL_STRTOK_R -char *strtok_r(char *restrict s, const char *restrict sep, - char **restrict lasts); +extern char *strtok_r(char *restrict s, const char *restrict sep, + char **restrict lasts); #endif #endif /* STRTOK_R_H */ -- 2.30.2