[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] Multithreaded strtok
From: |
Joerg Wunsch |
Subject: |
Re: [avr-libc-dev] Multithreaded strtok |
Date: |
Fri, 13 Sep 2002 12:03:27 +0200 |
User-agent: |
Mutt/1.2.5i |
As Harald Kipp wrote:
> I received an email from Peter Scandrett with an
> attached C source of a multithreaded mt_strtok.
> It contains a BSD-style licence.
Hmm, i don't like the name. There's already the (Posix) convention to
create a re-entrant function "foo_r" for any non-reentranct function
"foo". I suggest we follow this convention wherever it makes sense
(and basically we already followed it by importing rand_r()).
Apart from that, i don't see why it can't be added.
Here's the BSD prototype:
NAME
strtok, strtok_r - string tokens
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <string.h>
char *
strtok(char *str, const char *sep);
char *
strtok_r(char *str, const char *sep, char **last);
However, the next comment is:
DESCRIPTION
This interface is obsoleted by strsep(3).
So for reference, here's strsep(3). Maybe we should port this one
instead?
SYNOPSIS
#include <string.h>
char *
strsep(char **stringp, const char *delim);
DESCRIPTION
The strsep() function locates, in the string referenced by
*stringp, the first occurrence of any character in the string
delim (or the terminating `\0' character) and replaces it
with a `\0'. The location of the next character after the
delimiter character (or NULL, if the end of the string was
reached) is stored in *stringp. The original value of
*stringp is returned.
An ``empty'' field, i.e. one caused by two adjacent delimiter
characters, can be detected by comparing the location
referenced by the pointer returned in *stringp to `\0'.
If *stringp is initially NULL, strsep() returns NULL.
...
HISTORY
The strsep() function is intended as a replacement for the
strtok() function. While the strtok() function should be
preferred for portability reasons (it conforms to ISO/IEC
9899:1990 (``ISO C89'')) it is unable to handle empty fields,
i.e. detect fields delimited by two adjacent delimiter
characters, or to be used for more than a single string at a
time. The strsep() function first appeared in 4.4BSD.
--
J"org Wunsch Unix support engineer
address@hidden http://www.interface-systems.de/~j/
- Re: [avr-libc-dev] Re: [avr-gcc-list] I fixed dtostre(), (continued)
- Re: [avr-libc-dev] Re: [avr-gcc-list] I fixed dtostre(), Joerg Wunsch, 2002/09/10
- [avr-libc-dev] Re: printf in avr-libc, ken restivo, 2002/09/10
- Re: [avr-libc-dev] Re: printf in avr-libc, E. Weddington, 2002/09/11
- Re: [avr-libc-dev] Re: printf in avr-libc, Joerg Wunsch, 2002/09/11
- [avr-libc-dev] Re: printf in avr-libc, Jörgen, 2002/09/12
- Re: [avr-libc-dev] Re: printf in avr-libc, Joerg Wunsch, 2002/09/12
- Re: [avr-libc-dev] Re: printf in avr-libc, Joerg Wunsch, 2002/09/12
- Re: [avr-libc-dev] Re: printf in avr-libc, Jörgen, 2002/09/12
- Re: [avr-libc-dev] Re: printf in avr-libc, E. Weddington, 2002/09/12
- [avr-libc-dev] Multithreaded strtok, Harald Kipp, 2002/09/13
- Re: [avr-libc-dev] Multithreaded strtok,
Joerg Wunsch <=
- Re: [avr-libc-dev] Re: printf in avr-libc, Joerg Wunsch, 2002/09/13
- Re: [avr-libc-dev] Re: printf in avr-libc, daniel_laptop, 2002/09/13
- Re: [avr-libc-dev] Re: printf in avr-libc, Joerg Wunsch, 2002/09/13
- Re: [avr-libc-dev] Re: printf in avr-libc, daniel_laptop, 2002/09/13
- Re: [avr-libc-dev] Re: printf in avr-libc, Jörgen, 2002/09/16
- Re: [avr-libc-dev] Re: [avr-gcc-list] I fixed dtostre(), Chris Baugher, 2002/09/10