|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 1082 (0x43a)
Types: TextFile
Names: »strtok.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
└─⟦this⟧ »EUUGD11/euug-87hel/sec1/vn/strtok.c«
/*
** vn news reader.
**
** strtok.c - strtok() and strpbrk() string routines using UCB index().
**
** see copyright disclaimer / history in vn.c source file
*/
#include <stdio.h>
char *strpbrk (s,del)
char *s, *del;
{
char *ptr,*index();
if (s == NULL)
return (NULL);
for (; *del != '\0'; ++del)
if ((ptr = index(s,*del)) != NULL)
return (ptr);
return (NULL);
}
char *strtok(str,delim)
char *str, *delim;
{
char *tokstart, *tokend, *first_ch (), *last_ch();
static char *save=NULL;
if (str != NULL)
save = str;
if (save == NULL)
return (NULL);
tokstart = first_ch (save, delim);
tokend = last_ch (tokstart, delim);
save = first_ch (tokend, delim);
*tokend = '\0';
if (*tokstart == '\0')
return (NULL);
return (tokstart);
}
static char *first_ch (str,delim)
char *str,*delim;
{
char *index ();
char *f;
for (f = str; *f != '\0' && index(delim,*f) != NULL; ++f)
;
return (f);
}
static char *last_ch (str,delim)
char *str,*delim;
{
char *index ();
char *f;
for (f = str; *f != '\0' && index(delim,*f) == NULL; ++f)
;
return (f);
}