Update FSM on WAL replay. This is a bit limited; the FSM is only updated
[PostgreSQL.git] / src / timezone / scheck.c
blob588e7ff9c53a3d0bac9e629a9cd11f04acc83a6a
1 /*
2 * This file is in the public domain, so clarified as of
3 * 2006-07-17 by Arthur David Olson.
5 * IDENTIFICATION
6 * $PostgreSQL$
7 */
9 #include "postgres_fe.h"
11 #include "private.h"
14 const char *
15 scheck(const char *string, const char *format)
17 char *fbuf;
18 const char *fp;
19 char *tp;
20 int c;
21 const char *result;
22 char dummy;
24 result = "";
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')
34 if (c != '%')
35 continue;
36 if (*fp == '%')
38 *tp++ = *fp++;
39 continue;
41 *tp++ = '*';
42 if (*fp == '*')
43 ++fp;
44 while (is_digit(*fp))
45 *tp++ = *fp++;
46 if (*fp == 'l' || *fp == 'h')
47 *tp++ = *fp++;
48 else if (*fp == '[')
50 *tp++ = *fp++;
51 while (*fp != '\0' && *fp != ']');
52 if ((*tp++ = *fp++) == '\0')
53 break;
55 *(tp - 1) = '%';
56 *tp++ = 'c';
57 *tp = '\0';
58 if (sscanf(string, fbuf, &dummy) != 1)
59 result = (char *) format;
60 ifree(fbuf);
61 return result;