diff options
Diffstat (limited to 'src/strftime.c')
| -rw-r--r-- | src/strftime.c | 79 |
1 files changed, 17 insertions, 62 deletions
diff --git a/src/strftime.c b/src/strftime.c index a7617427793..5a0923e3723 100644 --- a/src/strftime.c +++ b/src/strftime.c | |||
| @@ -179,11 +179,8 @@ extern char *tzname[]; | |||
| 179 | Similarly for localtime_r. */ | 179 | Similarly for localtime_r. */ |
| 180 | 180 | ||
| 181 | # if ! HAVE_TM_GMTOFF | 181 | # if ! HAVE_TM_GMTOFF |
| 182 | static struct tm *my_strftime_gmtime_r (const time_t *, struct tm *); | ||
| 183 | static struct tm * | 182 | static struct tm * |
| 184 | my_strftime_gmtime_r (t, tp) | 183 | my_strftime_gmtime_r (const time_t *t, struct tm *tp) |
| 185 | const time_t *t; | ||
| 186 | struct tm *tp; | ||
| 187 | { | 184 | { |
| 188 | struct tm *l = gmtime (t); | 185 | struct tm *l = gmtime (t); |
| 189 | if (! l) | 186 | if (! l) |
| @@ -192,11 +189,8 @@ my_strftime_gmtime_r (t, tp) | |||
| 192 | return tp; | 189 | return tp; |
| 193 | } | 190 | } |
| 194 | 191 | ||
| 195 | static struct tm *my_strftime_localtime_r (const time_t *, struct tm *); | ||
| 196 | static struct tm * | 192 | static struct tm * |
| 197 | my_strftime_localtime_r (t, tp) | 193 | my_strftime_localtime_r (const time_t *t, struct tm *tp) |
| 198 | const time_t *t; | ||
| 199 | struct tm *tp; | ||
| 200 | { | 194 | { |
| 201 | struct tm *l = localtime (t); | 195 | struct tm *l = localtime (t); |
| 202 | if (! l) | 196 | if (! l) |
| @@ -318,14 +312,10 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ | |||
| 318 | # undef _NL_CURRENT | 312 | # undef _NL_CURRENT |
| 319 | # define _NL_CURRENT(category, item) \ | 313 | # define _NL_CURRENT(category, item) \ |
| 320 | (current->values[_NL_ITEM_INDEX (item)].string) | 314 | (current->values[_NL_ITEM_INDEX (item)].string) |
| 321 | # define LOCALE_PARAM , loc | ||
| 322 | # define LOCALE_ARG , loc | 315 | # define LOCALE_ARG , loc |
| 323 | # define LOCALE_PARAM_DECL __locale_t loc; | 316 | # define LOCALE_PARAM_DECL , __locale_t loc |
| 324 | # define LOCALE_PARAM_PROTO , __locale_t loc | ||
| 325 | # define HELPER_LOCALE_ARG , current | 317 | # define HELPER_LOCALE_ARG , current |
| 326 | #else | 318 | #else |
| 327 | # define LOCALE_PARAM | ||
| 328 | # define LOCALE_PARAM_PROTO | ||
| 329 | # define LOCALE_ARG | 319 | # define LOCALE_ARG |
| 330 | # define LOCALE_PARAM_DECL | 320 | # define LOCALE_PARAM_DECL |
| 331 | # ifdef _LIBC | 321 | # ifdef _LIBC |
| @@ -363,30 +353,16 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ | |||
| 363 | more reliable way to accept other sets of digits. */ | 353 | more reliable way to accept other sets of digits. */ |
| 364 | #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) | 354 | #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) |
| 365 | 355 | ||
| 366 | static CHAR_T *memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, | ||
| 367 | size_t len LOCALE_PARAM_PROTO); | ||
| 368 | |||
| 369 | static CHAR_T * | 356 | static CHAR_T * |
| 370 | memcpy_lowcase (dest, src, len LOCALE_PARAM) | 357 | memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL) |
| 371 | CHAR_T *dest; | ||
| 372 | const CHAR_T *src; | ||
| 373 | size_t len; | ||
| 374 | LOCALE_PARAM_DECL | ||
| 375 | { | 358 | { |
| 376 | while (len-- > 0) | 359 | while (len-- > 0) |
| 377 | dest[len] = TOLOWER ((UCHAR_T) src[len], loc); | 360 | dest[len] = TOLOWER ((UCHAR_T) src[len], loc); |
| 378 | return dest; | 361 | return dest; |
| 379 | } | 362 | } |
| 380 | 363 | ||
| 381 | static CHAR_T *memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, | ||
| 382 | size_t len LOCALE_PARAM_PROTO); | ||
| 383 | |||
| 384 | static CHAR_T * | 364 | static CHAR_T * |
| 385 | memcpy_uppcase (dest, src, len LOCALE_PARAM) | 365 | memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL) |
| 386 | CHAR_T *dest; | ||
| 387 | const CHAR_T *src; | ||
| 388 | size_t len; | ||
| 389 | LOCALE_PARAM_DECL | ||
| 390 | { | 366 | { |
| 391 | while (len-- > 0) | 367 | while (len-- > 0) |
| 392 | dest[len] = TOUPPER ((UCHAR_T) src[len], loc); | 368 | dest[len] = TOUPPER ((UCHAR_T) src[len], loc); |
| @@ -398,11 +374,8 @@ memcpy_uppcase (dest, src, len LOCALE_PARAM) | |||
| 398 | /* Yield the difference between *A and *B, | 374 | /* Yield the difference between *A and *B, |
| 399 | measured in seconds, ignoring leap seconds. */ | 375 | measured in seconds, ignoring leap seconds. */ |
| 400 | # define tm_diff ftime_tm_diff | 376 | # define tm_diff ftime_tm_diff |
| 401 | static int tm_diff (const struct tm *, const struct tm *); | ||
| 402 | static int | 377 | static int |
| 403 | tm_diff (a, b) | 378 | tm_diff (const struct tm *a, const struct tm *b) |
| 404 | const struct tm *a; | ||
| 405 | const struct tm *b; | ||
| 406 | { | 379 | { |
| 407 | /* Compute intervening leap days correctly even if year is negative. | 380 | /* Compute intervening leap days correctly even if year is negative. |
| 408 | Take care to avoid int overflow in leap day calculations, | 381 | Take care to avoid int overflow in leap day calculations, |
| @@ -437,9 +410,7 @@ static int iso_week_days (int, int); | |||
| 437 | __inline__ | 410 | __inline__ |
| 438 | #endif | 411 | #endif |
| 439 | static int | 412 | static int |
| 440 | iso_week_days (yday, wday) | 413 | iso_week_days (int yday, int wday) |
| 441 | int yday; | ||
| 442 | int wday; | ||
| 443 | { | 414 | { |
| 444 | /* Add enough to the first operand of % to make it nonnegative. */ | 415 | /* Add enough to the first operand of % to make it nonnegative. */ |
| 445 | int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; | 416 | int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; |
| @@ -470,8 +441,7 @@ static CHAR_T const month_name[][10] = | |||
| 470 | 441 | ||
| 471 | #ifdef my_strftime | 442 | #ifdef my_strftime |
| 472 | # define extra_args , ut, ns | 443 | # define extra_args , ut, ns |
| 473 | # define extra_args_spec int ut; int ns; | 444 | # define extra_args_spec , int ut, int ns |
| 474 | # define extra_args_spec_iso , int ut, int ns | ||
| 475 | #else | 445 | #else |
| 476 | # ifdef COMPILE_WIDE | 446 | # ifdef COMPILE_WIDE |
| 477 | # define my_strftime wcsftime | 447 | # define my_strftime wcsftime |
| @@ -482,7 +452,6 @@ static CHAR_T const month_name[][10] = | |||
| 482 | # endif | 452 | # endif |
| 483 | # define extra_args | 453 | # define extra_args |
| 484 | # define extra_args_spec | 454 | # define extra_args_spec |
| 485 | # define extra_args_spec_iso | ||
| 486 | /* We don't have this information in general. */ | 455 | /* We don't have this information in general. */ |
| 487 | # define ut 0 | 456 | # define ut 0 |
| 488 | # define ns 0 | 457 | # define ns 0 |
| @@ -491,15 +460,12 @@ static CHAR_T const month_name[][10] = | |||
| 491 | #if !defined _LIBC && !defined(WINDOWSNT) && HAVE_TZNAME && HAVE_TZSET | 460 | #if !defined _LIBC && !defined(WINDOWSNT) && HAVE_TZNAME && HAVE_TZSET |
| 492 | /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. | 461 | /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. |
| 493 | Work around this bug by copying *tp before it might be munged. */ | 462 | Work around this bug by copying *tp before it might be munged. */ |
| 494 | size_t _strftime_copytm (char *, size_t, const char *, | ||
| 495 | const struct tm * extra_args_spec_iso); | ||
| 496 | size_t | 463 | size_t |
| 497 | my_strftime (s, maxsize, format, tp extra_args) | 464 | _strftime_copytm (CHAR_T *s, size_t maxsize, const CHAR_T *format, |
| 498 | CHAR_T *s; | 465 | const struct tm *tp extra_args_spec LOCALE_PARAM_DECL); |
| 499 | size_t maxsize; | 466 | size_t |
| 500 | const CHAR_T *format; | 467 | my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, |
| 501 | const struct tm *tp; | 468 | const struct tm *tp extra_args_spec) |
| 502 | extra_args_spec | ||
| 503 | { | 469 | { |
| 504 | struct tm tmcopy; | 470 | struct tm tmcopy; |
| 505 | tmcopy = *tp; | 471 | tmcopy = *tp; |
| @@ -517,13 +483,8 @@ static CHAR_T const month_name[][10] = | |||
| 517 | anywhere, so to determine how many characters would be | 483 | anywhere, so to determine how many characters would be |
| 518 | written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ | 484 | written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ |
| 519 | size_t | 485 | size_t |
| 520 | my_strftime (s, maxsize, format, tp extra_args LOCALE_PARAM) | 486 | my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, |
| 521 | CHAR_T *s; | 487 | const struct tm *tp extra_args_spec LOCALE_PARAM_DECL) |
| 522 | size_t maxsize; | ||
| 523 | const CHAR_T *format; | ||
| 524 | const struct tm *tp; | ||
| 525 | extra_args_spec | ||
| 526 | LOCALE_PARAM_DECL | ||
| 527 | { | 488 | { |
| 528 | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL | 489 | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL |
| 529 | struct locale_data *const current = loc->__locales[LC_TIME]; | 490 | struct locale_data *const current = loc->__locales[LC_TIME]; |
| @@ -1474,16 +1435,10 @@ libc_hidden_def (my_strftime) | |||
| 1474 | /* For Emacs we have a separate interface which corresponds to the normal | 1435 | /* For Emacs we have a separate interface which corresponds to the normal |
| 1475 | strftime function plus the ut argument, but without the ns argument. */ | 1436 | strftime function plus the ut argument, but without the ns argument. */ |
| 1476 | size_t | 1437 | size_t |
| 1477 | emacs_strftimeu (s, maxsize, format, tp, ut) | 1438 | emacs_strftimeu (char *s, size_t maxsize, const char *format, |
| 1478 | char *s; | 1439 | const struct tm *tp, int ut) |
| 1479 | size_t maxsize; | ||
| 1480 | const char *format; | ||
| 1481 | const struct tm *tp; | ||
| 1482 | int ut; | ||
| 1483 | { | 1440 | { |
| 1484 | return my_strftime (s, maxsize, format, tp, ut, 0); | 1441 | return my_strftime (s, maxsize, format, tp, ut, 0); |
| 1485 | } | 1442 | } |
| 1486 | #endif | 1443 | #endif |
| 1487 | 1444 | ||
| 1488 | /* arch-tag: 662bc9c4-f8e2-41b6-bf96-b8346d0ce0d8 | ||
| 1489 | (do not change this comment) */ | ||