| 1 |
/* { dg-options "-Wno-old-style-definition -O2 -mcmodel=small -fPIC -fno-builtin" } */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-require-effective-target fpic } */ |
| 4 |
|
| 5 |
typedef long unsigned int size_t; |
| 6 |
enum |
| 7 |
{ |
| 8 |
__LC_TIME = 2, |
| 9 |
}; |
| 10 |
enum |
| 11 |
{ |
| 12 |
ABDAY_1 = (((__LC_TIME) << 16) | (0)), |
| 13 |
DAY_1, |
| 14 |
ABMON_1, |
| 15 |
MON_1, |
| 16 |
D_T_FMT, |
| 17 |
}; |
| 18 |
typedef struct __locale_struct |
| 19 |
{ |
| 20 |
struct locale_data *__locales[13]; |
| 21 |
} *__locale_t; |
| 22 |
struct tm |
| 23 |
{ |
| 24 |
int tm_sec; |
| 25 |
int tm_min; |
| 26 |
int tm_hour; |
| 27 |
}; |
| 28 |
struct locale_data |
| 29 |
{ |
| 30 |
const char *name; |
| 31 |
struct |
| 32 |
{ |
| 33 |
const char *string; |
| 34 |
} |
| 35 |
values []; |
| 36 |
}; |
| 37 |
extern const struct locale_data _nl_C_LC_TIME __attribute__ ((visibility ("hidden"))); |
| 38 |
extern void *memset (void *s, int c, size_t n); |
| 39 |
extern size_t strlen (const char *s); |
| 40 |
extern int __strncasecmp_l (const char *s1, const char *s2, size_t n, __locale_t locale); |
| 41 |
char * |
| 42 |
__strptime_internal (rp, fmt, tmp, statep , locale) |
| 43 |
const char *rp; |
| 44 |
const char *fmt; |
| 45 |
__locale_t locale; |
| 46 |
void *statep; |
| 47 |
int tmp; |
| 48 |
{ |
| 49 |
struct locale_data *const current = locale->__locales[__LC_TIME]; |
| 50 |
const char *rp_backup; |
| 51 |
const char *rp_longest; |
| 52 |
int cnt; |
| 53 |
size_t val; |
| 54 |
enum ptime_locale_status { not, loc, raw } decided_longest; |
| 55 |
struct __strptime_state |
| 56 |
{ |
| 57 |
enum ptime_locale_status decided : 2; |
| 58 |
} s; |
| 59 |
struct tm tmb; |
| 60 |
struct tm *tm; |
| 61 |
if (statep == ((void *)0)) |
| 62 |
{ |
| 63 |
memset (&s, 0, sizeof (s)); |
| 64 |
} |
| 65 |
{ |
| 66 |
tm = &tmb; |
| 67 |
} |
| 68 |
while (*fmt != '\0') |
| 69 |
{ |
| 70 |
if (*fmt != '%') |
| 71 |
{ |
| 72 |
if (*fmt++ != *rp++) return ((void *)0); |
| 73 |
continue; |
| 74 |
} |
| 75 |
if (statep != ((void *)0)) |
| 76 |
{ |
| 77 |
++fmt; |
| 78 |
} |
| 79 |
rp_backup = rp; |
| 80 |
switch (*fmt++) |
| 81 |
{ |
| 82 |
case '%': |
| 83 |
for (cnt = 0; cnt < 7; ++cnt) |
| 84 |
{ |
| 85 |
const char *trp; |
| 86 |
if (s.decided !=raw) |
| 87 |
{ |
| 88 |
if (({ size_t len = strlen ((current->values[((int) (DAY_1 + cnt) & 0xffff)].string)); int result = __strncasecmp_l (((current->values[((int) (DAY_1 + cnt) & 0xffff)].string)), (trp), len, locale) == 0; if (result) (trp) += len; result; }) |
| 89 |
&& trp > rp_longest) |
| 90 |
{ |
| 91 |
} |
| 92 |
if (({ size_t len = strlen ((current->values[((int) (ABDAY_1 + cnt) & 0xffff)].string)); int result = __strncasecmp_l (((current->values[((int) (ABDAY_1 + cnt) & 0xffff)].string)), (trp), len, locale) == 0; if (result) (trp) += len; result; }) |
| 93 |
&& trp > rp_longest) |
| 94 |
{ |
| 95 |
} |
| 96 |
} |
| 97 |
if (s.decided != loc |
| 98 |
&& (((trp = rp, ({ size_t len = strlen ((&_nl_C_LC_TIME.values[((int) (DAY_1) & 0xffff)].string)[cnt]); int result = __strncasecmp_l (((&_nl_C_LC_TIME.values[((int) (DAY_1) & 0xffff)].string)[cnt]), (trp), len, locale) == 0; if (result) (trp) += len; result; })) |
| 99 |
&& trp > rp_longest) |
| 100 |
|| ((trp = rp, ({ size_t len = strlen ((&_nl_C_LC_TIME.values[((int) (ABDAY_1) & 0xffff)].string)[cnt]); int result = __strncasecmp_l (((&_nl_C_LC_TIME.values[((int) (ABDAY_1) & 0xffff)].string)[cnt]), (rp), len, locale) == 0; if (result) (rp) += len; result; })) |
| 101 |
&& trp > rp_longest))) |
| 102 |
{ |
| 103 |
} |
| 104 |
} |
| 105 |
{ |
| 106 |
const char *trp; |
| 107 |
if (s.decided != loc |
| 108 |
&& (((trp = rp, ({ size_t len = strlen ((&_nl_C_LC_TIME.values[((int) (MON_1) & 0xffff)].string)[cnt]); int result = __strncasecmp_l (((&_nl_C_LC_TIME.values[((int) (MON_1) & 0xffff)].string)[cnt]), (trp), len, locale) == 0; if (result) (trp) += len; result; })) |
| 109 |
&& trp > rp_longest) |
| 110 |
|| ((trp = rp, ({ size_t len = strlen ((&_nl_C_LC_TIME.values[((int) (ABMON_1) & 0xffff)].string)[cnt]); int result = __strncasecmp_l (((&_nl_C_LC_TIME.values[((int) (ABMON_1) & 0xffff)].string)[cnt]), (trp), len, locale) == 0; if (result) (trp) += len; result; })) |
| 111 |
&& trp > rp_longest))) |
| 112 |
{ |
| 113 |
} |
| 114 |
} |
| 115 |
case 'c': |
| 116 |
{ |
| 117 |
if (!(*((current->values[((int) (D_T_FMT) & 0xffff)].string)) != '\0' && (rp = __strptime_internal (rp, ((current->values[((int) (D_T_FMT) & 0xffff)].string)), tm, &s , locale)) != ((void *)0))) |
| 118 |
{ |
| 119 |
rp = rp_backup; |
| 120 |
} |
| 121 |
} |
| 122 |
case 'C': |
| 123 |
do { int __n = 2; val = 0; while (*rp == ' ') ++rp; if (*rp < '0' || *rp > '9') return ((void *)0); do { val *= 10; val += *rp++ - '0'; } while (--__n > 0 && val * 10 <= 99 && *rp >= '0' && *rp <= '9'); if (val < 0 || val > 99) return ((void *)0); } while (0); |
| 124 |
case 'F': |
| 125 |
if (!(*("%Y-%m-%d") != '\0' && (rp = __strptime_internal (rp, ("%Y-%m-%d"), tm, &s , locale)) != ((void *)0))) |
| 126 |
tm->tm_hour = val % 12; |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
char * |
| 131 |
__strptime_l (buf, format, tm , locale) |
| 132 |
int buf; |
| 133 |
int format; |
| 134 |
int tm; |
| 135 |
int locale; |
| 136 |
{ |
| 137 |
} |