2002-05-23 Jeff Johnston <jjohnstn@redhat.com>
* 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.
This commit is contained in:
parent
bb2b4dedc6
commit
7a364eb364
@ -1,3 +1,13 @@
|
|||||||
|
2002-05-23 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2002-05-23 Gareth Pearce <tilps@hotmail.com>
|
2002-05-23 Gareth Pearce <tilps@hotmail.com>
|
||||||
|
|
||||||
* libc/stdio/Makefile.am: Modify to add setbuffer.c and setlinebuf.c.
|
* libc/stdio/Makefile.am: Modify to add setbuffer.c and setlinebuf.c.
|
||||||
|
@ -33,6 +33,7 @@ LIB_SOURCES = \
|
|||||||
strncpy.c \
|
strncpy.c \
|
||||||
strpbrk.c \
|
strpbrk.c \
|
||||||
strrchr.c \
|
strrchr.c \
|
||||||
|
strsep.c \
|
||||||
strspn.c \
|
strspn.c \
|
||||||
strtok.c \
|
strtok.c \
|
||||||
strtok_r.c \
|
strtok_r.c \
|
||||||
|
@ -131,6 +131,7 @@ LIB_SOURCES = \
|
|||||||
strncpy.c \
|
strncpy.c \
|
||||||
strpbrk.c \
|
strpbrk.c \
|
||||||
strrchr.c \
|
strrchr.c \
|
||||||
|
strsep.c \
|
||||||
strspn.c \
|
strspn.c \
|
||||||
strtok.c \
|
strtok.c \
|
||||||
strtok_r.c \
|
strtok_r.c \
|
||||||
@ -181,9 +182,9 @@ lib_a_LIBADD =
|
|||||||
@USE_LIBTOOL_FALSE@rindex.o strcat.o strchr.o strcmp.o strcasecmp.o \
|
@USE_LIBTOOL_FALSE@rindex.o strcat.o strchr.o strcmp.o strcasecmp.o \
|
||||||
@USE_LIBTOOL_FALSE@strcoll.o strcpy.o strcspn.o strerror.o strlcat.o \
|
@USE_LIBTOOL_FALSE@strcoll.o strcpy.o strcspn.o strerror.o strlcat.o \
|
||||||
@USE_LIBTOOL_FALSE@strlcpy.o strlen.o strlwr.o strncat.o strncmp.o \
|
@USE_LIBTOOL_FALSE@strlcpy.o strlen.o strlwr.o strncat.o strncmp.o \
|
||||||
@USE_LIBTOOL_FALSE@strncasecmp.o strncpy.o strpbrk.o strrchr.o strspn.o \
|
@USE_LIBTOOL_FALSE@strncasecmp.o strncpy.o strpbrk.o strrchr.o strsep.o \
|
||||||
@USE_LIBTOOL_FALSE@strtok.o strtok_r.o strupr.o strxfrm.o strstr.o \
|
@USE_LIBTOOL_FALSE@strspn.o strtok.o strtok_r.o strupr.o strxfrm.o \
|
||||||
@USE_LIBTOOL_FALSE@swab.o u_strerr.o
|
@USE_LIBTOOL_FALSE@strstr.o swab.o u_strerr.o
|
||||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||||
|
|
||||||
libstring_la_LIBADD =
|
libstring_la_LIBADD =
|
||||||
@ -193,8 +194,9 @@ libstring_la_LIBADD =
|
|||||||
@USE_LIBTOOL_TRUE@strcasecmp.lo strcoll.lo strcpy.lo strcspn.lo \
|
@USE_LIBTOOL_TRUE@strcasecmp.lo strcoll.lo strcpy.lo strcspn.lo \
|
||||||
@USE_LIBTOOL_TRUE@strerror.lo strlcat.lo strlcpy.lo strlen.lo strlwr.lo \
|
@USE_LIBTOOL_TRUE@strerror.lo strlcat.lo strlcpy.lo strlen.lo strlwr.lo \
|
||||||
@USE_LIBTOOL_TRUE@strncat.lo strncmp.lo strncasecmp.lo strncpy.lo \
|
@USE_LIBTOOL_TRUE@strncat.lo strncmp.lo strncasecmp.lo strncpy.lo \
|
||||||
@USE_LIBTOOL_TRUE@strpbrk.lo strrchr.lo strspn.lo strtok.lo strtok_r.lo \
|
@USE_LIBTOOL_TRUE@strpbrk.lo strrchr.lo strsep.lo strspn.lo strtok.lo \
|
||||||
@USE_LIBTOOL_TRUE@strupr.lo strxfrm.lo strstr.lo swab.lo u_strerr.lo
|
@USE_LIBTOOL_TRUE@strtok_r.lo strupr.lo strxfrm.lo strstr.lo swab.lo \
|
||||||
|
@USE_LIBTOOL_TRUE@u_strerr.lo
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
19
newlib/libc/string/strsep.c
Normal file
19
newlib/libc/string/strsep.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* BSD strsep function */
|
||||||
|
|
||||||
|
/* Copyright 2002, Red Hat Inc. */
|
||||||
|
|
||||||
|
/* undef STRICT_ANSI so that strsep prototype will be defined */
|
||||||
|
#undef __STRICT_ANSI__
|
||||||
|
#include <string.h>
|
||||||
|
#include <_ansi.h>
|
||||||
|
#include <reent.h>
|
||||||
|
|
||||||
|
extern char *__strtok_r (char *, const char *, char **, int);
|
||||||
|
|
||||||
|
char *
|
||||||
|
_DEFUN (strsep, (source_ptr, delim),
|
||||||
|
register char **source_ptr _AND
|
||||||
|
register const char *delim)
|
||||||
|
{
|
||||||
|
return __strtok_r (*source_ptr, delim, source_ptr, 0);
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
FUNCTION
|
FUNCTION
|
||||||
<<strtok>>---get next token from a string
|
<<strtok>>,<<strtok_r>>,<<strsep>>---get next token from a string
|
||||||
|
|
||||||
INDEX
|
INDEX
|
||||||
strtok
|
strtok
|
||||||
@ -8,11 +8,15 @@ INDEX
|
|||||||
INDEX
|
INDEX
|
||||||
strtok_r
|
strtok_r
|
||||||
|
|
||||||
|
INDEX
|
||||||
|
strsep
|
||||||
|
|
||||||
ANSI_SYNOPSIS
|
ANSI_SYNOPSIS
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
char *strtok(char *<[source]>, const char *<[delimiters]>)
|
char *strtok(char *<[source]>, const char *<[delimiters]>)
|
||||||
char *strtok_r(char *<[source]>, const char *<[delimiters]>,
|
char *strtok_r(char *<[source]>, const char *<[delimiters]>,
|
||||||
char **<[lasts]>)
|
char **<[lasts]>)
|
||||||
|
char *strsep(char **<[source_ptr]>, const char *<[delimiters]>)
|
||||||
|
|
||||||
TRAD_SYNOPSIS
|
TRAD_SYNOPSIS
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -25,6 +29,10 @@ TRAD_SYNOPSIS
|
|||||||
char *<[delimiters]>;
|
char *<[delimiters]>;
|
||||||
char **<[lasts]>;
|
char **<[lasts]>;
|
||||||
|
|
||||||
|
char *strsep(<[source_ptr]>, <[delimiters]>)
|
||||||
|
char **<[source_ptr]>;
|
||||||
|
char *<[delimiters]>;
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
The <<strtok>> function is used to isolate sequential tokens in a
|
The <<strtok>> function is used to isolate sequential tokens in a
|
||||||
null-terminated string, <<*<[source]>>>. These tokens are delimited
|
null-terminated string, <<*<[source]>>>. These tokens are delimited
|
||||||
@ -43,18 +51,30 @@ DESCRIPTION
|
|||||||
The <<strtok_r>> function has the same behavior as <<strtok>>, except
|
The <<strtok_r>> function has the same behavior as <<strtok>>, except
|
||||||
a pointer to placeholder <<*[lasts]>> must be supplied by the caller.
|
a pointer to placeholder <<*[lasts]>> must be supplied by the caller.
|
||||||
|
|
||||||
|
The <<strsep>> function is similar in behavior to <<strtok>>, 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 <<strtok_r>> and <<strtok>>, 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
|
||||||
<<strtok>> returns a pointer to the next token, or <<NULL>> if
|
<<strtok>>, <<strtok_r>>, and <<strsep>> all return a pointer to the
|
||||||
no more tokens can be found.
|
next token, or <<NULL>> if no more tokens can be found. For
|
||||||
|
<<strsep>>, a token may be the empty string.
|
||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
<<strtok>> is unsafe for multi-thread applications. <<strtok_r>>
|
<<strtok>> is unsafe for multi-thread applications. <<strtok_r>>
|
||||||
is MT-Safe and should be used instead.
|
and <<strsep>> are MT-Safe and should be used instead.
|
||||||
|
|
||||||
PORTABILITY
|
PORTABILITY
|
||||||
<<strtok>> is ANSI C.
|
<<strtok>> is ANSI C.
|
||||||
|
<<strtok_r>> is POSIX.
|
||||||
|
<<strsep>> is a BSD-extension.
|
||||||
|
|
||||||
<<strtok>> requires no supporting OS subroutines.
|
<<strtok>>, <<strtok_r>>, and <<strsep>> require no supporting OS subroutines.
|
||||||
|
|
||||||
QUICKREF
|
QUICKREF
|
||||||
strtok ansi impure
|
strtok ansi impure
|
||||||
@ -68,12 +88,14 @@ QUICKREF
|
|||||||
|
|
||||||
#ifndef _REENT_ONLY
|
#ifndef _REENT_ONLY
|
||||||
|
|
||||||
|
extern char *__strtok_r (char *, const char *, char **, int);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
_DEFUN (strtok, (s, delim),
|
_DEFUN (strtok, (s, delim),
|
||||||
register char *s _AND
|
register char *s _AND
|
||||||
register const char *delim)
|
register const char *delim)
|
||||||
{
|
{
|
||||||
_REENT_CHECK_MISC(_REENT);
|
_REENT_CHECK_MISC(_REENT);
|
||||||
return strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT)));
|
return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT)), 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,10 +34,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char *
|
char *
|
||||||
_DEFUN (strtok_r, (s, delim, lasts),
|
_DEFUN (__strtok_r, (s, delim, lasts, skip_leading_delim),
|
||||||
register char *s _AND
|
register char *s _AND
|
||||||
register const char *delim _AND
|
register const char *delim _AND
|
||||||
char **lasts)
|
char **lasts _AND
|
||||||
|
int skip_leading_delim)
|
||||||
{
|
{
|
||||||
register char *spanp;
|
register char *spanp;
|
||||||
register int c, sc;
|
register int c, sc;
|
||||||
@ -53,8 +54,16 @@ _DEFUN (strtok_r, (s, delim, lasts),
|
|||||||
cont:
|
cont:
|
||||||
c = *s++;
|
c = *s++;
|
||||||
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
|
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
|
||||||
if (c == sc)
|
if (c == sc) {
|
||||||
goto cont;
|
if (skip_leading_delim) {
|
||||||
|
goto cont;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*lasts = s;
|
||||||
|
s[-1] = 0;
|
||||||
|
return (s - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == 0) { /* no non-delimiter characters */
|
if (c == 0) { /* no non-delimiter characters */
|
||||||
@ -83,3 +92,12 @@ cont:
|
|||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
_DEFUN (strtok_r, (s, delim, lasts),
|
||||||
|
register char *s _AND
|
||||||
|
register const char *delim _AND
|
||||||
|
char **lasts)
|
||||||
|
{
|
||||||
|
return __strtok_r (s, delim, lasts, 1);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user