From 1ebae4666c585ad9573cccde5c2b697d72363a9b Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 20 Sep 2017 09:30:30 -0400 Subject: [PATCH] commit bash-20170915 snapshot --- CWRU/CWRU.chlog | 8 ++++++++ builtins/printf.def | 13 ++++++------- doc/bash.1 | 4 +++- lib/readline/doc/hsuser.texi | 4 +++- lib/sh/strtrans.c | 4 ---- shell.c | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 6a2491db..e7819bb2 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -14301,3 +14301,11 @@ execute_cmd.c (source/eval/unset) not run by the command builtin (flags & CMD_COMMAND_BUILTIN == 0). Fixes bug reported by Martijn Dekker + + 9/17 + ---- +builtins/printf.def + - asciicode: don't use mblen to check whether or not a character is a + valid multibyte character; use mbtowc right away and then inspect + the return value. Fixes bug reported by Stephane Chazelas + diff --git a/builtins/printf.def b/builtins/printf.def index 3d374ffc..fc089291 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -1245,18 +1245,17 @@ asciicode () register intmax_t ch; #if defined (HANDLE_MULTIBYTE) wchar_t wc; - size_t mblength, slen; + size_t slen; + int mblength; #endif DECLARE_MBSTATE; #if defined (HANDLE_MULTIBYTE) slen = strlen (garglist->word->word+1); - mblength = MBLEN (garglist->word->word+1, slen); - if (mblength > 1) - { - mblength = mbtowc (&wc, garglist->word->word+1, slen); - ch = wc; /* XXX */ - } + wc = 0; + mblength = mbtowc (&wc, garglist->word->word+1, slen); + if (mblength > 0) + ch = wc; /* XXX */ else #endif ch = (unsigned char)garglist->word->word[1]; diff --git a/doc/bash.1 b/doc/bash.1 index 52d5a5e2..337ac3e9 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -6945,7 +6945,9 @@ arguments to a previous command into the current input line, or fix errors in previous commands quickly. .PP History expansion is performed immediately after a complete line -is read, before the shell breaks it into words. +is read, before the shell breaks it into words, and is performed +on each line individually without taking quoting on previous lines into +account. It takes place in two parts. The first is to determine which line from the history list to use during substitution. diff --git a/lib/readline/doc/hsuser.texi b/lib/readline/doc/hsuser.texi index 7999eb56..392112fc 100644 --- a/lib/readline/doc/hsuser.texi +++ b/lib/readline/doc/hsuser.texi @@ -255,7 +255,9 @@ fix errors in previous commands quickly. @ifset BashFeatures History expansion is performed immediately after a complete line -is read, before the shell breaks it into words. +is read, before the shell breaks it into words, and is performed +on each line individually without taking quoting on previous lines into +account. @end ifset History expansion takes place in two parts. The first is to determine diff --git a/lib/sh/strtrans.c b/lib/sh/strtrans.c index 79831476..48f255f5 100644 --- a/lib/sh/strtrans.c +++ b/lib/sh/strtrans.c @@ -230,8 +230,6 @@ ansic_quote (str, flags, rlen) *r++ = '$'; *r++ = '\''; - s = str; - for (s = str; c = *s; s++) { b = l = 1; /* 1 == add backslash; 0 == no backslash */ @@ -305,11 +303,9 @@ ansic_wshouldquote (string) { const wchar_t *wcs; wchar_t wcc; - wchar_t *wcstr = NULL; size_t slen; - slen = mbstowcs (wcstr, string, 0); if (slen == (size_t)-1) diff --git a/shell.c b/shell.c index d395c8db..013fece3 100644 --- a/shell.c +++ b/shell.c @@ -1,6 +1,6 @@ /* shell.c -- GNU's idea of the POSIX shell specification. */ -/* Copyright (C) 1987-2017 Free Software Foundation, Inc. +/* Copyright (C) 1987-2015 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell.