home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
CMDS
/
file.lzh
/
strextra.c
< prev
next >
Wrap
Text File
|
1995-04-27
|
2KB
|
98 lines
/**************************************************
* strextra.c *
**************************************************
* extra str functions for the OS-9 3.2 compiler. *
*************************************************/
#if defined(_OSK) && defined(_BSD)
#include <stdio.h> /* For NULL */
char *scanpoint = NULL;
/* NULL if no token left */
char *
strtok(s, delim)
char *s;
register char *delim;
{
register char *scan;
char *tok;
register char *dscan;
if ((s == NULL) && (scanpoint == NULL))
return(NULL);
if (s != NULL)
scan = s;
else
scan = scanpoint;
/* Scan leading delimiters. */
for (; *scan != '\0'; scan++) {
for (dscan = delim; *dscan != '\0'; dscan++) {
if (*scan == *dscan)
break;
}
if (*dscan == '\0')
break;
}
if (*scan == '\0') {
scanpoint = NULL;
return(NULL);
}
tok = scan;
/* Scan token. */
for (; *scan != '\0'; scan++) {
for (dscan = delim; *dscan != '\0';) { /* ++ moved down. */
if (*scan == *dscan++) {
scanpoint = scan+1;
*scan = '\0';
return(tok);
}
}
}
/* Reached end of string. */
scanpoint = NULL;
return(tok);
} /* end of strtok */
/*
* strspn - find length of initial segment of s consisting entirely
* of characters from accept
*/
int strspn(s, accept)
char *s;
char *accept;
{
register char *sscan;
register char *ascan;
register int count;
count = 0;
for (sscan = s; *sscan ; sscan++)
{
for (ascan = accept; *ascan ; ascan++)
{
if (*sscan == *ascan)
break;
}
if (*ascan == '\0')
return(count);
count++;
}
return(count);
} /* end of strspn */
#endif