mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Add LC_TIME to the supported locale variables (#257)
The current version of 93u+m does not have proper support for the LC_TIME variable. Setting LC_TIME has no effect on printf %T, and if the locale is invalid no error message is shown: $ LC_TIME=ja_JP.UTF-8 $ printf '%T\n' now Wed Apr 7 15:18:13 PDT 2021 $ LC_TIME=invalid.locale $ # No error message src/cmd/ksh93/data/variables.c, src/cmd/ksh93/include/variables.h, src/cmd/ksh93/sh/init.c: - Add support for the $LC_TIME variable. ksh93v- attempted to add support for LC_TIME, but the patch from that version was extended because the variable still didn't function correctly. src/cmd/ksh93/tests/variables.sh: - Add LC_TIME to the regression tests for LC_* variables.
This commit is contained in:
parent
3667aa4f71
commit
b2a7ec032f
6 changed files with 43 additions and 29 deletions
5
NEWS
5
NEWS
|
@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh
|
|||
|
||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||
|
||||
2021-04-07:
|
||||
|
||||
- The $LC_TIME variable is now recognized by ksh and if set to an invalid
|
||||
locale will show an error.
|
||||
|
||||
2021-04-05:
|
||||
|
||||
- Fixed a regression, introduced in ksh 93t+ 2009-07-31, that caused a command
|
||||
|
|
|
@ -78,6 +78,7 @@ const struct shtable2 shtab_variables[] =
|
|||
"LC_CTYPE", 0, (char*)0,
|
||||
"LC_MESSAGES", 0, (char*)0,
|
||||
"LC_NUMERIC", 0, (char*)0,
|
||||
"LC_TIME", 0, (char*)0,
|
||||
"FIGNORE", 0, (char*)0,
|
||||
"KSH_VERSION", 0, (char*)0,
|
||||
"JOBMAX", NV_NOFREE|NV_INTEGER, (char*)0,
|
||||
|
|
|
@ -67,31 +67,32 @@
|
|||
#define LCTYPENOD (shgd->bltin_nodes+37)
|
||||
#define LCMSGNOD (shgd->bltin_nodes+38)
|
||||
#define LCNUMNOD (shgd->bltin_nodes+39)
|
||||
#define FIGNORENOD (shgd->bltin_nodes+40)
|
||||
#define VERSIONNOD (shgd->bltin_nodes+41)
|
||||
#define JOBMAXNOD (shgd->bltin_nodes+42)
|
||||
#define DOTSHNOD (shgd->bltin_nodes+43)
|
||||
#define ED_CHRNOD (shgd->bltin_nodes+44)
|
||||
#define ED_COLNOD (shgd->bltin_nodes+45)
|
||||
#define ED_TXTNOD (shgd->bltin_nodes+46)
|
||||
#define ED_MODENOD (shgd->bltin_nodes+47)
|
||||
#define SH_NAMENOD (shgd->bltin_nodes+48)
|
||||
#define SH_SUBSCRNOD (shgd->bltin_nodes+49)
|
||||
#define SH_VALNOD (shgd->bltin_nodes+50)
|
||||
#define SH_VERSIONNOD (shgd->bltin_nodes+51)
|
||||
#define SH_DOLLARNOD (shgd->bltin_nodes+52)
|
||||
#define SH_MATCHNOD (shgd->bltin_nodes+53)
|
||||
#define SH_COMMANDNOD (shgd->bltin_nodes+54)
|
||||
#define SH_PATHNAMENOD (shgd->bltin_nodes+55)
|
||||
#define SH_FUNNAMENOD (shgd->bltin_nodes+56)
|
||||
#define SH_SUBSHELLNOD (shgd->bltin_nodes+57)
|
||||
#define SH_LEVELNOD (shgd->bltin_nodes+58)
|
||||
#define SH_LINENO (shgd->bltin_nodes+59)
|
||||
#define SH_STATS (shgd->bltin_nodes+60)
|
||||
#define SH_MATHNOD (shgd->bltin_nodes+61)
|
||||
#define SH_JOBPOOL (shgd->bltin_nodes+62)
|
||||
#define SH_PIDNOD (shgd->bltin_nodes+63)
|
||||
#define SH_TILDENOD (shgd->bltin_nodes+64)
|
||||
#define SHLVL (shgd->bltin_nodes+65)
|
||||
#define LCTIMENOD (shgd->bltin_nodes+40)
|
||||
#define FIGNORENOD (shgd->bltin_nodes+41)
|
||||
#define VERSIONNOD (shgd->bltin_nodes+42)
|
||||
#define JOBMAXNOD (shgd->bltin_nodes+43)
|
||||
#define DOTSHNOD (shgd->bltin_nodes+44)
|
||||
#define ED_CHRNOD (shgd->bltin_nodes+45)
|
||||
#define ED_COLNOD (shgd->bltin_nodes+46)
|
||||
#define ED_TXTNOD (shgd->bltin_nodes+47)
|
||||
#define ED_MODENOD (shgd->bltin_nodes+48)
|
||||
#define SH_NAMENOD (shgd->bltin_nodes+49)
|
||||
#define SH_SUBSCRNOD (shgd->bltin_nodes+50)
|
||||
#define SH_VALNOD (shgd->bltin_nodes+51)
|
||||
#define SH_VERSIONNOD (shgd->bltin_nodes+52)
|
||||
#define SH_DOLLARNOD (shgd->bltin_nodes+53)
|
||||
#define SH_MATCHNOD (shgd->bltin_nodes+54)
|
||||
#define SH_COMMANDNOD (shgd->bltin_nodes+55)
|
||||
#define SH_PATHNAMENOD (shgd->bltin_nodes+56)
|
||||
#define SH_FUNNAMENOD (shgd->bltin_nodes+57)
|
||||
#define SH_SUBSHELLNOD (shgd->bltin_nodes+58)
|
||||
#define SH_LEVELNOD (shgd->bltin_nodes+59)
|
||||
#define SH_LINENO (shgd->bltin_nodes+60)
|
||||
#define SH_STATS (shgd->bltin_nodes+61)
|
||||
#define SH_MATHNOD (shgd->bltin_nodes+62)
|
||||
#define SH_JOBPOOL (shgd->bltin_nodes+63)
|
||||
#define SH_PIDNOD (shgd->bltin_nodes+64)
|
||||
#define SH_TILDENOD (shgd->bltin_nodes+65)
|
||||
#define SHLVL (shgd->bltin_nodes+66)
|
||||
|
||||
#endif /* SH_VALNOD */
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||
#define SH_RELEASE_SVER "1.0.0-alpha" /* semantic version number: https://semver.org */
|
||||
#define SH_RELEASE_DATE "2021-04-05" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_DATE "2021-04-07" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK
|
||||
|
||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||
|
|
|
@ -194,6 +194,7 @@ typedef struct _init_
|
|||
Namfun_t SH_MATH_init;
|
||||
#ifdef _hdr_locale
|
||||
Namfun_t LC_TYPE_init;
|
||||
Namfun_t LC_TIME_init;
|
||||
Namfun_t LC_NUM_init;
|
||||
Namfun_t LC_COLL_init;
|
||||
Namfun_t LC_MSG_init;
|
||||
|
@ -438,6 +439,8 @@ static void put_cdpath(register Namval_t* np,const char *val,int flags,Namfun_t
|
|||
type = LC_COLLATE;
|
||||
else if(name==(LCNUMNOD)->nvname)
|
||||
type = LC_NUMERIC;
|
||||
else if(name==(LCTIMENOD)->nvname)
|
||||
type = LC_TIME;
|
||||
#ifdef LC_LANG
|
||||
else if(name==(LANGNOD)->nvname)
|
||||
type = LC_LANG;
|
||||
|
@ -1598,7 +1601,7 @@ Namfun_t *nv_cover(register Namval_t *np)
|
|||
if(np==IFSNOD || np==PATHNOD || np==SHELLNOD || np==FPATHNOD || np==CDPNOD || np==SECONDS || np==ENVNOD || np==LINENO)
|
||||
return(np->nvfun);
|
||||
#ifdef _hdr_locale
|
||||
if(np==LCALLNOD || np==LCTYPENOD || np==LCMSGNOD || np==LCCOLLNOD || np==LCNUMNOD || np==LANGNOD)
|
||||
if(np==LCALLNOD || np==LCTYPENOD || np==LCMSGNOD || np==LCCOLLNOD || np==LCNUMNOD || np==LCTIMENOD || np==LANGNOD)
|
||||
return(np->nvfun);
|
||||
#endif
|
||||
return(0);
|
||||
|
@ -1765,6 +1768,8 @@ static Init_t *nv_init(Shell_t *shp)
|
|||
#ifdef _hdr_locale
|
||||
ip->LC_TYPE_init.disc = &LC_disc;
|
||||
ip->LC_TYPE_init.nofree = 1;
|
||||
ip->LC_TIME_init.disc = &LC_disc;
|
||||
ip->LC_TIME_init.nofree = 1;
|
||||
ip->LC_NUM_init.disc = &LC_disc;
|
||||
ip->LC_NUM_init.nofree = 1;
|
||||
ip->LC_COLL_init.disc = &LC_disc;
|
||||
|
@ -1807,6 +1812,7 @@ static Init_t *nv_init(Shell_t *shp)
|
|||
nv_stack(LCMSGNOD, &ip->LC_MSG_init);
|
||||
nv_stack(LCCOLLNOD, &ip->LC_COLL_init);
|
||||
nv_stack(LCNUMNOD, &ip->LC_NUM_init);
|
||||
nv_stack(LCTIMENOD, &ip->LC_TIME_init);
|
||||
nv_stack(LANGNOD, &ip->LANG_init);
|
||||
#endif /* _hdr_locale */
|
||||
(PPIDNOD)->nvalue.pidp = (&shp->gd->ppid);
|
||||
|
|
|
@ -746,7 +746,7 @@ Errors=$? # ensure error count survives subshell
|
|||
exit $Errors
|
||||
fi
|
||||
|
||||
for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC
|
||||
for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC LC_TIME
|
||||
do nameref r=$v
|
||||
unset $v
|
||||
[[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'"
|
||||
|
@ -921,6 +921,7 @@ set -- \
|
|||
"LC_CTYPE" \
|
||||
"LC_MESSAGES" \
|
||||
"LC_NUMERIC" \
|
||||
"LC_TIME" \
|
||||
"FIGNORE" \
|
||||
"KSH_VERSION" \
|
||||
"JOBMAX" \
|
||||
|
|
Loading…
Reference in a new issue