X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrtok_r.h;h=7d3f21b5f0ec680ae8624a2cd1bba68f81d326e7;hb=cb07569c0de7172006a6dcf94adc5658fdaa523c;hp=1535209283fea7c3b78d16f6662e0c7770bf7030;hpb=854a5d353795189e727ba52631ec5b5862cbcb8f;p=gnulib.git diff --git a/lib/strtok_r.h b/lib/strtok_r.h index 153520928..7d3f21b5f 100644 --- a/lib/strtok_r.h +++ b/lib/strtok_r.h @@ -1,5 +1,5 @@ /* Split string into tokens - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004-2005 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef STRTOK_R_H #define 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/susv3xsh/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 */