--- ray/src/common/words.c 1991/07/23 11:36:42 1.2 +++ ray/src/common/words.c 1996/01/17 10:53:38 2.3 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1996 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -37,7 +37,7 @@ register char *s; char * -sskip(s) /* skip word in string */ +sskip(s) /* skip word in string, leaving on space */ register char *s; { while (isspace(*s)) @@ -49,6 +49,23 @@ register char *s; char * +sskip2(s, n) /* skip word(s) in string, leaving on word */ +register char *s; +register int n; +{ + while (isspace(*s)) + s++; + while (n-- > 0) { + while (*s && !isspace(*s)) + s++; + while (isspace(*s)) + s++; + } + return(s); +} + + +char * iskip(s) /* skip integer in string */ register char *s; { @@ -69,13 +86,13 @@ char * fskip(s) /* skip float in string */ register char *s; { - register char *cp = s; + register char *cp; - while (isspace(*cp)) - cp++; - if (*cp == '-' || *cp == '+') - cp++; - s = cp; + while (isspace(*s)) + s++; + if (*s == '-' || *s == '+') + s++; + cp = s; while (isdigit(*cp)) cp++; if (*cp == '.') { @@ -107,7 +124,7 @@ char *s, *ds; register char *cp; cp = iskip(s); - return(cp != NULL && strchr(*cp, ds) != NULL); + return(cp != NULL && strchr(ds, *cp) != NULL); } @@ -127,5 +144,5 @@ char *s, *ds; register char *cp; cp = fskip(s); - return(cp != NULL && strchr(*cp, ds) != NULL); + return(cp != NULL && strchr(ds, *cp) != NULL); }