Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Remove utf-8 requirement (Yuichiro NAITO)
details: https://anonhg.NetBSD.org/src/rev/2e810da0359a
branches: trunk
changeset: 837073:2e810da0359a
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 18 17:09:39 2018 +0000
description:
Remove utf-8 requirement (Yuichiro NAITO)
diffstat:
lib/libedit/chartype.c | 20 +++++++-------------
lib/libedit/editline.3 | 6 ++----
lib/libedit/el.c | 10 +++-------
lib/libedit/el.h | 3 +--
lib/libedit/read.c | 15 ++-------------
5 files changed, 15 insertions(+), 39 deletions(-)
diffs (159 lines):
diff -r bbc45a86a7bf -r 2e810da0359a lib/libedit/chartype.c
--- a/lib/libedit/chartype.c Sun Nov 18 16:34:07 2018 +0000
+++ b/lib/libedit/chartype.c Sun Nov 18 17:09:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.32 2018/11/18 17:09:39 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.31 2017/01/09 02:54:18 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.32 2018/11/18 17:09:39 christos Exp $");
#endif /* not lint && not SCCSID */
#include <ctype.h>
@@ -183,17 +183,11 @@
libedit_private size_t
ct_enc_width(wchar_t c)
{
- /* UTF-8 encoding specific values */
- if (c < 0x80)
- return 1;
- else if (c < 0x0800)
- return 2;
- else if (c < 0x10000)
- return 3;
- else if (c < 0x110000)
- return 4;
- else
- return 0; /* not a valid codepoint */
+ char buf[MB_LEN_MAX];
+ int size;
+ if ((size = ct_wctomb(buf, c)) < 0)
+ return 0;
+ return size;
}
libedit_private ssize_t
diff -r bbc45a86a7bf -r 2e810da0359a lib/libedit/editline.3
--- a/lib/libedit/editline.3 Sun Nov 18 16:34:07 2018 +0000
+++ b/lib/libedit/editline.3 Sun Nov 18 17:09:39 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: editline.3,v 1.98 2017/09/02 06:48:10 wiz Exp $
+.\" $NetBSD: editline.3,v 1.99 2018/11/18 17:09:39 christos Exp $
.\"
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 1, 2017
+.Dd November 9, 2018
.Dt EDITLINE 3
.Os
.Sh NAME
@@ -181,8 +181,6 @@
locale set by the application program and never uses
.Xr setlocale 3
to change the locale.
-The only locales supported are UTF-8 and the default C or POSIX locale.
-If any other locale is set, behaviour is undefined.
.Sh LINE EDITING FUNCTIONS
The line editing functions use a common data structure,
.Fa EditLine ,
diff -r bbc45a86a7bf -r 2e810da0359a lib/libedit/el.c
--- a/lib/libedit/el.c Sun Nov 18 16:34:07 2018 +0000
+++ b/lib/libedit/el.c Sun Nov 18 17:09:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.96 2018/01/01 22:32:46 christos Exp $ */
+/* $NetBSD: el.c,v 1.97 2018/11/18 17:09:39 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
-__RCSID("$NetBSD: el.c,v 1.96 2018/01/01 22:32:46 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.97 2018/11/18 17:09:39 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -96,10 +96,6 @@
* Initialize all the modules. Order is important!!!
*/
el->el_flags = flags;
- if (setlocale(LC_CTYPE, NULL) != NULL){
- if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
- el->el_flags |= CHARSET_IS_UTF8;
- }
if (terminal_init(el) == -1) {
el_free(el->el_prog);
@@ -301,7 +297,7 @@
void *ptr = va_arg(ap, void *);
rv = hist_set(el, func, ptr);
- if (!(el->el_flags & CHARSET_IS_UTF8))
+ if (MB_CUR_MAX == 1)
el->el_flags &= ~NARROW_HISTORY;
break;
}
diff -r bbc45a86a7bf -r 2e810da0359a lib/libedit/el.h
--- a/lib/libedit/el.h Sun Nov 18 16:34:07 2018 +0000
+++ b/lib/libedit/el.h Sun Nov 18 17:09:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: el.h,v 1.43 2017/09/05 18:07:59 christos Exp $ */
+/* $NetBSD: el.h,v 1.44 2018/11/18 17:09:39 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -55,7 +55,6 @@
#define NO_TTY 0x02
#define EDIT_DISABLED 0x04
#define UNBUFFERED 0x08
-#define CHARSET_IS_UTF8 0x10
#define NARROW_HISTORY 0x40
#define NO_RESET 0x80
diff -r bbc45a86a7bf -r 2e810da0359a lib/libedit/read.c
--- a/lib/libedit/read.c Sun Nov 18 16:34:07 2018 +0000
+++ b/lib/libedit/read.c Sun Nov 18 17:09:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.103 2017/06/27 23:24:19 christos Exp $ */
+/* $NetBSD: read.c,v 1.104 2018/11/18 17:09:39 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.103 2017/06/27 23:24:19 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.104 2018/11/18 17:09:39 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -335,17 +335,6 @@
goto again;
}
case (size_t)-2:
- /*
- * We don't support other multibyte charsets.
- * The second condition shouldn't happen
- * and is here merely for additional safety.
- */
- if ((el->el_flags & CHARSET_IS_UTF8) == 0 ||
- cbp >= MB_LEN_MAX) {
- errno = EILSEQ;
- *cp = L'\0';
- return -1;
- }
/* Incomplete sequence, read another byte. */
goto again;
default:
Home |
Main Index |
Thread Index |
Old Index