From 7a364eb36494dcac90196db3d93d15086d6c1bc1 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 24 May 2002 00:13:57 +0000 Subject: 2002-05-23 Jeff Johnston * libc/string/Makefile.am: Add support for strsep.c. * libc/string/Makefile.in: Regenerated. * libc/string/strsep.c: New file. * libc/string/strtok.c: Change to call __strtok_r service routine. * libc/string/strtok_r.c: Add __strtok_r routine which takes additional flag parameter regarding whether to skip leading delimeters. Change strtok_r to call __strtok_r. --- newlib/libc/string/strtok.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'newlib/libc/string/strtok.c') diff --git a/newlib/libc/string/strtok.c b/newlib/libc/string/strtok.c index 292c16743..8d53290c7 100644 --- a/newlib/libc/string/strtok.c +++ b/newlib/libc/string/strtok.c @@ -1,6 +1,6 @@ /* FUNCTION - <>---get next token from a string + <>,<>,<>---get next token from a string INDEX strtok @@ -8,11 +8,15 @@ INDEX INDEX strtok_r +INDEX + strsep + ANSI_SYNOPSIS #include char *strtok(char *<[source]>, const char *<[delimiters]>) char *strtok_r(char *<[source]>, const char *<[delimiters]>, char **<[lasts]>) + char *strsep(char **<[source_ptr]>, const char *<[delimiters]>) TRAD_SYNOPSIS #include @@ -25,6 +29,10 @@ TRAD_SYNOPSIS char *<[delimiters]>; char **<[lasts]>; + char *strsep(<[source_ptr]>, <[delimiters]>) + char **<[source_ptr]>; + char *<[delimiters]>; + DESCRIPTION The <> function is used to isolate sequential tokens in a null-terminated string, <<*<[source]>>>. These tokens are delimited @@ -43,18 +51,30 @@ DESCRIPTION The <> function has the same behavior as <>, except a pointer to placeholder <<*[lasts]>> must be supplied by the caller. + The <> function is similar in behavior to <>, except + a pointer to the string pointer must be supplied <<[source_ptr]>> and + the function does not skip leading delimeters. When the string starts + with a delimeter, the delimeter is changed to the NUL character and + the empty string is returned. Like <> and <>, the + <<*[source_ptr]>> is updated to the next character following the + last delimeter found or NULL if the end of string is reached with + no more delimeters. + RETURNS - <> returns a pointer to the next token, or <> if - no more tokens can be found. + <>, <>, and <> all return a pointer to the + next token, or <> if no more tokens can be found. For + <>, a token may be the empty string. NOTES <> is unsafe for multi-thread applications. <> - is MT-Safe and should be used instead. + and <> are MT-Safe and should be used instead. PORTABILITY <> is ANSI C. +<> is POSIX. +<> is a BSD-extension. -<> requires no supporting OS subroutines. +<>, <>, and <> require no supporting OS subroutines. QUICKREF strtok ansi impure @@ -68,12 +88,14 @@ QUICKREF #ifndef _REENT_ONLY +extern char *__strtok_r (char *, const char *, char **, int); + char * _DEFUN (strtok, (s, delim), register char *s _AND register const char *delim) { _REENT_CHECK_MISC(_REENT); - return strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT))); + return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT)), 1); } #endif -- cgit v1.2.3