[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] strtok_r diff from glibc?
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] strtok_r diff from glibc? |
Date: |
Thu, 18 Nov 2004 18:58:54 +0100 |
User-agent: |
KMail/1.5 |
Karl Berry wrote:
> Has this change been submitted to glibc?
No, and actually I think it would be quite useless to add lots of comments
to glibc source that is not installed and not viewed by most developers.
So I propose to move these comments to the .h file, and don't bother with
the glibc source file.
Opinions? Objections?
Bruno
diff -c -3 -r1.3 strtok_r.c
*** strtok_r.c 12 Nov 2004 16:18:49 -0000 1.3
--- strtok_r.c 18 Nov 2004 17:59:55 -0000
***************
*** 41,57 ****
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)
--- 41,46 ----
diff -c -3 -r1.1 strtok_r.h
*** strtok_r.h 12 Nov 2004 00:00:47 -0000 1.1
--- strtok_r.h 18 Nov 2004 17:59:55 -0000
***************
*** 22,30 ****
/* Get strtok_r declaration, if available. */
#include <string.h>
#if defined HAVE_DECL_STRTOK_R && !HAVE_DECL_STRTOK_R
! char *strtok_r(char *restrict s, const char *restrict sep,
! char **restrict lasts);
#endif
#endif /* STRTOK_R_H */
--- 22,51 ----
/* Get strtok_r declaration, if available. */
#include <string.h>
+ /* 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"
+
+ 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
! extern char *strtok_r(char *restrict s, const char *restrict sep,
! char **restrict lasts);
#endif
#endif /* STRTOK_R_H */