| 182 | #endif |
| 183 | |
| 184 | size_t |
| 185 | strftime(char *restrict s, size_t maxsize, char const *restrict format, |
| 186 | struct tm const *restrict t) |
| 187 | { |
| 188 | char * p; |
| 189 | int saved_errno = errno; |
| 190 | enum warn warn = IN_NONE; |
| 191 | |
| 192 | tzset(); |
| 193 | p = _fmt(format, t, s, s + maxsize, &warn); |
| 194 | if (DEPRECATE_TWO_DIGIT_YEARS |
| 195 | && warn != IN_NONE && getenv(YEAR_2000_NAME)) { |
| 196 | fprintf(stderr, "\n"); |
| 197 | fprintf(stderr, "strftime format \"%s\" ", format); |
| 198 | fprintf(stderr, "yields only two digits of years in "); |
| 199 | if (warn == IN_SOME) |
| 200 | fprintf(stderr, "some locales"); |
| 201 | else if (warn == IN_THIS) |
| 202 | fprintf(stderr, "the current locale"); |
| 203 | else fprintf(stderr, "all locales"); |
| 204 | fprintf(stderr, "\n"); |
| 205 | } |
| 206 | if (p == s + maxsize) { |
| 207 | errno = ERANGE; |
| 208 | return 0; |
| 209 | } |
| 210 | *p = '\0'; |
| 211 | errno = saved_errno; |
| 212 | return p - s; |
| 213 | } |
| 214 | |
| 215 | static char * |
| 216 | _fmt(const char *format, const struct tm *t, char *pt, |
no test coverage detected