implement early (mediæval) locale tracking, as a compile-time option,

for SuSE; slightly inspired by the original patch submitted by
From: Dr. Werner Fink <werner@suse.de>
This commit is contained in:
tg 2018-01-13 21:38:10 +00:00
parent 9f3c0efefc
commit aa530d4343
6 changed files with 58 additions and 13 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.730 2018/01/05 20:05:26 tg Exp $' srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.731 2018/01/13 21:38:06 tg Exp $'
#- #-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017 # 2011, 2012, 2013, 2014, 2015, 2016, 2017
@ -2427,7 +2427,7 @@ addsrcs '!' HAVE_STRLCPY strlcpy.c
addsrcs USE_PRINTF_BUILTIN printf.c addsrcs USE_PRINTF_BUILTIN printf.c
test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN test 1 = "$USE_PRINTF_BUILTIN" && add_cppflags -DMKSH_PRINTF_BUILTIN
test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose" test 1 = "$HAVE_CAN_VERB" && CFLAGS="$CFLAGS -verbose"
add_cppflags -DMKSH_BUILD_R=562 add_cppflags -DMKSH_BUILD_R=563
$e $bi$me: Finished configuration testing, now producing output.$ao $e $bi$me: Finished configuration testing, now producing output.$ao
@ -2751,6 +2751,7 @@ MKSH_DISABLE_DEPRECATED disable code paths scheduled for later removal
MKSH_DISABLE_EXPERIMENTAL disable code not yet comfy for (LTS) snapshots MKSH_DISABLE_EXPERIMENTAL disable code not yet comfy for (LTS) snapshots
MKSH_DISABLE_TTY_WARNING shut up warning about ctty if OS cant be fixed MKSH_DISABLE_TTY_WARNING shut up warning about ctty if OS cant be fixed
MKSH_DONT_EMIT_IDSTRING omit RCS IDs from binary MKSH_DONT_EMIT_IDSTRING omit RCS IDs from binary
MKSH_EARLY_LOCALE_TRACKING track utf8-mode from POSIX locale, for SuSE
MKSH_MIDNIGHTBSD01ASH_COMPAT set -o sh: additional compatibility quirk MKSH_MIDNIGHTBSD01ASH_COMPAT set -o sh: additional compatibility quirk
MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use) MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use)
MKSH_NOPWNAM skip PAM calls, for -static on glibc or Solaris MKSH_NOPWNAM skip PAM calls, for -static on glibc or Solaris

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/Makefile,v 1.162 2017/08/29 13:38:29 tg Exp $ # $MirOS: src/bin/mksh/Makefile,v 1.163 2018/01/13 21:38:08 tg Exp $
#- #-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017 # 2011, 2012, 2013, 2014, 2015, 2016, 2017
@ -58,7 +58,7 @@ CPPFLAGS+= -DMKSH_ASSUME_UTF8 -DMKSH_DISABLE_DEPRECATED \
-DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 \ -DHAVE_STRERROR=0 -DHAVE_STRSIGNAL=0 -DHAVE_STRLCPY=1 \
-DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \ -DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 \
-DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \ -DHAVE_SYS_ERRLIST_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
-DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=562 -DHAVE_PERSISTENT_HISTORY=1 -DMKSH_BUILD_R=563
CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U} CPPFLAGS+= -D${${PROG:L}_tf:C/(Mir${MAN:E}{0,1}){2}/4/:S/x/mksh_BUILD/:U}
CPPFLAGS+= -I. CPPFLAGS+= -I.
COPTS+= -std=c89 -Wall COPTS+= -std=c89 -Wall

28
main.c
View File

@ -5,7 +5,7 @@
/*- /*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017 * 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -34,7 +34,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.345 2017/10/14 21:05:22 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.346 2018/01/13 21:38:08 tg Exp $");
#ifndef MKSHRC_PATH #ifndef MKSHRC_PATH
#define MKSHRC_PATH "~/.mkshrc" #define MKSHRC_PATH "~/.mkshrc"
@ -2049,3 +2049,27 @@ init_environ(void)
} }
} }
#endif #endif
#ifdef MKSH_EARLY_LOCALE_TRACKING
void
recheck_ctype(void)
{
const char *ccp;
ccp = str_val(global("LC_ALL"));
if (ccp == null)
ccp = str_val(global("LC_CTYPE"));
if (ccp == null)
ccp = str_val(global("LANG"));
UTFMODE = isuc(ccp);
#if HAVE_SETLOCALE_CTYPE
ccp = setlocale(LC_CTYPE, ccp);
#if HAVE_LANGINFO_CODESET
if (!isuc(ccp))
ccp = nl_langinfo(CODESET);
#endif
if (isuc(ccp))
UTFMODE = 1;
#endif
}
#endif

5
sh.h
View File

@ -182,7 +182,7 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.849 2017/10/17 23:45:19 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.850 2018/01/13 21:38:09 tg Exp $");
#endif #endif
#define MKSH_VERSION "R56 2017/10/17" #define MKSH_VERSION "R56 2017/10/17"
@ -643,7 +643,7 @@ char *ucstrstr(char *, const char *);
#endif #endif
#endif #endif
#if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 562) #if (!defined(MKSH_BUILDMAKEFILE4BSD) && !defined(MKSH_BUILDSH)) || (MKSH_BUILD_R != 563)
#error Must run Build.sh to compile this. #error Must run Build.sh to compile this.
extern void thiswillneverbedefinedIhope(void); extern void thiswillneverbedefinedIhope(void);
int int
@ -2500,6 +2500,7 @@ void shprintf(const char *, ...)
MKSH_A_FORMAT(__printf__, 1, 2); MKSH_A_FORMAT(__printf__, 1, 2);
int can_seek(int); int can_seek(int);
void initio(void); void initio(void);
void recheck_ctype(void);
int ksh_dup2(int, int, bool); int ksh_dup2(int, int, bool);
short savefd(int); short savefd(int);
void restfd(int, int); void restfd(int, int);

20
var.c
View File

@ -2,7 +2,7 @@
/*- /*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015, 2016, 2017 * 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -28,7 +28,7 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.221 2017/10/13 23:34:49 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/var.c,v 1.222 2018/01/13 21:38:10 tg Exp $");
/*- /*-
* Variables * Variables
@ -136,7 +136,7 @@ initvar(void)
struct tbl *tp; struct tbl *tp;
ktinit(APERM, &specials, ktinit(APERM, &specials,
/* currently 18 specials: 75% of 32 = 2^5 */ /* currently 21 specials: 75% of 32 = 2^5 */
5); 5);
while (i < V_MAX - 1) { while (i < V_MAX - 1) {
tp = ktenter(&specials, initvar_names[i], tp = ktenter(&specials, initvar_names[i],
@ -1386,6 +1386,13 @@ setspec(struct tbl *vp)
} }
vp->flag |= SPECIAL; vp->flag |= SPECIAL;
break; break;
#ifdef MKSH_EARLY_LOCALE_TRACKING
case V_LANG:
case V_LC_ALL:
case V_LC_CTYPE:
recheck_ctype();
return;
#endif
default: default:
/* do nothing, do not touch vp at all */ /* do nothing, do not touch vp at all */
return; return;
@ -1485,6 +1492,13 @@ unsetspec(struct tbl *vp)
/* AT&T ksh leaves previous value in place */ /* AT&T ksh leaves previous value in place */
unspecial(vp->name); unspecial(vp->name);
break; break;
#ifdef MKSH_EARLY_LOCALE_TRACKING
case V_LANG:
case V_LC_ALL:
case V_LC_CTYPE:
recheck_ctype();
return;
#endif
} }
} }

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009, 2011, 2012, 2016 * Copyright (c) 2009, 2011, 2012, 2016, 2018
* mirabilos <m@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
@ -19,7 +19,7 @@
*/ */
#if defined(VARSPEC_DEFNS) #if defined(VARSPEC_DEFNS)
__RCSID("$MirOS: src/bin/mksh/var_spec.h,v 1.10 2016/11/11 23:31:39 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/var_spec.h,v 1.11 2018/01/13 21:38:10 tg Exp $");
#define FN(name) /* nothing */ #define FN(name) /* nothing */
#elif defined(VARSPEC_ENUMS) #elif defined(VARSPEC_ENUMS)
#define FN(name) V_##name, #define FN(name) V_##name,
@ -53,6 +53,11 @@ FN(HISTFILE)
#endif #endif
FN(HISTSIZE) FN(HISTSIZE)
FN(IFS) FN(IFS)
#ifdef MKSH_EARLY_LOCALE_TRACKING
FN(LANG)
FN(LC_ALL)
FN(LC_CTYPE)
#endif
#ifdef __OS2__ #ifdef __OS2__
FN(LIBPATHSTRICT) FN(LIBPATHSTRICT)
#endif #endif