Module Name: src
Committed By: christos
Date: Mon Apr 11 00:22:48 UTC 2016
Modified Files:
src/lib/libedit: chared.c chartype.h common.c el.c eln.c filecomplete.c
hist.c hist.h history.c keymacro.c makelist map.c parse.c read.c
refresh.c search.c terminal.c tokenizer.c tty.c vi.c
Log Message:
more macro WIDECHAR undoing from Ingo Schwarze.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/lib/libedit/chared.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libedit/chartype.h
cvs rdiff -u -r1.41 -r1.42 src/lib/libedit/common.c \
src/lib/libedit/filecomplete.c src/lib/libedit/search.c
cvs rdiff -u -r1.85 -r1.86 src/lib/libedit/el.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libedit/eln.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libedit/hist.c src/lib/libedit/terminal.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libedit/hist.h
cvs rdiff -u -r1.53 -r1.54 src/lib/libedit/history.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libedit/keymacro.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libedit/makelist
cvs rdiff -u -r1.44 -r1.45 src/lib/libedit/map.c
cvs rdiff -u -r1.35 -r1.36 src/lib/libedit/parse.c
cvs rdiff -u -r1.88 -r1.89 src/lib/libedit/read.c
cvs rdiff -u -r1.46 -r1.47 src/lib/libedit/refresh.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libedit/tokenizer.c
cvs rdiff -u -r1.60 -r1.61 src/lib/libedit/tty.c
cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/vi.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/chared.c
diff -u src/lib/libedit/chared.c:1.50 src/lib/libedit/chared.c:1.51
--- src/lib/libedit/chared.c:1.50 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/chared.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.50 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: chared.c,v 1.51 2016/04/11 00:22:48 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.50 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.51 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -205,7 +205,7 @@ c_delbefore1(EditLine *el)
protected int
ce__isword(wint_t p)
{
- return iswalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
+ return iswalnum(p) || wcschr(L"*?_-.[]~=", p) != NULL;
}
@@ -614,11 +614,11 @@ ch_end(EditLine *el)
* Insert string at cursorI
*/
public int
-FUN(el,insertstr)(EditLine *el, const Char *s)
+el_winsertstr(EditLine *el, const Char *s)
{
size_t len;
- if (s == NULL || (len = Strlen(s)) == 0)
+ if (s == NULL || (len = wcslen(s)) == 0)
return -1;
if (el->el_line.lastchar + len >= el->el_line.limit) {
if (!ch_enlargebufs(el, len))
@@ -680,7 +680,7 @@ c_gets(EditLine *el, Char *buf, const Ch
Char *cp = el->el_line.buffer, ch;
if (prompt) {
- len = (ssize_t)Strlen(prompt);
+ len = (ssize_t)wcslen(prompt);
(void)memcpy(cp, prompt, (size_t)len * sizeof(*cp));
cp += len;
}
Index: src/lib/libedit/chartype.h
diff -u src/lib/libedit/chartype.h:1.27 src/lib/libedit/chartype.h:1.28
--- src/lib/libedit/chartype.h:1.27 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/chartype.h Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.27 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: chartype.h,v 1.28 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -52,35 +52,8 @@
#endif
#define Char wchar_t
-#define FUN(prefix,rest) prefix ## _w ## rest
-#define FUNW(type) type ## _w
-#define TYPE(type) type ## W
-#define STR(x) L ## x
-
-#define Strlen(x) wcslen(x)
-#define Strchr(s,c) wcschr(s,c)
-#define Strdup(x) wcsdup(x)
-#define Strncpy(d,s,n) wcsncpy(d,s,n)
-#define Strncat(d,s,n) wcsncat(d,s,n)
-#define Strcmp(s,v) wcscmp(s,v)
-#define Strncmp(s,v,n) wcsncmp(s,v,n)
-
#else /* NARROW */
-
#define Char char
-#define FUN(prefix,rest) prefix ## _ ## rest
-#define FUNW(type) type
-#define TYPE(type) type
-#define STR(x) x
-
-#define Strlen(x) strlen(x)
-#define Strchr(s,c) strchr(s,c)
-#define Strdup(x) strdup(x)
-#define Strncpy(d,s,n) strncpy(d,s,n)
-#define Strncat(d,s,n) strncat(d,s,n)
-
-#define Strcmp(s,v) strcmp(s,v)
-#define Strncmp(s,v,n) strncmp(s,v,n)
#endif
Index: src/lib/libedit/common.c
diff -u src/lib/libedit/common.c:1.41 src/lib/libedit/common.c:1.42
--- src/lib/libedit/common.c:1.41 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/common.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.41 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: common.c,v 1.42 2016/04/11 00:22:48 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.41 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.42 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -652,7 +652,7 @@ ed_prev_history(EditLine *el, wint_t c _
if (el->el_history.eventno == 0) { /* save the current buffer
* away */
- (void) Strncpy(el->el_history.buf, el->el_line.buffer,
+ (void) wcsncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
@@ -724,7 +724,7 @@ ed_search_prev_history(EditLine *el, win
return CC_ERROR;
}
if (el->el_history.eventno == 0) {
- (void) Strncpy(el->el_history.buf, el->el_line.buffer,
+ (void) wcsncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
@@ -745,7 +745,7 @@ ed_search_prev_history(EditLine *el, win
#ifdef SDEBUG
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
#endif
- if ((Strncmp(hp, el->el_line.buffer, (size_t)
+ if ((wcsncmp(hp, el->el_line.buffer, (size_t)
(el->el_line.lastchar - el->el_line.buffer)) ||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
c_hmatch(el, hp)) {
@@ -800,7 +800,7 @@ ed_search_next_history(EditLine *el, win
#ifdef SDEBUG
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
#endif
- if ((Strncmp(hp, el->el_line.buffer, (size_t)
+ if ((wcsncmp(hp, el->el_line.buffer, (size_t)
(el->el_line.lastchar - el->el_line.buffer)) ||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
c_hmatch(el, hp))
@@ -910,7 +910,7 @@ ed_command(EditLine *el, wint_t c __attr
Char tmpbuf[EL_BUFSIZ];
int tmplen;
- tmplen = c_gets(el, tmpbuf, STR("\n: "));
+ tmplen = c_gets(el, tmpbuf, L"\n: ");
terminal__putc(el, '\n');
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
Index: src/lib/libedit/filecomplete.c
diff -u src/lib/libedit/filecomplete.c:1.41 src/lib/libedit/filecomplete.c:1.42
--- src/lib/libedit/filecomplete.c:1.41 Sat Apr 9 14:47:05 2016
+++ src/lib/libedit/filecomplete.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.41 2016/04/09 18:47:05 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.42 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.41 2016/04/09 18:47:05 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.42 2016/04/11 00:22:48 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -414,7 +414,7 @@ fn_complete(EditLine *el,
const char *(*app_func)(const char *), size_t query_items,
int *completion_type, int *over, int *point, int *end)
{
- const TYPE(LineInfo) *li;
+ const LineInfoW *li;
Char *temp;
char **matches;
const Char *ctemp;
@@ -435,16 +435,16 @@ fn_complete(EditLine *el,
app_func = append_char_function;
/* We now look backwards for the start of a filename/variable word */
- li = FUN(el,line)(el);
+ li = el_wline(el);
ctemp = li->cursor;
while (ctemp > li->buffer
- && !Strchr(word_break, ctemp[-1])
- && (!special_prefixes || !Strchr(special_prefixes, ctemp[-1]) ) )
+ && !wcschr(word_break, ctemp[-1])
+ && (!special_prefixes || !wcschr(special_prefixes, ctemp[-1]) ) )
ctemp--;
len = (size_t)(li->cursor - ctemp);
temp = el_malloc((len + 1) * sizeof(*temp));
- (void)Strncpy(temp, ctemp, len);
+ (void)wcsncpy(temp, ctemp, len);
temp[len] = '\0';
/* these can be used by function called in completion_matches() */
@@ -480,7 +480,7 @@ fn_complete(EditLine *el,
*/
if (matches[0][0] != '\0') {
el_deletestr(el, (int) len);
- FUN(el,insertstr)(el,
+ el_winsertstr(el,
ct_decode_string(matches[0], &el->el_scratch));
}
@@ -494,7 +494,7 @@ fn_complete(EditLine *el,
* it, unless we do filename completion and the
* object is a directory.
*/
- FUN(el,insertstr)(el,
+ el_winsertstr(el,
ct_decode_string((*app_func)(matches[0]),
&el->el_scratch));
} else if (what_to_do == '!') {
Index: src/lib/libedit/search.c
diff -u src/lib/libedit/search.c:1.41 src/lib/libedit/search.c:1.42
--- src/lib/libedit/search.c:1.41 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/search.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: search.c,v 1.41 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: search.c,v 1.42 2016/04/11 00:22:48 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.41 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: search.c,v 1.42 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -181,11 +181,11 @@ c_setpat(EditLine *el)
if (el->el_search.patlen >= EL_BUFSIZ)
el->el_search.patlen = EL_BUFSIZ - 1;
if (el->el_search.patlen != 0) {
- (void) Strncpy(el->el_search.patbuf, el->el_line.buffer,
+ (void) wcsncpy(el->el_search.patbuf, el->el_line.buffer,
el->el_search.patlen);
el->el_search.patbuf[el->el_search.patlen] = '\0';
} else
- el->el_search.patlen = Strlen(el->el_search.patbuf);
+ el->el_search.patlen = wcslen(el->el_search.patbuf);
}
#ifdef SDEBUG
(void) fprintf(el->el_errfile, "\neventno = %d\n",
@@ -329,7 +329,7 @@ ce_inc_search(EditLine *el, int dir)
default: /* Terminate and execute cmd */
endcmd[0] = ch;
- FUN(el,push)(el, endcmd);
+ el_wpush(el, endcmd);
/* FALLTHROUGH */
case 0033: /* ESC: Terminate */
@@ -470,7 +470,7 @@ cv_search(EditLine *el, int dir)
el->el_search.patdir = dir;
tmplen = c_gets(el, &tmpbuf[LEN],
- dir == ED_SEARCH_PREV_HISTORY ? STR("\n/") : STR("\n?") );
+ dir == ED_SEARCH_PREV_HISTORY ? L"\n/" : L"\n?" );
if (tmplen == -1)
return CC_REFRESH;
@@ -489,11 +489,11 @@ cv_search(EditLine *el, int dir)
#ifdef ANCHOR
if (el->el_search.patbuf[0] != '.' &&
el->el_search.patbuf[0] != '*') {
- (void) Strncpy(tmpbuf, el->el_search.patbuf,
+ (void) wcsncpy(tmpbuf, el->el_search.patbuf,
sizeof(tmpbuf) / sizeof(*tmpbuf) - 1);
el->el_search.patbuf[0] = '.';
el->el_search.patbuf[1] = '*';
- (void) Strncpy(&el->el_search.patbuf[2], tmpbuf,
+ (void) wcsncpy(&el->el_search.patbuf[2], tmpbuf,
EL_BUFSIZ - 3);
el->el_search.patlen++;
el->el_search.patbuf[el->el_search.patlen++] = '.';
@@ -507,7 +507,7 @@ cv_search(EditLine *el, int dir)
tmpbuf[tmplen++] = '*';
#endif
tmpbuf[tmplen] = '\0';
- (void) Strncpy(el->el_search.patbuf, tmpbuf, EL_BUFSIZ - 1);
+ (void) wcsncpy(el->el_search.patbuf, tmpbuf, EL_BUFSIZ - 1);
el->el_search.patlen = (size_t)tmplen;
}
el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */
Index: src/lib/libedit/el.c
diff -u src/lib/libedit/el.c:1.85 src/lib/libedit/el.c:1.86
--- src/lib/libedit/el.c:1.85 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/el.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.85 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: el.c,v 1.86 2016/04/11 00:22:48 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.85 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.86 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -85,7 +85,7 @@ el_init_fd(const char *prog, FILE *fin,
el->el_outfd = fdout;
el->el_errfd = fderr;
- el->el_prog = Strdup(ct_decode_string(prog, &el->el_scratch));
+ el->el_prog = wcsdup(ct_decode_string(prog, &el->el_scratch));
if (el->el_prog == NULL) {
el_free(el);
return NULL;
@@ -168,7 +168,7 @@ el_reset(EditLine *el)
* set the editline parameters
*/
public int
-FUN(el,set)(EditLine *el, int op, ...)
+el_wset(EditLine *el, int op, ...)
{
va_list ap;
int rv = 0;
@@ -239,27 +239,27 @@ FUN(el,set)(EditLine *el, int op, ...)
switch (op) {
case EL_BIND:
- argv[0] = STR("bind");
+ argv[0] = L"bind";
rv = map_bind(el, i, argv);
break;
case EL_TELLTC:
- argv[0] = STR("telltc");
+ argv[0] = L"telltc";
rv = terminal_telltc(el, i, argv);
break;
case EL_SETTC:
- argv[0] = STR("settc");
+ argv[0] = L"settc";
rv = terminal_settc(el, i, argv);
break;
case EL_ECHOTC:
- argv[0] = STR("echotc");
+ argv[0] = L"echotc";
rv = terminal_echotc(el, i, argv);
break;
case EL_SETTY:
- argv[0] = STR("setty");
+ argv[0] = L"setty";
rv = tty_stty(el, i, argv);
break;
@@ -381,7 +381,7 @@ FUN(el,set)(EditLine *el, int op, ...)
* retrieve the editline parameters
*/
public int
-FUN(el,get)(EditLine *el, int op, ...)
+el_wget(EditLine *el, int op, ...)
{
va_list ap;
int rv;
@@ -493,11 +493,11 @@ FUN(el,get)(EditLine *el, int op, ...)
/* el_line():
* Return editing info
*/
-public const TYPE(LineInfo) *
-FUN(el,line)(EditLine *el)
+public const LineInfoW *
+el_wline(EditLine *el)
{
- return (const TYPE(LineInfo) *)(void *)&el->el_line;
+ return (const LineInfoW *)(void *)&el->el_line;
}
@@ -618,10 +618,10 @@ el_editmode(EditLine *el, int argc, cons
return -1;
how = argv[1];
- if (Strcmp(how, STR("on")) == 0) {
+ if (wcscmp(how, L"on") == 0) {
el->el_flags &= ~EDIT_DISABLED;
tty_rawmode(el);
- } else if (Strcmp(how, STR("off")) == 0) {
+ } else if (wcscmp(how, L"off") == 0) {
tty_cookedmode(el);
el->el_flags |= EDIT_DISABLED;
}
Index: src/lib/libedit/eln.c
diff -u src/lib/libedit/eln.c:1.30 src/lib/libedit/eln.c:1.31
--- src/lib/libedit/eln.c:1.30 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/eln.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.30 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: eln.c,v 1.31 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.30 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.31 2016/04/11 00:22:48 christos Exp $");
#endif /* not lint && not SCCSID */
#include <errno.h>
@@ -184,23 +184,23 @@ el_set(EditLine *el, int op, ...)
*/
switch (op) {
case EL_BIND:
- wargv[0] = STR("bind");
+ wargv[0] = L"bind";
ret = map_bind(el, i, wargv);
break;
case EL_TELLTC:
- wargv[0] = STR("telltc");
+ wargv[0] = L"telltc";
ret = terminal_telltc(el, i, wargv);
break;
case EL_SETTC:
- wargv[0] = STR("settc");
+ wargv[0] = L"settc";
ret = terminal_settc(el, i, wargv);
break;
case EL_ECHOTC:
- wargv[0] = STR("echotc");
+ wargv[0] = L"echotc";
ret = terminal_echotc(el, i, wargv);
break;
case EL_SETTY:
- wargv[0] = STR("setty");
+ wargv[0] = L"setty";
ret = tty_stty(el, i, wargv);
break;
default:
@@ -226,7 +226,7 @@ el_set(EditLine *el, int op, ...)
goto out;
}
/* XXX: The two strdup's leak */
- ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
+ ret = map_addfunc(el, wcsdup(wargv[0]), wcsdup(wargv[1]),
func);
el_free(wargv);
break;
Index: src/lib/libedit/hist.c
diff -u src/lib/libedit/hist.c:1.26 src/lib/libedit/hist.c:1.27
--- src/lib/libedit/hist.c:1.26 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/hist.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.c,v 1.26 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: hist.c,v 1.27 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: hist.c,v 1.26 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: hist.c,v 1.27 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -103,7 +103,7 @@ hist_get(EditLine *el)
int h;
if (el->el_history.eventno == 0) { /* if really the current line */
- (void) Strncpy(el->el_line.buffer, el->el_history.buf,
+ (void) wcsncpy(el->el_line.buffer, el->el_history.buf,
el->el_history.sz);
el->el_line.lastchar = el->el_line.buffer +
(el->el_history.last - el->el_history.buf);
@@ -130,10 +130,10 @@ hist_get(EditLine *el)
el->el_history.eventno = h;
return CC_ERROR;
}
- (void) Strncpy(el->el_line.buffer, hp,
+ (void) wcsncpy(el->el_line.buffer, hp,
(size_t)(el->el_line.limit - el->el_line.buffer));
el->el_line.buffer[el->el_line.limit - el->el_line.buffer - 1] = '\0';
- el->el_line.lastchar = el->el_line.buffer + Strlen(el->el_line.buffer);
+ el->el_line.lastchar = el->el_line.buffer + wcslen(el->el_line.buffer);
if (el->el_line.lastchar > el->el_line.buffer
&& el->el_line.lastchar[-1] == '\n')
@@ -160,12 +160,12 @@ hist_command(EditLine *el, int argc, con
{
const Char *str;
int num;
- TYPE(HistEvent) ev;
+ HistEventW ev;
if (el->el_history.ref == NULL)
return -1;
- if (argc == 1 || Strcmp(argv[1], STR("list")) == 0) {
+ if (argc == 1 || wcscmp(argv[1], L"list") == 0) {
/* List history entries */
for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
@@ -179,11 +179,11 @@ hist_command(EditLine *el, int argc, con
num = (int)wcstol(argv[2], NULL, 0);
- if (Strcmp(argv[1], STR("size")) == 0)
- return FUNW(history)(el->el_history.ref, &ev, H_SETSIZE, num);
+ if (wcscmp(argv[1], L"size") == 0)
+ return history_w(el->el_history.ref, &ev, H_SETSIZE, num);
- if (Strcmp(argv[1], STR("unique")) == 0)
- return FUNW(history)(el->el_history.ref, &ev, H_SETUNIQUE, num);
+ if (wcscmp(argv[1], L"unique") == 0)
+ return history_w(el->el_history.ref, &ev, H_SETUNIQUE, num);
return -1;
}
Index: src/lib/libedit/terminal.c
diff -u src/lib/libedit/terminal.c:1.26 src/lib/libedit/terminal.c:1.27
--- src/lib/libedit/terminal.c:1.26 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/terminal.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.c,v 1.26 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: terminal.c,v 1.27 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: terminal.c,v 1.26 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.27 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1012,37 +1012,37 @@ terminal_init_arrow(EditLine *el)
{
funckey_t *arrow = el->el_terminal.t_fkey;
- arrow[A_K_DN].name = STR("down");
+ arrow[A_K_DN].name = L"down";
arrow[A_K_DN].key = T_kd;
arrow[A_K_DN].fun.cmd = ED_NEXT_HISTORY;
arrow[A_K_DN].type = XK_CMD;
- arrow[A_K_UP].name = STR("up");
+ arrow[A_K_UP].name = L"up";
arrow[A_K_UP].key = T_ku;
arrow[A_K_UP].fun.cmd = ED_PREV_HISTORY;
arrow[A_K_UP].type = XK_CMD;
- arrow[A_K_LT].name = STR("left");
+ arrow[A_K_LT].name = L"left";
arrow[A_K_LT].key = T_kl;
arrow[A_K_LT].fun.cmd = ED_PREV_CHAR;
arrow[A_K_LT].type = XK_CMD;
- arrow[A_K_RT].name = STR("right");
+ arrow[A_K_RT].name = L"right";
arrow[A_K_RT].key = T_kr;
arrow[A_K_RT].fun.cmd = ED_NEXT_CHAR;
arrow[A_K_RT].type = XK_CMD;
- arrow[A_K_HO].name = STR("home");
+ arrow[A_K_HO].name = L"home";
arrow[A_K_HO].key = T_kh;
arrow[A_K_HO].fun.cmd = ED_MOVE_TO_BEG;
arrow[A_K_HO].type = XK_CMD;
- arrow[A_K_EN].name = STR("end");
+ arrow[A_K_EN].name = L"end";
arrow[A_K_EN].key = T_at7;
arrow[A_K_EN].fun.cmd = ED_MOVE_TO_END;
arrow[A_K_EN].type = XK_CMD;
- arrow[A_K_DE].name = STR("delete");
+ arrow[A_K_DE].name = L"delete";
arrow[A_K_DE].key = T_kD;
arrow[A_K_DE].fun.cmd = ED_DELETE_NEXT_CHAR;
arrow[A_K_DE].type = XK_CMD;
@@ -1110,7 +1110,7 @@ terminal_set_arrow(EditLine *el, const C
int i;
for (i = 0; i < A_K_NKEYS; i++)
- if (Strcmp(name, arrow[i].name) == 0) {
+ if (wcscmp(name, arrow[i].name) == 0) {
arrow[i].fun = *fun;
arrow[i].type = type;
return 0;
@@ -1129,7 +1129,7 @@ terminal_clear_arrow(EditLine *el, const
int i;
for (i = 0; i < A_K_NKEYS; i++)
- if (Strcmp(name, arrow[i].name) == 0) {
+ if (wcscmp(name, arrow[i].name) == 0) {
arrow[i].type = XK_NOD;
return 0;
}
@@ -1147,7 +1147,7 @@ terminal_print_arrow(EditLine *el, const
funckey_t *arrow = el->el_terminal.t_fkey;
for (i = 0; i < A_K_NKEYS; i++)
- if (*name == '\0' || Strcmp(name, arrow[i].name) == 0)
+ if (*name == '\0' || wcscmp(name, arrow[i].name) == 0)
if (arrow[i].type != XK_NOD)
keymacro_kprint(el, arrow[i].name,
&arrow[i].fun, arrow[i].type);
@@ -1501,28 +1501,28 @@ terminal_echotc(EditLine *el, int argc _
}
if (!*argv || *argv[0] == '\0')
return 0;
- if (Strcmp(*argv, STR("tabs")) == 0) {
+ if (wcscmp(*argv, L"tabs") == 0) {
(void) fprintf(el->el_outfile, fmts, EL_CAN_TAB ? "yes" : "no");
return 0;
- } else if (Strcmp(*argv, STR("meta")) == 0) {
+ } else if (wcscmp(*argv, L"meta") == 0) {
(void) fprintf(el->el_outfile, fmts, Val(T_km) ? "yes" : "no");
return 0;
- } else if (Strcmp(*argv, STR("xn")) == 0) {
+ } else if (wcscmp(*argv, L"xn") == 0) {
(void) fprintf(el->el_outfile, fmts, EL_HAS_MAGIC_MARGINS ?
"yes" : "no");
return 0;
- } else if (Strcmp(*argv, STR("am")) == 0) {
+ } else if (wcscmp(*argv, L"am") == 0) {
(void) fprintf(el->el_outfile, fmts, EL_HAS_AUTO_MARGINS ?
"yes" : "no");
return 0;
- } else if (Strcmp(*argv, STR("baud")) == 0) {
+ } else if (wcscmp(*argv, L"baud") == 0) {
(void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed);
return 0;
- } else if (Strcmp(*argv, STR("rows")) == 0 ||
- Strcmp(*argv, STR("lines")) == 0) {
+ } else if (wcscmp(*argv, L"rows") == 0 ||
+ wcscmp(*argv, L"lines") == 0) {
(void) fprintf(el->el_outfile, fmtd, Val(T_li));
return 0;
- } else if (Strcmp(*argv, STR("cols")) == 0) {
+ } else if (wcscmp(*argv, L"cols") == 0) {
(void) fprintf(el->el_outfile, fmtd, Val(T_co));
return 0;
}
Index: src/lib/libedit/hist.h
diff -u src/lib/libedit/hist.h:1.19 src/lib/libedit/hist.h:1.20
--- src/lib/libedit/hist.h:1.19 Wed Mar 23 18:27:48 2016
+++ src/lib/libedit/hist.h Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.h,v 1.19 2016/03/23 22:27:48 christos Exp $ */
+/* $NetBSD: hist.h,v 1.20 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
#ifndef _h_el_hist
#define _h_el_hist
-typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...);
+typedef int (*hist_fun_t)(void *, HistEventW *, int, ...);
typedef struct el_history_t {
Char *buf; /* The history buffer */
@@ -49,7 +49,7 @@ typedef struct el_history_t {
int eventno; /* Event we are looking for */
void *ref; /* Argument for history fcns */
hist_fun_t fun; /* Event access */
- TYPE(HistEvent) ev; /* Event cookie */
+ HistEventW ev; /* Event cookie */
} el_history_t;
#define HIST_FUN_INTERNAL(el, fn, arg) \
Index: src/lib/libedit/history.c
diff -u src/lib/libedit/history.c:1.53 src/lib/libedit/history.c:1.54
--- src/lib/libedit/history.c:1.53 Wed Mar 23 18:27:48 2016
+++ src/lib/libedit/history.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.53 2016/03/23 22:27:48 christos Exp $ */
+/* $NetBSD: history.c,v 1.54 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: history.c,v 1.53 2016/03/23 22:27:48 christos Exp $");
+__RCSID("$NetBSD: history.c,v 1.54 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -55,6 +55,38 @@ static const char hist_cookie[] = "_HiSt
#include "histedit.h"
#include "chartype.h"
+
+#ifdef NARROWCHAR
+
+#define FUN(prefix, rest) prefix ## _ ## rest
+#define FUNW(type) type
+#define TYPE(type) type
+#define STR(x) x
+
+#define Strlen(s) strlen(s)
+#define Strdup(s) strdup(s)
+#define Strcmp(d, s) strcmp(d, s)
+#define Strncmp(d, s, n) strncmp(d, s, n)
+#define Strncpy(d, s, n) strncpy(d, s, n)
+#define Strncat(d, s, n) strncat(d, s, n)
+
+#else
+
+#define FUN(prefix, rest) prefix ## _w ## rest
+#define FUNW(type) type ## _w
+#define TYPE(type) type ## W
+#define STR(x) L ## x
+
+#define Strlen(s) wcslen(s)
+#define Strdup(s) wcsdup(s)
+#define Strcmp(d, s) wcscmp(d, s)
+#define Strncmp(d, s, n) wcsncmp(d, s, n)
+#define Strncpy(d, s, n) wcsncpy(d, s, n)
+#define Strncat(d, s, n) wcsncat(d, s, n)
+
+#endif
+
+
typedef int (*history_gfun_t)(void *, TYPE(HistEvent) *);
typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *);
typedef void (*history_vfun_t)(void *, TYPE(HistEvent) *);
Index: src/lib/libedit/keymacro.c
diff -u src/lib/libedit/keymacro.c:1.16 src/lib/libedit/keymacro.c:1.17
--- src/lib/libedit/keymacro.c:1.16 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/keymacro.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: keymacro.c,v 1.16 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: keymacro.c,v 1.17 2016/04/11 00:22:48 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.16 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: keymacro.c,v 1.17 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -357,7 +357,7 @@ node__try(EditLine *el, keymacro_node_t
break;
case XK_STR:
case XK_EXE:
- if ((ptr->val.str = Strdup(val->str)) == NULL)
+ if ((ptr->val.str = wcsdup(val->str)) == NULL)
return -1;
break;
default:
Index: src/lib/libedit/makelist
diff -u src/lib/libedit/makelist:1.25 src/lib/libedit/makelist:1.26
--- src/lib/libedit/makelist:1.25 Wed Mar 23 18:27:48 2016
+++ src/lib/libedit/makelist Sun Apr 10 20:22:48 2016
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: makelist,v 1.25 2016/03/23 22:27:48 christos Exp $
+# $NetBSD: makelist,v 1.26 2016/04/11 00:22:48 christos Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@@ -114,16 +114,16 @@ _EOF
fname = fname s;
}
- printf(" { %-30.30s %-30.30s\n","STR(\"" fname "\"),", uname ",");
+ printf(" { %-30.30s %-30.30s\n","L\"" fname "\",", uname ",");
ok = 1;
}
}
/^ \*/ {
if (ok) {
- printf(" STR(\"");
+ printf(" L\"");
for (i = 2; i < NF; i++)
printf("%s ", $i);
- printf("%s\") },\n", $i);
+ printf("%s\" },\n", $i);
ok = 0;
}
}
Index: src/lib/libedit/map.c
diff -u src/lib/libedit/map.c:1.44 src/lib/libedit/map.c:1.45
--- src/lib/libedit/map.c:1.44 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/map.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.44 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: map.c,v 1.45 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: map.c,v 1.44 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.45 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1087,11 +1087,11 @@ protected int
map_set_editor(EditLine *el, Char *editor)
{
- if (Strcmp(editor, STR("emacs")) == 0) {
+ if (wcscmp(editor, L"emacs") == 0) {
map_init_emacs(el);
return 0;
}
- if (Strcmp(editor, STR("vi")) == 0) {
+ if (wcscmp(editor, L"vi") == 0) {
map_init_vi(el);
return 0;
}
@@ -1110,10 +1110,10 @@ map_get_editor(EditLine *el, const Char
return -1;
switch (el->el_map.type) {
case MAP_EMACS:
- *editor = STR("emacs");
+ *editor = L"emacs";
return 0;
case MAP_VI:
- *editor = STR("vi");
+ *editor = L"vi";
return 0;
}
return -1;
@@ -1236,9 +1236,9 @@ map_print_all_keys(EditLine *el)
map_print_some_keys(el, el->el_map.alt, prev, i - 1);
(void) fprintf(el->el_outfile, "Multi-character bindings\n");
- keymacro_print(el, STR(""));
+ keymacro_print(el, L"");
(void) fprintf(el->el_outfile, "Arrow key bindings\n");
- terminal_print_arrow(el, STR(""));
+ terminal_print_arrow(el, L"");
}
Index: src/lib/libedit/parse.c
diff -u src/lib/libedit/parse.c:1.35 src/lib/libedit/parse.c:1.36
--- src/lib/libedit/parse.c:1.35 Wed Feb 17 14:47:49 2016
+++ src/lib/libedit/parse.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $ */
+/* $NetBSD: parse.c,v 1.36 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.36 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -64,13 +64,13 @@ private const struct {
const Char *name;
int (*func)(EditLine *, int, const Char **);
} cmds[] = {
- { STR("bind"), map_bind },
- { STR("echotc"), terminal_echotc },
- { STR("edit"), el_editmode },
- { STR("history"), hist_command },
- { STR("telltc"), terminal_telltc },
- { STR("settc"), terminal_settc },
- { STR("setty"), tty_stty },
+ { L"bind", map_bind },
+ { L"echotc", terminal_echotc },
+ { L"edit", el_editmode },
+ { L"history", hist_command },
+ { L"telltc", terminal_telltc },
+ { L"settc", terminal_settc },
+ { L"setty", tty_stty },
{ NULL, NULL }
};
@@ -83,12 +83,12 @@ parse_line(EditLine *el, const Char *lin
{
const Char **argv;
int argc;
- TYPE(Tokenizer) *tok;
+ TokenizerW *tok;
- tok = FUN(tok,init)(NULL);
- FUN(tok,str)(tok, line, &argc, &argv);
- argc = FUN(el,parse)(el, argc, argv);
- FUN(tok,end)(tok);
+ tok = tok_winit(NULL);
+ tok_wstr(tok, line, &argc, &argv);
+ argc = el_wparse(el, argc, argv);
+ tok_wend(tok);
return argc;
}
@@ -97,14 +97,14 @@ parse_line(EditLine *el, const Char *lin
* Command dispatcher
*/
public int
-FUN(el,parse)(EditLine *el, int argc, const Char *argv[])
+el_wparse(EditLine *el, int argc, const Char *argv[])
{
const Char *ptr;
int i;
if (argc < 1)
return -1;
- ptr = Strchr(argv[0], ':');
+ ptr = wcschr(argv[0], L':');
if (ptr != NULL) {
Char *tprog;
size_t l;
@@ -115,7 +115,7 @@ FUN(el,parse)(EditLine *el, int argc, co
tprog = el_malloc((l + 1) * sizeof(*tprog));
if (tprog == NULL)
return 0;
- (void) Strncpy(tprog, argv[0], l);
+ (void) wcsncpy(tprog, argv[0], l);
tprog[l] = '\0';
ptr++;
l = (size_t)el_match(el->el_prog, tprog);
@@ -126,7 +126,7 @@ FUN(el,parse)(EditLine *el, int argc, co
ptr = argv[0];
for (i = 0; cmds[i].name != NULL; i++)
- if (Strcmp(cmds[i].name, ptr) == 0) {
+ if (wcscmp(cmds[i].name, ptr) == 0) {
i = (*cmds[i].func) (el, argc, argv);
return -i;
}
@@ -179,14 +179,14 @@ parse__escape(const Char **ptr)
case 'U': /* Unicode \U+xxxx or \U+xxxxx format */
{
int i;
- const Char hex[] = STR("0123456789ABCDEF");
+ const Char hex[] = L"0123456789ABCDEF";
const Char *h;
++p;
if (*p++ != '+')
return -1;
c = 0;
for (i = 0; i < 5; ++i) {
- h = Strchr(hex, *p++);
+ h = wcschr(hex, *p++);
if (!h && i < 4)
return -1;
else if (h)
@@ -283,7 +283,7 @@ parse_cmd(EditLine *el, const Char *cmd)
size_t i;
for (i = 0; i < el->el_map.nfunc; i++)
- if (Strcmp(b[i].name, cmd) == 0)
+ if (wcscmp(b[i].name, cmd) == 0)
return b[i].func;
return -1;
}
Index: src/lib/libedit/read.c
diff -u src/lib/libedit/read.c:1.88 src/lib/libedit/read.c:1.89
--- src/lib/libedit/read.c:1.88 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/read.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.88 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: read.c,v 1.89 2016/04/11 00:22:48 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.88 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.89 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -187,13 +187,13 @@ read__fixio(int fd __attribute__((__unus
* Push a macro
*/
public void
-FUN(el,push)(EditLine *el, const Char *str)
+el_wpush(EditLine *el, const Char *str)
{
c_macro_t *ma = &el->el_chared.c_macro;
if (str != NULL && ma->level + 1 < EL_MAXMACRO) {
ma->level++;
- if ((ma->macro[ma->level] = Strdup(str)) != NULL)
+ if ((ma->macro[ma->level] = wcsdup(str)) != NULL)
return;
ma->level--;
}
@@ -245,7 +245,7 @@ read_getcmd(EditLine *el, el_action_t *c
cmd = val.cmd;
break;
case XK_STR:
- FUN(el,push)(el, val.str);
+ el_wpush(el, val.str);
break;
#ifdef notyet
case XK_EXE:
@@ -283,7 +283,7 @@ read_char(EditLine *el, wchar_t *cp)
int e = errno;
switch (el->el_signal->sig_no) {
case SIGCONT:
- FUN(el,set)(el, EL_REFRESH);
+ el_wset(el, EL_REFRESH);
/*FALLTHROUGH*/
case SIGWINCH:
sig_set(el);
@@ -442,7 +442,7 @@ read_finish(EditLine *el)
}
public const Char *
-FUN(el,gets)(EditLine *el, int *nread)
+el_wgets(EditLine *el, int *nread)
{
int retval;
el_action_t cmdnum = 0;
Index: src/lib/libedit/refresh.c
diff -u src/lib/libedit/refresh.c:1.46 src/lib/libedit/refresh.c:1.47
--- src/lib/libedit/refresh.c:1.46 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/refresh.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.c,v 1.46 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: refresh.c,v 1.47 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: refresh.c,v 1.46 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.47 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -321,10 +321,10 @@ re_refresh(EditLine *el)
for (; i <= el->el_refresh.r_oldcv; i++) {
terminal_move_to_line(el, i);
terminal_move_to_char(el, 0);
- /* This Strlen should be safe even with MB_FILL_CHARs */
- terminal_clear_EOL(el, (int) Strlen(el->el_display[i]));
+ /* This wcslen should be safe even with MB_FILL_CHARs */
+ terminal_clear_EOL(el, (int) wcslen(el->el_display[i]));
#ifdef DEBUG_REFRESH
- terminal_overwrite(el, STR("C\b"), 2);
+ terminal_overwrite(el, L"C\b", 2);
#endif /* DEBUG_REFRESH */
el->el_display[i][0] = '\0';
}
@@ -1085,7 +1085,7 @@ re_fastputc(EditLine *el, wint_t c)
for(i = 1; i < lins; i++)
el->el_display[i - 1] = el->el_display[i];
- re__copy_and_pad(firstline, STR(""), (size_t)0);
+ re__copy_and_pad(firstline, L"", (size_t)0);
el->el_display[i - 1] = firstline;
} else {
el->el_cursor.v++;
Index: src/lib/libedit/tokenizer.c
diff -u src/lib/libedit/tokenizer.c:1.24 src/lib/libedit/tokenizer.c:1.25
--- src/lib/libedit/tokenizer.c:1.24 Wed Feb 17 14:47:49 2016
+++ src/lib/libedit/tokenizer.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $ */
+/* $NetBSD: tokenizer.c,v 1.25 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: tokenizer.c,v 1.25 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -66,8 +66,20 @@ typedef enum {
#define tok_malloc(a) malloc(a)
#define tok_free(a) free(a)
#define tok_realloc(a, b) realloc(a, b)
-#define tok_strdup(a) Strdup(a)
+#ifdef NARROWCHAR
+#define FUN(prefix, rest) prefix ## _ ## rest
+#define TYPE(type) type
+#define STR(x) x
+#define Strchr(s, c) strchr(s, c)
+#define tok_strdup(s) strdup(s)
+#else
+#define FUN(prefix, rest) prefix ## _w ## rest
+#define TYPE(type) type ## W
+#define STR(x) L ## x
+#define Strchr(s, c) wcschr(s, c)
+#define tok_strdup(s) wcsdup(s)
+#endif
struct TYPE(tokenizer) {
Char *ifs; /* In field separator */
Index: src/lib/libedit/tty.c
diff -u src/lib/libedit/tty.c:1.60 src/lib/libedit/tty.c:1.61
--- src/lib/libedit/tty.c:1.60 Sat Apr 9 14:43:17 2016
+++ src/lib/libedit/tty.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.60 2016/04/09 18:43:17 christos Exp $ */
+/* $NetBSD: tty.c,v 1.61 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tty.c,v 1.60 2016/04/09 18:43:17 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.61 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1248,7 +1248,7 @@ tty_stty(EditLine *el, int argc __attrib
break;
}
d = s;
- p = Strchr(s, '=');
+ p = wcschr(s, L'=');
for (m = ttymodes; m->m_name; m++)
if ((p ? strncmp(m->m_name, ct_encode_string(d,
&el->el_scratch), (size_t)(p - d)) :
Index: src/lib/libedit/vi.c
diff -u src/lib/libedit/vi.c:1.57 src/lib/libedit/vi.c:1.58
--- src/lib/libedit/vi.c:1.57 Sat Apr 9 14:47:05 2016
+++ src/lib/libedit/vi.c Sun Apr 10 20:22:48 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.57 2016/04/09 18:47:05 christos Exp $ */
+/* $NetBSD: vi.c,v 1.58 2016/04/11 00:22:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vi.c,v 1.57 2016/04/09 18:47:05 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.58 2016/04/11 00:22:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -809,7 +809,7 @@ protected el_action_t
/*ARGSUSED*/
vi_match(EditLine *el, wint_t c __attribute__((__unused__)))
{
- const Char match_chars[] = STR("()[]{}");
+ const Char match_chars[] = L"()[]{}";
Char *cp;
size_t delta, i, count;
Char o_ch, c_ch;
@@ -820,7 +820,7 @@ vi_match(EditLine *el, wint_t c __attrib
o_ch = el->el_line.cursor[i];
if (o_ch == 0)
return CC_ERROR;
- delta = (size_t)(Strchr(match_chars, o_ch) - match_chars);
+ delta = (size_t)(wcschr(match_chars, o_ch) - match_chars);
c_ch = match_chars[delta ^ 1];
count = 1;
delta = 1 - (delta & 1) * 2;
@@ -942,7 +942,7 @@ vi_alias(EditLine *el, wint_t c __attrib
alias_text = (*el->el_chared.c_aliasfun)(el->el_chared.c_aliasarg,
alias_name);
if (alias_text != NULL)
- FUN(el,push)(el, ct_decode_string(alias_text, &el->el_scratch));
+ el_wpush(el, ct_decode_string(alias_text, &el->el_scratch));
return CC_NORM;
}
@@ -959,7 +959,7 @@ vi_to_history_line(EditLine *el, wint_t
if (el->el_history.eventno == 0) {
- (void) Strncpy(el->el_history.buf, el->el_line.buffer,
+ (void) wcsncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
@@ -1024,7 +1024,7 @@ vi_histedit(EditLine *el, wint_t c __att
line = el_malloc(len * sizeof(*line) + 1);
if (line == NULL)
goto error;
- Strncpy(line, el->el_line.buffer, len);
+ wcsncpy(line, el->el_line.buffer, len);
line[len] = '\0';
wcstombs(cp, line, TMP_BUFSIZ - 1);
cp[TMP_BUFSIZ - 1] = '\0';
@@ -1147,7 +1147,7 @@ vi_redo(EditLine *el, wint_t c __attribu
/* sanity */
r->pos = r->lim - 1;
r->pos[0] = 0;
- FUN(el,push)(el, r->buf);
+ el_wpush(el, r->buf);
}
el->el_state.thiscmd = r->cmd;