]> git.ipfire.org Git - thirdparty/glibc.git/blame - timezone/scheck.c
.
[thirdparty/glibc.git] / timezone / scheck.c
CommitLineData
28f540f4
RM
1#ifndef lint
2#ifndef NOID
32c075e1 3static char elsieid[] = "@(#)scheck.c 8.17";
28f540f4
RM
4#endif /* !defined lint */
5#endif /* !defined NOID */
6
7/*LINTLIBRARY*/
8
9#include "private.h"
10
026b372a 11const char *
28f540f4
RM
12scheck(string, format)
13const char * const string;
026b372a 14const char * const format;
28f540f4
RM
15{
16 register char * fbuf;
17 register const char * fp;
18 register char * tp;
19 register int c;
026b372a 20 register const char * result;
28f540f4 21 char dummy;
28f540f4 22
026b372a 23 result = "";
28f540f4
RM
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;
37 }
38 *tp++ = '*';
39 if (*fp == '*')
40 ++fp;
f2e235b9 41 while (is_digit(*fp))
28f540f4
RM
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;
50 }
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;
58}