diff options
Diffstat (limited to 'gl/nl_langinfo.c')
| -rw-r--r-- | gl/nl_langinfo.c | 105 |
1 files changed, 77 insertions, 28 deletions
diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c index 64ff93b0..0180c26a 100644 --- a/gl/nl_langinfo.c +++ b/gl/nl_langinfo.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* nl_langinfo() replacement: query locale dependent information. | 1 | /* nl_langinfo() replacement: query locale dependent information. |
| 2 | 2 | ||
| 3 | Copyright (C) 2007-2024 Free Software Foundation, Inc. | 3 | Copyright (C) 2007-2025 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -154,11 +154,15 @@ ctype_codeset (void) | |||
| 154 | "thread5 disturbed by threadN!", even when threadN invokes only | 154 | "thread5 disturbed by threadN!", even when threadN invokes only |
| 155 | nl_langinfo (CODESET); | 155 | nl_langinfo (CODESET); |
| 156 | nl_langinfo (CRNCYSTR); | 156 | nl_langinfo (CRNCYSTR); |
| 157 | Similarly on Solaris 10. */ | 157 | Similarly on Solaris 10 and macOS 26. */ |
| 158 | 158 | ||
| 159 | # if !NL_LANGINFO_MTSAFE /* Solaris */ | 159 | # if !NL_LANGINFO_MTSAFE /* macOS, Solaris */ |
| 160 | 160 | ||
| 161 | # define ITEMS (MAXSTRMSG + 1) | 161 | # ifdef __sun /* Solaris */ |
| 162 | # define ITEMS (MAXSTRMSG + 1) | ||
| 163 | # else /* macOS */ | ||
| 164 | # define ITEMS (CRNCYSTR + 20) | ||
| 165 | # endif | ||
| 162 | # define MAX_RESULT_LEN 80 | 166 | # define MAX_RESULT_LEN 80 |
| 163 | 167 | ||
| 164 | static char * | 168 | static char * |
| @@ -317,6 +321,24 @@ rpl_nl_langinfo (nl_item item) | |||
| 317 | item = item - ALTMON_1 + MON_1; | 321 | item = item - ALTMON_1 + MON_1; |
| 318 | break; | 322 | break; |
| 319 | # endif | 323 | # endif |
| 324 | # if GNULIB_defined_ABALTMON | ||
| 325 | case ABALTMON_1: | ||
| 326 | case ABALTMON_2: | ||
| 327 | case ABALTMON_3: | ||
| 328 | case ABALTMON_4: | ||
| 329 | case ABALTMON_5: | ||
| 330 | case ABALTMON_6: | ||
| 331 | case ABALTMON_7: | ||
| 332 | case ABALTMON_8: | ||
| 333 | case ABALTMON_9: | ||
| 334 | case ABALTMON_10: | ||
| 335 | case ABALTMON_11: | ||
| 336 | case ABALTMON_12: | ||
| 337 | /* We don't ship the appropriate localizations with gnulib. Therefore, | ||
| 338 | treat ABALTMON_i like ABMON_i. */ | ||
| 339 | item = item - ABALTMON_1 + ABMON_1; | ||
| 340 | break; | ||
| 341 | # endif | ||
| 320 | # if GNULIB_defined_ERA | 342 | # if GNULIB_defined_ERA |
| 321 | case ERA: | 343 | case ERA: |
| 322 | /* The format is not standardized. In glibc it is a sequence of strings | 344 | /* The format is not standardized. In glibc it is a sequence of strings |
| @@ -510,30 +532,57 @@ nl_langinfo (nl_item item) | |||
| 510 | return result[item - ALTMON_1]; | 532 | return result[item - ALTMON_1]; |
| 511 | } | 533 | } |
| 512 | } | 534 | } |
| 513 | case ABMON_1: | 535 | { |
| 514 | case ABMON_2: | 536 | static char const abmonths[][sizeof "Jan"] = { |
| 515 | case ABMON_3: | 537 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", |
| 516 | case ABMON_4: | 538 | "Aug", "Sep", "Oct", "Nov", "Dec" |
| 517 | case ABMON_5: | 539 | }; |
| 518 | case ABMON_6: | 540 | case ABMON_1: |
| 519 | case ABMON_7: | 541 | case ABMON_2: |
| 520 | case ABMON_8: | 542 | case ABMON_3: |
| 521 | case ABMON_9: | 543 | case ABMON_4: |
| 522 | case ABMON_10: | 544 | case ABMON_5: |
| 523 | case ABMON_11: | 545 | case ABMON_6: |
| 524 | case ABMON_12: | 546 | case ABMON_7: |
| 525 | { | 547 | case ABMON_8: |
| 526 | static char result[12][30]; | 548 | case ABMON_9: |
| 527 | static char const abmonths[][sizeof "Jan"] = { | 549 | case ABMON_10: |
| 528 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", | 550 | case ABMON_11: |
| 529 | "Aug", "Sep", "Oct", "Nov", "Dec" | 551 | case ABMON_12: |
| 530 | }; | 552 | { |
| 531 | tmm.tm_mon = item - ABMON_1; | 553 | static char result[12][30]; |
| 532 | if (!strftime (buf, sizeof result[0], "%b", &tmm)) | 554 | tmm.tm_mon = item - ABMON_1; |
| 533 | return (char *) abmonths[item - ABMON_1]; | 555 | if (!strftime (buf, sizeof result[0], "%b", &tmm)) |
| 534 | strcpy (result[item - ABMON_1], buf); | 556 | return (char *) abmonths[item - ABMON_1]; |
| 535 | return result[item - ABMON_1]; | 557 | strcpy (result[item - ABMON_1], buf); |
| 536 | } | 558 | return result[item - ABMON_1]; |
| 559 | } | ||
| 560 | case ABALTMON_1: | ||
| 561 | case ABALTMON_2: | ||
| 562 | case ABALTMON_3: | ||
| 563 | case ABALTMON_4: | ||
| 564 | case ABALTMON_5: | ||
| 565 | case ABALTMON_6: | ||
| 566 | case ABALTMON_7: | ||
| 567 | case ABALTMON_8: | ||
| 568 | case ABALTMON_9: | ||
| 569 | case ABALTMON_10: | ||
| 570 | case ABALTMON_11: | ||
| 571 | case ABALTMON_12: | ||
| 572 | { | ||
| 573 | static char result[12][50]; | ||
| 574 | tmm.tm_mon = item - ABALTMON_1; | ||
| 575 | /* The platforms without nl_langinfo() don't support strftime with | ||
| 576 | %Ob. We don't even need to try. */ | ||
| 577 | #if 0 | ||
| 578 | if (!strftime (buf, sizeof result[0], "%Ob", &tmm)) | ||
| 579 | #endif | ||
| 580 | if (!strftime (buf, sizeof result[0], "%b", &tmm)) | ||
| 581 | return (char *) abmonths[item - ABALTMON_1]; | ||
| 582 | strcpy (result[item - ABALTMON_1], buf); | ||
| 583 | return result[item - ABALTMON_1]; | ||
| 584 | } | ||
| 585 | } | ||
| 537 | case ERA: | 586 | case ERA: |
| 538 | return (char *) ""; | 587 | return (char *) ""; |
| 539 | case ALT_DIGITS: | 588 | case ALT_DIGITS: |
