summaryrefslogtreecommitdiff
path: root/src/string/strtok_s.c
blob: 9742d09cf3f1acd32a37d96bdcdd63e28db3a9f0 (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
#include "string.h"
#include "stddef.h"

char * strtok_s(char * restrict s1, rsize_t * restrict s1max, const char * restrict s2, char **restrict ptr)
{
	__C_EXT(1, 201112L);
  int i = 0;

  if (s == NULL)
    s = *lasts;

  while (i < strlen (s)) {
    if (strchr (sep, s[i]) == NULL) {
      i++;
    } else {
      s[i] = '\0';
      *lasts = &(s[i+1]);
      return s;
    }
  }
  return NULL;
}

/*
CEXT1(201112)
*/