9 char *strptime(const char *restrict s, const char *restrict f, struct tm *restrict tm)
11 int i, w, neg, adj, min, range, *dest, dummy;
16 if (isspace(*f)) for (; *s && isspace(*s); s++);
17 else if (*s != *f) return 0;
24 if (isdigit(*f)) w=strtoul(f, (void *)&f, 10);
33 case 'b': case 'B': case 'h':
39 s = strptime(s, nl_langinfo(D_T_FMT), tm);
53 s = strptime(s, "%m/%d/%y", tm);
83 for (; *s && isspace(*s); s++);
86 ex = nl_langinfo(AM_STR);
88 if (!strncasecmp(s, ex, len)) {
92 ex = nl_langinfo(PM_STR);
94 if (!strncasecmp(s, ex, len)) {
101 s = strptime(s, nl_langinfo(T_FMT_AMPM), tm);
105 s = strptime(s, "%H:%M", tm);
114 s = strptime(s, "%H:%M:%S", tm);
119 /* Throw away result, for now. (FIXME?) */
130 s = strptime(s, nl_langinfo(D_FMT), tm);
134 s = strptime(s, nl_langinfo(T_FMT), tm);
148 if (*s++ != '%') return 0;
153 if (!isdigit(*s)) return 0;
155 for (i=1; i<=min+range && isdigit(*s); i*=10)
156 *dest = *dest * 10 + *s++ - '0';
157 if (*dest - min >= (unsigned)range) return 0;
159 switch((char *)dest - (char *)tm) {
160 case offsetof(struct tm, tm_yday):
167 else if (*s == '-') neg=1, s++;
168 if (!isdigit(*s)) return 0;
169 for (*dest=i=0; i<w && isdigit(*s); i++)
170 *dest = *dest * 10 + *s++ - '0';
171 if (neg) *dest = -*dest;
175 for (i=2*range-1; i>=0; i--) {
176 ex = nl_langinfo(min+i);
178 if (strncasecmp(s, ex, len)) continue;