Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.1.6-pws-5: hungetc() after keyboard interruption



With debugging enabled,

% ((foo
math> ^C
BUG: wrong character in hungetc() 
BUG: hungetc attempted at buffer start
BUG: wrong character in hungetc() 

The error happens because when the interruption occurs the input is flushed
completely, which a hungetc() later on in lexing doesn't notice, so it
tries to put nonsense back into the input queue.  hungetc() is only used
during lexing, which always returns a LEXERR if errflag is set, so I hope
it's possible simply not to unget when errflag is set.  But there's no
special flag to say that the error came from the keyboard, or that input
has been flushed, so it's possible that may be too drastic.

Unless somebody remember explicitly removing this test?

--- Src/hist.c.hu	Mon Sep 20 10:59:52 1999
+++ Src/hist.c	Tue Sep 21 15:00:31 1999
@@ -642,7 +642,7 @@
 {
     int doit = 1;
 
-    while (!lexstop) {
+    while (!lexstop && !errflag) {
 	if (hptr[-1] != (char) c && stophist < 4 &&
 	    hptr > chline + 1 && hptr[-1] == '\n' && hptr[-2] == '\\')
 	    hungetc('\n'), hungetc('\\');

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author