]> git.ipfire.org Git - thirdparty/glibc.git/blame - time/scheck.c
Update.
[thirdparty/glibc.git] / time / scheck.c
CommitLineData
28f540f4
RM
1#ifndef lint
2#ifndef NOID
4cca6b86 3static char elsieid[] = "@(#)scheck.c 8.14";
28f540f4
RM
4#endif /* !defined lint */
5#endif /* !defined NOID */
6
7/*LINTLIBRARY*/
8
9#include "private.h"
10
28f540f4
RM
11char *
12scheck(string, format)
13const char * const string;
14char * const format;
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}