diff options
| author | christos <christos@NetBSD.org> | 2016-02-24 14:25:38 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2016-02-24 14:25:38 +0000 |
| commit | ce74c8d2e7d88a04f69731bd01092feae274fdc1 (patch) | |
| tree | 49832ea10cbec475589376a9ebcbc30073366610 /lib/libedit | |
| parent | 2413324545fa331de0b9b1a7599fbbf44f97514b (diff) | |
Get split el_getc and el_wgetc completely and call el_wgetc internally.
Change some character constants to they wide versions. (Ingo Schwarze)
Diffstat (limited to 'lib/libedit')
| -rw-r--r-- | lib/libedit/Makefile | 5 | ||||
| -rw-r--r-- | lib/libedit/chared.c | 17 | ||||
| -rw-r--r-- | lib/libedit/chartype.c | 7 | ||||
| -rw-r--r-- | lib/libedit/common.c | 8 | ||||
| -rw-r--r-- | lib/libedit/eln.c | 6 | ||||
| -rw-r--r-- | lib/libedit/keymacro.c | 8 | ||||
| -rw-r--r-- | lib/libedit/read.c | 20 | ||||
| -rw-r--r-- | lib/libedit/search.c | 19 |
8 files changed, 49 insertions, 41 deletions
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile index 1060541f202..58732918ba2 100644 --- a/lib/libedit/Makefile +++ b/lib/libedit/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.54 2016/02/17 19:47:49 christos Exp $ +# $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/4/93 USE_SHLIBDIR= yes @@ -15,7 +15,7 @@ COPTS+= -Wunused-parameter CWARNFLAGS.gcc+= -Wconversion CWARNFLAGS.clang+= -Wno-cast-qual -OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \ +OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \ hist.c keymacro.c map.c chartype.c \ parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c @@ -37,7 +37,6 @@ MLINKS= editline.3 el_init.3 editline.3 el_end.3 editline.3 el_reset.3 \ SRCS= editline.c readline.c tokenizer.c history.c .if ${WIDECHAR} == "yes" -OSRCS += eln.c SRCS += tokenizern.c historyn.c CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c CPPFLAGS+=-DWIDECHAR diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index 1fea32eda30..f0207f3608f 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.47 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: chared.c,v 1.48 2016/02/24 14:25:38 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: chared.c,v 1.47 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: chared.c,v 1.48 2016/02/24 14:25:38 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -675,9 +675,9 @@ out: protected int c_gets(EditLine *el, Char *buf, const Char *prompt) { - Char ch; + wchar_t wch; ssize_t len; - Char *cp = el->el_line.buffer; + Char *cp = el->el_line.buffer, ch; if (prompt) { len = (ssize_t)Strlen(prompt); @@ -692,15 +692,16 @@ c_gets(EditLine *el, Char *buf, const Char *prompt) el->el_line.lastchar = cp + 1; re_refresh(el); - if (FUN(el,getc)(el, &ch) != 1) { + if (el_wgetc(el, &wch) != 1) { ed_end_of_file(el, 0); len = -1; break; } + ch = (Char)wch; switch (ch) { - case 0010: /* Delete and backspace */ + case L'\b': /* Delete and backspace */ case 0177: if (len == 0) { len = -1; @@ -710,8 +711,8 @@ c_gets(EditLine *el, Char *buf, const Char *prompt) continue; case 0033: /* ESC */ - case '\r': /* Newline */ - case '\n': + case L'\r': /* Newline */ + case L'\n': buf[len] = ch; break; diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c index 8d4d4927711..fb836cbb4ff 100644 --- a/lib/libedit/chartype.c +++ b/lib/libedit/chartype.c @@ -1,4 +1,4 @@ -/* $NetBSD: chartype.c,v 1.19 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: chartype.c,v 1.20 2016/02/24 14:25:38 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: chartype.c,v 1.19 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: chartype.c,v 1.20 2016/02/24 14:25:38 christos Exp $"); #endif /* not lint && not SCCSID */ #include <ctype.h> @@ -218,8 +218,9 @@ ct_encode_char(char *dst, size_t len, Char c) #else size_t +/*ARGSUSED*/ ct_mbrtowc(char *wc, const char *s, size_t n, - void *mbs __attribute((__unused__))) { + void *mbs __attribute__((__unused__))) { if (s == NULL) return 0; if (n == 0) diff --git a/lib/libedit/common.c b/lib/libedit/common.c index 2043e5e8011..11dd40e982a 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -1,4 +1,4 @@ -/* $NetBSD: common.c,v 1.38 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: common.c,v 1.38 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -365,11 +365,9 @@ protected el_action_t ed_quoted_insert(EditLine *el, wint_t c) { int num; - Char tc; tty_quotemode(el); - num = FUN(el,getc)(el, &tc); - c = tc; + num = el_wgetc(el, &c); tty_noquotemode(el); if (num == 1) return ed_insert(el, c); diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 7df6572a82f..cc0db7d59d4 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/eln.c @@ -1,4 +1,4 @@ -/* $NetBSD: eln.c,v 1.25 2016/02/16 15:53:48 christos Exp $ */ +/* $NetBSD: eln.c,v 1.26 2016/02/24 14:25:38 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.25 2016/02/16 15:53:48 christos Exp $"); +__RCSID("$NetBSD: eln.c,v 1.26 2016/02/24 14:25:38 christos Exp $"); #endif /* not lint && not SCCSID */ #include <errno.h> @@ -65,6 +65,7 @@ el_getc(EditLine *el, char *cp) } +#ifdef WIDECHAR public void el_push(EditLine *el, const char *str) { @@ -398,3 +399,4 @@ el_insertstr(EditLine *el, const char *str) { return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv)); } +#endif /* WIDECHAR */ diff --git a/lib/libedit/keymacro.c b/lib/libedit/keymacro.c index 6ca64f4f615..89558b5edf4 100644 --- a/lib/libedit/keymacro.c +++ b/lib/libedit/keymacro.c @@ -1,4 +1,4 @@ -/* $NetBSD: keymacro.c,v 1.13 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: keymacro.c,v 1.13 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -280,16 +280,18 @@ keymacro_print(EditLine *el, const Char *key) private int node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) { + wchar_t wc; if (ptr->ch == *ch) { /* match found */ if (ptr->next) { /* key not complete so get next char */ - if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */ + if (el_wgetc(el, &wc) != 1) {/* if EOF or error */ val->cmd = ED_END_OF_FILE; return XK_CMD; /* PWP: Pretend we just read an end-of-file */ } + *ch = (Char)wc; return node_trav(el, ptr->next, ch, val); } else { *val = ptr->val; diff --git a/lib/libedit/read.c b/lib/libedit/read.c index 62b86f70439..7ed02bf0d04 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.82 2016/02/17 19:47:49 christos Exp $ */ +/* $NetBSD: read.c,v 1.83 2016/02/24 14:25:38 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.82 2016/02/17 19:47:49 christos Exp $"); +__RCSID("$NetBSD: read.c,v 1.83 2016/02/24 14:25:38 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -244,14 +244,16 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) { static const Char meta = (Char)0x80; el_action_t cmd; + wchar_t wc; int num; el->el_errno = 0; do { - if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */ + if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */ el->el_errno = num == 0 ? 0 : errno; return 0; /* not OKCMD */ } + *ch = (Char)wc; #ifdef KANJI if ((*ch & meta)) { @@ -397,14 +399,15 @@ read_pop(c_macro_t *ma) ma->offset = 0; } -/* el_getc(): - * Read a character +/* el_wgetc(): + * Read a wide character */ public int -FUN(el,getc)(EditLine *el, Char *cp) +el_wgetc(EditLine *el, wchar_t *cp) { int num_read; c_macro_t *ma = &el->el_chared.c_macro; + Char cp_temp; terminal__flush(el); for (;;) { @@ -440,15 +443,16 @@ FUN(el,getc)(EditLine *el, Char *cp) #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Reading a character\n"); #endif /* DEBUG_READ */ - num_read = (*el->el_read.read_char)(el, cp); + num_read = (*el->el_read.read_char)(el, &cp_temp); if (num_read < 0) el->el_errno = errno; + *cp = cp_temp; #ifdef WIDECHAR if (el->el_flags & NARROW_READ) *cp = *(char *)(void *)cp; #endif #ifdef DEBUG_READ - (void) fprintf(el->el_errfile, "Got it %c\n", *cp); + (void) fprintf(el->el_errfile, "Got it %lc\n", *cp); #endif /* DEBUG_READ */ return num_read; } diff --git a/lib/libedit/search.c b/lib/libedit/search.c index 67c3dcdefc6..7fcd4ae6b5a 100644 --- a/lib/libedit/search.c +++ b/lib/libedit/search.c @@ -1,4 +1,4 @@ -/* $NetBSD: search.c,v 1.38 2016/02/16 22:53:14 christos Exp $ */ +/* $NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: search.c,v 1.38 2016/02/16 22:53:14 christos Exp $"); +__RCSID("$NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $"); #endif #endif /* not lint && not SCCSID */ @@ -212,8 +212,9 @@ ce_inc_search(EditLine *el, int dir) STRbck[] = {'b', 'c', 'k', '\0'}; static Char pchar = ':';/* ':' = normal, '?' = failed */ static Char endcmd[2] = {'\0', '\0'}; - Char ch, *ocursor = el->el_line.cursor, oldpchar = pchar; + Char *ocursor = el->el_line.cursor, oldpchar = pchar, ch; const Char *cp; + wchar_t wch; el_action_t ret = CC_NORM; @@ -252,9 +253,11 @@ ce_inc_search(EditLine *el, int dir) *el->el_line.lastchar = '\0'; re_refresh(el); - if (FUN(el,getc)(el, &ch) != 1) + if (el_wgetc(el, &wch) != 1) return ed_end_of_file(el, 0); + ch = (Char)wch; + switch (el->el_map.current[(unsigned char) ch]) { case ED_INSERT: case ED_DIGIT: @@ -348,14 +351,14 @@ ce_inc_search(EditLine *el, int dir) /* Can't search if unmatched '[' */ for (cp = &el->el_search.patbuf[el->el_search.patlen-1], - ch = ']'; + ch = L']'; cp >= &el->el_search.patbuf[LEN]; cp--) if (*cp == '[' || *cp == ']') { ch = *cp; break; } - if (el->el_search.patlen > LEN && ch != '[') { + if (el->el_search.patlen > LEN && ch != L'[') { if (redo && newdir == dir) { if (pchar == '?') { /* wrap around */ el->el_history.eventno = @@ -604,10 +607,8 @@ cv_csearch(EditLine *el, int direction, wint_t ch, int count, int tflag) return CC_ERROR; if (ch == (wint_t)-1) { - Char c; - if (FUN(el,getc)(el, &c) != 1) + if (el_wgetc(el, &ch) != 1) return ed_end_of_file(el, 0); - ch = c; } /* Save for ';' and ',' commands */ |
