intl/icu/source/tools/tzcode/scheck.c

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 ** This file is in the public domain, so clarified as of
michael@0 3 ** 2006-07-17 by Arthur David Olson.
michael@0 4 */
michael@0 5
michael@0 6 #ifndef lint
michael@0 7 #ifndef NOID
michael@0 8 static char elsieid[] = "@(#)scheck.c 8.19";
michael@0 9 #endif /* !defined lint */
michael@0 10 #endif /* !defined NOID */
michael@0 11
michael@0 12 /*LINTLIBRARY*/
michael@0 13
michael@0 14 #include "private.h"
michael@0 15
michael@0 16 const char *
michael@0 17 scheck(string, format)
michael@0 18 const char * const string;
michael@0 19 const char * const format;
michael@0 20 {
michael@0 21 register char * fbuf;
michael@0 22 register const char * fp;
michael@0 23 register char * tp;
michael@0 24 register int c;
michael@0 25 register const char * result;
michael@0 26 char dummy;
michael@0 27
michael@0 28 result = "";
michael@0 29 if (string == NULL || format == NULL)
michael@0 30 return result;
michael@0 31 fbuf = imalloc((int) (2 * strlen(format) + 4));
michael@0 32 if (fbuf == NULL)
michael@0 33 return result;
michael@0 34 fp = format;
michael@0 35 tp = fbuf;
michael@0 36 while ((*tp++ = c = *fp++) != '\0') {
michael@0 37 if (c != '%')
michael@0 38 continue;
michael@0 39 if (*fp == '%') {
michael@0 40 *tp++ = *fp++;
michael@0 41 continue;
michael@0 42 }
michael@0 43 *tp++ = '*';
michael@0 44 if (*fp == '*')
michael@0 45 ++fp;
michael@0 46 while (is_digit(*fp))
michael@0 47 *tp++ = *fp++;
michael@0 48 if (*fp == 'l' || *fp == 'h')
michael@0 49 *tp++ = *fp++;
michael@0 50 else if (*fp == '[')
michael@0 51 do *tp++ = *fp++;
michael@0 52 while (*fp != '\0' && *fp != ']');
michael@0 53 if ((*tp++ = *fp++) == '\0')
michael@0 54 break;
michael@0 55 }
michael@0 56 *(tp - 1) = '%';
michael@0 57 *tp++ = 'c';
michael@0 58 *tp = '\0';
michael@0 59 if (sscanf(string, fbuf, &dummy) != 1)
michael@0 60 result = (char *) format;
michael@0 61 ifree(fbuf);
michael@0 62 return result;
michael@0 63 }

mercurial