Check supported DF_1_XXX bits
[glibc.git] / timezone / scheck.c
blobed60980d832c14bf49be87157ecb9b5964e9c9dc
1 /*
2 ** This file is in the public domain, so clarified as of
3 ** 2006-07-17 by Arthur David Olson.
4 */
6 /*LINTLIBRARY*/
8 #include "private.h"
10 const char *
11 scheck(const char *const string, const char *const format)
13 register char * fbuf;
14 register const char * fp;
15 register char * tp;
16 register int c;
17 register const char * result;
18 char dummy;
20 result = "";
21 if (string == NULL || format == NULL)
22 return result;
23 fbuf = malloc(2 * strlen(format) + 4);
24 if (fbuf == NULL)
25 return result;
26 fp = format;
27 tp = fbuf;
28 while ((*tp++ = c = *fp++) != '\0') {
29 if (c != '%')
30 continue;
31 if (*fp == '%') {
32 *tp++ = *fp++;
33 continue;
35 *tp++ = '*';
36 if (*fp == '*')
37 ++fp;
38 while (is_digit(*fp))
39 *tp++ = *fp++;
40 if (*fp == 'l' || *fp == 'h')
41 *tp++ = *fp++;
42 else if (*fp == '[')
43 do *tp++ = *fp++;
44 while (*fp != '\0' && *fp != ']');
45 if ((*tp++ = *fp++) == '\0')
46 break;
48 *(tp - 1) = '%';
49 *tp++ = 'c';
50 *tp = '\0';
51 if (sscanf(string, fbuf, &dummy) != 1)
52 result = format;
53 free(fbuf);
54 return result;