* sysdeps/posix/spawni.c (__spawni): Use local_seteuid and
[glibc.git] / timezone / scheck.c
blobbc156379a001f96e483589f09e6872b96ba1b9f0
1 #ifndef lint
2 #ifndef NOID
3 static char elsieid[] = "@(#)scheck.c 8.17";
4 #endif /* !defined lint */
5 #endif /* !defined NOID */
7 /*LINTLIBRARY*/
9 #include "private.h"
11 const 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 const char * result;
21 char dummy;
23 result = "";
24 if (string == NULL || format == NULL)
25 return result;
26 fbuf = imalloc((int) (2 * strlen(format) + 4));
27 if (fbuf == NULL)
28 return result;
29 fp = format;
30 tp = fbuf;
31 while ((*tp++ = c = *fp++) != '\0') {
32 if (c != '%')
33 continue;
34 if (*fp == '%') {
35 *tp++ = *fp++;
36 continue;
38 *tp++ = '*';
39 if (*fp == '*')
40 ++fp;
41 while (is_digit(*fp))
42 *tp++ = *fp++;
43 if (*fp == 'l' || *fp == 'h')
44 *tp++ = *fp++;
45 else if (*fp == '[')
46 do *tp++ = *fp++;
47 while (*fp != '\0' && *fp != ']');
48 if ((*tp++ = *fp++) == '\0')
49 break;
51 *(tp - 1) = '%';
52 *tp++ = 'c';
53 *tp = '\0';
54 if (sscanf(string, fbuf, &dummy) != 1)
55 result = (char *) format;
56 ifree(fbuf);
57 return result;