--- ray/src/common/words.c 1996/01/17 10:53:38 2.3 +++ ray/src/common/words.c 2003/07/17 09:21:29 2.8 @@ -1,26 +1,21 @@ -/* Copyright (c) 1996 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id"; #endif - /* * Routines for recognizing and moving about words in strings. + * + * External symbols declared in standard.h */ +#include "copyright.h" + #include +#include -#ifdef BSD -#define strchr index -#endif +#include "rtio.h" -#define NULL 0 - -extern char *strchr(); - - char * -atos(rs, nb, s) /* get next word from string */ +atos(rs, nb, s) /* get word from string, returning rs */ char *rs; register int nb; register char *s; @@ -37,6 +32,33 @@ register char *s; char * +nextword(cp, nb, s) /* get (quoted) word, returning new s */ +register char *cp; +register int nb; +register char *s; +{ + int quote = 0; + + if (s == NULL) return(NULL); + while (isspace(*s)) + s++; + switch (*s) { + case '\0': + return(NULL); + case '"': + case '\'': + quote = *s++; + } + while (--nb > 0 && *s && (quote ? *s!=quote : !isspace(*s))) + *cp++ = *s++; + *cp = '\0'; + if (quote && *s==quote) + s++; + return(s); +} + + +char * sskip(s) /* skip word in string, leaving on space */ register char *s; { @@ -108,6 +130,7 @@ register char *s; } +int isint(s) /* check integer format */ char *s; { @@ -118,6 +141,7 @@ char *s; } +int isintd(s, ds) /* check integer format with delimiter set */ char *s, *ds; { @@ -128,6 +152,7 @@ char *s, *ds; } +int isflt(s) /* check float format */ char *s; { @@ -138,6 +163,7 @@ char *s; } +int isfltd(s, ds) /* check integer format with delimiter set */ char *s, *ds; {