Back to index

glibc  2.9
Functions | Variables
strtok.c File Reference
#include <string.h>

Go to the source code of this file.

Functions

char * strtok (char *s, const char *delim)

Variables

static char * olds

Function Documentation

char* strtok ( char *  s,
const char *  delim 
)

Definition at line 37 of file strtok.c.

{
  char *token;

  if (s == NULL)
    s = olds;

  /* Scan leading delimiters.  */
  s += strspn (s, delim);
  if (*s == '\0')
    {
      olds = s;
      return NULL;
    }

  /* Find the end of the token.  */
  token = s;
  s = strpbrk (token, delim);
  if (s == NULL)
    /* This token finishes the string.  */
    olds = __rawmemchr (token, '\0');
  else
    {
      /* Terminate the token and make OLDS point past it.  */
      *s = '\0';
      olds = s + 1;
    }
  return token;
}

Variable Documentation

char* olds [static]

Definition at line 23 of file strtok.c.