1cc8c6d3d7f2357898ad366c94b1f33a403a2aee angie Thu Dec 8 14:14:33 2016 -0800 Libifying isAllDigits from a handful of places into common.c. diff --git src/lib/common.c src/lib/common.c index a7ebe33..b44b3ee 100644 --- src/lib/common.c +++ src/lib/common.c @@ -3455,30 +3455,42 @@ return s; } char *splitOffNonNumeric(char *s) /* Split off non-numeric part, e.g. mm of mm8. Result should be freed when done */ { return cloneStringZ(s,skipToNumeric(s)-s); } char *splitOffNumber(char *db) /* Split off number part, e.g. 8 of mm8. Result should be freed when done */ { return cloneString(skipToNumeric(db)); } +boolean isAllDigits(char *s) +/* Return TRUE if string is non-empty and contains only digits (i.e. is a nonnegative integer). */ +{ +if (isEmpty(s)) + return FALSE; +char c; +while ((c = *s++) != 0) + if (!isdigit(c)) + return FALSE; +return TRUE; +} + time_t mktimeFromUtc (struct tm *t) /* Return time_t for tm in UTC (GMT) * Useful for stuff like converting to time_t the * last-modified HTTP response header * which is always GMT. Returns -1 on failure of mktime */ { time_t time; char *tz; char save_tz[100]; tz=getenv("TZ"); if (tz) safecpy(save_tz, sizeof(save_tz), tz); setenv("TZ", "GMT0", 1); tzset(); t->tm_isdst = 0;