blob: b48bba1850f6b792129bf5601365a74f756aa8de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <string.h>
#include "_safety.h"
/** split string into tokens **/
char * strtok(char * restrict s1, const char * restrict s2)
{
static char *current = NULL;
static char **state = ¤t;
/* TODO */
SIGNAL_SAFE(0);
ASSERT_NONNULL(s2);
if (current == NULL && s1 == NULL) {
UNDEFINED("strtok() called with NULL input and no previous call");
}
/* nothing is copied, overlap is OK */
/*
RETURN(CONSTANT(NULL), there are no further tokens, only token separators);
RETURN(NONNULL, a pointer to the first character of the next token);
*/
#include "_strtok.h"
return current;
}
CHECK_2(char *, 0, strtok, char * restrict, char * restrict)
/***
splits the string ARGUMENT(s1) into a series of tokens
delimited by characters from the string ARGUMENT(s2).
The first call in a sequence specifies a string for ARGUMENT(s1). Further calls
specify CONSTANT(NULL) in order to continue from the end of the previous token.
The list of token separators in ARGUMENT(s2) may vary from call to call.
When tokens are found, the next token separate character is replaced with a
CHAR(\0), terminating the token.
***/
/*
STDC(1)
*/
|