7cef70c86777d4067c8b2f7097939723b6475fd9 kent Wed Feb 10 14:01:28 2016 -0800 Adding isSymbolString function to common string library. diff --git src/lib/common.c src/lib/common.c index 4eb60b8..23ccf41 100644 --- src/lib/common.c +++ src/lib/common.c @@ -3403,30 +3403,44 @@ strcpy(pathBuf, path); if (*next == '/') next++; while((*next != '\0') && (next = strchr(next, '/')) != NULL) { *next = '\0'; makeDir(pathBuf); *next = '/'; next++; } makeDir(pathBuf); } +boolean isSymbolString(char *s) +/* Return TRUE if s can be used as a symbol in the C language */ +{ +char c = *s++; +if (!isalpha(c) && (c != '_')) + return FALSE; +while ((c = *s++) != 0) + { + if (!(isalnum(c) || (c == '_'))) + return FALSE; + } +return TRUE; +} + boolean isNumericString(char *s) /* Return TRUE if string is numeric (integer or floating point) */ { char *end; strtod(s, &end); return (end != s && *end == 0); } char *skipNumeric(char *s) /* Return first char of s that's not a digit */ { while (isdigit(*s)) ++s; return s; } @@ -3573,15 +3587,16 @@ { dateAdd(&tp,addYears,addMonths,addDays); // tp.tm_year only contains years since 1900 strftime(newDate,12,format,&tp); } return cloneString(newDate); // newDate is never freed! } boolean haplotype(const char *name) /* Is this name a haplotype name ? _hap or _alt in the name */ { if (stringIn("_hap", name) || stringIn("_alt", name)) return TRUE; else return FALSE; } +