8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / zic / scheck.c
blobd7aae2afc1d09315a2f81a69e4c9758f78f4c37d
1 #pragma ident "%Z%%M% %I% %E% SMI"
3 /* static char elsieid[] = "@(#)scheck.c 8.17"; */
5 /*LINTLIBRARY*/
7 #include "private.h"
9 const char *
10 scheck(string, format)
11 const char * const string;
12 const char * const format;
14 register char *fbuf;
15 register const char *fp;
16 register char *tp;
17 register int c;
18 register const char *result;
19 char dummy;
21 result = "";
22 if (string == NULL || format == NULL)
23 return (result);
24 fbuf = imalloc((int)(2 * strlen(format) + 4));
25 if (fbuf == NULL)
26 return (result);
27 fp = format;
28 tp = fbuf;
29 while ((*tp++ = c = *fp++) != '\0') {
30 if (c != '%')
31 continue;
32 if (*fp == '%') {
33 *tp++ = *fp++;
34 continue;
36 *tp++ = '*';
37 if (*fp == '*')
38 ++fp;
39 while (is_digit(*fp))
40 *tp++ = *fp++;
41 if (*fp == 'l' || *fp == 'h')
42 *tp++ = *fp++;
43 else if (*fp == '[')
44 do *tp++ = *fp++;
45 while (*fp != '\0' && *fp != ']');
46 if ((*tp++ = *fp++) == '\0')
47 break;
49 *(tp - 1) = '%';
50 *tp++ = 'c';
51 *tp = '\0';
52 if (sscanf(string, fbuf, &dummy) != 1)
53 result = (char *)format;
54 ifree(fbuf);
55 return (result);