Remove utf-8 requirement (Yuichiro NAITO)

This commit is contained in:
christos 2018-11-18 17:09:39 +00:00
parent 7855f80d00
commit 18bb6ea433
5 changed files with 15 additions and 39 deletions

View File

@ -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 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv)
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

View File

@ -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 @@ library respects the
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 ,

View File

@ -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 @@ el_init_internal(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
* 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 @@ el_wset(EditLine *el, int op, ...)
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;
}

View File

@ -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

View File

@ -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 @@ read_char(EditLine *el, wchar_t *cp)
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: