OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [strtok.c] - Blame information for rev 171

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
        <<strtok>>, <<strtok_r>>, <<strsep>>---get next token from a string
4
 
5
INDEX
6
        strtok
7
 
8
INDEX
9
        strtok_r
10
 
11
INDEX
12
        strsep
13
 
14
ANSI_SYNOPSIS
15
        #include <string.h>
16
        char *strtok(char *<[source]>, const char *<[delimiters]>)
17
        char *strtok_r(char *<[source]>, const char *<[delimiters]>,
18
                        char **<[lasts]>)
19
        char *strsep(char **<[source_ptr]>, const char *<[delimiters]>)
20
 
21
TRAD_SYNOPSIS
22
        #include <string.h>
23
        char *strtok(<[source]>, <[delimiters]>)
24
        char *<[source]>;
25
        char *<[delimiters]>;
26
 
27
        char *strtok_r(<[source]>, <[delimiters]>, <[lasts]>)
28
        char *<[source]>;
29
        char *<[delimiters]>;
30
        char **<[lasts]>;
31
 
32
        char *strsep(<[source_ptr]>, <[delimiters]>)
33
        char **<[source_ptr]>;
34
        char *<[delimiters]>;
35
 
36
DESCRIPTION
37
        The <<strtok>> function is used to isolate sequential tokens in a
38
        null-terminated string, <<*<[source]>>>. These tokens are delimited
39
        in the string by at least one of the characters in <<*<[delimiters]>>>.
40
        The first time that <<strtok>> is called, <<*<[source]>>> should be
41
        specified; subsequent calls, wishing to obtain further tokens from
42
        the same string, should pass a null pointer instead.  The separator
43
        string, <<*<[delimiters]>>>, must be supplied each time and may
44
        change between calls.
45
 
46
        The <<strtok>> function returns a pointer to the beginning of each
47
        subsequent token in the string, after replacing the separator
48
        character itself with a null character.  When no more tokens remain,
49
        a null pointer is returned.
50
 
51
        The <<strtok_r>> function has the same behavior as <<strtok>>, except
52
        a pointer to placeholder <<*<[lasts]>>> must be supplied by the caller.
53
 
54
        The <<strsep>> function is similar in behavior to <<strtok>>, except
55
        a pointer to the string pointer must be supplied <<<[source_ptr]>>> and
56
        the function does not skip leading delimiters.  When the string starts
57
        with a delimiter, the delimiter is changed to the null character and
58
        the empty string is returned.  Like <<strtok_r>> and <<strtok>>, the
59
        <<*<[source_ptr]>>> is updated to the next character following the
60
        last delimiter found or NULL if the end of string is reached with
61
        no more delimiters.
62
 
63
RETURNS
64
        <<strtok>>, <<strtok_r>>, and <<strsep>> all return a pointer to the
65
        next token, or <<NULL>> if no more tokens can be found.  For
66
        <<strsep>>, a token may be the empty string.
67
 
68
NOTES
69
        <<strtok>> is unsafe for multi-threaded applications.  <<strtok_r>>
70
        and <<strsep>> are thread-safe and should be used instead.
71
 
72
PORTABILITY
73
<<strtok>> is ANSI C.
74
<<strtok_r>> is POSIX.
75
<<strsep>> is a BSD extension.
76
 
77
<<strtok>>, <<strtok_r>>, and <<strsep>> require no supporting OS subroutines.
78
 
79
QUICKREF
80
        strtok ansi impure
81
*/
82
 
83
/* undef STRICT_ANSI so that strtok_r prototype will be defined */
84
#undef  __STRICT_ANSI__
85
#include <string.h>
86
#include <_ansi.h>
87
#include <reent.h>
88
 
89
#ifndef _REENT_ONLY
90
 
91
extern char *__strtok_r (char *, const char *, char **, int);
92
 
93
char *
94
_DEFUN (strtok, (s, delim),
95
        register char *s _AND
96
        register const char *delim)
97
{
98
        _REENT_CHECK_MISC(_REENT);
99
        return __strtok_r (s, delim, &(_REENT_STRTOK_LAST(_REENT)), 1);
100
}
101
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.