diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-04-11 20:43:34 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-04-11 20:43:34 +0000 |
commit | b4c93c7ba9d727cb7cd0cdbe52c0123401424db1 (patch) | |
tree | 82760cb62e68d8a09fd1e773ad001637fb560665 | |
parent | abf221675b71c007d7d79df6e96b6c7cdc20da9e (diff) |
get rid of the non-standard data type "Char" in almost all files;
ok martijn@
32 files changed, 375 insertions, 378 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index eb290145f08..197b11768a4 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chared.c,v 1.23 2016/04/11 19:54:53 schwarze Exp $ */ +/* $OpenBSD: chared.c,v 1.24 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -78,7 +78,7 @@ cv_undo(EditLine *el) * Save yank/delete data for paste */ protected void -cv_yank(EditLine *el, const Char *ptr, int size) +cv_yank(EditLine *el, const wchar_t *ptr, int size) { c_kill_t *k = &el->el_chared.c_kill; @@ -93,7 +93,7 @@ cv_yank(EditLine *el, const Char *ptr, int size) protected void c_insert(EditLine *el, int num) { - Char *cp; + wchar_t *cp; if (el->el_line.lastchar + num >= el->el_line.limit) { if (!ch_enlargebufs(el, (size_t)num)) @@ -125,7 +125,7 @@ c_delafter(EditLine *el, int num) } if (num > 0) { - Char *cp; + wchar_t *cp; for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) *cp = cp[num]; @@ -141,7 +141,7 @@ c_delafter(EditLine *el, int num) protected void c_delafter1(EditLine *el) { - Char *cp; + wchar_t *cp; for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) *cp = cp[1]; @@ -166,7 +166,7 @@ c_delbefore(EditLine *el, int num) } if (num > 0) { - Char *cp; + wchar_t *cp; for (cp = el->el_line.cursor - num; cp <= el->el_line.lastchar; @@ -184,7 +184,7 @@ c_delbefore(EditLine *el, int num) protected void c_delbefore1(EditLine *el) { - Char *cp; + wchar_t *cp; for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) *cp = cp[1]; @@ -230,8 +230,8 @@ cv__isWord(wint_t p) /* c__prev_word(): * Find the previous word */ -protected Char * -c__prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t)) +protected wchar_t * +c__prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t)) { p--; @@ -254,8 +254,8 @@ c__prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t)) /* c__next_word(): * Find the next word */ -protected Char * -c__next_word(Char *p, Char *high, int n, int (*wtest)(wint_t)) +protected wchar_t * +c__next_word(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t)) { while (n--) { while ((p < high) && !(*wtest)(*p)) @@ -272,8 +272,9 @@ c__next_word(Char *p, Char *high, int n, int (*wtest)(wint_t)) /* cv_next_word(): * Find the next word vi style */ -protected Char * -cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(wint_t)) +protected wchar_t * +cv_next_word(EditLine *el, wchar_t *p, wchar_t *high, int n, + int (*wtest)(wint_t)) { int test; @@ -301,8 +302,8 @@ cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(wint_t)) /* cv_prev_word(): * Find the previous word vi style */ -protected Char * -cv_prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t)) +protected wchar_t * +cv_prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t)) { int test; @@ -365,8 +366,8 @@ cv_delfini(EditLine *el) /* cv__endword(): * Go to the end of this word according to vi */ -protected Char * -cv__endword(Char *p, Char *high, int n, int (*wtest)(wint_t)) +protected wchar_t * +cv__endword(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t)) { int test; @@ -497,7 +498,7 @@ protected int ch_enlargebufs(EditLine *el, size_t addlen) { size_t sz, newsz; - Char *newbuffer, *oldbuf, *oldkbuf; + wchar_t *newbuffer, *oldbuf, *oldkbuf; sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE; newsz = sz * 2; @@ -608,7 +609,7 @@ ch_end(EditLine *el) * Insert string at cursorI */ public int -el_winsertstr(EditLine *el, const Char *s) +el_winsertstr(EditLine *el, const wchar_t *s) { size_t len; @@ -648,11 +649,10 @@ el_deletestr(EditLine *el, int n) * Get a string */ protected int -c_gets(EditLine *el, Char *buf, const Char *prompt) +c_gets(EditLine *el, wchar_t *buf, const wchar_t *prompt) { - wchar_t wch; ssize_t len; - Char *cp = el->el_line.buffer, ch; + wchar_t *cp = el->el_line.buffer, ch; if (prompt) { len = wcslen(prompt); @@ -667,12 +667,11 @@ c_gets(EditLine *el, Char *buf, const Char *prompt) el->el_line.lastchar = cp + 1; re_refresh(el); - if (el_wgetc(el, &wch) != 1) { + if (el_wgetc(el, &ch) != 1) { ed_end_of_file(el, 0); len = -1; break; } - ch = (Char)wch; switch (ch) { @@ -717,7 +716,7 @@ c_gets(EditLine *el, Char *buf, const Char *prompt) protected int c_hpos(EditLine *el) { - Char *ptr; + wchar_t *ptr; /* * Find how many characters till the beginning of this line. diff --git a/lib/libedit/chared.h b/lib/libedit/chared.h index 91a26d974b8..8de380a30e6 100644 --- a/lib/libedit/chared.h +++ b/lib/libedit/chared.h @@ -1,4 +1,4 @@ -/* $OpenBSD: chared.h,v 1.13 2016/03/20 23:48:27 schwarze Exp $ */ +/* $OpenBSD: chared.h,v 1.14 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: chared.h,v 1.20 2010/04/15 00:57:33 christos Exp $ */ /*- @@ -59,7 +59,7 @@ typedef struct c_macro_t { int level; int offset; - Char **macro; + wchar_t **macro; } c_macro_t; /* @@ -68,16 +68,16 @@ typedef struct c_macro_t { typedef struct c_undo_t { ssize_t len; /* length of saved line */ int cursor; /* position of saved cursor */ - Char *buf; /* full saved text */ + wchar_t *buf; /* full saved text */ } c_undo_t; /* redo for vi */ typedef struct c_redo_t { - Char *buf; /* redo insert key sequence */ - Char *pos; - Char *lim; + wchar_t *buf; /* redo insert key sequence */ + wchar_t *pos; + wchar_t *lim; el_action_t cmd; /* command to redo */ - Char ch; /* char that invoked it */ + wchar_t ch; /* char that invoked it */ int count; int action; /* from cv_action() */ } c_redo_t; @@ -87,16 +87,16 @@ typedef struct c_redo_t { */ typedef struct c_vcmd_t { int action; - Char *pos; + wchar_t *pos; } c_vcmd_t; /* * Kill buffer for emacs */ typedef struct c_kill_t { - Char *buf; - Char *last; - Char *mark; + wchar_t *buf; + wchar_t *last; + wchar_t *mark; } c_kill_t; typedef void (*el_zfunc_t)(EditLine *, void *); @@ -136,20 +136,21 @@ typedef struct el_chared_t { protected int cv__isword(wint_t); protected int cv__isWord(wint_t); protected void cv_delfini(EditLine *); -protected Char *cv__endword(Char *, Char *, int, int (*)(wint_t)); +protected wchar_t *cv__endword(wchar_t *, wchar_t *, int, int (*)(wint_t)); protected int ce__isword(wint_t); protected void cv_undo(EditLine *); -protected void cv_yank(EditLine *, const Char *, int); -protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(wint_t)); -protected Char *cv_prev_word(Char *, Char *, int, int (*)(wint_t)); -protected Char *c__next_word(Char *, Char *, int, int (*)(wint_t)); -protected Char *c__prev_word(Char *, Char *, int, int (*)(wint_t)); +protected void cv_yank(EditLine *, const wchar_t *, int); +protected wchar_t *cv_next_word(EditLine*, wchar_t *, wchar_t *, int, + int (*)(wint_t)); +protected wchar_t *cv_prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t)); +protected wchar_t *c__next_word(wchar_t *, wchar_t *, int, int (*)(wint_t)); +protected wchar_t *c__prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t)); protected void c_insert(EditLine *, int); protected void c_delbefore(EditLine *, int); protected void c_delbefore1(EditLine *); protected void c_delafter(EditLine *, int); protected void c_delafter1(EditLine *); -protected int c_gets(EditLine *, Char *, const Char *); +protected int c_gets(EditLine *, wchar_t *, const wchar_t *); protected int c_hpos(EditLine *); protected int ch_init(EditLine *); diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c index 60b2e41485e..5d94347e9df 100644 --- a/lib/libedit/chartype.c +++ b/lib/libedit/chartype.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chartype.c,v 1.12 2016/04/09 20:15:26 schwarze Exp $ */ +/* $OpenBSD: chartype.c,v 1.13 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: chartype.c,v 1.6 2011/07/28 00:48:21 christos Exp $ */ /*- @@ -57,7 +57,7 @@ ct_conv_buff_resize(ct_buffer_t *conv, size_t mincsize, size_t minwsize) if (minwsize > conv->wsize) { conv->wsize = minwsize; - p = reallocarray(conv->wbuff, conv->wsize, sizeof(Char)); + p = reallocarray(conv->wbuff, conv->wsize, sizeof(wchar_t)); if (p == NULL) { conv->wsize = 0; free(conv->wbuff); @@ -69,7 +69,7 @@ ct_conv_buff_resize(ct_buffer_t *conv, size_t mincsize, size_t minwsize) public char * -ct_encode_string(const Char *s, ct_buffer_t *conv) +ct_encode_string(const wchar_t *s, ct_buffer_t *conv) { char *dst; ssize_t used = 0; @@ -101,7 +101,7 @@ ct_encode_string(const Char *s, ct_buffer_t *conv) return conv->cbuff; } -public Char * +public wchar_t * ct_decode_string(const char *s, ct_buffer_t *conv) { size_t len = 0; @@ -126,13 +126,13 @@ ct_decode_string(const char *s, ct_buffer_t *conv) } -protected Char ** +protected wchar_t ** ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv) { size_t bufspace; int i; - Char *p; - Char **wargv; + wchar_t *p; + wchar_t **wargv; size_t wlen; /* Make sure we have enough space in the conversion buffer to store all @@ -168,7 +168,7 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv) protected size_t -ct_enc_width(Char c) +ct_enc_width(wchar_t c) { /* UTF-8 encoding specific values */ if (c < 0x80) @@ -184,7 +184,7 @@ ct_enc_width(Char c) } protected ssize_t -ct_encode_char(char *dst, size_t len, Char c) +ct_encode_char(char *dst, size_t len, wchar_t c) { ssize_t l = 0; if (len < ct_enc_width(c)) @@ -198,13 +198,13 @@ ct_encode_char(char *dst, size_t len, Char c) return l; } -protected const Char * -ct_visual_string(const Char *s) +protected const wchar_t * +ct_visual_string(const wchar_t *s) { - static Char *buff = NULL; + static wchar_t *buff = NULL; static size_t buffsize = 0; void *p; - Char *dst; + wchar_t *dst; ssize_t used = 0; if (!s) @@ -249,7 +249,7 @@ out: protected int -ct_visual_width(Char c) +ct_visual_width(wchar_t c) { int t = ct_chr_class(c); int w; @@ -275,7 +275,7 @@ ct_visual_width(Char c) protected ssize_t -ct_visual_char(Char *dst, size_t len, Char c) +ct_visual_char(wchar_t *dst, size_t len, wchar_t c) { int t = ct_chr_class(c); switch (t) { @@ -322,7 +322,7 @@ ct_visual_char(Char *dst, size_t len, Char c) protected int -ct_chr_class(Char c) +ct_chr_class(wchar_t c) { if (c == '\t') return CHTYPE_TAB; diff --git a/lib/libedit/chartype.h b/lib/libedit/chartype.h index 4a3c999b997..787520cc94f 100644 --- a/lib/libedit/chartype.h +++ b/lib/libedit/chartype.h @@ -1,4 +1,4 @@ -/* $OpenBSD: chartype.h,v 1.16 2016/04/11 19:54:53 schwarze Exp $ */ +/* $OpenBSD: chartype.h,v 1.17 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: chartype.h,v 1.5 2010/04/15 00:55:57 christos Exp $ */ /*- @@ -52,39 +52,32 @@ #warning Build environment does not support non-BMP characters #endif -#define Char wchar_t -#else /* NARROW */ -#define Char char -#endif - - -#ifndef NARROWCHAR /* * Conversion buffer */ typedef struct ct_buffer_t { char *cbuff; size_t csize; - Char *wbuff; + wchar_t *wbuff; size_t wsize; } ct_buffer_t; #define ct_encode_string __ct_encode_string /* Encode a wide-character string and return the UTF-8 encoded result. */ -public char *ct_encode_string(const Char *, ct_buffer_t *); +public char *ct_encode_string(const wchar_t *, ct_buffer_t *); #define ct_decode_string __ct_decode_string /* Decode a (multi)?byte string and return the wide-character string result. */ -public Char *ct_decode_string(const char *, ct_buffer_t *); +public wchar_t *ct_decode_string(const char *, ct_buffer_t *); /* Decode a (multi)?byte argv string array. * The pointer returned must be free()d when done. */ -protected Char **ct_decode_argv(int, const char *[], ct_buffer_t *); +protected wchar_t **ct_decode_argv(int, const char *[], ct_buffer_t *); /* Resizes the conversion buffer(s) if needed. */ protected void ct_conv_buff_resize(ct_buffer_t *, size_t, size_t); -protected ssize_t ct_encode_char(char *, size_t, Char); -protected size_t ct_enc_width(Char); +protected ssize_t ct_encode_char(char *, size_t, wchar_t); +protected size_t ct_enc_width(wchar_t); #else #define ct_encode_string(s, b) (s) @@ -103,20 +96,20 @@ protected size_t ct_enc_width(Char); /* The terminal is thought of in terms of X columns by Y lines. In the cases * where a wide character takes up more than one column, the adjacent * occupied column entries will contain this faux character. */ -#define MB_FILL_CHAR ((Char)-1) +#define MB_FILL_CHAR ((wchar_t)-1) /* Visual width of character c, taking into account ^? , \0177 and \U+nnnnn * style visual expansions. */ -protected int ct_visual_width(Char); +protected int ct_visual_width(wchar_t); /* Turn the given character into the appropriate visual format, matching * the width given by ct_visual_width(). Returns the number of characters used - * up, or -1 if insufficient space. Buffer length is in count of Char's. */ -protected ssize_t ct_visual_char(Char *, size_t, Char); + * up, or -1 if insufficient space. Buffer length is in count of wchar_t's. */ +protected ssize_t ct_visual_char(wchar_t *, size_t, wchar_t); /* Convert the given string into visual format, using the ct_visual_char() * function. Uses a static buffer, so not threadsafe. */ -protected const Char *ct_visual_string(const Char *); +protected const wchar_t *ct_visual_string(const wchar_t *); /* printable character, use ct_visual_width() to find out display width */ @@ -130,7 +123,7 @@ protected const Char *ct_visual_string(const Char *); /* non-printable character */ #define CHTYPE_NONPRINT (-4) /* classification of character c, as one of the above defines */ -protected int ct_chr_class(Char c); +protected int ct_chr_class(wchar_t c); #endif #endif /* _chartype_f */ diff --git a/lib/libedit/common.c b/lib/libedit/common.c index 4d101a47201..49429742fc7 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.18 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: common.c,v 1.19 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -111,7 +111,7 @@ protected el_action_t /*ARGSUSED*/ ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp, *p, *kp; + wchar_t *cp, *p, *kp; if (el->el_line.cursor == el->el_line.buffer) return CC_ERROR; @@ -189,7 +189,7 @@ protected el_action_t /*ARGSUSED*/ ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *kp, *cp; + wchar_t *kp, *cp; cp = el->el_line.cursor; kp = el->el_chared.c_kill.buf; @@ -282,7 +282,7 @@ protected el_action_t /*ARGSUSED*/ ed_next_char(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *lim = el->el_line.lastchar; + wchar_t *lim = el->el_line.lastchar; if (el->el_line.cursor >= lim || (el->el_line.cursor == lim - 1 && @@ -704,7 +704,7 @@ protected el_action_t /*ARGSUSED*/ ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__))) { - const Char *hp; + const wchar_t *hp; int h; int found = 0; @@ -772,7 +772,7 @@ protected el_action_t /*ARGSUSED*/ ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__))) { - const Char *hp; + const wchar_t *hp; int h; int found = 0; @@ -826,7 +826,7 @@ protected el_action_t /*ARGSUSED*/ ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *ptr; + wchar_t *ptr; int nchars = c_hpos(el); /* @@ -869,7 +869,7 @@ protected el_action_t /*ARGSUSED*/ ed_next_line(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *ptr; + wchar_t *ptr; int nchars = c_hpos(el); /* @@ -903,7 +903,7 @@ protected el_action_t /*ARGSUSED*/ ed_command(EditLine *el, wint_t c __attribute__((__unused__))) { - Char tmpbuf[EL_BUFSIZ]; + wchar_t tmpbuf[EL_BUFSIZ]; int tmplen; tmplen = c_gets(el, tmpbuf, L"\n: "); diff --git a/lib/libedit/el.c b/lib/libedit/el.c index b90f2988472..d56576a6bbd 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -1,4 +1,4 @@ -/* $OpenBSD: el.c,v 1.32 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: el.c,v 1.33 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $ */ /*- @@ -192,7 +192,7 @@ el_wset(EditLine *el, int op, ...) break; case EL_EDITOR: - rv = map_set_editor(el, va_arg(ap, Char *)); + rv = map_set_editor(el, va_arg(ap, wchar_t *)); break; case EL_SIGNAL: @@ -208,11 +208,11 @@ el_wset(EditLine *el, int op, ...) case EL_ECHOTC: case EL_SETTY: { - const Char *argv[20]; + const wchar_t *argv[20]; int i; for (i = 1; i < 20; i++) - if ((argv[i] = va_arg(ap, Char *)) == NULL) + if ((argv[i] = va_arg(ap, wchar_t *)) == NULL) break; switch (op) { @@ -251,8 +251,8 @@ el_wset(EditLine *el, int op, ...) case EL_ADDFN: { - Char *name = va_arg(ap, Char *); - Char *help = va_arg(ap, Char *); + wchar_t *name = va_arg(ap, wchar_t *); + wchar_t *help = va_arg(ap, wchar_t *); el_func_t func = va_arg(ap, el_func_t); rv = map_addfunc(el, name, help, func); @@ -379,14 +379,14 @@ el_wget(EditLine *el, int op, ...) case EL_PROMPT_ESC: case EL_RPROMPT_ESC: { el_pfunc_t *p = va_arg(ap, el_pfunc_t *); - Char *c = va_arg(ap, Char *); + wchar_t *c = va_arg(ap, wchar_t *); rv = prompt_get(el, p, c, op); break; } case EL_EDITOR: - rv = map_get_editor(el, va_arg(ap, const Char **)); + rv = map_get_editor(el, va_arg(ap, const wchar_t **)); break; case EL_SIGNAL: @@ -501,7 +501,7 @@ el_source(EditLine *el, const char *fname) #ifdef HAVE_ISSETUGID char path[PATH_MAX]; #endif - const Char *dptr; + const wchar_t *dptr; fp = NULL; if (fname == NULL) { @@ -596,9 +596,9 @@ el_beep(EditLine *el) */ protected int /*ARGSUSED*/ -el_editmode(EditLine *el, int argc, const Char **argv) +el_editmode(EditLine *el, int argc, const wchar_t **argv) { - const Char *how; + const wchar_t *how; if (argv == NULL || argc != 2 || argv[1] == NULL) return -1; diff --git a/lib/libedit/el.h b/lib/libedit/el.h index da30cd42ea9..761c6f54d66 100644 --- a/lib/libedit/el.h +++ b/lib/libedit/el.h @@ -1,5 +1,5 @@ -/* $OpenBSD: el.h,v 1.18 2016/04/09 19:31:55 schwarze Exp $ */ -/* $NetBSD: el.h,v 1.35 2016/03/23 22:27:48 christos Exp $ */ +/* $OpenBSD: el.h,v 1.19 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: el.h,v 1.36 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -67,10 +67,10 @@ typedef struct coord_t { /* Position on the screen */ } coord_t; typedef struct el_line_t { - Char *buffer; /* Input line */ - Char *cursor; /* Cursor position */ - Char *lastchar; /* Last character */ - const Char *limit; /* Max position */ + wchar_t *buffer; /* Input line */ + wchar_t *cursor; /* Cursor position */ + wchar_t *lastchar; /* Last character */ + const wchar_t *limit; /* Max position */ } el_line_t; /* @@ -83,7 +83,7 @@ typedef struct el_state_t { int metanext; /* Is the next char a meta char */ el_action_t lastcmd; /* Previous command */ el_action_t thiscmd; /* this command */ - Char thisch; /* char that generated it */ + wchar_t thisch; /* char that generated it */ } el_state_t; #include "tty.h" @@ -100,7 +100,7 @@ typedef struct el_state_t { #include "read.h" struct editline { - Char *el_prog; /* the program name */ + wchar_t *el_prog; /* the program name */ FILE *el_infile; /* Stdio stuff */ FILE *el_outfile; /* Stdio stuff */ FILE *el_errfile; /* Stdio stuff */ @@ -110,8 +110,8 @@ struct editline { int el_flags; /* Various flags. */ int el_errno; /* Local copy of errno */ coord_t el_cursor; /* Cursor location */ - Char **el_display; /* Real screen image = what is there */ - Char **el_vdisplay; /* Virtual screen image = what we see */ + wchar_t **el_display; /* Real screen image = what is there */ + wchar_t **el_vdisplay; /* Virtual screen image = what we see */ void *el_data; /* Client data */ el_line_t el_line; /* The current line information */ el_state_t el_state; /* Current editor state */ @@ -132,7 +132,7 @@ struct editline { LineInfo el_lgcylinfo; /* Legacy LineInfo buffer */ }; -protected int el_editmode(EditLine *, int, const Char **); +protected int el_editmode(EditLine *, int, const wchar_t **); #ifdef DEBUG #define EL_ABORT(a) do { \ diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 0679c46aaf6..0af820a7dfb 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/eln.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eln.c,v 1.16 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: eln.c,v 1.17 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */ /*- @@ -352,7 +352,7 @@ el_line(EditLine *el) const LineInfoW *winfo = el_wline(el); LineInfo *info = &el->el_lgcylinfo; size_t offset; - const Char *p; + const wchar_t *p; info->buffer = ct_encode_string(winfo->buffer, &el->el_lgcyconv); diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c index 693e5e2559c..5f59c3dd03d 100644 --- a/lib/libedit/emacs.c +++ b/lib/libedit/emacs.c @@ -1,5 +1,5 @@ -/* $OpenBSD: emacs.c,v 1.15 2016/04/09 20:15:26 schwarze Exp $ */ -/* $NetBSD: emacs.c,v 1.33 2016/04/09 18:43:17 christos Exp $ */ +/* $OpenBSD: emacs.c,v 1.16 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: emacs.c,v 1.34 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -87,7 +87,7 @@ protected el_action_t /*ARGSUSED*/ em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp, *p, *kp; + wchar_t *cp, *p, *kp; if (el->el_line.cursor == el->el_line.lastchar) return CC_ERROR; @@ -116,7 +116,7 @@ protected el_action_t /*ARGSUSED*/ em_yank(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *kp, *cp; + wchar_t *kp, *cp; if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) return CC_NORM; @@ -152,7 +152,7 @@ protected el_action_t /*ARGSUSED*/ em_kill_line(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *kp, *cp; + wchar_t *kp, *cp; cp = el->el_line.buffer; kp = el->el_chared.c_kill.buf; @@ -174,7 +174,7 @@ protected el_action_t /*ARGSUSED*/ em_kill_region(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *kp, *cp; + wchar_t *kp, *cp; if (!el->el_chared.c_kill.mark) return CC_ERROR; @@ -207,7 +207,7 @@ protected el_action_t /*ARGSUSED*/ em_copy_region(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *kp, *cp; + wchar_t *kp, *cp; if (!el->el_chared.c_kill.mark) return CC_ERROR; @@ -281,7 +281,7 @@ protected el_action_t /*ARGSUSED*/ em_upper_case(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp, *ep; + wchar_t *cp, *ep; ep = c__next_word(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, ce__isword); @@ -305,7 +305,7 @@ protected el_action_t /*ARGSUSED*/ em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp, *ep; + wchar_t *cp, *ep; ep = c__next_word(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, ce__isword); @@ -337,7 +337,7 @@ protected el_action_t /*ARGSUSED*/ em_lower_case(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp, *ep; + wchar_t *cp, *ep; ep = c__next_word(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, ce__isword); @@ -375,7 +375,7 @@ protected el_action_t /*ARGSUSED*/ em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp; + wchar_t *cp; cp = el->el_line.cursor; el->el_line.cursor = el->el_chared.c_kill.mark; @@ -436,7 +436,7 @@ protected el_action_t /*ARGSUSED*/ em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *cp, *oldc, *dp; + wchar_t *cp, *oldc, *dp; if (el->el_line.cursor == el->el_line.buffer) return CC_ERROR; diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c index 9f56be234cf..6c22624f75b 100644 --- a/lib/libedit/filecomplete.c +++ b/lib/libedit/filecomplete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filecomplete.c,v 1.11 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: filecomplete.c,v 1.12 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: filecomplete.c,v 1.22 2010/12/02 04:42:46 dholland Exp $ */ /*- @@ -47,9 +47,7 @@ #include "el.h" #include "filecomplete.h" -static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', - '$', '>', '<', '=', ';', '|', '&', '{', '(', '\0' }; - +static const wchar_t break_chars[] = L" \t\n\"\\'`@$><=;|&{("; /********************************/ /* completion functions */ @@ -390,14 +388,14 @@ int fn_complete(EditLine *el, char *(*complet_func)(const char *, int), char **(*attempted_completion_function)(const char *, int, int), - const Char *word_break, const Char *special_prefixes, + const wchar_t *word_break, const wchar_t *special_prefixes, const char *(*app_func)(const char *), size_t query_items, int *completion_type, int *over, int *point, int *end) { const LineInfoW *li; - Char *temp; + wchar_t *temp; char **matches; - const Char *ctemp; + const wchar_t *ctemp; size_t len; int what_to_do = '\t'; int retval = CC_NORM; diff --git a/lib/libedit/filecomplete.h b/lib/libedit/filecomplete.h index 3830244eb76..9d42e6f44d2 100644 --- a/lib/libedit/filecomplete.h +++ b/lib/libedit/filecomplete.h @@ -1,5 +1,5 @@ -/* $OpenBSD: filecomplete.h,v 1.1 2010/06/30 00:05:35 nicm Exp $ */ -/* $NetBSD: filecomplete.h,v 1.9 2009/12/30 22:37:40 christos Exp $ */ +/* $OpenBSD: filecomplete.h,v 1.2 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: filecomplete.h,v 1.10 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ int fn_complete(EditLine *, char *(*)(const char *, int), char **(*)(const char *, int, int), - const Char *, const Char *, const char *(*)(const char *), size_t, + const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t, int *, int *, int *, int *); void fn_display_match_list(EditLine *, char **, size_t, size_t); diff --git a/lib/libedit/hist.c b/lib/libedit/hist.c index 20b55f38312..8358e33cffc 100644 --- a/lib/libedit/hist.c +++ b/lib/libedit/hist.c @@ -1,5 +1,5 @@ -/* $OpenBSD: hist.c,v 1.16 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: hist.c,v 1.26 2016/04/09 18:43:17 christos Exp $ */ +/* $OpenBSD: hist.c,v 1.17 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: hist.c,v 1.28 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -94,7 +94,7 @@ hist_set(EditLine *el, hist_fun_t fun, void *ptr) protected el_action_t hist_get(EditLine *el) { - const Char *hp; + const wchar_t *hp; int h; if (el->el_history.eventno == 0) { /* if really the current line */ @@ -151,9 +151,9 @@ hist_get(EditLine *el) * process a history command */ protected int -hist_command(EditLine *el, int argc, const Char **argv) +hist_command(EditLine *el, int argc, const wchar_t **argv) { - const Char *str; + const wchar_t *str; int num; HistEvent ev; @@ -191,7 +191,7 @@ protected int /*ARGSUSED*/ hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz) { - Char *newbuf; + wchar_t *newbuf; newbuf = reallocarray(el->el_history.buf, newsz, sizeof(*newbuf)); if (!newbuf) diff --git a/lib/libedit/hist.h b/lib/libedit/hist.h index 1173b7de13a..a941449b970 100644 --- a/lib/libedit/hist.h +++ b/lib/libedit/hist.h @@ -1,5 +1,5 @@ -/* $OpenBSD: hist.h,v 1.14 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: hist.h,v 1.19 2016/03/23 22:27:48 christos Exp $ */ +/* $OpenBSD: hist.h,v 1.15 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: hist.h,v 1.21 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -44,9 +44,9 @@ typedef int (*hist_fun_t)(void *, HistEventW *, int, ...); typedef struct el_history_t { - Char *buf; /* The history buffer */ + wchar_t *buf; /* The history buffer */ size_t sz; /* Size of history buffer */ - Char *last; /* The last character */ + wchar_t *last; /* The last character */ int eventno; /* Event we are looking for */ void *ref; /* Argument for history fcns */ hist_fun_t fun; /* Event access */ @@ -73,7 +73,7 @@ protected int hist_init(EditLine *); protected void hist_end(EditLine *); protected el_action_t hist_get(EditLine *); protected int hist_set(EditLine *, hist_fun_t, void *); -protected int hist_command(EditLine *, int, const Char **); +protected int hist_command(EditLine *, int, const wchar_t **); protected int hist_enlargebuf(EditLine *, size_t, size_t); protected wchar_t *hist_convert(EditLine *, int, void *); diff --git a/lib/libedit/history.c b/lib/libedit/history.c index 110aad9ad0e..8ecc11e78fe 100644 --- a/lib/libedit/history.c +++ b/lib/libedit/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.25 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: history.c,v 1.26 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: history.c,v 1.37 2010/01/03 18:27:10 christos Exp $ */ /*- @@ -56,6 +56,7 @@ static const char hist_cookie[] = "_HiStOrY_V2_\n"; #ifdef NARROWCHAR +#define Char char #define FUN(prefix, rest) prefix ## _ ## rest #define FUNW(type) type #define TYPE(type) type @@ -70,6 +71,7 @@ static const char hist_cookie[] = "_HiStOrY_V2_\n"; #else +#define Char wchar_t #define FUN(prefix, rest) prefix ## _w ## rest #define FUNW(type) type ## _w #define TYPE(type) type ## W diff --git a/lib/libedit/keymacro.c b/lib/libedit/keymacro.c index ed1dd6acbdb..dc2137aa1a7 100644 --- a/lib/libedit/keymacro.c +++ b/lib/libedit/keymacro.c @@ -1,5 +1,5 @@ -/* $OpenBSD: keymacro.c,v 1.11 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: keymacro.c,v 1.16 2016/04/09 18:43:17 christos Exp $ */ +/* $OpenBSD: keymacro.c,v 1.12 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: keymacro.c,v 1.18 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -67,7 +67,7 @@ * linked list of these node elements */ struct keymacro_node_t { - Char ch; /* single character of key */ + wchar_t ch; /* single character of key */ int type; /* node type */ keymacro_value_t val; /* command code or pointer to str, */ /* if this is a leaf */ @@ -75,16 +75,16 @@ struct keymacro_node_t { struct keymacro_node_t *sibling;/* ptr to another key with same prefix*/ }; -private int node_trav(EditLine *, keymacro_node_t *, Char *, +private int node_trav(EditLine *, keymacro_node_t *, wchar_t *, keymacro_value_t *); -private int node__try(EditLine *, keymacro_node_t *, const Char *, - keymacro_value_t *, int); +private int node__try(EditLine *, keymacro_node_t *, + const wchar_t *, keymacro_value_t *, int); private keymacro_node_t *node__get(wint_t); private void node__free(keymacro_node_t *); private void node__put(EditLine *, keymacro_node_t *); private int node__delete(EditLine *, keymacro_node_t **, - const Char *); -private int node_lookup(EditLine *, const Char *, + const wchar_t *); +private int node_lookup(EditLine *, const wchar_t *, keymacro_node_t *, size_t); private int node_enum(EditLine *, keymacro_node_t *, size_t); @@ -136,7 +136,7 @@ keymacro_map_cmd(EditLine *el, int cmd) * Associate str with a key value */ protected keymacro_value_t * -keymacro_map_str(EditLine *el, Char *str) +keymacro_map_str(EditLine *el, wchar_t *str) { el->el_keymacro.val.str = str; @@ -168,7 +168,7 @@ keymacro_reset(EditLine *el) * The last character read is returned in *ch. */ protected int -keymacro_get(EditLine *el, Char *ch, keymacro_value_t *val) +keymacro_get(EditLine *el, wchar_t *ch, keymacro_value_t *val) { return node_trav(el, el->el_keymacro.map, ch, val); @@ -182,7 +182,8 @@ keymacro_get(EditLine *el, Char *ch, keymacro_value_t *val) * command, an out str or a unix command. */ protected void -keymacro_add(EditLine *el, const Char *key, keymacro_value_t *val, int ntype) +keymacro_add(EditLine *el, const wchar_t *key, keymacro_value_t *val, + int ntype) { if (key[0] == '\0') { @@ -210,7 +211,7 @@ keymacro_add(EditLine *el, const Char *key, keymacro_value_t *val, int ntype) * */ protected void -keymacro_clear(EditLine *el, el_action_t *map, const Char *in) +keymacro_clear(EditLine *el, el_action_t *map, const wchar_t *in) { if (*in > N_KEYS) /* can't be in the map */ return; @@ -228,7 +229,7 @@ keymacro_clear(EditLine *el, el_action_t *map, const Char *in) * they exists. */ protected int -keymacro_delete(EditLine *el, const Char *key) +keymacro_delete(EditLine *el, const wchar_t *key) { if (key[0] == '\0') { @@ -249,7 +250,7 @@ keymacro_delete(EditLine *el, const Char *key) * Print entire el->el_keymacro.map if null */ protected void -keymacro_print(EditLine *el, const Char *key) +keymacro_print(EditLine *el, const wchar_t *key) { /* do nothing if el->el_keymacro.map is empty and null key specified */ @@ -270,20 +271,19 @@ keymacro_print(EditLine *el, const Char *key) * found. May read in more characters. */ private int -node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) +node_trav(EditLine *el, keymacro_node_t *ptr, wchar_t *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 (el_wgetc(el, &wc) != 1) {/* if EOF or error */ + if (el_wgetc(el, ch) != 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; @@ -309,7 +309,7 @@ node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) * Find a node that matches *str or allocate a new one */ private int -node__try(EditLine *el, keymacro_node_t *ptr, const Char *str, +node__try(EditLine *el, keymacro_node_t *ptr, const wchar_t *str, keymacro_value_t *val, int ntype) { @@ -372,7 +372,7 @@ node__try(EditLine *el, keymacro_node_t *ptr, const Char *str, * Delete node that matches str */ private int -node__delete(EditLine *el, keymacro_node_t **inptr, const Char *str) +node__delete(EditLine *el, keymacro_node_t **inptr, const wchar_t *str) { keymacro_node_t *ptr; keymacro_node_t *prev_ptr = NULL; @@ -482,7 +482,8 @@ node__free(keymacro_node_t *k) * Print if last node */ private int -node_lookup(EditLine *el, const Char *str, keymacro_node_t *ptr, size_t cnt) +node_lookup(EditLine *el, const wchar_t *str, keymacro_node_t *ptr, + size_t cnt) { ssize_t used; @@ -576,7 +577,8 @@ node_enum(EditLine *el, keymacro_node_t *ptr, size_t cnt) * function specified by val */ protected void -keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype) +keymacro_kprint(EditLine *el, const wchar_t *key, keymacro_value_t *val, + int ntype) { el_bindings_t *fp; char unparsbuf[EL_BUFSIZ]; @@ -627,10 +629,11 @@ keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype) * Make a printable version of the ey */ protected size_t -keymacro__decode_str(const Char *str, char *buf, size_t len, const char *sep) +keymacro__decode_str(const wchar_t *str, char *buf, size_t len, + const char *sep) { char *b = buf, *eb = b + len; - const Char *p; + const wchar_t *p; b = buf; if (sep[0] != '\0') { @@ -642,8 +645,8 @@ keymacro__decode_str(const Char *str, char *buf, size_t len, const char *sep) goto add_endsep; } for (p = str; *p != 0; p++) { - Char dbuf[VISUAL_WIDTH_MAX]; - Char *p2 = dbuf; + wchar_t dbuf[VISUAL_WIDTH_MAX]; + wchar_t *p2 = dbuf; ssize_t l = ct_visual_char(dbuf, VISUAL_WIDTH_MAX, *p); while (l-- > 0) { ssize_t n = ct_encode_char(b, (size_t)(eb - b), *p2++); diff --git a/lib/libedit/keymacro.h b/lib/libedit/keymacro.h index 3b6aed8c563..d538d85632f 100644 --- a/lib/libedit/keymacro.h +++ b/lib/libedit/keymacro.h @@ -1,5 +1,5 @@ -/* $OpenBSD: keymacro.h,v 1.2 2016/01/29 19:32:33 schwarze Exp $ */ -/* $NetBSD: keymacro.h,v 1.2 2011/07/28 03:44:36 christos Exp $ */ +/* $OpenBSD: keymacro.h,v 1.3 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: keymacro.h,v 1.4 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -43,13 +43,13 @@ typedef union keymacro_value_t { el_action_t cmd; /* If it is a command the # */ - Char *str; /* If it is a string... */ + wchar_t *str; /* If it is a string... */ } keymacro_value_t; typedef struct keymacro_node_t keymacro_node_t; typedef struct el_keymacro_t { - Char *buf; /* Key print buffer */ + wchar_t *buf; /* Key print buffer */ keymacro_node_t *map; /* Key map */ keymacro_value_t val; /* Local conversion buffer */ } el_keymacro_t; @@ -62,16 +62,17 @@ typedef struct el_keymacro_t { protected int keymacro_init(EditLine *); protected void keymacro_end(EditLine *); protected keymacro_value_t *keymacro_map_cmd(EditLine *, int); -protected keymacro_value_t *keymacro_map_str(EditLine *, Char *); +protected keymacro_value_t *keymacro_map_str(EditLine *, wchar_t *); protected void keymacro_reset(EditLine *); -protected int keymacro_get(EditLine *, Char *, keymacro_value_t *); -protected void keymacro_add(EditLine *, const Char *, keymacro_value_t *, int); -protected void keymacro_clear(EditLine *, el_action_t *, const Char *); -protected int keymacro_delete(EditLine *, const Char *); -protected void keymacro_print(EditLine *, const Char *); -protected void keymacro_kprint(EditLine *, const Char *, keymacro_value_t *, - int); -protected size_t keymacro__decode_str(const Char *, char *, size_t, +protected int keymacro_get(EditLine *, wchar_t *, keymacro_value_t *); +protected void keymacro_add(EditLine *, const wchar_t *, + keymacro_value_t *, int); +protected void keymacro_clear(EditLine *, el_action_t *, const wchar_t *); +protected int keymacro_delete(EditLine *, const wchar_t *); +protected void keymacro_print(EditLine *, const wchar_t *); +protected void keymacro_kprint(EditLine *, const wchar_t *, + keymacro_value_t *, int); +protected size_t keymacro__decode_str(const wchar_t *, char *, size_t, const char *); #endif /* _h_el_keymacro */ diff --git a/lib/libedit/map.c b/lib/libedit/map.c index 4eb562abd65..b27441efc86 100644 --- a/lib/libedit/map.c +++ b/lib/libedit/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.21 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: map.c,v 1.22 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: map.c,v 1.25 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -46,7 +46,7 @@ #include "help.h" #include "parse.h" -private void map_print_key(EditLine *, el_action_t *, const Char *); +private void map_print_key(EditLine *, el_action_t *, const wchar_t *); private void map_print_some_keys(EditLine *, el_action_t *, wint_t, wint_t); private void map_print_all_keys(EditLine *); private void map_init_nls(EditLine *); @@ -976,7 +976,7 @@ map_init_nls(EditLine *el) private void map_init_meta(EditLine *el) { - Char buf[3]; + wchar_t buf[3]; int i; el_action_t *map = el->el_map.key; el_action_t *alt = el->el_map.alt; @@ -994,7 +994,7 @@ map_init_meta(EditLine *el) } else map = alt; } - buf[0] = (Char) i; + buf[0] = (wchar_t)i; buf[2] = 0; for (i = 0200; i <= 0377; i++) switch (map[i]) { @@ -1048,7 +1048,7 @@ protected void map_init_emacs(EditLine *el) { int i; - Char buf[3]; + wchar_t buf[3]; el_action_t *key = el->el_map.key; el_action_t *alt = el->el_map.alt; const el_action_t *emacs = el->el_map.emacs; @@ -1079,7 +1079,7 @@ map_init_emacs(EditLine *el) * Set the editor */ protected int -map_set_editor(EditLine *el, Char *editor) +map_set_editor(EditLine *el, wchar_t *editor) { if (wcscmp(editor, L"emacs") == 0) { @@ -1098,7 +1098,7 @@ map_set_editor(EditLine *el, Char *editor) * Retrieve the editor */ protected int -map_get_editor(EditLine *el, const Char **editor) +map_get_editor(EditLine *el, const wchar_t **editor) { if (editor == NULL) @@ -1119,7 +1119,7 @@ map_get_editor(EditLine *el, const Char **editor) * Print the function description for 1 key */ private void -map_print_key(EditLine *el, el_action_t *map, const Char *in) +map_print_key(EditLine *el, el_action_t *map, const wchar_t *in) { char outbuf[EL_BUFSIZ]; el_bindings_t *bp, *ep; @@ -1145,7 +1145,7 @@ private void map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last) { el_bindings_t *bp, *ep; - Char firstbuf[2], lastbuf[2]; + wchar_t firstbuf[2], lastbuf[2]; char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ]; firstbuf[0] = first; @@ -1241,15 +1241,15 @@ map_print_all_keys(EditLine *el) * Add/remove/change bindings */ protected int -map_bind(EditLine *el, int argc, const Char **argv) +map_bind(EditLine *el, int argc, const wchar_t **argv) { el_action_t *map; int ntype, rem; - const Char *p; - Char inbuf[EL_BUFSIZ]; - Char outbuf[EL_BUFSIZ]; - const Char *in = NULL; - Char *out = NULL; + const wchar_t *p; + wchar_t inbuf[EL_BUFSIZ]; + wchar_t outbuf[EL_BUFSIZ]; + const wchar_t *in = NULL; + wchar_t *out = NULL; el_bindings_t *bp, *ep; int cmd; int key; @@ -1392,7 +1392,8 @@ map_bind(EditLine *el, int argc, const Char **argv) * add a user defined function */ protected int -map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func) +map_addfunc(EditLine *el, const wchar_t *name, const wchar_t *help, + el_func_t func) { void *p; int nf = el->el_map.nfunc + 1; diff --git a/lib/libedit/map.h b/lib/libedit/map.h index 1dedbef6802..8540aafa1f6 100644 --- a/lib/libedit/map.h +++ b/lib/libedit/map.h @@ -1,5 +1,5 @@ -/* $OpenBSD: map.h,v 1.8 2010/06/30 00:05:35 nicm Exp $ */ -/* $NetBSD: map.h,v 1.9 2009/12/30 22:37:40 christos Exp $ */ +/* $OpenBSD: map.h,v 1.9 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: map.h,v 1.11 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -42,9 +42,9 @@ #define _h_el_map typedef struct el_bindings_t { /* for the "bind" shell command */ - const Char *name; /* function name for bind command */ + const wchar_t *name; /* function name for bind command */ int func; /* function numeric value */ - const Char *description; /* description of function */ + const wchar_t *description; /* description of function */ } el_bindings_t; @@ -66,13 +66,14 @@ typedef struct el_map_t { #define N_KEYS 256 -protected int map_bind(EditLine *, int, const Char **); +protected int map_bind(EditLine *, int, const wchar_t **); protected int map_init(EditLine *); protected void map_end(EditLine *); protected void map_init_vi(EditLine *); protected void map_init_emacs(EditLine *); -protected int map_set_editor(EditLine *, Char *); -protected int map_get_editor(EditLine *, const Char **); -protected int map_addfunc(EditLine *, const Char *, const Char *, el_func_t); +protected int map_set_editor(EditLine *, wchar_t *); +protected int map_get_editor(EditLine *, const wchar_t **); +protected int map_addfunc(EditLine *, const wchar_t *, const wchar_t *, + el_func_t); #endif /* _h_el_map */ diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c index bc76e7db7a7..09009a035ff 100644 --- a/lib/libedit/parse.c +++ b/lib/libedit/parse.c @@ -1,5 +1,5 @@ -/* $OpenBSD: parse.c,v 1.18 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $ */ +/* $OpenBSD: parse.c,v 1.19 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: parse.c,v 1.37 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -55,8 +55,8 @@ #include "parse.h" private const struct { - const Char *name; - int (*func)(EditLine *, int, const Char **); + const wchar_t *name; + int (*func)(EditLine *, int, const wchar_t **); } cmds[] = { { L"bind", map_bind }, { L"echotc", terminal_echotc }, @@ -73,9 +73,9 @@ private const struct { * Parse a line and dispatch it */ protected int -parse_line(EditLine *el, const Char *line) +parse_line(EditLine *el, const wchar_t *line) { - const Char **argv; + const wchar_t **argv; int argc; TokenizerW *tok; @@ -91,16 +91,16 @@ parse_line(EditLine *el, const Char *line) * Command dispatcher */ public int -el_wparse(EditLine *el, int argc, const Char *argv[]) +el_wparse(EditLine *el, int argc, const wchar_t *argv[]) { - const Char *ptr; + const wchar_t *ptr; int i; if (argc < 1) return -1; ptr = wcschr(argv[0], L':'); if (ptr != NULL) { - Char *tprog; + wchar_t *tprog; size_t l; if (ptr == argv[0]) @@ -133,9 +133,9 @@ el_wparse(EditLine *el, int argc, const Char *argv[]) * the appropriate character or -1 if the escape is not valid */ protected int -parse__escape(const Char **ptr) +parse__escape(const wchar_t **ptr) { - const Char *p; + const wchar_t *p; wint_t c; p = *ptr; @@ -173,8 +173,8 @@ parse__escape(const Char **ptr) case 'U': /* Unicode \U+xxxx or \U+xxxxx format */ { int i; - const Char hex[] = L"0123456789ABCDEF"; - const Char *h; + const wchar_t hex[] = L"0123456789ABCDEF"; + const wchar_t *h; ++p; if (*p++ != '+') return -1; @@ -232,10 +232,10 @@ parse__escape(const Char **ptr) /* parse__string(): * Parse the escapes from in and put the raw string out */ -protected Char * -parse__string(Char *out, const Char *in) +protected wchar_t * +parse__string(wchar_t *out, const wchar_t *in) { - Char *rv = out; + wchar_t *rv = out; int n; for (;;) @@ -248,7 +248,7 @@ parse__string(Char *out, const Char *in) case '^': if ((n = parse__escape(&in)) == -1) return NULL; - *out++ = n; + *out++ = (wchar_t)n; break; case 'M': @@ -271,7 +271,7 @@ parse__string(Char *out, const Char *in) * or -1 if one is not found */ protected int -parse_cmd(EditLine *el, const Char *cmd) +parse_cmd(EditLine *el, const wchar_t *cmd) { el_bindings_t *b; int i; diff --git a/lib/libedit/parse.h b/lib/libedit/parse.h index b2dfdebe19c..5e6474128a1 100644 --- a/lib/libedit/parse.h +++ b/lib/libedit/parse.h @@ -1,5 +1,5 @@ -/* $OpenBSD: parse.h,v 1.7 2010/06/30 00:05:35 nicm Exp $ */ -/* $NetBSD: parse.h,v 1.7 2009/12/30 22:37:40 christos Exp $ */ +/* $OpenBSD: parse.h,v 1.8 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: parse.h,v 1.8 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,9 +41,9 @@ #ifndef _h_el_parse #define _h_el_parse -protected int parse_line(EditLine *, const Char *); -protected int parse__escape(const Char **); -protected Char *parse__string(Char *, const Char *); -protected int parse_cmd(EditLine *, const Char *); +protected int parse_line(EditLine *, const wchar_t *); +protected int parse__escape(const wchar_t **); +protected wchar_t *parse__string(wchar_t *, const wchar_t *); +protected int parse_cmd(EditLine *, const wchar_t *); #endif /* _h_el_parse */ diff --git a/lib/libedit/prompt.c b/lib/libedit/prompt.c index 5463bd21dcb..58d575e5c01 100644 --- a/lib/libedit/prompt.c +++ b/lib/libedit/prompt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prompt.c,v 1.11 2016/01/30 12:22:20 schwarze Exp $ */ +/* $OpenBSD: prompt.c,v 1.12 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */ /*- @@ -41,17 +41,17 @@ #include <stdio.h> #include "el.h" -private Char *prompt_default(EditLine *); -private Char *prompt_default_r(EditLine *); +private wchar_t *prompt_default(EditLine *); +private wchar_t *prompt_default_r(EditLine *); /* prompt_default(): * Just a default prompt, in case the user did not provide one */ -private Char * +private wchar_t * /*ARGSUSED*/ prompt_default(EditLine *el __attribute__((__unused__))) { - static Char a[3] = {'?', ' ', '\0'}; + static wchar_t a[3] = L"? "; return a; } @@ -60,11 +60,11 @@ prompt_default(EditLine *el __attribute__((__unused__))) /* prompt_default_r(): * Just a default rprompt, in case the user did not provide one */ -private Char * +private wchar_t * /*ARGSUSED*/ prompt_default_r(EditLine *el __attribute__((__unused__))) { - static Char a[1] = {'\0'}; + static wchar_t a[1] = L""; return a; } @@ -77,7 +77,7 @@ protected void prompt_print(EditLine *el, int op) { el_prompt_t *elp; - Char *p; + wchar_t *p; int ignore = 0; if (op == EL_PROMPT) @@ -140,7 +140,7 @@ prompt_end(EditLine *el __attribute__((__unused__))) * Install a prompt printing function */ protected int -prompt_set(EditLine *el, el_pfunc_t prf, Char c, int op, int wide) +prompt_set(EditLine *el, el_pfunc_t prf, wchar_t c, int op, int wide) { el_prompt_t *p; @@ -172,7 +172,7 @@ prompt_set(EditLine *el, el_pfunc_t prf, Char c, int op, int wide) * Retrieve the prompt printing function */ protected int -prompt_get(EditLine *el, el_pfunc_t *prf, Char *c, int op) +prompt_get(EditLine *el, el_pfunc_t *prf, wchar_t *c, int op) { el_prompt_t *p; diff --git a/lib/libedit/prompt.h b/lib/libedit/prompt.h index 077b61bcd4c..ce77ffb183b 100644 --- a/lib/libedit/prompt.h +++ b/lib/libedit/prompt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: prompt.h,v 1.9 2016/03/20 23:48:27 schwarze Exp $ */ +/* $OpenBSD: prompt.h,v 1.10 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: prompt.h,v 1.13 2016/02/17 19:47:49 christos Exp $ */ /*- @@ -41,18 +41,18 @@ #ifndef _h_el_prompt #define _h_el_prompt -typedef Char *(*el_pfunc_t)(EditLine *); +typedef wchar_t *(*el_pfunc_t)(EditLine *); typedef struct el_prompt_t { el_pfunc_t p_func; /* Function to return the prompt */ coord_t p_pos; /* position in the line after prompt */ - Char p_ignore; /* character to start/end literal */ + wchar_t p_ignore; /* character to start/end literal */ int p_wide; } el_prompt_t; protected void prompt_print(EditLine *, int); -protected int prompt_set(EditLine *, el_pfunc_t, Char, int, int); -protected int prompt_get(EditLine *, el_pfunc_t *, Char *, int); +protected int prompt_set(EditLine *, el_pfunc_t, wchar_t, int, int); +protected int prompt_get(EditLine *, el_pfunc_t *, wchar_t *, int); protected int prompt_init(EditLine *); protected void prompt_end(EditLine *); diff --git a/lib/libedit/read.c b/lib/libedit/read.c index 68d105f2098..c8599af8099 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,5 +1,5 @@ -/* $OpenBSD: read.c,v 1.33 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: read.c,v 1.88 2016/04/09 18:43:17 christos Exp $ */ +/* $OpenBSD: read.c,v 1.34 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: read.c,v 1.90 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -53,7 +53,7 @@ private int read__fixio(int, int); private int read_char(EditLine *, wchar_t *); -private int read_getcmd(EditLine *, el_action_t *, Char *); +private int read_getcmd(EditLine *, el_action_t *, wchar_t *); private void read_pop(c_macro_t *); /* read_init(): @@ -181,7 +181,7 @@ read__fixio(int fd __attribute__((__unused__)), int e) * Push a macro */ public void -el_wpush(EditLine *el, const Char *str) +el_wpush(EditLine *el, const wchar_t *str) { c_macro_t *ma = &el->el_chared.c_macro; @@ -201,20 +201,18 @@ el_wpush(EditLine *el, const Char *str) * Character values > 255 are not looked up in the map, but inserted. */ private int -read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) +read_getcmd(EditLine *el, el_action_t *cmdnum, wchar_t *ch) { - static const Char meta = (Char)0x80; + static const wchar_t meta = (wchar_t)0x80; el_action_t cmd; - wchar_t wc; int num; el->el_errno = 0; do { - if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */ + if ((num = el_wgetc(el, ch)) != 1) {/* if EOF or error */ el->el_errno = num == 0 ? 0 : errno; return 0; /* not OKCMD */ } - *ch = (Char)wc; #ifdef KANJI if ((*ch & meta)) { @@ -435,14 +433,14 @@ read_finish(EditLine *el) sig_clr(el); } -public const Char * +public const wchar_t * el_wgets(EditLine *el, int *nread) { int retval; el_action_t cmdnum = 0; int num; /* how many chars we have read at NL */ wchar_t wc; - Char ch, *cp; + wchar_t ch, *cp; int crlf = 0; int nrb; #ifdef FIONREAD @@ -458,7 +456,7 @@ el_wgets(EditLine *el, int *nread) cp = el->el_line.buffer; while ((num = (*el->el_read.read_char)(el, &wc)) == 1) { - *cp = (Char)wc; + *cp = wc; /* make sure there is space for next character */ if (cp + 1 >= el->el_line.limit) { idx = (cp - el->el_line.buffer); @@ -511,7 +509,7 @@ el_wgets(EditLine *el, int *nread) terminal__flush(el); while ((num = (*el->el_read.read_char)(el, &wc)) == 1) { - *cp = (Char)wc; + *cp = wc; /* make sure there is space next character */ if (cp + 1 >= el->el_line.limit) { idx = (cp - el->el_line.buffer); diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index f7481bb8aeb..85498d30296 100644 --- a/lib/libedit/refresh.c +++ b/lib/libedit/refresh.c @@ -1,5 +1,5 @@ -/* $OpenBSD: refresh.c,v 1.17 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: refresh.c,v 1.46 2016/04/09 18:43:17 christos Exp $ */ +/* $OpenBSD: refresh.c,v 1.18 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: refresh.c,v 1.48 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -46,16 +46,16 @@ private void re_nextline(EditLine *); private void re_addc(EditLine *, wint_t); -private void re_update_line(EditLine *, Char *, Char *, int); -private void re_insert (EditLine *, Char *, int, int, Char *, int); -private void re_delete(EditLine *, Char *, int, int, int); +private void re_update_line(EditLine *, wchar_t *, wchar_t *, int); +private void re_insert (EditLine *, wchar_t *, int, int, wchar_t *, int); +private void re_delete(EditLine *, wchar_t *, int, int, int); private void re_fastputc(EditLine *, wint_t); private void re_clear_eol(EditLine *, int, int, int); -private void re__strncopy(Char *, Char *, size_t); -private void re__copy_and_pad(Char *, const Char *, size_t); +private void re__strncopy(wchar_t *, wchar_t *, size_t); +private void re__copy_and_pad(wchar_t *, const wchar_t *, size_t); #ifdef DEBUG_REFRESH -private void re_printstr(EditLine *, const char *, Char *, Char *); +private void re_printstr(EditLine *, const char *, wchar_t *, wchar_t *); #define __F el->el_errfile #define ELRE_ASSERT(a, b, c) do \ if (/*CONSTCOND*/ a) { \ @@ -69,7 +69,7 @@ private void re_printstr(EditLine *, const char *, Char *, Char *); * Print a string on the debugging pty */ private void -re_printstr(EditLine *el, const char *str, Char *f, Char *t) +re_printstr(EditLine *el, const char *str, wchar_t *f, wchar_t *t) { ELRE_DEBUG(1, (__F, "%s:\"", str)); @@ -98,7 +98,7 @@ re_nextline(EditLine *el) */ if (el->el_refresh.r_cursor.v + 1 >= el->el_terminal.t_size.v) { int i, lins = el->el_terminal.t_size.v; - Char *firstline = el->el_vdisplay[0]; + wchar_t *firstline = el->el_vdisplay[0]; for(i = 1; i < lins; i++) el->el_vdisplay[i - 1] = el->el_vdisplay[i]; @@ -120,7 +120,7 @@ re_nextline(EditLine *el) private void re_addc(EditLine *el, wint_t c) { - switch (ct_chr_class((Char)c)) { + switch (ct_chr_class(c)) { case CHTYPE_TAB: /* expand the tab */ for (;;) { re_putc(el, ' ', 1); @@ -139,9 +139,9 @@ re_addc(EditLine *el, wint_t c) re_putc(el, c, 1); break; default: { - Char visbuf[VISUAL_WIDTH_MAX]; + wchar_t visbuf[VISUAL_WIDTH_MAX]; ssize_t i, n = - ct_visual_char(visbuf, VISUAL_WIDTH_MAX, (Char)c); + ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c); for (i = 0; n-- > 0; ++i) re_putc(el, visbuf[i], 1); break; @@ -195,7 +195,7 @@ protected void re_refresh(EditLine *el) { int i, rhdiff; - Char *cp, *st; + wchar_t *cp, *st; coord_t cur; #ifdef notyet size_t termsz; @@ -354,9 +354,9 @@ re_goto_bottom(EditLine *el) private void /*ARGSUSED*/ re_insert(EditLine *el __attribute__((__unused__)), - Char *d, int dat, int dlen, Char *s, int num) + wchar_t *d, int dat, int dlen, wchar_t *s, int num) { - Char *a, *b; + wchar_t *a, *b; if (num <= 0) return; @@ -405,9 +405,9 @@ re_insert(EditLine *el __attribute__((__unused__)), private void /*ARGSUSED*/ re_delete(EditLine *el __attribute__((__unused__)), - Char *d, int dat, int dlen, int num) + wchar_t *d, int dat, int dlen, int num) { - Char *a, *b; + wchar_t *a, *b; if (num <= 0) return; @@ -437,7 +437,7 @@ re_delete(EditLine *el __attribute__((__unused__)), * Like strncpy without padding. */ private void -re__strncopy(Char *a, Char *b, size_t n) +re__strncopy(wchar_t *a, wchar_t *b, size_t n) { while (n-- && *b) @@ -496,11 +496,11 @@ new: eddie> Oh, my little buggy says to me, as lurgid as #define MIN_END_KEEP 4 private void -re_update_line(EditLine *el, Char *old, Char *new, int i) +re_update_line(EditLine *el, wchar_t *old, wchar_t *new, int i) { - Char *o, *n, *p, c; - Char *ofd, *ols, *oe, *nfd, *nls, *ne; - Char *osb, *ose, *nsb, *nse; + wchar_t *o, *n, *p, c; + wchar_t *ofd, *ols, *oe, *nfd, *nls, *ne; + wchar_t *osb, *ose, *nsb, *nse; int fx, sx; size_t len; @@ -966,7 +966,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * Copy string and pad with spaces */ private void -re__copy_and_pad(Char *dst, const Char *src, size_t width) +re__copy_and_pad(wchar_t *dst, const wchar_t *src, size_t width) { size_t i; @@ -989,7 +989,7 @@ re__copy_and_pad(Char *dst, const Char *src, size_t width) protected void re_refresh_cursor(EditLine *el) { - Char *cp; + wchar_t *cp; int h, v, th, w; if (el->el_line.cursor >= el->el_line.lastchar) { @@ -1052,7 +1052,7 @@ re_refresh_cursor(EditLine *el) private void re_fastputc(EditLine *el, wint_t c) { - int w = wcwidth((Char)c); + int w = wcwidth(c); while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h) re_fastputc(el, ' '); @@ -1074,7 +1074,7 @@ re_fastputc(EditLine *el, wint_t c) */ if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { int i, lins = el->el_terminal.t_size.v; - Char *firstline = el->el_display[0]; + wchar_t *firstline = el->el_display[0]; for(i = 1; i < lins; i++) el->el_display[i - 1] = el->el_display[i]; @@ -1105,7 +1105,7 @@ re_fastputc(EditLine *el, wint_t c) protected void re_fastaddc(EditLine *el) { - Char c; + wchar_t c; int rhdiff; c = el->el_line.cursor[-1]; @@ -1129,9 +1129,9 @@ re_fastaddc(EditLine *el) break; case CHTYPE_ASCIICTL: case CHTYPE_NONPRINT: { - Char visbuf[VISUAL_WIDTH_MAX]; + wchar_t visbuf[VISUAL_WIDTH_MAX]; ssize_t i, n = - ct_visual_char(visbuf, VISUAL_WIDTH_MAX, (Char)c); + ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c); for (i = 0; n-- > 0; ++i) re_fastputc(el, visbuf[i]); break; diff --git a/lib/libedit/search.c b/lib/libedit/search.c index 1b1b6aef2ca..1a134c3422b 100644 --- a/lib/libedit/search.c +++ b/lib/libedit/search.c @@ -1,5 +1,5 @@ -/* $OpenBSD: search.c,v 1.23 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: search.c,v 1.41 2016/04/09 18:43:17 christos Exp $ */ +/* $OpenBSD: search.c,v 1.24 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: search.c,v 1.43 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -104,7 +104,7 @@ regerror(const char *msg) * Return if string matches pattern */ protected int -el_match(const Char *str, const Char *pat) +el_match(const wchar_t *str, const wchar_t *pat) { static ct_buffer_t conv; #if defined (REGEX) @@ -150,7 +150,7 @@ el_match(const Char *str, const Char *pat) * return True if the pattern matches the prefix */ protected int -c_hmatch(EditLine *el, const Char *str) +c_hmatch(EditLine *el, const wchar_t *str) { #ifdef SDEBUG (void) fprintf(el->el_errfile, "match `%s' with `%s'\n", @@ -198,13 +198,11 @@ c_setpat(EditLine *el) protected el_action_t ce_inc_search(EditLine *el, int dir) { - static const Char STRfwd[] = {'f', 'w', 'd', '\0'}, - STRbck[] = {'b', 'c', 'k', '\0'}; - static Char pchar = ':';/* ':' = normal, '?' = failed */ - static Char endcmd[2] = {'\0', '\0'}; - Char *ocursor = el->el_line.cursor, oldpchar = pchar, ch; - const Char *cp; - wchar_t wch; + static const wchar_t STRfwd[] = L"fwd", STRbck[] = L"bck"; + static wchar_t pchar = L':'; /* ':' = normal, '?' = failed */ + static wchar_t endcmd[2] = {'\0', '\0'}; + wchar_t *ocursor = el->el_line.cursor, oldpchar = pchar, ch; + const wchar_t *cp; el_action_t ret = CC_NORM; @@ -243,11 +241,9 @@ ce_inc_search(EditLine *el, int dir) *el->el_line.lastchar = '\0'; re_refresh(el); - if (el_wgetc(el, &wch) != 1) + if (el_wgetc(el, &ch) != 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: @@ -448,8 +444,8 @@ ce_inc_search(EditLine *el, int dir) protected el_action_t cv_search(EditLine *el, int dir) { - Char ch; - Char tmpbuf[EL_BUFSIZ]; + wchar_t ch; + wchar_t tmpbuf[EL_BUFSIZ]; int tmplen; #ifdef ANCHOR @@ -522,9 +518,9 @@ cv_search(EditLine *el, int dir) protected el_action_t ce_search_line(EditLine *el, int dir) { - Char *cp = el->el_line.cursor; - Char *pattern = el->el_search.patbuf; - Char oc, *ocp; + wchar_t *cp = el->el_line.cursor; + wchar_t *pattern = el->el_search.patbuf; + wchar_t oc, *ocp; #ifdef ANCHOR ocp = &pattern[1]; oc = *ocp; @@ -590,7 +586,7 @@ cv_repeat_srch(EditLine *el, wint_t c) protected el_action_t cv_csearch(EditLine *el, int direction, wint_t ch, int count, int tflag) { - Char *cp; + wchar_t *cp; if (ch == 0) return CC_ERROR; diff --git a/lib/libedit/search.h b/lib/libedit/search.h index 64616a7ad54..2f299a3572b 100644 --- a/lib/libedit/search.h +++ b/lib/libedit/search.h @@ -1,5 +1,5 @@ -/* $OpenBSD: search.h,v 1.10 2016/03/20 22:57:59 schwarze Exp $ */ -/* $NetBSD: search.h,v 1.12 2016/02/16 15:53:48 christos Exp $ */ +/* $OpenBSD: search.h,v 1.11 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: search.h,v 1.13 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -42,19 +42,19 @@ #define _h_el_search typedef struct el_search_t { - Char *patbuf; /* The pattern buffer */ + wchar_t *patbuf; /* The pattern buffer */ size_t patlen; /* Length of the pattern buffer */ int patdir; /* Direction of the last search */ int chadir; /* Character search direction */ - Char chacha; /* Character we are looking for */ + wchar_t chacha; /* Character we are looking for */ char chatflg; /* 0 if f, 1 if t */ } el_search_t; -protected int el_match(const Char *, const Char *); +protected int el_match(const wchar_t *, const wchar_t *); protected int search_init(EditLine *); protected void search_end(EditLine *); -protected int c_hmatch(EditLine *, const Char *); +protected int c_hmatch(EditLine *, const wchar_t *); protected void c_setpat(EditLine *); protected el_action_t ce_inc_search(EditLine *, int); protected el_action_t cv_search(EditLine *, int); diff --git a/lib/libedit/terminal.c b/lib/libedit/terminal.c index 47d5b777ee8..1b1da0f596c 100644 --- a/lib/libedit/terminal.c +++ b/lib/libedit/terminal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.c,v 1.14 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: terminal.c,v 1.15 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: terminal.c,v 1.17 2016/02/15 15:35:03 christos Exp $ */ /*- @@ -411,7 +411,7 @@ private int terminal_alloc_display(EditLine *el) { int i; - Char **b; + wchar_t **b; coord_t *c = &el->el_terminal.t_size; b = reallocarray(NULL, c->v + 1, sizeof(*b)); @@ -456,8 +456,8 @@ done: private void terminal_free_display(EditLine *el) { - Char **b; - Char **bufp; + wchar_t **b; + wchar_t **bufp; b = el->el_display; el->el_display = NULL; @@ -640,7 +640,7 @@ mc_again: * Assumes MB_FILL_CHARs are present to keep the column count correct */ protected void -terminal_overwrite(EditLine *el, const Char *cp, size_t n) +terminal_overwrite(EditLine *el, const wchar_t *cp, size_t n) { if (n == 0) return; @@ -666,7 +666,7 @@ terminal_overwrite(EditLine *el, const Char *cp, size_t n) if (EL_HAS_MAGIC_MARGINS) { /* force the wrap to avoid the "magic" * situation */ - Char c; + wchar_t c; if ((c = el->el_display[el->el_cursor.v] [el->el_cursor.h]) != '\0') { terminal_overwrite(el, &c, 1); @@ -730,7 +730,7 @@ terminal_deletechars(EditLine *el, int num) * Assumes MB_FILL_CHARs are present to keep column count correct */ protected void -terminal_insertwrite(EditLine *el, Char *cp, int num) +terminal_insertwrite(EditLine *el, wchar_t *cp, int num) { if (num <= 0) return; @@ -1037,18 +1037,18 @@ private void terminal_reset_arrow(EditLine *el) { funckey_t *arrow = el->el_terminal.t_fkey; - static const Char strA[] = {033, '[', 'A', '\0'}; - static const Char strB[] = {033, '[', 'B', '\0'}; - static const Char strC[] = {033, '[', 'C', '\0'}; - static const Char strD[] = {033, '[', 'D', '\0'}; - static const Char strH[] = {033, '[', 'H', '\0'}; - static const Char strF[] = {033, '[', 'F', '\0'}; - static const Char stOA[] = {033, 'O', 'A', '\0'}; - static const Char stOB[] = {033, 'O', 'B', '\0'}; - static const Char stOC[] = {033, 'O', 'C', '\0'}; - static const Char stOD[] = {033, 'O', 'D', '\0'}; - static const Char stOH[] = {033, 'O', 'H', '\0'}; - static const Char stOF[] = {033, 'O', 'F', '\0'}; + static const wchar_t strA[] = L"\033[A"; + static const wchar_t strB[] = L"\033[B"; + static const wchar_t strC[] = L"\033[C"; + static const wchar_t strD[] = L"\033[D"; + static const wchar_t strH[] = L"\033[H"; + static const wchar_t strF[] = L"\033[F"; + static const wchar_t stOA[] = L"\033OA"; + static const wchar_t stOB[] = L"\033OB"; + static const wchar_t stOC[] = L"\033OC"; + static const wchar_t stOD[] = L"\033OD"; + static const wchar_t stOH[] = L"\033OH"; + static const wchar_t stOF[] = L"\033OF"; keymacro_add(el, strA, &arrow[A_K_UP].fun, arrow[A_K_UP].type); keymacro_add(el, strB, &arrow[A_K_DN].fun, arrow[A_K_DN].type); @@ -1084,7 +1084,7 @@ terminal_reset_arrow(EditLine *el) * Set an arrow key binding */ protected int -terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, +terminal_set_arrow(EditLine *el, const wchar_t *name, keymacro_value_t *fun, int type) { funckey_t *arrow = el->el_terminal.t_fkey; @@ -1104,7 +1104,7 @@ terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, * Clear an arrow key binding */ protected int -terminal_clear_arrow(EditLine *el, const Char *name) +terminal_clear_arrow(EditLine *el, const wchar_t *name) { funckey_t *arrow = el->el_terminal.t_fkey; int i; @@ -1122,7 +1122,7 @@ terminal_clear_arrow(EditLine *el, const Char *name) * Print the arrow key bindings */ protected void -terminal_print_arrow(EditLine *el, const Char *name) +terminal_print_arrow(EditLine *el, const wchar_t *name) { int i; funckey_t *arrow = el->el_terminal.t_fkey; @@ -1157,8 +1157,8 @@ terminal_bind_arrow(EditLine *el) terminal_reset_arrow(el); for (i = 0; i < A_K_NKEYS; i++) { - Char wt_str[VISUAL_WIDTH_MAX]; - Char *px; + wchar_t wt_str[VISUAL_WIDTH_MAX]; + wchar_t *px; size_t n; p = el->el_terminal.t_str[arrow[i].key]; @@ -1257,7 +1257,7 @@ terminal__flush(EditLine *el) protected void terminal_writec(EditLine *el, wint_t c) { - Char visbuf[VISUAL_WIDTH_MAX +1]; + wchar_t visbuf[VISUAL_WIDTH_MAX +1]; ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c); visbuf[vcnt] = '\0'; terminal_overwrite(el, visbuf, (size_t)vcnt); @@ -1271,7 +1271,7 @@ terminal_writec(EditLine *el, wint_t c) protected int /*ARGSUSED*/ terminal_telltc(EditLine *el, int argc __attribute__((__unused__)), - const Char **argv __attribute__((__unused__))) + const wchar_t **argv __attribute__((__unused__))) { const struct termcapstr *t; char **ts; @@ -1313,7 +1313,7 @@ terminal_telltc(EditLine *el, int argc __attribute__((__unused__)), protected int /*ARGSUSED*/ terminal_settc(EditLine *el, int argc __attribute__((__unused__)), - const Char **argv) + const wchar_t **argv) { const struct termcapstr *ts; const struct termcapval *tv; @@ -1446,10 +1446,10 @@ terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv) protected int /*ARGSUSED*/ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), - const Char **argv) + const wchar_t **argv) { char *cap, *scap; - Char *ep; + wchar_t *ep; int arg_need, arg_cols, arg_rows; int verbose = 0, silent = 0; char *area; diff --git a/lib/libedit/terminal.h b/lib/libedit/terminal.h index 23fbe059667..7d7bd028ed8 100644 --- a/lib/libedit/terminal.h +++ b/lib/libedit/terminal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.h,v 1.5 2016/03/20 22:57:59 schwarze Exp $ */ +/* $OpenBSD: terminal.h,v 1.6 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: term.h,v 1.21 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -42,7 +42,7 @@ #define _h_el_terminal typedef struct { /* Symbolic function key bindings */ - const Char *name; /* name of the key */ + const wchar_t *name; /* name of the key */ int key; /* Index in termcap table */ keymacro_value_t fun; /* Function bound to it */ int type; /* Type of function */ @@ -83,8 +83,8 @@ typedef struct { protected void terminal_move_to_line(EditLine *, int); protected void terminal_move_to_char(EditLine *, int); protected void terminal_clear_EOL(EditLine *, int); -protected void terminal_overwrite(EditLine *, const Char *, size_t); -protected void terminal_insertwrite(EditLine *, Char *, int); +protected void terminal_overwrite(EditLine *, const wchar_t *, size_t); +protected void terminal_insertwrite(EditLine *, wchar_t *, int); protected void terminal_deletechars(EditLine *, int); protected void terminal_clear_screen(EditLine *); protected void terminal_beep(EditLine *); @@ -92,16 +92,17 @@ protected int terminal_change_size(EditLine *, int, int); protected int terminal_get_size(EditLine *, int *, int *); protected int terminal_init(EditLine *); protected void terminal_bind_arrow(EditLine *); -protected void terminal_print_arrow(EditLine *, const Char *); -protected int terminal_clear_arrow(EditLine *, const Char *); -protected int terminal_set_arrow(EditLine *, const Char *, keymacro_value_t *, int); +protected void terminal_print_arrow(EditLine *, const wchar_t *); +protected int terminal_clear_arrow(EditLine *, const wchar_t *); +protected int terminal_set_arrow(EditLine *, const wchar_t *, + keymacro_value_t *, int); protected void terminal_end(EditLine *); protected void terminal_get(EditLine *, const char **); protected int terminal_set(EditLine *, const char *); -protected int terminal_settc(EditLine *, int, const Char **); +protected int terminal_settc(EditLine *, int, const wchar_t **); protected int terminal_gettc(EditLine *, int, char **); -protected int terminal_telltc(EditLine *, int, const Char **); -protected int terminal_echotc(EditLine *, int, const Char **); +protected int terminal_telltc(EditLine *, int, const wchar_t **); +protected int terminal_echotc(EditLine *, int, const wchar_t **); protected void terminal_writec(EditLine *, wint_t); protected int terminal__putc(EditLine *, wint_t); protected void terminal__flush(EditLine *); diff --git a/lib/libedit/tokenizer.c b/lib/libedit/tokenizer.c index 1cdb9019d22..d88054382b0 100644 --- a/lib/libedit/tokenizer.c +++ b/lib/libedit/tokenizer.c @@ -1,5 +1,5 @@ -/* $OpenBSD: tokenizer.c,v 1.18 2016/04/11 19:54:54 schwarze Exp $ */ -/* $NetBSD: tokenizer.c,v 1.23 2016/02/15 15:37:20 christos Exp $ */ +/* $OpenBSD: tokenizer.c,v 1.19 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: tokenizer.c,v 1.26 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -58,12 +58,14 @@ typedef enum { #define IFS STR("\t \n") #ifdef NARROWCHAR +#define Char char #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 Char wchar_t #define FUN(prefix, rest) prefix ## _w ## rest #define TYPE(type) type ## W #define STR(x) L ## x diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c index 452b0cfb934..c7134e3a135 100644 --- a/lib/libedit/tty.c +++ b/lib/libedit/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.24 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: tty.c,v 1.25 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: tty.c,v 1.34 2011/01/27 23:11:40 christos Exp $ */ /*- @@ -891,7 +891,7 @@ tty_bind_char(EditLine *el, int force) unsigned char *t_n = el->el_tty.t_c[ED_IO]; unsigned char *t_o = el->el_tty.t_ed.c_cc; - Char new[2], old[2]; + wchar_t new[2], old[2]; const ttymap_t *tp; el_action_t *map, *alt; const el_action_t *dmap, *dalt; @@ -908,8 +908,8 @@ tty_bind_char(EditLine *el, int force) } for (tp = tty_map; tp->nch != (wint_t)-1; tp++) { - new[0] = t_n[tp->nch]; - old[0] = t_o[tp->och]; + new[0] = (wchar_t)t_n[tp->nch]; + old[0] = (wchar_t)t_o[tp->och]; if (new[0] == old[0] && !force) continue; /* Put the old default binding back, and set the new binding */ @@ -1144,12 +1144,13 @@ tty_noquotemode(EditLine *el) */ protected int /*ARGSUSED*/ -tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) +tty_stty(EditLine *el, int argc __attribute__((__unused__)), + const wchar_t **argv) { const ttymodes_t *m; char x; int aflag = 0; - const Char *s, *d; + const wchar_t *s, *d; char name[EL_BUFSIZ]; struct termios *tios = &el->el_tty.t_ex; int z = EX_IO; @@ -1232,7 +1233,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) return 0; } while (argv && (s = *argv++)) { - const Char *p; + const wchar_t *p; switch (*s) { case '+': case '-': diff --git a/lib/libedit/tty.h b/lib/libedit/tty.h index 1e004e06404..36ed1b8e99c 100644 --- a/lib/libedit/tty.h +++ b/lib/libedit/tty.h @@ -1,5 +1,5 @@ -/* $OpenBSD: tty.h,v 1.11 2016/04/09 18:42:49 schwarze Exp $ */ -/* $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $ */ +/* $OpenBSD: tty.h,v 1.12 2016/04/11 20:43:33 schwarze Exp $ */ +/* $NetBSD: tty.h,v 1.20 2016/04/11 00:50:13 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -459,7 +459,7 @@ typedef unsigned char ttychar_t[NN_IO][C_NCC]; protected int tty_init(EditLine *); protected void tty_end(EditLine *); -protected int tty_stty(EditLine *, int, const Char **); +protected int tty_stty(EditLine *, int, const wchar_t **); protected int tty_rawmode(EditLine *); protected int tty_cookedmode(EditLine *); protected int tty_quotemode(EditLine *); diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index d279a1c6616..592d552c294 100644 --- a/lib/libedit/vi.c +++ b/lib/libedit/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.22 2016/04/11 19:54:54 schwarze Exp $ */ +/* $OpenBSD: vi.c,v 1.23 2016/04/11 20:43:33 schwarze Exp $ */ /* $NetBSD: vi.c,v 1.33 2011/02/17 16:44:48 joerg Exp $ */ /*- @@ -642,7 +642,7 @@ protected el_action_t /*ARGSUSED*/ vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__))) { - Char *kp, *cp; + wchar_t *kp, *cp; cp = el->el_line.buffer; kp = el->el_chared.c_kill.buf; @@ -803,10 +803,10 @@ protected el_action_t /*ARGSUSED*/ vi_match(EditLine *el, wint_t c __attribute__((__unused__))) { - const Char match_chars[] = L"()[]{}"; - Char *cp; + const wchar_t match_chars[] = L"()[]{}"; + wchar_t *cp; size_t delta, i, count; - Char o_ch, c_ch; + wchar_t o_ch, c_ch; *el->el_line.lastchar = '\0'; /* just in case */ @@ -1008,7 +1008,7 @@ vi_histedit(EditLine *el, wint_t c __attribute__((__unused__))) char tempfile[] = "/tmp/histedit.XXXXXXXXXX"; char *cp; size_t len; - Char *line; + wchar_t *line; if (el->el_state.doingarg) { if (vi_to_history_line(el, 0) == CC_ERROR) @@ -1090,11 +1090,11 @@ protected el_action_t /*ARGSUSED*/ vi_history_word(EditLine *el, wint_t c __attribute__((__unused__))) { - const Char *wp = HIST_FIRST(el); - const Char *wep, *wsp; + const wchar_t *wp = HIST_FIRST(el); + const wchar_t *wep, *wsp; int len; - Char *cp; - const Char *lim; + wchar_t *cp; + const wchar_t *lim; if (wp == NULL) return CC_ERROR; |