- sv_isrchterm: make sure we check for v[end] == 0 while in the loop
looking for whitespace. Bug report and fix from Sergio Durigan
Junior <sergiodj@sergiodj.net>
+
+lib/sh/shmbchar.c
+ - mbstrlen,mbsmbchar: move calculation of MB_CUR_MAX out of loop;
+ calculate it once at beginning
+
+lib/sh/mbscmp.c
+ - mbscmp: move calculation of MB_CUR_MAX out of loop; calculate it once
+ at beginning
+
+lib/sh/mbscasecmp.c
+ - mbscasecmp: move calculation of MB_CUR_MAX out of loop; calculate it once
+ at beginning
+
+lib/sh/shquote.c
+ - sh_backslash_quote: move calculation of MB_CUR_MAX out of loop;
+ calculate it once at beginning
+
+lib/sh/casemod.c
+ - sh_modcase: move calculation of MB_CUR_MAX out of loop; calculate it once
+ at beginning
+
+subst.c
+ - expand_word_internal: move calculation of MB_CUR_MAX out of loops;
+ calculate it once at beginning of function (XXX should use
+ locale_mb_cur_max)
+
+ 5/22
+ ----
+lib/readline/rlmbutil.h
+ - _rl_wcwidth: new function, short-circuits wcwidth calls for ASCII
+ printable characters, returns 1 for those
+ - WCWIDTH: call _rl_wcwidth instead of wcwidth
+
+lib/readline/display.c
+ - rl_redisplay: move calculation of MB_CUR_MAX out of loop; calculate
+ it once at beginning. Report and patch from Ole Laursen
+ <ole.laursen@gmail.com>
+
+ 5/24
+ ----
+lib/readline/text.c
+ - rl_insert: change to attempt to batch-insert pending typeahead (not
+ pushed input or input from a macro) that maps to rl_insert. An
+ attempt to suppress redisplay until readline reads all typeahead --
+ pasted input, for instance. Inspired by report from Ole Laursen
+ <ole.laursen@gmail.com>. XXX - need to make this a bindable
+ variable; already controlled by _rl_optimize_typeahead
+
+lib/readline/rlprivate.h
+ - _rl_optimize_typeahead: extern declaration
+
+lib/readline/doc/{hstech.texi,history.3}
+ - next_history: clarify under what circumstances the history offset is
+ incremented; suggestion from Glenn Golden <gdg@zplane.com>
+
+print_cmd.c
+ - print_arith_command: should be compiled in if either DPAREN_ARITHMETIC
+ or ARITH_FOR_COMMAND is defined. Report from Flavio Medeiros
+ <flaviomotamederios@gmail.com>
+
+flags.c
+ - change_flag: new variable verbose_flag, set when `v' flag modified;
+ sets value of echo_input_at_read correspondingly
+
+flags.h
+ - verbose_flag: new extern declaration
+
+shell.c
+ - long_options: --verbose now sets verbose_flag
+ - main: set echo_input_at_read from verbose_flag after parsing any
+ long options
+
+builtins/fc.def
+ - fc_builtin: don't unwind-protect echo_input_at_read directly; set it
+ to 1 before calling fc_execute_file as before, and reset it to value
+ of global verbose_flag using set_verbose_flag called from an
+ unwind_protect. Report from isabella parakiss <izaberina@gmail.com>
+
+builtins/shopt.def
+ - shopt_set_debug_mode: new function, called when the extdebug shell
+ option changes. Right now, it sets function_trace_mode when extdebug
+ is enabled, and turns off when extdebug is disabled. The documentation
+ has always said that shopt does this. Report from Peng Yu
+ <pengyu.ut@gmail.com>
static void fc_addhist __P((char *));
#endif
+static void
+set_verbose_flag ()
+{
+ echo_input_at_read = verbose_flag;
+}
+
/* String to execute on a file that we want to edit. */
#define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}"
#if defined (STRICT_POSIX)
begin_unwind_frame ("fc builtin");
add_unwind_protect ((Function *)xfree, fn);
add_unwind_protect (unlink, fn);
- unwind_protect_int (echo_input_at_read);
+ add_unwind_protect (set_verbose_flag, (char *)NULL);
echo_input_at_read = 1;
-
+
retval = fc_execute_file (fn);
run_unwind_frame ("fc builtin");
static int shopt_set_complete_direxpand __P((char *, int));
#endif
+static int shopt_set_debug_mode __P((char *, int));
+
static int shopt_login_shell;
static int shopt_compat31;
static int shopt_compat32;
{ "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
{ "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
#if defined (DEBUGGER)
- { "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
+ { "extdebug", &debugging_mode, shopt_set_debug_mode },
#endif
#if defined (EXTENDED_GLOB)
{ "extglob", &extended_glob, (shopt_set_func_t *)NULL },
return (0);
}
+static int
+shopt_set_debug_mode (option_name, mode)
+ char *option_name;
+ int mode;
+{
+#if defined (DEBUGGER)
+ function_trace_mode = debugging_mode;
+#endif
+}
+
static int
shopt_enable_hostname_completion (option_name, mode)
char *option_name;
#! /bin/sh
-# From configure.ac for Bash 4.4, version 4.069.
+# From configure.ac for Bash 4.4, version 4.070.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for bash 4.4-devel.
#
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
- 2.[456789]*|3*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
+ 2.[456789]*|[34]*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
;;
esac ;;
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-AC_REVISION([for Bash 4.4, version 4.069])dnl
+AC_REVISION([for Bash 4.4, version 4.070])dnl
define(bashvers, 4.4)
define(relstatus, devel)
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
- 2.[[456789]]*|3*) AC_DEFINE(PGRP_PIPE) ;;
+ 2.[[456789]]*|[[34]]*) AC_DEFINE(PGRP_PIPE) ;;
esac ;;
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
/* Non-zero means type out input lines after you read them. */
int echo_input_at_read = 0;
+int verbose_flag = 0;
/* Non-zero means type out the command definition after reading, but
before executing. */
#endif /* RESTRICTED_SHELL */
{ 't', &just_one_command },
{ 'u', &unbound_vars_is_error },
- { 'v', &echo_input_at_read },
+ { 'v', &verbose_flag },
{ 'x', &echo_command_at_execute },
/* New flags that control non-standard things. */
break;
#endif
+ case 'v':
+ echo_input_at_read = verbose_flag;
+ break;
}
return (old_value);
{
mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0;
place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
- noclobber = unbound_vars_is_error = echo_input_at_read = 0;
+ noclobber = unbound_vars_is_error = echo_input_at_read = verbose_flag = 0;
echo_command_at_execute = jobs_m_flag = forced_interactive = 0;
no_symbolic_links = no_invisible_vars = privileged_mode = pipefail_opt = 0;
mark_modified_vars, errexit_flag, exit_immediately_on_error,
disallow_filename_globbing,
place_keywords_in_env, read_but_dont_execute,
- just_one_command, unbound_vars_is_error, echo_input_at_read,
+ just_one_command, unbound_vars_is_error, echo_input_at_read, verbose_flag,
echo_command_at_execute, no_invisible_vars, noclobber,
hashing_enabled, forced_interactive, privileged_mode, jobs_m_flag,
asynchronous_notification, interactive_comments, no_symbolic_links,
return arg;
}
-void _rl_callback_data_dispose (arg)
+void
+_rl_callback_data_dispose (arg)
_rl_callback_generic_arg *arg;
{
xfree (arg);
int wc_width;
mbstate_t ps;
int _rl_wrapped_multicolumn = 0;
+ int mb_cur_max = MB_CUR_MAX;
#endif
if (_rl_echoing_p == 0)
prompts that exceed two physical lines?
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
{
n0 = num;
temp = local_prompt_len;
inv_lbreaks[++newlines] = temp;
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
lpos -= _rl_col_width (local_prompt, n0, num, 1);
else
#endif
lb_linenum = 0;
#if defined (HANDLE_MULTIBYTE)
in = 0;
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
memset (&ps, 0, sizeof (mbstate_t));
/* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
c = (unsigned char)rl_line_buffer[in];
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
if (MB_INVALIDCH (wc_bytes))
{
else
{
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
register int i;
}
#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
in += wc_bytes;
/* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
not the first. */
if (out >= _rl_screenchars)
{
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
else
out = _rl_screenchars - 1;
time update_line is called, then we can assume in our
calculations that o_cpos does not need to be adjusted by
wrap_offset. */
- if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
+ if (linenum == 0 && (mb_cur_max > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
- (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+ (mb_cur_max > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
(wrap_offset > visible_wrap_offset) &&
(_rl_last_c_pos < visible_first_line_len))
{
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
nleft = _rl_screenwidth - _rl_last_c_pos;
else
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
the physical cursor position on the screen stays the same,
but the buffer position needs to be adjusted to account
for invisible characters. */
- if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
+ if ((mb_cur_max == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
_rl_last_c_pos += wrap_offset;
}
_rl_output_some_chars ("*", 1);
_rl_output_some_chars (local_prompt, nleft);
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
else
_rl_last_c_pos = nleft + modmark;
if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
{
/* TX == new physical cursor position in multibyte locale. */
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
else
tx = nleft;
_rl_last_c_pos as an absolute cursor position, but moving to a
point specified by a buffer position (NLEFT) that doesn't take
invisible characters into account. */
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (mb_cur_max > 1 && rl_byte_oriented == 0)
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
else if (nleft != _rl_last_c_pos)
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
0);
- if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+ if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
displaying_prompt_first_line && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
-.\" Last Change: Mon Apr 6 14:13:28 EDT 2015
+.\" Last Change: Sun May 24 18:01:17 EDT 2015
.\"
-.TH HISTORY 3 "2014 April 6" "GNU History 6.3"
+.TH HISTORY 3 "2015 May 24" "GNU History 6.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
a \fBNULL\fP pointer.
.Fn1 "HIST_ENTRY *" next_history "void"
-If the current history offset is not already at the end of the history
-list, move the current history offset forward to the next history entry.
-If the incremented history offset refers to a valid history entry, return
-a pointer to that entry.
-If there is no next entry, as when the history offset before being
-incremented refers to the last valid entry in the history list, return
-a \fBNULL\fP pointer.
-If this function returns \fBNULL\fP, the current history offset when the
-function returns (possibly incremented as described above)
-is at the end of the history list.
+If the current history offset refers to a valid history entry,
+increment the current history offset.
+If the possibly-incremented history offset refers to a valid history
+entry, return a pointer to that entry;
+otherwise, return a \fBNULL\fP pointer.
.SS Searching the History List
@end deftypefun
@deftypefun {HIST_ENTRY *} next_history (void)
-If the current history offset is not already at the end of the history
-list, move the current history offset forward to the next history entry.
-If the incremented history offset refers to a valid history entry, return
-a pointer to that entry.
-If there is no next entry, as when the history offset before being
-incremented refers to the last valid entry in the history list, return
-a @code{NULL} pointer.
-If this function returns @code{NULL}, the current history offset when the
-function returns (possibly incremented as described above)
-is at the end of the history list.
+If the current history offset refers to a valid history entry,
+increment the current history offset.
+If the possibly-incremented history offset refers to a valid history
+entry, return a pointer to that entry;
+otherwise, return a @code{BNULL} pointer.
@end deftypefun
@node Searching the History List
@set EDITION 6.4
@set VERSION 6.4
-@set UPDATED 6 April 2015
-@set UPDATED-MONTH April 2015
+@set UPDATED 24 May 2015
+@set UPDATED-MONTH May 2015
-@set LASTCHANGE Mon Apr 6 14:13:14 EDT 2015
+@set LASTCHANGE Sun May 24 18:01:45 EDT 2015
FD_ZERO (&readfds);
FD_SET (fileno (stream), &readfds);
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
-# if 0
- if (result < 0 && errno == EINTR)
- goto handle_error;
-# endif
#endif
if (result >= 0)
result = read (fileno (stream), &c, sizeof (unsigned char));
#define MB_INVALIDCH(x) ((x) == (size_t)-1 || (x) == (size_t)-2)
#define MB_NULLWCH(x) ((x) == 0)
+/* Try and shortcut the printable ascii characters to cut down the number of
+ calls to a libc wcwidth() */
+static inline int
+_rl_wcwidth (wc)
+ wchar_t wc;
+{
+ switch (wc)
+ {
+ case ' ': case '!': case '"': case '#': case '%':
+ case '&': case '\'': case '(': case ')': case '*':
+ case '+': case ',': case '-': case '.': case '/':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case ':': case ';': case '<': case '=': case '>':
+ case '?':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case '[': case '\\': case ']': case '^': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z': case '{': case '|': case '}': case '~':
+ return 1;
+ default:
+ return wcwidth (wc);
+ }
+}
+
/* Unicode combining characters range from U+0300 to U+036F */
#define UNICODE_COMBINING_CHAR(x) ((x) >= 768 && (x) <= 879)
#if defined (WCWIDTH_BROKEN)
-# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : wcwidth(wc))
+# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : _rl_wcwidth(wc))
#else
-# define WCWIDTH(wc) wcwidth(wc)
+# define WCWIDTH(wc) _rl_wcwidth(wc)
#endif
#if defined (WCWIDTH_BROKEN)
extern int _rl_terminal_can_insert;
extern int _rl_term_autowrap;
+/* text.c */
+extern int _rl_optimize_typeahead;
+
/* undo.c */
extern int _rl_doing_an_undo;
extern int _rl_undo_group_level;
rl_insert_text. Text blocks larger than this are divided. */
#define TEXT_COUNT_MAX 1024
+int _rl_optimize_typeahead = 1; /* rl_insert tries to read typeahead */
+
/* **************************************************************** */
/* */
/* Insert and Delete */
rl_insert (count, c)
int count, c;
{
- return (rl_insert_mode == RL_IM_INSERT ? _rl_insert_char (count, c)
- : _rl_overwrite_char (count, c));
+ int r, n, x;
+
+ r = (rl_insert_mode == RL_IM_INSERT) ? _rl_insert_char (count, c) : _rl_overwrite_char (count, c);
+
+ /* XXX -- attempt to batch-insert pending input that maps to self-insert */
+ x = 0;
+ n = (unsigned short)-2;
+ while (_rl_optimize_typeahead &&
+ (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
+ _rl_pushed_input_available () == 0 &&
+ _rl_input_queued (0) &&
+ (n = rl_read_key ()) > 0 &&
+ _rl_keymap[(unsigned char)n].type == ISFUNC &&
+ _rl_keymap[(unsigned char)n].function == rl_insert)
+ {
+ r = (rl_insert_mode == RL_IM_INSERT) ? _rl_insert_char (1, n) : _rl_overwrite_char (1, n);
+ /* _rl_insert_char keeps its own set of pending characters to compose a
+ complete multibyte character, and only returns 1 if it sees a character
+ that's part of a multibyte character but too short to complete one. We
+ can try to read another character in the hopes that we will get the
+ next one or just punt. Right now we try to read another character.
+ We don't want to call rl_insert_next if _rl_insert_char has already
+ stored the character in the pending_bytes array because that will
+ result in doubled input. */
+ n = (unsigned short)-2;
+ x++; /* count of bytes of typeahead read, currently unused */
+ if (r == 1) /* read partial multibyte character */
+ continue;
+ if (rl_done || r != 0)
+ break;
+ }
+
+ if (n != (unsigned short)-2) /* -2 = sentinel value for having inserted N */
+ r = rl_execute_next (n);
+
+ return r;
}
/* Insert the next typed character verbatim. */
#if defined (HANDLE_MULTIBYTE)
wchar_t nwc;
char mb[MB_LEN_MAX+1];
- int mlen;
+ int mlen, mb_cur_max;
size_t m;
mbstate_t state;
#endif
start = 0;
end = strlen (string);
+ mb_cur_max = MB_CUR_MAX;
ret = (char *)xmalloc (2*end + 1);
retind = 0;
/* Can't short-circuit, some locales have multibyte upper and lower
case equivalents of single-byte ascii characters (e.g., Turkish) */
- if (MB_CUR_MAX == 1)
+ if (mb_cur_max == 1)
{
singlebyte:
switch (nop)
const char *mbs1;
const char *mbs2;
{
- int len1, len2;
+ int len1, len2, mb_cur_max;
wchar_t c1, c2, l1, l2;
len1 = len2 = 0;
/* Reset multibyte characters to their initial state. */
(void) mblen ((char *) NULL, 0);
+ mb_cur_max = MB_CUR_MAX;
do
{
- len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
- len2 = mbtowc (&c2, mbs2, MB_CUR_MAX);
+ len1 = mbtowc (&c1, mbs1, mb_cur_max);
+ len2 = mbtowc (&c2, mbs2, mb_cur_max);
if (len1 == 0)
return len2 == 0 ? 0 : -1;
const char *mbs1;
const char *mbs2;
{
- int len1, len2;
+ int len1, len2, mb_cur_max;
wchar_t c1, c2;
len1 = len2 = 0;
/* Reset multibyte characters to their initial state. */
(void) mblen ((char *) NULL, 0);
+ mb_cur_max = MB_CUR_MAX;
do
{
- len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
- len2 = mbtowc (&c2, mbs2, MB_CUR_MAX);
+ len1 = mbtowc (&c1, mbs1, mb_cur_max);
+ len2 = mbtowc (&c2, mbs2, mb_cur_max);
if (len1 == 0)
return len2 == 0 ? 0 : -1;
{
size_t clen, nc;
mbstate_t mbs = { 0 }, mbsbak = { 0 };
- int f;
+ int f, mb_cur_max;
nc = 0;
- while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, MB_CUR_MAX, &mbs)) != 0)
+ mb_cur_max = MB_CUR_MAX;
+ while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, mb_cur_max, &mbs)) != 0)
{
if (MB_INVALIDCH(clen))
{
char *t;
size_t clen;
mbstate_t mbs = { 0 };
+ int mb_cur_max;
+ mb_cur_max = MB_CUR_MAX;
for (t = (char *)s; *t; t++)
{
if (is_basic (*t))
continue;
- clen = mbrlen (t, MB_CUR_MAX, &mbs);
+ clen = mbrlen (t, mb_cur_max, &mbs);
if (clen == 0)
return 0;
char *table;
int flags;
{
- int c;
+ int c, mb_cur_max;
size_t slen;
char *result, *r, *s, *backslash_table, *send;
DECLARE_MBSTATE;
result = (char *)xmalloc (2 * slen + 1);
backslash_table = table ? table : (char *)bstab;
+ mb_cur_max = MB_CUR_MAX;
+
for (r = result, s = string; s && (c = *s); s++)
{
#if defined (HANDLE_MULTIBYTE)
*r++ = c;
continue;
}
- if (MB_CUR_MAX > 1 && is_basic (c) == 0)
+ if (mb_cur_max > 1 && is_basic (c) == 0)
{
COPY_CHAR_P (r, s, send);
s--; /* compensate for auto-increment in loop above */
newline ("fi");
}
-#if defined (DPAREN_ARITHMETIC)
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
void
print_arith_command (arith_cmd_list)
WORD_LIST *arith_cmd_list;
#if defined (RESTRICTED_SHELL)
{ "restricted", Int, &restricted, (char **)0x0 },
#endif
- { "verbose", Int, &echo_input_at_read, (char **)0x0 },
+ { "verbose", Int, &verbose_flag, (char **)0x0 },
{ "version", Int, &do_version, (char **)0x0 },
#if defined (WORDEXP_OPTION)
{ "wordexp", Int, &wordexp_only, (char **)0x0 },
/* Find full word arguments first. */
arg_index = parse_long_options (argv, arg_index, argc);
-
+
if (want_initial_help)
{
show_shell_usage (stdout, 1);
exit (EXECUTION_SUCCESS);
}
+ echo_input_at_read = verbose_flag; /* --verbose given */
+
/* All done with full word options; do standard shell option parsing.*/
this_command_name = shell_name; /* for error reporting */
arg_index = parse_shell_options (argv, arg_index, argc);
extract a word, stopping at a separator
skip sequences of spc, tab, or nl as long as they are separators
This obeys the field splitting rules in Posix.2. */
- slen = (MB_CUR_MAX > 1) ? strlen (string) : 1;
+ slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 1;
for (result = (WORD_LIST *)NULL, sindex = 0; string[sindex]; )
{
/* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
sindex = 0;
/* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
unless multibyte chars are possible. */
- slen = (MB_CUR_MAX > 1) ? strlen (s) : 1;
+ slen = (MB_CUR_MAX > 1) ? STRLEN (s) : 1;
current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
/* Set ENDPTR to the first character after the end of the word. */
int split_on_spaces;
int tflag;
int pflags; /* flags passed to param_expand */
+ int mb_cur_max;
int assignoff; /* If assignment, offset of `=' */
string = word->word;
if (string == 0)
goto finished_with_string;
+ mb_cur_max = MB_CUR_MAX;
+
/* Don't need the string length for the SADD... and COPY_ macros unless
multibyte characters are possible. */
- string_size = (MB_CUR_MAX > 1) ? strlen (string) : 1;
+ string_size = (mb_cur_max > 1) ? strlen (string) : 1;
if (contains_dollar_at)
*contains_dollar_at = 0;
case CTLESC:
sindex++;
#if HANDLE_MULTIBYTE
- if (MB_CUR_MAX > 1 && string[sindex])
+ if (mb_cur_max > 1 && string[sindex])
{
SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
}
else
{
#if HANDLE_MULTIBYTE
- if (MB_CUR_MAX > 1)
+ if (mb_cur_max > 1)
sindex--;
- if (MB_CUR_MAX > 1)
+ if (mb_cur_max > 1)
{
SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
}