Skip idle info on uu-lines from uucpd
[unix-history] / share / zoneinfo / scheck.c
CommitLineData
15637ed4 1#ifndef lint
1bd76676
GW
2#ifndef NOID
3static char elsieid[] = "@(#)scheck.c 8.11";
4#endif /* !defined lint */
5#endif /* !defined NOID */
15637ed4
RG
6
7/*LINTLIBRARY*/
8
1bd76676
GW
9#include "private.h"
10
11extern char * imalloc P((int n));
12extern void ifree P((char * p));
15637ed4
RG
13
14char *
15scheck(string, format)
16const char * const string;
17const char * const format;
18{
19 register char * fbuf;
20 register const char * fp;
21 register char * tp;
22 register int c;
23 register char * result;
24 char dummy;
1bd76676 25 static char nada[1];
15637ed4 26
1bd76676 27 result = nada;
15637ed4
RG
28 if (string == NULL || format == NULL)
29 return result;
1bd76676 30 fbuf = imalloc(2 * strlen(format) + 4);
15637ed4
RG
31 if (fbuf == NULL)
32 return result;
33 fp = format;
34 tp = fbuf;
35 while ((*tp++ = c = *fp++) != '\0') {
36 if (c != '%')
37 continue;
38 if (*fp == '%') {
39 *tp++ = *fp++;
40 continue;
41 }
42 *tp++ = '*';
43 if (*fp == '*')
44 ++fp;
45 while (isascii(*fp) && isdigit(*fp))
46 *tp++ = *fp++;
47 if (*fp == 'l' || *fp == 'h')
48 *tp++ = *fp++;
49 else if (*fp == '[')
50 do *tp++ = *fp++;
51 while (*fp != '\0' && *fp != ']');
52 if ((*tp++ = *fp++) == '\0')
53 break;
54 }
55 *(tp - 1) = '%';
56 *tp++ = 'c';
57 *tp = '\0';
1bd76676 58 if (sscanf(string, fbuf, &dummy) != 1)
15637ed4
RG
59 result = (char *) format;
60 ifree(fbuf);
61 return result;
62}