--- ray/src/cv/mgflib/words.c 1994/06/21 14:45:47 1.1 +++ ray/src/cv/mgflib/words.c 2003/03/11 17:08:55 1.4 @@ -1,24 +1,14 @@ -/* Copyright (c) 1994 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: words.c,v 1.4 2003/03/11 17:08:55 greg Exp $"; #endif - /* * Routines for recognizing and moving about words in strings. */ +#include #include -#ifdef BSD -#define strchr index -#endif -#define NULL 0 - -extern char *strchr(); - - char * iskip(s) /* skip integer in string */ register char *s; @@ -103,4 +93,18 @@ char *s, *ds; cp = fskip(s); return(cp != NULL && strchr(ds, *cp) != NULL); +} + + +int +isname(s) /* check for legal identifier name */ +register char *s; +{ + while (*s == '_') /* skip leading underscores */ + s++; + if (!isascii(*s) || !isalpha(*s)) /* start with a letter */ + return(0); + while (isascii(*++s) && isgraph(*s)) /* all visible characters */ + ; + return(*s == '\0'); /* ending in nul */ }