]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
1 | #ifndef lint |
2 | #ifndef NOID | |
907a1bac | 3 | static char elsieid[] = "@(#)scheck.c 8.15"; |
28f540f4 RM |
4 | #endif /* !defined lint */ |
5 | #endif /* !defined NOID */ | |
6 | ||
7 | /*LINTLIBRARY*/ | |
8 | ||
9 | #include "private.h" | |
10 | ||
28f540f4 RM |
11 | char * |
12 | scheck(string, format) | |
13 | const char * const string; | |
ebbad4cc | 14 | const char * const format; |
28f540f4 RM |
15 | { |
16 | register char * fbuf; | |
17 | register const char * fp; | |
18 | register char * tp; | |
19 | register int c; | |
20 | register char * result; | |
21 | char dummy; | |
22 | static char nada; | |
23 | ||
24 | result = &nada; | |
25 | if (string == NULL || format == NULL) | |
26 | return result; | |
27 | fbuf = imalloc((int) (2 * strlen(format) + 4)); | |
28 | if (fbuf == NULL) | |
29 | return result; | |
30 | fp = format; | |
31 | tp = fbuf; | |
32 | while ((*tp++ = c = *fp++) != '\0') { | |
33 | if (c != '%') | |
34 | continue; | |
35 | if (*fp == '%') { | |
36 | *tp++ = *fp++; | |
37 | continue; | |
38 | } | |
39 | *tp++ = '*'; | |
40 | if (*fp == '*') | |
41 | ++fp; | |
f2e235b9 | 42 | while (is_digit(*fp)) |
28f540f4 RM |
43 | *tp++ = *fp++; |
44 | if (*fp == 'l' || *fp == 'h') | |
45 | *tp++ = *fp++; | |
46 | else if (*fp == '[') | |
47 | do *tp++ = *fp++; | |
48 | while (*fp != '\0' && *fp != ']'); | |
49 | if ((*tp++ = *fp++) == '\0') | |
50 | break; | |
51 | } | |
52 | *(tp - 1) = '%'; | |
53 | *tp++ = 'c'; | |
54 | *tp = '\0'; | |
55 | if (sscanf(string, fbuf, &dummy) != 1) | |
56 | result = (char *) format; | |
57 | ifree(fbuf); | |
58 | return result; | |
59 | } |