File: tokensep.c

package info (click to toggle)
sn 0.3.8-10
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 924 kB
  • ctags: 852
  • sloc: ansic: 9,262; sh: 466; makefile: 208
file content (35 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (6)
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
/*
 * This file is part of the sn package.
 * Distribution of sn is covered by the GNU GPL. See file COPYING.
 * Copyright  1998-2000 Harold Tay.
 * Copyright  2000- Patrik Rdman.
 */

#include <stdlib.h>

static const char ver_ctrl_id[] = "$Id: tokensep.c 40 2004-04-28 18:00:25Z patrik $";

char *tokensep (char **p, char *delim)
{
   char map[256] = { 0, };
   char *start;
   char *end;

   while (*delim)
   {
      map[(unsigned) *delim] = 1;
      delim++;
   }
   for (start = *p; *start && map[(unsigned) *start]; start++) ;
   if (!*start)
      return NULL;
   for (end = start; *end && !map[(unsigned) *end]; end++) ;
   if (*end)
   {
      *p = end + 1;
      *end = '\0';
   }
   else
      *p = end;
   return start;
}