This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 3/3] time: Add tests for Minguo calendar [BZ #24293]
- From: TAMUKI Shoichi <tamuki at linet dot gr dot jp>
- To: Rafal Luzynski <digitalfreak at lingonborough dot com>, libc-alpha at sourceware dot org
- Cc: Felix Yan <felixonmars at archlinux dot org>
- Date: Sun, 17 Mar 2019 19:35:15 +0900
- Subject: Re: [PATCH 3/3] time: Add tests for Minguo calendar [BZ #24293]
- References: <1517391513.248381.1552650568043@poczta.nazwa.pl>
Hello Rafal-san,
From: Rafal Luzynski <digitalfreak@lingonborough.com>
Subject: [PATCH 3/3] time: Add tests for Minguo calendar [BZ #24293]
Date: Fri, 15 Mar 2019 12:49:27 +0100 (CET)
> [BZ #24293]
> * time/Makefile (LOCALES): Add cmn_TW.UTF-8 and zh_TW.UTF-8.
> * time/tst-strftime2.c (locales): Likewise.
Since cmn_TW.UTF8 and zh_TW.UTF-8 are practically the same, I think
that the test of only zh_TW.UTF-8 is sufficient.
> (dates): Add 1910-04-01, 1911-12-31, 1912-07-29, 1912-07-30,
> and 1913-04-01.
It is recommended to add 2010 and 2011 to see Y1C issue of Minguo
calendar.
> (mkreftable): Add rules for the new locales and the new dates.
Looks good to me.
> diff --git a/time/Makefile b/time/Makefile
> index 5c6304e..9f70800 100644
> --- a/time/Makefile
> +++ b/time/Makefile
> @@ -50,7 +50,7 @@ include ../Rules
> ifeq ($(run-built-tests),yes)
> LOCALES := de_DE.ISO-8859-1 en_US.ISO-8859-1 ja_JP.EUC-JP fr_FR.UTF-8 \
> es_ES.UTF-8 pl_PL.UTF-8 ru_RU.UTF-8 \
> - ja_JP.UTF-8 lo_LA.UTF-8 th_TH.UTF-8
> + ja_JP.UTF-8 lo_LA.UTF-8 th_TH.UTF-8 cmn_TW.UTF-8 zh_TW.UTF-8
> include ../gen-locales.mk
>
> $(objpfx)tst-ftime_l.out: $(gen-locales)
I think that the addition of only zh_TW.UTF-8 is good enough.
> diff --git a/time/tst-strftime2.c b/time/tst-strftime2.c
> index bf5a66d..fb7f6cd 100644
> --- a/time/tst-strftime2.c
> +++ b/time/tst-strftime2.c
> @@ -26,7 +26,8 @@
> #include <stdio.h>
> #include <string.h>
>
> -static const char *locales[] = { "ja_JP.UTF-8", "lo_LA.UTF-8",
> "th_TH.UTF-8" };
> +static const char *locales[] = { "ja_JP.UTF-8", "lo_LA.UTF-8",
> "th_TH.UTF-8",
> + "cmn_TW.UTF-8", "zh_TW.UTF-8" };
>
> static const char *formats[] = { "%EY", "%_EY", "%-EY" };
>
Ditto.
> @@ -37,6 +38,11 @@ typedef struct
>
> static const date_t dates[] =
> {
> + { 1, 4, 1910 },
> + { 31, 12, 1911 },
> + { 29, 7, 1912 },
> + { 30, 7, 1912 },
> + { 1, 4, 1913 },
> { 1, 4, 1988 },
> { 7, 1, 1989 },
> { 8, 1, 1989 },
It is recommended to add 2010 and 2011. Also, please align existing
lines.
Recommend instead:
| @@ -37,12 +38,19 @@ typedef struct
|
| static const date_t dates[] =
| {
| - { 1, 4, 1988 },
| - { 7, 1, 1989 },
| - { 8, 1, 1989 },
| - { 1, 4, 1990 },
| - { 1, 4, 1997 },
| - { 1, 4, 1998 }
| + { 1, 4, 1910 },
| + { 31, 12, 1911 },
| + { 29, 7, 1912 },
| + { 30, 7, 1912 },
| + { 1, 4, 1913 },
| + { 1, 4, 1988 },
| + { 7, 1, 1989 },
| + { 8, 1, 1989 },
| + { 1, 4, 1990 },
| + { 1, 4, 1997 },
| + { 1, 4, 1998 },
| + { 1, 4, 2010 },
| + { 1, 4, 2011 }
| };
|
| static char ref[array_length (locales)][array_length (formats)]
> @@ -68,8 +74,10 @@ mkreftable (void)
> {
> int i, j, k;
> const char *era;
> - static const int yrj[] = { 63, 64, 1, 2, 9, 10 };
> - static const int yrb[] = { 2531, 2532, 2532, 2533, 2540, 2541 };
> + static const int yrj[] = { 43, 44, 45, 1, 2, 63, 64, 1, 2, 9, 10 };
> + static const int yrb[] = { 2453, 2454, 2455, 2455, 2456,
> + 2531, 2532, 2532, 2533, 2540, 2541 };
> + static const int yrc[] = { 2, 1, 1, 1, 2, 77, 78, 78, 79, 86, 87 };
>
> for (i = 0; i < array_length (locales); i++)
> for (j = 0; j < array_length (formats); j++)
Please add 2010 and 2011 according to the above.
> @@ -77,7 +85,11 @@ mkreftable (void)
> {
> if (i == 0) /* ja_JP */
> {
> - if (is_before (&dates[k], 8, 1, 1989))
> + if (is_before (&dates[k], 30, 7, 1912))
> + era = "\xe6\x98\x8e\xe6\xb2\xbb";
> + else if (is_before (&dates[k], 25, 12, 1926))
> + era = "\xe5\xa4\xa7\xe6\xad\xa3";
> + else if (is_before (&dates[k], 8, 1, 1989))
> era = "\xe6\x98\xad\xe5\x92\x8c";
> else
> era = "\xe5\xb9\xb3\xe6\x88\x90";
OK.
> @@ -104,6 +116,36 @@ mkreftable (void)
> era = "\xe0\xb8\x9e\x2e\xe0\xb8\xa8\x2e ";
> sprintf (ref[i][j][k], "%s%d", era, yrb[k]);
> }
> + else if (i == 3) /* cmn_TW */
> + {
> + if (is_before (&dates[k], 1, 1, 1912))
> + era = "\xe6\xb0\x91\xe5\x89\x8d";
> + else
> + era = "\xe6\xb0\x91\xe5\x9c\x8b";
> + if (dates[k].y == 1912)
> + sprintf (ref[i][j][k], "%s\xe5\x85\x83\xe5\xb9\xb4", era);
> + else if (j == 0)
> + sprintf (ref[i][j][k], "%s%02d\xe5\xb9\xb4", era, yrc[k]);
> + else if (j == 1)
> + sprintf (ref[i][j][k], "%s%2d\xe5\xb9\xb4", era, yrc[k]);
> + else
> + sprintf (ref[i][j][k], "%s%d\xe5\xb9\xb4", era, yrc[k]);
> + }
> + else if (i == 4) /* zh_TW */
> + {
> + if (is_before (&dates[k], 1, 1, 1912))
> + era = "\xe6\xb0\x91\xe5\x89\x8d";
> + else
> + era = "\xe6\xb0\x91\xe5\x9c\x8b";
> + if (dates[k].y == 1912)
> + sprintf (ref[i][j][k], "%s\xe5\x85\x83\xe5\xb9\xb4", era);
> + else if (j == 0)
> + sprintf (ref[i][j][k], "%s%02d\xe5\xb9\xb4", era, yrc[k]);
> + else if (j == 1)
> + sprintf (ref[i][j][k], "%s%2d\xe5\xb9\xb4", era, yrc[k]);
> + else
> + sprintf (ref[i][j][k], "%s%d\xe5\xb9\xb4", era, yrc[k]);
> + }
> else
> {
> assert (0); /* Unreachable. */
Since cmn_TW.UTF8 and zh_TW.UTF-8 are practically the same, you can
omit the test of cmn_TW.
Thank you for your contribution.
Regards,
TAMUKI Shoichi