|
|
1.1 ! root 1: #ifndef lint ! 2: #ifndef NOID ! 3: static char elsieid[] = "@(#)scheck.c 8.9"; ! 4: #endif /* !defined lint */ ! 5: #endif /* !defined NOID */ ! 6: ! 7: /*LINTLIBRARY*/ ! 8: ! 9: #include "stdio.h" ! 10: #include "ctype.h" ! 11: #include "string.h" ! 12: #include "stdlib.h" ! 13: #include "nonstd.h" ! 14: ! 15: extern char * imalloc P((int n)); ! 16: extern void ifree P((char * p)); ! 17: ! 18: char * ! 19: scheck(string, format) ! 20: const char * const string; ! 21: const char * const format; ! 22: { ! 23: register char * fbuf; ! 24: register const char * fp; ! 25: register char * tp; ! 26: register int c; ! 27: register char * result; ! 28: char dummy; ! 29: ! 30: result = ""; ! 31: if (string == NULL || format == NULL) ! 32: return result; ! 33: fbuf = imalloc(2 * strlen(format) + 4); ! 34: if (fbuf == NULL) ! 35: return result; ! 36: fp = format; ! 37: tp = fbuf; ! 38: while ((*tp++ = c = *fp++) != '\0') { ! 39: if (c != '%') ! 40: continue; ! 41: if (*fp == '%') { ! 42: *tp++ = *fp++; ! 43: continue; ! 44: } ! 45: *tp++ = '*'; ! 46: if (*fp == '*') ! 47: ++fp; ! 48: while (isascii(*fp) && isdigit(*fp)) ! 49: *tp++ = *fp++; ! 50: if (*fp == 'l' || *fp == 'h') ! 51: *tp++ = *fp++; ! 52: else if (*fp == '[') ! 53: do *tp++ = *fp++; ! 54: while (*fp != '\0' && *fp != ']'); ! 55: if ((*tp++ = *fp++) == '\0') ! 56: break; ! 57: } ! 58: *(tp - 1) = '%'; ! 59: *tp++ = 'c'; ! 60: *tp = '\0'; ! 61: if (sscanf(string, fbuf, &dummy) != 1) ! 62: result = (char *) format; ! 63: ifree(fbuf); ! 64: return result; ! 65: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.