Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Sep 2012 13:40:11 GMT
From:      Steffen "Daode" Nurpmeso <sdaoden@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/170651: On 9.0-RELEASE#0 and master sh(1) gobbles high bit at first
Message-ID:  <201209011340.q81DeBj2013615@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/170651; it has been noted by GNATS.

From: Steffen "Daode" Nurpmeso <sdaoden@gmail.com>
To: bug-followup@FreeBSD.org
Cc: eadler@FreeBSD.org, jilles@stack.nl
Subject: Re: bin/170651: On 9.0-RELEASE#0 and master sh(1) gobbles high bit at first
Date: Sat, 01 Sep 2012 15:33:41 +0200

 Steffen "Daode" Nurpmeso <sdaoden@gmail.com> wrote:
  |Jilles Tjoelker <jilles@stack.nl> 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 :)
 
 Hmm, looking deeper at the code as such i indeed see some more
 issues.  E.g., bindings get all lost if a set command occurs, as
 in '$ bind ^H sh-complete', '$ set +o' and it's gone ... and
 everything around in there.
 So i think this should encapsulate itself further than what
 currently happens and what i've sent to you already, and instead
 act upon real changes on the actual iflag/Vflag/Eflag combination
 only.
 
 I've still not wrapped my head around that entirely, but i (also
 still) wonder why there is not a single histedit_init() in main(),
 and maximally a histedit_destroy() after an exec (forgotten
 where), as *iflag* is a pretty constant condition!?  Then a single
 histedit_on_change() could be called and conditionalize further
 execution on 'is_init && STATE_CHANGE_OCCURRED'.
 I would like to give that a try now..
 
 I'll append a patch which does some cleanup on really ugly code.
 Thanks and ciao,
 
 --steffen
 
 diff --git a/bin/sh/input.c b/bin/sh/input.c
 index 12f285f..1da03c6 100644
 --- a/bin/sh/input.c
 +++ b/bin/sh/input.c
 @@ -59,8 +59,10 @@ __FBSDID("$FreeBSD$");
  #include "error.h"
  #include "alias.h"
  #include "parser.h"
 -#include "myhistedit.h"
  #include "trap.h"
 +#ifndef NO_HISTORY
 +# include "myhistedit.h"
 +#endif
  
  #define EOF_NLEFT -99		/* value of parsenleft when EOF pushed back */
  
 @@ -102,8 +104,6 @@ static struct parsefile *parsefile = &basepf;	/* current input file */
  int init_editline = 0;		/* editline library initialized? */
  int whichprompt;		/* 1 == PS1, 2 == PS2 */
  
 -EditLine *el;			/* cookie for editline package */
 -
  static void pushfile(void);
  static int preadfd(void);
  static void popstring(void);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209011340.q81DeBj2013615>