summaryrefslogtreecommitdiff
path: root/fonts/utilities/mff-29/stritem.c
blob: a6de73c23607217ee4918d2c7303930a896ad762 (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
/*  stritem.c 2.9.0 92/07/06 -- like strtok except different */

/*
 *  This is a replacement for the SysV strtok(3C) function.
 *  (It has a different signature.)  See stritem(3).
 */

/* - Damian Cugley <pdc@prg.ox.ac.uk> Thur. 20 June 1991
-----------------------------------------------------------------------
    This software module copyright (c) 1991 Damian Cugley.  
    It is provided for free on an "as-is" basis.
    See the file COPYING for more information.
-----------------------------------------------------------------------
*/

#include "strmisc.h"

char *
stritem(s, c, state)
     char *s;
     int c;
     char **state;
{
  char *result;
  register char *p;
  
  result = (s ? s : *state);
  if (!result || !*result) return (char *)NULL;
  
  for (p = result; *p && *p != c; p++)
    ;
  if (*p)
    *state = p + 1, *p = '\0';
  else
    *state = (char *)NULL;		/* next call will return NULL */
  return result;
}