Module Name:    src
Committed By:   christos
Date:           Fri Feb 12 15:36:08 UTC 2016

Modified Files:
        src/lib/libedit: el.h eln.c read.c

Log Message:
GC IGNORE_EXTCHARS and simplify code (Ingo Schwarze)


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libedit/el.h
cvs rdiff -u -r1.19 -r1.20 src/lib/libedit/eln.c
cvs rdiff -u -r1.75 -r1.76 src/lib/libedit/read.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libedit/el.h
diff -u src/lib/libedit/el.h:1.25 src/lib/libedit/el.h:1.26
--- src/lib/libedit/el.h:1.25	Fri Jul 29 19:44:44 2011
+++ src/lib/libedit/el.h	Fri Feb 12 10:36:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $	*/
+/*	$NetBSD: el.h,v 1.26 2016/02/12 15:36:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -58,7 +58,6 @@
 #define	EDIT_DISABLED	0x04
 #define	UNBUFFERED	0x08
 #define	CHARSET_IS_UTF8 0x10
-#define	IGNORE_EXTCHARS 0x20            /* Ignore characters read > 0xff */
 #define	NARROW_HISTORY	0x40
 #define	NARROW_READ	0x80
 

Index: src/lib/libedit/eln.c
diff -u src/lib/libedit/eln.c:1.19 src/lib/libedit/eln.c:1.20
--- src/lib/libedit/eln.c:1.19	Mon May 18 11:07:04 2015
+++ src/lib/libedit/eln.c	Fri Feb 12 10:36:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $	*/
+/*	$NetBSD: eln.c,v 1.20 2016/02/12 15:36:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.20 2016/02/12 15:36:08 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -50,12 +50,7 @@ el_getc(EditLine *el, char *cp)
 	int num_read;
 	wchar_t wc = 0;
 
-	if (!(el->el_flags & CHARSET_IS_UTF8))
-		el->el_flags |= IGNORE_EXTCHARS;
 	num_read = el_wgetc (el, &wc);
-	if (!(el->el_flags & CHARSET_IS_UTF8))
-		el->el_flags &= ~IGNORE_EXTCHARS;
-
 	if (num_read > 0)
 		*cp = (char)wc;
 	return num_read;
@@ -76,8 +71,6 @@ el_gets(EditLine *el, int *nread)
 {
 	const wchar_t *tmp;
 
-	if (!(el->el_flags & CHARSET_IS_UTF8))
-		el->el_flags |= IGNORE_EXTCHARS;
 	tmp = el_wgets(el, nread);
 	if (tmp != NULL) {
 	    size_t nwread = 0;
@@ -85,8 +78,6 @@ el_gets(EditLine *el, int *nread)
 		nwread += ct_enc_width(tmp[i]);
 	    *nread = (int)nwread;
 	}
-	if (!(el->el_flags & CHARSET_IS_UTF8))
-		el->el_flags &= ~IGNORE_EXTCHARS;
 	return ct_encode_string(tmp, &el->el_lgcyconv);
 }
 

Index: src/lib/libedit/read.c
diff -u src/lib/libedit/read.c:1.75 src/lib/libedit/read.c:1.76
--- src/lib/libedit/read.c:1.75	Fri Feb 12 10:11:09 2016
+++ src/lib/libedit/read.c	Fri Feb 12 10:36:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: read.c,v 1.75 2016/02/12 15:11:09 christos Exp $	*/
+/*	$NetBSD: read.c,v 1.76 2016/02/12 15:36:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)read.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: read.c,v 1.75 2016/02/12 15:11:09 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.76 2016/02/12 15:36:08 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -305,7 +305,6 @@ read_char(EditLine *el, Char *cp)
 	int tried = 0;
 	char cbuf[MB_LEN_MAX];
 	size_t cbp = 0;
-	int bytes = 0;
 	int save_errno = errno;
 
  again:
@@ -341,12 +340,11 @@ read_char(EditLine *el, Char *cp)
 #ifdef WIDECHAR
 	do {
 		mbstate_t mbs;
-		size_t rbytes;
 again_lastbyte:
 		++cbp;
 		/* This only works because UTF8 is stateless */
 		memset(&mbs, 0, sizeof(mbs));
-		switch (rbytes = ct_mbrtowc(cp, cbuf, cbp, &mbs)) {
+		switch (ct_mbrtowc(cp, cbuf, cbp, &mbs)) {
 		case (size_t)-1:
 			if (cbp > 1) {
 				/*
@@ -377,20 +375,14 @@ again_lastbyte:
 			goto again;
 		default:
 			/* Valid character, process it. */
-			bytes = (int)rbytes;
 			break;
 		}
 	} while (/*CONSTCOND*/0);
 #else
-		*cp = (Char)(unsigned char)cbuf[0];
+	*cp = (Char)(unsigned char)cbuf[0];
 #endif
 
-	if ((el->el_flags & IGNORE_EXTCHARS) && bytes > 1) {
-		cbp = 0; /* skip this character */
-		goto again;
-	}
-
-	return (int)num_read;
+	return 1;
 }
 
 /* read_pop():

Reply via email to