mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-28 16:09:51 +02:00
test suite fixes for some locales; fix to make bind -x bindings work with negative arguments; several portability fixes from pkgsrc; fixes for funsubs with return builtin state and local OPTIND
This commit is contained in:
@@ -8029,3 +8029,57 @@ examples/loadables/strptime.c
|
||||
to a number of built-in formats. If successful, it outputs the
|
||||
result as a number of seconds since the epoch. Understands some
|
||||
handy shorthands like "now" and "tomorrow".
|
||||
|
||||
11/24
|
||||
-----
|
||||
tests/unicode1.sub
|
||||
- update the driver function using namerefs and ${!x[@]}
|
||||
- zh_TW.BIG5: fixed some problems with the test encodings.
|
||||
Report and patches from Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
11/25
|
||||
-----
|
||||
tests/glob2.sub
|
||||
- zh_HK.big5hkscs -> zh_TW.big5 to work around macOS 14 issues with
|
||||
BSD-based locale definition
|
||||
|
||||
bashline.c
|
||||
- bash_execute_unix_command: check count != 1 instead of count > 1 to
|
||||
handle negative arguments
|
||||
|
||||
lib/readline/bind.c
|
||||
- rl_trim_arg_from_keyseq: change the parsing_digits logic to handle
|
||||
multiple instances of `-' the same way rl_digit_loop does (collapse
|
||||
to 1)
|
||||
- rl_trim_arg_from_keyseq: fix typo to correctly recognize a `-'
|
||||
after a key sequence bound to universal-argument
|
||||
- rl_trim_arg_from_keyseq: trim negative argument for a key sequence
|
||||
that is shadowed by a longer key sequence (ANYOTHERKEY)
|
||||
Report and patches from Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
11/27
|
||||
-----
|
||||
support/shobj-conf
|
||||
- solaris2: change PIC option for non-gcc Solaris 2 builds
|
||||
|
||||
lib/malloc/malloc.c
|
||||
- binsize: make sure indexing into binsizes casts to size_t (unsigned)
|
||||
|
||||
examples/loadables/getconf.c
|
||||
- protect more of the _SC defines with #ifdefs for different systems
|
||||
|
||||
examples/loadables/fdflags.c
|
||||
- ALLFLAGS: add some more flag values from Solaris/AIX/HP-UX
|
||||
|
||||
11/28
|
||||
-----
|
||||
subst.c
|
||||
- function_substitute: unwind return_catch_flag unconditionally
|
||||
Report and patch from Grisha Levit <grishalevit@gmail.com>
|
||||
- function_substitute: save getopts state and restore it if the
|
||||
funsub declares a local copy of OPTIND
|
||||
Report and patch from Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
lib/readline/display.c
|
||||
- rl_redisplay: make sure lpos is initialized to 0 if local_prompt is
|
||||
NULL
|
||||
|
||||
+2
-2
@@ -4484,7 +4484,7 @@ bash_execute_unix_command (int count, int key)
|
||||
kslen = rl_key_sequence_length;
|
||||
|
||||
/* If we have a numeric argument, chop it off the front of the key sequence */
|
||||
if (count > 1 || rl_explicit_arg)
|
||||
if (count != 1 || rl_explicit_arg)
|
||||
{
|
||||
i = rl_trim_arg_from_keyseq (rl_executing_keyseq, rl_key_sequence_length, rl_get_keymap ());
|
||||
if (i > 0)
|
||||
@@ -4536,7 +4536,7 @@ bash_execute_unix_command (int count, int key)
|
||||
if (v)
|
||||
VSETATTR (v, att_exported);
|
||||
|
||||
if (count > 1 || rl_explicit_arg)
|
||||
if (count != 1 || rl_explicit_arg)
|
||||
{
|
||||
value = inttostr (count, ibuf, sizeof (ibuf));
|
||||
v = bind_int_variable ("READLINE_ARGUMENT", value, 0);
|
||||
|
||||
+769
-768
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 2020,2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 2020,2022,2023 Free Software Foundation, Inc.
|
||||
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -210,7 +210,7 @@ asort_builtin(WORD_LIST *list)
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
if (legal_identifier (list->word->word) == 0) {
|
||||
if (valid_identifier (list->word->word) == 0) {
|
||||
sh_invalidid (list->word->word);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ asort_builtin(WORD_LIST *list)
|
||||
builtin_usage();
|
||||
return EX_USAGE;
|
||||
}
|
||||
if (legal_identifier (list->next->word->word) == 0) {
|
||||
if (valid_identifier (list->next->word->word) == 0) {
|
||||
sh_invalidid (list->next->word->word);
|
||||
return EXECUTION_FAILURE;
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ cut_internal (int which, WORD_LIST *list)
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
if (array_name && (legal_identifier (array_name) == 0))
|
||||
if (array_name && (valid_identifier (array_name) == 0))
|
||||
{
|
||||
sh_invalidid (array_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
array with the fields */
|
||||
|
||||
/*
|
||||
Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 2022,2023 Free Software Foundation, Inc.
|
||||
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -203,7 +203,7 @@ dsv_builtin (WORD_LIST *list)
|
||||
if (array_name == 0)
|
||||
array_name = DSV_ARRAY_DEFAULT;
|
||||
|
||||
if (legal_identifier (array_name) == 0)
|
||||
if (valid_identifier (array_name) == 0)
|
||||
{
|
||||
sh_invalidid (array_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
@@ -98,9 +98,21 @@ static const struct
|
||||
# define O_NOSIGPIPE 0
|
||||
#endif
|
||||
|
||||
#ifndef O_NDELAY
|
||||
/* Solaris has this */
|
||||
# define O_NDELAY 0
|
||||
#endif
|
||||
|
||||
#ifndef O_LARGEFILE
|
||||
/* HP-UX has this */
|
||||
# define O_LARGEFILE 0
|
||||
#endif
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
# define IGNOREFLAGS (O_RDONLY|O_WRONLY|O_RDWR)
|
||||
# define ALLFLAGS (O_APPEND|O_ASYNC|O_SYNC|O_NONBLOCK|O_FSYNC|O_DSYNC|\
|
||||
O_RSYNC|O_ALT_IO|O_DIRECT|O_NOATIME|O_NOSIGPIPE)
|
||||
O_RSYNC|O_ALT_IO|O_DIRECT|O_NOATIME|O_NOSIGPIPE|O_NDELAY|O_LARGEFILE|\
|
||||
IGNOREFLAGS)
|
||||
|
||||
/* An unused bit in the file status flags word we can use to pass around the
|
||||
state of close-on-exec. */
|
||||
|
||||
@@ -340,7 +340,9 @@ static const struct conf vars[] =
|
||||
{ "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
|
||||
#endif
|
||||
{ "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
|
||||
#ifdef _SC_REALTIME_SIGNALS
|
||||
{ "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
|
||||
#endif
|
||||
{ "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
|
||||
#ifdef _SC_SELECT
|
||||
{ "_POSIX_SELECT", _SC_SELECT, SYSCONF },
|
||||
@@ -377,7 +379,9 @@ static const struct conf vars[] =
|
||||
{ "_POSIX_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED, SYSCONF },
|
||||
{ "_POSIX_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
|
||||
{ "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
|
||||
#ifdef _SC_TIMER_MAX
|
||||
{ "TIMER_MAX", _SC_TIMER_MAX, SYSCONF },
|
||||
#endif
|
||||
#ifdef _POSIX_TZNAME_MAX
|
||||
{ "_POSIX_TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
|
||||
#else
|
||||
@@ -754,8 +758,12 @@ static const struct conf vars[] =
|
||||
{ "_POSIX_C_LANG_SUPPORT_R", _SC_C_LANG_SUPPORT_R, SYSCONF },
|
||||
#endif
|
||||
{ "_POSIX_CLOCK_SELECTION", _SC_CLOCK_SELECTION, SYSCONF },
|
||||
#ifdef _SC_CPUTIME
|
||||
{ "_POSIX_CPUTIME", _SC_CPUTIME, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_THREAD_CPUTIME
|
||||
{ "_POSIX_THREAD_CPUTIME", _SC_THREAD_CPUTIME, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_DEVICE_SPECIFIC
|
||||
{ "_POSIX_DEVICE_SPECIFIC", _SC_DEVICE_SPECIFIC, SYSCONF },
|
||||
#endif
|
||||
@@ -837,7 +845,9 @@ static const struct conf vars[] =
|
||||
#ifdef _SC_AIO_PRIO_DELTA_MAX
|
||||
{ "AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_DELAYTIMER_MAX
|
||||
{ "DELAYTIMER_MAX", _SC_DELAYTIMER_MAX, SYSCONF },
|
||||
#endif
|
||||
{ "HOST_NAME_MAX", _SC_HOST_NAME_MAX, SYSCONF },
|
||||
{ "LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
|
||||
{ "MQ_OPEN_MAX", _SC_MQ_OPEN_MAX, SYSCONF },
|
||||
@@ -857,14 +867,18 @@ static const struct conf vars[] =
|
||||
#ifdef _SC_TRACE_LOG
|
||||
{ "_POSIX_TRACE_LOG", _SC_TRACE_LOG, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_RTSIG_MAX
|
||||
{ "RTSIG_MAX", _SC_RTSIG_MAX, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_SEM_NSEMS_MAX
|
||||
{ "SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_SEM_VALUE_MAX
|
||||
{ "SEM_VALUE_MAX", _SC_SEM_VALUE_MAX, SYSCONF },
|
||||
#endif
|
||||
#ifdef _SC_SIGQUEUE_MAX
|
||||
{ "SIGQUEUE_MAX", _SC_SIGQUEUE_MAX, SYSCONF },
|
||||
#endif
|
||||
#ifdef _PC_FILESIZEBITS
|
||||
{ "FILESIZEBITS", _PC_FILESIZEBITS, PATHCONF },
|
||||
#endif
|
||||
|
||||
@@ -157,7 +157,7 @@ kv_builtin (WORD_LIST *list)
|
||||
if (array_name == 0)
|
||||
array_name = KV_ARRAY_DEFAULT;
|
||||
|
||||
if (legal_identifier (array_name) == 0)
|
||||
if (valid_identifier (array_name) == 0)
|
||||
{
|
||||
sh_invalidid (array_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
@@ -428,7 +428,7 @@ cut_internal (int which, WORD_LIST *list)
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
if (array_name && (legal_identifier (array_name) == 0))
|
||||
if (array_name && (valid_identifier (array_name) == 0))
|
||||
{
|
||||
sh_invalidid (array_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
@@ -75,7 +75,7 @@ mktemp_builtin (WORD_LIST *list)
|
||||
|
||||
if (varname) /* check for validity, not readonly */
|
||||
{
|
||||
if (legal_identifier (varname) == 0)
|
||||
if (valid_identifier (varname) == 0)
|
||||
{
|
||||
if (qflag == 0)
|
||||
sh_invalidid (varname);
|
||||
|
||||
@@ -109,7 +109,7 @@ print_builtin (WORD_LIST *list)
|
||||
case 'p':
|
||||
break; /* NOP */
|
||||
case 'u':
|
||||
if (all_digits (list_optarg) && legal_number (list_optarg, &lfd) && lfd == (int)lfd)
|
||||
if (all_digits (list_optarg) && valid_number (list_optarg, &lfd) && lfd == (int)lfd)
|
||||
ofd = lfd;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2009,2021,2022 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2009,2021,2022,2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash.
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
@@ -122,7 +122,7 @@ realpath_builtin(WORD_LIST *list)
|
||||
}
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
if (aflag && legal_identifier (aname) == 0) {
|
||||
if (aflag && valid_identifier (aname) == 0) {
|
||||
sh_invalidid(aname);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ stat_builtin (WORD_LIST *list)
|
||||
}
|
||||
}
|
||||
|
||||
if (legal_identifier (aname) == 0)
|
||||
if (valid_identifier (aname) == 0)
|
||||
{
|
||||
sh_invalidid (aname);
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
+1
-1
@@ -5035,7 +5035,7 @@ execute_builtin (sh_builtin_func_t *builtin, WORD_LIST *words, int flags, int su
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
uw_maybe_restore_getopt_state (void *arg)
|
||||
{
|
||||
sh_getopt_state_t *gs;
|
||||
|
||||
@@ -121,6 +121,7 @@ extern void restore_funcarray_state (struct func_array_state *);
|
||||
extern void uw_restore_funcarray_state (void *);
|
||||
#endif
|
||||
|
||||
extern void uw_maybe_restore_getopt_state (void *);
|
||||
extern void uw_lastpipe_cleanup (void *);
|
||||
|
||||
extern void bind_lastarg (char *);
|
||||
|
||||
+1
-1
@@ -299,7 +299,7 @@ static const unsigned long binsizes[NBUCKETS] = {
|
||||
};
|
||||
|
||||
/* binsizes[x] == (1 << ((x) + 5)) */
|
||||
#define binsize(x) binsizes[(x)]
|
||||
#define binsize(x) binsizes[(size_t) (x)]
|
||||
|
||||
#define MAXALLOC_SIZE binsizes[NBUCKETS-1]
|
||||
|
||||
|
||||
+23
-18
@@ -874,21 +874,30 @@ int
|
||||
rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
|
||||
{
|
||||
register int i, j, parsing_digits;
|
||||
unsigned char ic;
|
||||
unsigned int ic; /* int to handle ANYOTHERKEY */
|
||||
Keymap map0;
|
||||
|
||||
if (map == 0)
|
||||
map = _rl_keymap;
|
||||
map0 = map;
|
||||
|
||||
/* The digits following the initial one (e.g., the binding to digit-argument)
|
||||
or the optional `-' in a binding to digit-argument or universal-argument
|
||||
are not added to rl_executing_keyseq. This is basically everything read by
|
||||
rl_digit_loop. The parsing_digits logic is here in case they ever are. */
|
||||
/* Make sure to add the digits following the initial one (e.g., the binding
|
||||
to digit-argument) and the optional `-' in a binding to digit-argument
|
||||
or universal-argument to rl_executing_keyseq. This is basically
|
||||
everything read by rl_digit_loop. */
|
||||
for (i = j = parsing_digits = 0; keyseq && i < len; i++)
|
||||
{
|
||||
ic = keyseq[i];
|
||||
|
||||
if (parsing_digits == 2)
|
||||
{
|
||||
if (ic == '-') /* skip over runs of minus chars */
|
||||
{
|
||||
j = i + 1;
|
||||
continue;
|
||||
}
|
||||
parsing_digits = 1;
|
||||
}
|
||||
if (parsing_digits)
|
||||
{
|
||||
if (_rl_digit_p (ic))
|
||||
@@ -901,10 +910,11 @@ rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
|
||||
|
||||
if (map[ic].type == ISKMAP)
|
||||
{
|
||||
if (i + 1 == len)
|
||||
return -1;
|
||||
map = FUNCTION_TO_KEYMAP (map, ic);
|
||||
continue;
|
||||
if (i + 1 == len)
|
||||
ic = ANYOTHERKEY;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (map[ic].type == ISFUNC)
|
||||
{
|
||||
@@ -923,16 +933,11 @@ rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
|
||||
|
||||
/* This logic should be identical to rl_digit_loop */
|
||||
/* We accept M-- as equivalent to M--1, C-u- as equivalent to C-u-1
|
||||
but set parsing_digits to 2 to note that we saw `-' */
|
||||
if (map[ic].function == rl_universal_argument && (i + 1 == '-'))
|
||||
{
|
||||
i++;
|
||||
parsing_digits = 2;
|
||||
}
|
||||
if (map[ic].function == rl_digit_argument && ic == '-')
|
||||
{
|
||||
parsing_digits = 2;
|
||||
}
|
||||
but set parsing_digits to 2 to note that we saw `-'. See above
|
||||
for the check that skips over one or more `-' characters. */
|
||||
if (map[ic].function == rl_universal_argument ||
|
||||
(map[ic].function == rl_digit_argument && ic == '-'))
|
||||
parsing_digits = 2;
|
||||
|
||||
map = map0;
|
||||
j = i + 1;
|
||||
|
||||
@@ -999,7 +999,7 @@ rl_redisplay (void)
|
||||
the line breaks in the prompt string in expand_prompt, taking invisible
|
||||
characters into account, and if lpos exceeds the screen width, we copy
|
||||
the data in the loop below. */
|
||||
lpos = prompt_physical_chars + modmark;
|
||||
lpos = local_prompt ? prompt_physical_chars + modmark : 0;
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
memset (line_state_invisible->wrapped_line, 0, line_state_invisible->wbsize * sizeof (int));
|
||||
|
||||
@@ -6857,7 +6857,7 @@ static SHELL_VAR lambdafunc = { ".bash.lambda", 0, 0, 0, 0, 0, 0 };
|
||||
WORD_DESC *
|
||||
function_substitute (char *string, int quoted, int flags)
|
||||
{
|
||||
volatile int save_return_catch_flag, function_code;
|
||||
volatile int function_code;
|
||||
int valsub, stdout_valid, saveout, old_frozen;
|
||||
int result, pflags, tflag, was_trap;
|
||||
char *istring, *s;
|
||||
@@ -6867,6 +6867,8 @@ function_substitute (char *string, int quoted, int flags)
|
||||
int afd;
|
||||
char *afn;
|
||||
sigset_t set, oset;
|
||||
sh_getopt_state_t *gs;
|
||||
SHELL_VAR *gv;
|
||||
#if defined (ARRAY_VARS)
|
||||
ARRAY *ps;
|
||||
#endif
|
||||
@@ -6896,6 +6898,8 @@ function_substitute (char *string, int quoted, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
gs = sh_getopt_save_istate ();
|
||||
|
||||
begin_unwind_frame ("nofork comsub");
|
||||
|
||||
/* Save command and expansion state we need. */
|
||||
@@ -6912,6 +6916,7 @@ function_substitute (char *string, int quoted, int flags)
|
||||
unwind_protect_pointer (this_shell_function);
|
||||
unwind_protect_int (eof_encountered);
|
||||
add_unwind_protect (uw_pop_var_context, 0);
|
||||
add_unwind_protect (uw_maybe_restore_getopt_state, gs);
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
ps = save_pipestatus_array ();
|
||||
@@ -6990,11 +6995,9 @@ function_substitute (char *string, int quoted, int flags)
|
||||
|
||||
/* if we are in a position to accept return, we have to save the old values */
|
||||
function_code = 0;
|
||||
if (save_return_catch_flag = return_catch_flag)
|
||||
{
|
||||
unwind_protect_int (return_catch_flag);
|
||||
unwind_protect_jmp_buf (return_catch);
|
||||
}
|
||||
unwind_protect_int (return_catch_flag);
|
||||
if (return_catch_flag)
|
||||
unwind_protect_jmp_buf (return_catch);
|
||||
|
||||
was_trap = running_trap;
|
||||
|
||||
@@ -7026,6 +7029,11 @@ function_substitute (char *string, int quoted, int flags)
|
||||
istring = s ? comsub_quote_string (s, quoted, flags) : savestring ("");
|
||||
}
|
||||
|
||||
/* Check for local OPTIND and note for cleanup */
|
||||
gv = find_variable ("OPTIND");
|
||||
if (gv && gv->context == variable_context)
|
||||
gs->gs_flags |= 1;
|
||||
|
||||
run_unwind_frame ("nofork comsub"); /* restores stdout, job control stuff */
|
||||
|
||||
last_command_subst_status = result;
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ sunos5*-*gcc*|solaris2*-*gcc*)
|
||||
;;
|
||||
|
||||
sunos5*|solaris2*)
|
||||
SHOBJ_CFLAGS='-K pic'
|
||||
SHOBJ_CFLAGS='-fPIC' # was -K pic
|
||||
SHOBJ_LD=/usr/ccs/bin/ld
|
||||
SHOBJ_LDFLAGS='-G -dy -z text -i -h $@'
|
||||
|
||||
|
||||
+4
-4
@@ -14,10 +14,10 @@
|
||||
. ./test-glue-functions
|
||||
|
||||
# this locale causes problems all over the place
|
||||
if locale -a | grep -i '^zh_HK\.big5hkscs' >/dev/null ; then
|
||||
if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then
|
||||
:
|
||||
else
|
||||
echo "glob2.sub: warning: you do not have the zh_HK.big5hkscs locale installed;" >&2
|
||||
echo "glob2.sub: warning: you do not have the zh_TW.big5 locale installed;" >&2
|
||||
echo "glob2.sub: warning: that will cause some of these tests to fail." >&2
|
||||
fi
|
||||
|
||||
@@ -41,7 +41,7 @@ esac
|
||||
[[ $var = $var ]] && echo ok 4
|
||||
[[ $var = $'ab\134' ]] && echo ok 5
|
||||
|
||||
LC_ALL=zh_HK.big5hkscs
|
||||
LC_ALL=zh_TW.big5
|
||||
|
||||
read a b c <<< $'\u3b1 b c\n'
|
||||
echo $b
|
||||
@@ -62,4 +62,4 @@ printf "%s" "a${alpha}b" | LC_ALL=C od -b | _intl_normalize_spaces
|
||||
a=$'\u3b1'
|
||||
[[ $a = $a ]] && echo ok 6
|
||||
|
||||
LC_ALL=zh_HK.big5hkscs ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7
|
||||
LC_ALL=zh_TW.big5 ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ aéb
|
||||
bytematch
|
||||
0000000 254 012
|
||||
0000002
|
||||
Passed all 1378 Unicode tests
|
||||
Passed all 1774 Unicode tests
|
||||
0000000 303 277 012
|
||||
0000003
|
||||
0000000 303 277 012
|
||||
|
||||
+18
-30
@@ -11,45 +11,27 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Originally donated by John Kearney <dethrophes@web.de> Tue, 21 Feb 2012
|
||||
# Updates from Grisha Levit <grishalevit@gmail.com> 22 Nov 2023
|
||||
#
|
||||
unset LC_ALL
|
||||
|
||||
ErrorCnt=0
|
||||
TestCnt=0
|
||||
|
||||
function check_valid_var_name {
|
||||
case "${1:?Missing Variable Name}" in
|
||||
[!a-zA-Z_]* | *[!a-zA-Z_0-9]* ) return 3;;
|
||||
esac
|
||||
}
|
||||
# get_array_element VariableName ArrayName ArrayElement
|
||||
function get_array_element {
|
||||
check_valid_var_name "${1:?Missing Variable Name}" || return $?
|
||||
check_valid_var_name "${2:?Missing Array Name}" || return $?
|
||||
eval "${1}"'="${'"${2}"'["${3:?Missing Array Index}"]}"'
|
||||
}
|
||||
# unset_array_element VarName ArrayName
|
||||
function get_array_element_cnt {
|
||||
check_valid_var_name "${1:?Missing Variable Name}" || return $?
|
||||
check_valid_var_name "${2:?Missing Array Name}" || return $?
|
||||
eval "${1}"'="${#'"${2}"'[@]}"'
|
||||
}
|
||||
|
||||
|
||||
function TestCodePage {
|
||||
local TargetCharset="${1:?Missing Test charset}"
|
||||
local EChar RChar TCnt
|
||||
get_array_element_cnt TCnt "${2:?Missing Array Name}"
|
||||
for (( x=1 ; x<${TCnt} ; x++ )); do
|
||||
get_array_element EChar "${2}" ${x}
|
||||
if [ -n "${EChar}" ]; then
|
||||
local EChar RChar Uval x
|
||||
local -n Array=${2:?Missing Array Name}
|
||||
for x in "${!Array[@]}"; do
|
||||
let TestCnt+=1
|
||||
EChar=${Array[$x]}
|
||||
printf -v UVal '\\U%08x' "${x}"
|
||||
LC_CTYPE=${TargetCharset} printf -v RChar "${UVal}" 2>/dev/null
|
||||
if [ "${EChar}" != "${RChar}" ]; then
|
||||
let ErrorCnt+=1
|
||||
printf "${TargetCharset}: Error Encoding U+%08X to ${TL} [ \"%q\" != \"%q\" ]\n" "${x}" "${EChar}" "${RChar}"
|
||||
printf "%s: Error Encoding U+%08X [ \"%q\" != \"%q\" ]\n" "${TargetCharset}" "${x}" "${EChar}" "${RChar}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
@@ -118,8 +100,14 @@ else
|
||||
fi
|
||||
|
||||
zh_TW_BIG5=(
|
||||
[0x00f6]=$'\366' [0x00f7]=$'\367' [0x00f8]=$'\370' [0x00f9]=$'\371' [0x00fa]=$'\372'
|
||||
[0x00fb]=$'\373' [0x00fc]=$'\374' [0x00fd]=$'\375' [0x00fe]=$'\376'
|
||||
# these are the original incorrect tests
|
||||
# [0x00f6]=$'\366' [0x00f7]=$'\367' [0x00f8]=$'\370' [0x00f9]=$'\371' [0x00fa]=$'\372'
|
||||
# [0x00fb]='\373' [0x00fc]=$'\374' [0x00fd]=$'\375' [0x00fe]=$'\376'
|
||||
# some valid encodings
|
||||
[0x03A8]=$'\243Z' [0x03A9]=$'\243[' [0x03B1]=$'\243\\' [0x03B2]=$'\243]'
|
||||
[0x03B3]=$'\243^' [0x03B4]=$'\243_' [0x03B5]=$'\243`' [0x03B6]=$'\243a'
|
||||
# and some invalid ones that output \u0XX
|
||||
[0x00fb]='\u00FB' [0x00fc]='\u00FC' [0x00fd]='\u00FD' [0x00fe]='\u00FE'
|
||||
)
|
||||
TestCodePage zh_TW.BIG5 zh_TW_BIG5
|
||||
|
||||
@@ -324,10 +312,10 @@ else
|
||||
echo "unicode1.sub: that will cause some of these tests to be skipped." >&2
|
||||
fi
|
||||
|
||||
#for ((x=1;x<1000;x++)); do printf ' [0x%04x]=%-11q' "$x" "$(printf "$(printf '\\U%08x' $x)")" ; [ $(($x%5)) = 0 ] && echo; done
|
||||
#for ((x=1;x<1000;x++)); do printf -v u '\\U%08x' "$x"; printf ' [0x%04x]=%-11q' "$x" "${u@E}"; [ $(($x%5)) = 0 ] && echo; done
|
||||
C_UTF_8=(
|
||||
[0x0001]=$'\001' [0x0002]=$'\002' [0x0003]=$'\003' [0x0004]=$'\004' [0x0005]=$'\005'
|
||||
[0x0006]=$'\006' [0x0007]=$'\a' [0x0008]=$'\b' [0x0009]=$'\t' [0x000a]=''
|
||||
[0x0006]=$'\006' [0x0007]=$'\a' [0x0008]=$'\b' [0x0009]=$'\t' [0x000a]=$'\n'
|
||||
[0x000b]=$'\v' [0x000c]=$'\f' [0x000d]=$'\r' [0x000e]=$'\016' [0x000f]=$'\017'
|
||||
[0x0010]=$'\020' [0x0011]=$'\021' [0x0012]=$'\022' [0x0013]=$'\023' [0x0014]=$'\024'
|
||||
[0x0015]=$'\025' [0x0016]=$'\026' [0x0017]=$'\027' [0x0018]=$'\030' [0x0019]=$'\031'
|
||||
|
||||
Reference in New Issue
Block a user