* sysdeps/mach/hurd/tmpfile.c: Remove USE_IN_LIBIO conditionals.
[glibc.git] / timezone / scheck.c
blob39feeba701171ca6def94627ecb04016866efb2c
1 #ifndef lint
2 #ifndef NOID
3 static char elsieid[] = "@(#)scheck.c 8.15";
4 #endif /* !defined lint */
5 #endif /* !defined NOID */
7 /*LINTLIBRARY*/
9 #include "private.h"
11 char *
12 scheck(string, format)
13 const char * const string;
14 const char * const format;
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;
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;
39 *tp++ = '*';
40 if (*fp == '*')
41 ++fp;
42 while (is_digit(*fp))
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;
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;