From owner-freebsd-bugs@FreeBSD.ORG Wed Aug 29 10:30:06 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74964106564A for ; Wed, 29 Aug 2012 10:30:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 5E31E8FC0C for ; Wed, 29 Aug 2012 10:30:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q7TAU641050322 for ; Wed, 29 Aug 2012 10:30:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q7TAU6qJ050319; Wed, 29 Aug 2012 10:30:06 GMT (envelope-from gnats) Date: Wed, 29 Aug 2012 10:30:06 GMT Message-Id: <201208291030.q7TAU6qJ050319@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Steffen "Daode" Nurpmeso Cc: Subject: Re: bin/170651: On 9.0-RELEASE#0 and master sh(1) gobbles high bit at first X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Steffen Daode Nurpmeso List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2012 10:30:06 -0000 The following reply was made to PR bin/170651; it has been noted by GNATS. From: Steffen "Daode" Nurpmeso To: Jilles Tjoelker Cc: bug-followup@FreeBSD.org Subject: Re: bin/170651: On 9.0-RELEASE#0 and master sh(1) gobbles high bit at first Date: Wed, 29 Aug 2012 12:24:11 +0200 This is a multi-part message in MIME format. --=_503dedcb.nteIZRWEG6EbH/vp9TUbaaUn9m8DsADejmyTkwQSsrStVaAf Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Jilles Tjoelker wrote: |This PR bin/170651 does in fact look valid. It looks like libedit only |partially picks up an LC_CTYPE change. Whether it shows '\OOO' or real |characters with bit 7 set changes immediately; whether it accepts |characters with bit 7 set changes only after doing something that causes |libedit to be reinitialized (such as 'set +o'). | |This is probably a bug in libedit and/or sh's use of it, although there |are bigger bugs in libedit and sh's use of it. | |-- |Jilles Tjoelker As all locale changes effectively boil down in var.c:{update,init}charset(), either call histedit() in updatecharset(), which is what the first (-easy) diff does, or introduce a new function which only performs the necessary libedit call-in to update the mapping (second patch, -harder). Since histedit() always causes a reparse of editrc(5) (and AFAIU), i would vote for the harder patch :) Thanks and ciao, --steffen --=_503dedcb.nteIZRWEG6EbH/vp9TUbaaUn9m8DsADejmyTkwQSsrStVaAf Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr_bin_170651-easy.diff" diff --git a/bin/sh/var.c b/bin/sh/var.c index 6041459..ccbb5d7 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -515,6 +515,7 @@ bltinunsetlocale(void) /* * Update the localeisutf8 flag. + * And force reinitialization of libedit's key mappings (PR bin/170651). */ void updatecharset(void) @@ -523,6 +524,9 @@ updatecharset(void) charset = nl_langinfo(CODESET); localeisutf8 = !strcmp(charset, "UTF-8"); +#ifndef NO_HISTORY + histedit(); +#endif } void --=_503dedcb.nteIZRWEG6EbH/vp9TUbaaUn9m8DsADejmyTkwQSsrStVaAf Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr_bin_170651-harder.diff" diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index 6371599..069ac04 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -158,6 +158,16 @@ bad: } } +void +hist_on_lc_change(void) +{ + if (iflag && editing) { + if (el) + el_set(el, EL_EDITOR, Vflag ? "vi" : "emacs"); + else + histedit(); + } +} void sethistsize(const char *hs) diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h index e31276d..3193a09 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -37,6 +37,7 @@ extern EditLine *el; extern int displayhist; void histedit(void); +void hist_on_lc_change(void); void sethistsize(const char *); void setterm(const char *); diff --git a/bin/sh/var.c b/bin/sh/var.c index 6041459..8f019bf 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -515,6 +515,7 @@ bltinunsetlocale(void) /* * Update the localeisutf8 flag. + * And force reinitialization of libedit's key mappings (PR bin/170651). */ void updatecharset(void) @@ -523,6 +524,9 @@ updatecharset(void) charset = nl_langinfo(CODESET); localeisutf8 = !strcmp(charset, "UTF-8"); +#ifndef NO_HISTORY + hist_on_lc_change(); +#endif } void --=_503dedcb.nteIZRWEG6EbH/vp9TUbaaUn9m8DsADejmyTkwQSsrStVaAf--