From 7cc66539636e90c9fd48779b3267d5e0b85133dd Mon Sep 17 00:00:00 2001 From: skimo Date: Fri, 14 Jul 2000 14:29:14 +0000 Subject: [PATCH] Another CHAR_T patch. The non USE_WIDECHAR version compiles without warnings. --- cl/cl_funcs.c | 25 +++++++++++-- cl/cl_main.c | 3 +- cl/cl_term.c | 36 +++++++++++++++---- common/api.c | 74 ++++++++++++++++++++++++++++++-------- common/common.h | 4 ++- common/cut.c | 8 ++--- common/cut.h | 3 +- common/db.c | 32 ++++++++--------- common/exf.c | 36 +++++++++++++------ common/exf.h | 4 +-- common/gs.h | 16 +++++---- common/key.c | 16 +++++---- common/key.h | 25 +++++++++++-- common/log.c | 34 ++++++++++-------- common/main.c | 13 ++++--- common/mark.h | 3 +- common/msg.c | 22 +++++++++++- common/nothread.c | 6 ++-- common/options.c | 102 +++++++++++++++++++++++++++++++++-------------------- common/options_f.c | 14 +++++++- common/pthread.c | 6 ++-- common/put.c | 4 +-- common/screen.c | 16 +++++---- common/screen.h | 21 +++++++---- common/search.c | 16 ++++----- common/seq.c | 10 +++--- common/util.c | 76 +++++++++++++++++++++++++++++++-------- dist/Makefile.am | 24 +++++++++++++ dist/acconfig.h | 5 ++- dist/config.h.in | 3 ++ dist/configure.in | 9 +++++ ex/ex.c | 96 ++++++++++++++++++++++++------------------------- ex/ex.h | 12 +++---- ex/ex_abbrev.c | 4 +-- ex/ex_append.c | 4 +-- ex/ex_args.c | 39 ++++++++++++++------ ex/ex_argv.c | 89 ++++++++++++++++++++++++++++------------------ ex/ex_at.c | 6 ++-- ex/ex_bang.c | 9 +++-- ex/ex_cd.c | 6 ++-- ex/ex_cscope.c | 95 ++++++++++++++++++++++++++++++++----------------- ex/ex_display.c | 6 ++-- ex/ex_edit.c | 10 ++++-- ex/ex_file.c | 11 +++--- ex/ex_filter.c | 19 ++++++---- ex/ex_global.c | 7 ++-- ex/ex_init.c | 25 ++++++++----- ex/ex_join.c | 4 +-- ex/ex_map.c | 4 +-- ex/ex_mkexrc.c | 6 ++-- ex/ex_move.c | 4 +-- ex/ex_preserve.c | 10 ++++-- ex/ex_print.c | 19 ++++++---- ex/ex_read.c | 20 +++++++---- ex/ex_script.c | 14 ++++---- ex/ex_shift.c | 4 +-- ex/ex_source.c | 15 +++++--- ex/ex_subst.c | 93 ++++++++++++++++++++++++++---------------------- ex/ex_tag.c | 86 +++++++++++++++++++++++++++++--------------- ex/ex_util.c | 4 +-- ex/ex_visual.c | 7 ++-- ex/ex_write.c | 22 +++++++----- ex/tag.h | 8 ++--- gtk/gtkviwindow.c | 7 ++-- ip/ip_funcs.c | 26 ++++++++++++-- ip/ip_main.c | 8 +++-- ipc/ip.h | 4 +-- regex/regcomp.c | 2 +- regex/regex.h | 7 ++-- regex/regexec.c | 2 +- vi/v_at.c | 15 +++++--- vi/v_event.c | 20 +++++++---- vi/v_ex.c | 24 ++++++++----- vi/v_increment.c | 10 +++--- vi/v_itxt.c | 7 ++-- vi/v_replace.c | 4 +-- vi/v_search.c | 27 +++++++++----- vi/v_txt.c | 88 ++++++++++++++++++++++++++++----------------- vi/v_ulcase.c | 6 ++-- vi/v_util.c | 6 ++-- vi/vi.c | 10 +++--- vi/vs_line.c | 4 +-- vi/vs_msg.c | 20 ++++++----- vi/vs_split.c | 11 +++--- 84 files changed, 1137 insertions(+), 595 deletions(-) diff --git a/cl/cl_funcs.c b/cl/cl_funcs.c index 7bf0473b..7811939c 100644 --- a/cl/cl_funcs.c +++ b/cl/cl_funcs.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_funcs.c,v 10.59 2000/07/10 15:28:43 skimo Exp $ (Berkeley) $Date: 2000/07/10 15:28:43 $"; +static const char sccsid[] = "$Id: cl_funcs.c,v 10.60 2000/07/14 14:29:14 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:14 $"; #endif /* not lint */ #include @@ -37,14 +37,33 @@ static void cl_rdiv __P((SCR *)); * cl_addstr -- * Add len bytes from the string at the cursor, advancing the cursor. * - * PUBLIC: int cl_addstr __P((SCR *, const CHAR_T *, size_t)); + * PUBLIC: int cl_waddstr __P((SCR *, const CHAR_T *, size_t)); */ int -cl_addstr(sp, str, len) +cl_waddstr(sp, str, len) SCR *sp; const CHAR_T *str; size_t len; { + CONST char *np; + size_t nlen; + + INT2CHAR(sp, str, len, np, nlen); + cl_addstr(sp, np, nlen); +} + +/* + * cl_addstr -- + * Add len bytes from the string at the cursor, advancing the cursor. + * + * PUBLIC: int cl_addstr __P((SCR *, const char *, size_t)); + */ +int +cl_addstr(sp, str, len) + SCR *sp; + const char *str; + size_t len; +{ CL_PRIVATE *clp; WINDOW *win; size_t y, x; diff --git a/cl/cl_main.c b/cl/cl_main.c index 63366483..d68baad9 100644 --- a/cl/cl_main.c +++ b/cl/cl_main.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_main.c,v 10.50 2000/07/11 15:10:58 skimo Exp $ (Berkeley) $Date: 2000/07/11 15:10:58 $"; +static const char sccsid[] = "$Id: cl_main.c,v 10.51 2000/07/14 14:29:14 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:14 $"; #endif /* not lint */ #include @@ -397,6 +397,7 @@ cl_func_std(gp) GS *gp; { gp->scr_addstr = cl_addstr; + gp->scr_waddstr = cl_waddstr; gp->scr_attr = cl_attr; gp->scr_baud = cl_baud; gp->scr_bell = cl_bell; diff --git a/cl/cl_term.c b/cl/cl_term.c index 49cb9c56..0b7da26a 100644 --- a/cl/cl_term.c +++ b/cl/cl_term.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cl_term.c,v 10.23 1996/12/16 09:38:27 bostic Exp $ (Berkeley) $Date: 1996/12/16 09:38:27 $"; +static const char sccsid[] = "$Id: cl_term.c,v 10.24 2000/07/14 14:29:14 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:14 $"; #endif /* not lint */ #include @@ -88,13 +88,24 @@ cl_term_init(sp) SEQ *qp; TKLIST const *tkp; char *t; + CHAR_T name[60]; + CHAR_T output[5]; + CHAR_T ts[20]; + CHAR_T *wp; + size_t wlen; /* Command mappings. */ for (tkp = c_tklist; tkp->name != NULL; ++tkp) { if ((t = tigetstr(tkp->ts)) == NULL || t == (char *)-1) continue; - if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t), - tkp->output, strlen(tkp->output), SEQ_COMMAND, + CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen); + memcpy(name, wp, wlen * sizeof(CHAR_T)); + CHAR2INT(sp, t, strlen(t), wp, wlen); + memcpy(ts, wp, wlen * sizeof(CHAR_T)); + CHAR2INT(sp, tkp->output, strlen(tkp->output), wp, wlen); + memcpy(output, wp, wlen * sizeof(CHAR_T)); + if (seq_set(sp, name, strlen(tkp->name), ts, strlen(t), + output, strlen(tkp->output), SEQ_COMMAND, SEQ_NOOVERWRITE | SEQ_SCREEN)) return (1); } @@ -108,7 +119,11 @@ cl_term_init(sp) break; if (kp == NULL) continue; - if (seq_set(sp, tkp->name, strlen(tkp->name), t, strlen(t), + CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen); + memcpy(name, wp, wlen * sizeof(CHAR_T)); + CHAR2INT(sp, t, strlen(t), wp, wlen); + memcpy(ts, wp, wlen * sizeof(CHAR_T)); + if (seq_set(sp, name, strlen(tkp->name), ts, strlen(t), &kp->ch, 1, SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN)) return (1); } @@ -131,11 +146,18 @@ cl_term_init(sp) t, strlen(t), NULL, 0, SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN)) return (1); - } else - if (seq_set(sp, tkp->name, strlen(tkp->name), - t, strlen(t), tkp->output, strlen(tkp->output), + } else { + CHAR2INT(sp, tkp->name, strlen(tkp->name), wp, wlen); + memcpy(name, wp, wlen * sizeof(CHAR_T)); + CHAR2INT(sp, t, strlen(t), wp, wlen); + memcpy(ts, wp, wlen * sizeof(CHAR_T)); + CHAR2INT(sp, tkp->output, strlen(tkp->output), wp, wlen); + memcpy(output, wp, wlen * sizeof(CHAR_T)); + if (seq_set(sp, name, strlen(tkp->name), + ts, strlen(t), output, strlen(tkp->output), SEQ_INPUT, SEQ_NOOVERWRITE | SEQ_SCREEN)) return (1); + } } /* diff --git a/common/api.c b/common/api.c index 8edaf226..736d2428 100644 --- a/common/api.c +++ b/common/api.c @@ -12,7 +12,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: api.c,v 8.30 2000/06/25 17:34:37 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:37 $"; +static const char sccsid[] = "$Id: api.c,v 8.31 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $"; #endif /* not lint */ #include @@ -85,7 +85,12 @@ api_aline(sp, lno, line, len) char *line; size_t len; { - return (db_append(sp, 1, lno, line, len)); + size_t wblen; + CHAR_T *wbp; + + CHAR2INT(sp, line, len, wbp, wblen); + + return (db_append(sp, 1, lno, wbp, wblen)); } /* @@ -103,7 +108,7 @@ api_extend(sp, lno) if (db_last(sp, &lastlno)) return 1; while(lastlno < lno) - if (db_append(sp, 1, lastlno++, "", 0)) + if (db_append(sp, 1, lastlno++, NULL, 0)) return 1; return 0; } @@ -165,7 +170,12 @@ api_iline(sp, lno, line, len) char *line; size_t len; { - return (db_insert(sp, lno, line, len)); + size_t wblen; + CHAR_T *wbp; + + CHAR2INT(sp, line, len, wbp, wblen); + + return (db_insert(sp, lno, wbp, wblen)); } /* @@ -195,7 +205,12 @@ api_sline(sp, lno, line, len) char *line; size_t len; { - return (db_set(sp, lno, line, len)); + size_t wblen; + CHAR_T *wbp; + + CHAR2INT(sp, line, len, wbp, wblen); + + return (db_set(sp, lno, wbp, wblen)); } /* @@ -341,10 +356,13 @@ api_edit(sp, file, spp, newscreen) int newscreen; { EXCMD cmd; + size_t wlen; + CHAR_T *wp; if (file) { ex_cinit(sp, &cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, file, strlen(file)); + CHAR2INT(sp, file, strlen(file) + 1, wp, wlen); + argv_exp0(sp, &cmd, wp, wlen - 1 /* terminating 0 */); } else ex_cinit(sp, &cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0); if (newscreen) @@ -410,10 +428,14 @@ api_map(sp, name, map, len) size_t len; { EXCMD cmd; + size_t wlen; + CHAR_T *wp; ex_cinit(sp, &cmd, C_MAP, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, name, strlen(name)); - argv_exp0(sp, &cmd, map, len); + CHAR2INT(sp, name, strlen(name) + 1, wp, wlen); + argv_exp0(sp, &cmd, wp, wlen - 1); + CHAR2INT(sp, map, len, wp, wlen); + argv_exp0(sp, &cmd, wp, wlen); return (cmd.cmd->fn(sp, &cmd)); } @@ -429,9 +451,12 @@ api_unmap(sp, name) char *name; { EXCMD cmd; + size_t wlen; + CHAR_T *wp; ex_cinit(sp, &cmd, C_UNMAP, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, name, strlen(name)); + CHAR2INT(sp, name, strlen(name) + 1, wp, wlen); + argv_exp0(sp, &cmd, wp, wlen - 1); return (cmd.cmd->fn(sp, &cmd)); } @@ -505,6 +530,8 @@ api_opts_set(sp, name, str_value, num_value, bool_value) int rval; size_t blen; char *bp; + size_t wblen; + CHAR_T *wbp; if ((op = opts_search(name)) == NULL) { opts_nomatch(sp, name); @@ -526,7 +553,11 @@ api_opts_set(sp, name, str_value, num_value, bool_value) a.len = snprintf(bp, 1024, "%s=%s", name, str_value); break; } - a.bp = bp; + + CHAR2INT(sp, bp, a.len, wbp, wblen); + a.len = wblen; + + a.bp = wbp; b.len = 0; b.bp = NULL; ap[0] = &a; @@ -549,7 +580,11 @@ api_run_str(sp, cmd) SCR *sp; char *cmd; { - return (ex_run_str(sp, NULL, cmd, strlen(cmd), 0, 0)); + size_t wlen; + CHAR_T *wp; + + CHAR2INT(sp, cmd, strlen(cmd)+1, wp, wlen); + return (ex_run_str(sp, NULL, wp, wlen - 1, 0, 0)); } /* @@ -586,16 +621,25 @@ api_tagq_add(sp, tqp, filename, search, msg) char *filename, *search, *msg; { TAG *tp; + CHAR_T *wp; + size_t wlen; size_t flen = strlen(filename); size_t slen = strlen(search); + size_t mlen = strlen(msg); - CALLOC_GOTO(sp, tp, TAG *, 1, sizeof(TAG) - 1 + flen + 1 + slen + 1); - tp->fname = tp->buf; + CALLOC_GOTO(sp, tp, TAG *, 1, + sizeof(TAG) - 1 + flen + 1 + slen + 1 + mlen + 1); + tp->fname = (char *)tp->buf; memcpy(tp->fname, filename, flen + 1); tp->fnlen = flen; - tp->search = tp->fname + flen + 1; - memcpy(tp->search, search, slen + 1); + tp->search = (CHAR_T *)((char *)tp->fname + flen + 1); + CHAR2INT(sp, search, slen + 1, wp, wlen); + memcpy(tp->search, wp, wlen); tp->slen = slen; + tp->msg = tp->search + slen + 1; + CHAR2INT(sp, msg, mlen + 1, wp, wlen); + memcpy(tp->msg, wp, wlen); + tp->mlen = mlen; CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q); alloc_err: diff --git a/common/common.h b/common/common.h index 291c82f7..2d072c7b 100644 --- a/common/common.h +++ b/common/common.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: common.h,v 10.16 2000/06/25 17:34:37 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:37 $ + * $Id: common.h,v 10.17 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $ */ /* @@ -35,6 +35,7 @@ */ typedef struct _cb CB; typedef struct _csc CSC; +typedef struct _conv CONV; typedef struct _event EVENT; typedef struct _excmd EXCMD; typedef struct _exf EXF; @@ -99,5 +100,6 @@ typedef enum { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT } seq_t; #include "exf.h" #include "log.h" #include "mem.h" +#include "conv.h" #include "extern.h" diff --git a/common/cut.c b/common/cut.c index 26ac827a..dcd435d8 100644 --- a/common/cut.c +++ b/common/cut.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: cut.c,v 10.13 2000/07/10 15:28:43 skimo Exp $ (Berkeley) $Date: 2000/07/10 15:28:43 $"; +static const char sccsid[] = "$Id: cut.c,v 10.14 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $"; #endif /* not lint */ #include @@ -307,12 +307,12 @@ cut_close(gp) * text_init -- * Allocate a new TEXT structure. * - * PUBLIC: TEXT *text_init __P((SCR *, const char *, size_t, size_t)); + * PUBLIC: TEXT *text_init __P((SCR *, const CHAR_T *, size_t, size_t)); */ TEXT * text_init(sp, p, len, total_len) SCR *sp; - const char *p; + const CHAR_T *p; size_t len, total_len; { TEXT *tp; @@ -328,7 +328,7 @@ text_init(sp, p, len, total_len) return (NULL); } if (p != NULL && len != 0) - memcpy(tp->lb, p, len); + memcpy(tp->lb, p, len * sizeof(CHAR_T)); } tp->len = len; return (tp); diff --git a/common/cut.h b/common/cut.h index b8c05da3..dda7ebe5 100644 --- a/common/cut.h +++ b/common/cut.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: cut.h,v 10.7 2000/07/10 15:28:44 skimo Exp $ (Berkeley) $Date: 2000/07/10 15:28:44 $ + * $Id: cut.h,v 10.8 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $ */ typedef struct _texth TEXTH; /* TEXT list head structure. */ @@ -16,6 +16,7 @@ CIRCLEQ_HEAD(_texth, _text); struct _cb { LIST_ENTRY(_cb) q; /* Linked list of cut buffers. */ TEXTH textq; /* Linked list of TEXT structures. */ + /* XXXX Needed ? Can non ascii-chars be cut buffer names ? */ CHAR_T name; /* Cut buffer name. */ size_t len; /* Total length of cut text. */ diff --git a/common/db.c b/common/db.c index 832e1c74..371d50a3 100644 --- a/common/db.c +++ b/common/db.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: db.c,v 10.26 2000/06/25 17:34:37 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:37 $"; +static const char sccsid[] = "$Id: db.c,v 10.27 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $"; #endif /* not lint */ #include @@ -27,7 +27,7 @@ static const char sccsid[] = "$Id: db.c,v 10.26 2000/06/25 17:34:37 skimo Exp $ #include "../vi/vi.h" static int scr_update __P((SCR *, db_recno_t, lnop_t, int)); -static int append __P((SCR*, db_recno_t, char*, size_t)); +static int append __P((SCR*, db_recno_t, CHAR_T*, size_t)); /* * db_eget -- @@ -173,14 +173,14 @@ err3: if (lenp != NULL) /* Reset the cache. */ ep->c_lno = lno; - ep->c_len = data.size; + ep->c_len = data.size / sizeof(CHAR_T); ep->c_lp = data.data; #if defined(DEBUG) && 0 vtrace(sp, "retrieve DB line %lu\n", (u_long)lno); #endif if (lenp != NULL) - *lenp = data.size; + *lenp = data.size / sizeof(CHAR_T); if (pp != NULL) *pp = ep->c_lp; return (0); @@ -256,7 +256,7 @@ static int append(sp, lno, p, len) SCR *sp; db_recno_t lno; - char *p; + CHAR_T *p; size_t len; { DBT data, key; @@ -278,7 +278,7 @@ append(sp, lno, p, len) goto err2; data.data = p; - data.size = len; + data.size = len * sizeof(CHAR_T); if ((sp->db_error = dbcp_put->c_put(dbcp_put, &key, &data, DB_AFTER)) != 0) { err2: (void)dbcp_put->c_close(dbcp_put); @@ -290,7 +290,7 @@ err2: goto err2; data.data = p; - data.size = len; + data.size = len * sizeof(CHAR_T); if ((sp->db_error = ep->db->put(ep->db, NULL, &key, &data, DB_APPEND)) != 0) { goto err2; } @@ -298,7 +298,7 @@ err2: key.data = &lno; key.size = sizeof(lno); data.data = p; - data.size = len; + data.size = len * sizeof(CHAR_T); if ((sp->db_error = dbcp_put->c_put(dbcp_put, &key, &data, DB_BEFORE)) != 0) { goto err2; } @@ -314,14 +314,14 @@ err2: * db_append -- * Append a line into the file. * - * PUBLIC: int db_append __P((SCR *, int, db_recno_t, char *, size_t)); + * PUBLIC: int db_append __P((SCR *, int, db_recno_t, CHAR_T *, size_t)); */ int db_append(sp, update, lno, p, len) SCR *sp; int update; db_recno_t lno; - char *p; + CHAR_T *p; size_t len; { EXF *ep; @@ -381,13 +381,13 @@ db_append(sp, update, lno, p, len) * db_insert -- * Insert a line into the file. * - * PUBLIC: int db_insert __P((SCR *, db_recno_t, char *, size_t)); + * PUBLIC: int db_insert __P((SCR *, db_recno_t, CHAR_T *, size_t)); */ int db_insert(sp, lno, p, len) SCR *sp; db_recno_t lno; - char *p; + CHAR_T *p; size_t len; { DBT data, key; @@ -441,13 +441,13 @@ db_insert(sp, lno, p, len) * db_set -- * Store a line in the file. * - * PUBLIC: int db_set __P((SCR *, db_recno_t, char *, size_t)); + * PUBLIC: int db_set __P((SCR *, db_recno_t, CHAR_T *, size_t)); */ int db_set(sp, lno, p, len) SCR *sp; db_recno_t lno; - char *p; + CHAR_T *p; size_t len; { DBT data, key; @@ -473,7 +473,7 @@ db_set(sp, lno, p, len) key.size = sizeof(lno); memset(&data, 0, sizeof(data)); data.data = p; - data.size = len; + data.size = len * sizeof(CHAR_T); if ((sp->db_error = ep->db->put(ep->db, NULL, &key, &data, 0)) != 0) { msgq(sp, M_DBERR, "006|unable to store line %lu", (u_long)lno); return (1); @@ -589,7 +589,7 @@ err1: /* Fill the cache. */ memcpy(&lno, key.data, sizeof(lno)); ep->c_nlines = ep->c_lno = lno; - ep->c_len = data.size; + ep->c_len = data.size / sizeof(CHAR_T); ep->c_lp = data.data; /* Return the value. */ diff --git a/common/exf.c b/common/exf.c index 93fb6b71..17fca8cc 100644 --- a/common/exf.c +++ b/common/exf.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: exf.c,v 10.55 2000/05/20 20:56:14 skimo Exp $ (Berkeley) $Date: 2000/05/20 20:56:14 $"; +static const char sccsid[] = "$Id: exf.c,v 10.56 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $"; #endif /* not lint */ #include @@ -56,12 +56,12 @@ static int file_spath __P((SCR *, FREF *, struct stat *, int *)); * vi now remembers the last location in any file that it has ever edited, * not just the previously edited file. * - * PUBLIC: FREF *file_add __P((SCR *, CHAR_T *)); + * PUBLIC: FREF *file_add __P((SCR *, char *)); */ FREF * file_add(sp, name) SCR *sp; - CHAR_T *name; + char *name; { GS *gp; FREF *frp, *tfrp; @@ -556,6 +556,8 @@ file_cinit(sp) MARK m; size_t len; int nb; + CHAR_T *wp; + size_t wlen; /* Set some basic defaults. */ sp->lno = 1; @@ -589,8 +591,9 @@ file_cinit(sp) sp->lno = 1; sp->cno = 0; } - if (ex_run_str(sp, - "-c option", gp->c_option, strlen(gp->c_option), 1, 1)) + CHAR2INT(sp, gp->c_option, strlen(gp->c_option) + 1, + wp, wlen); + if (ex_run_str(sp, "-c option", wp, wlen - 1, 1, 1)) return; gp->c_option = NULL; } else if (F_ISSET(sp, SC_EX)) { @@ -1049,6 +1052,10 @@ file_backup(sp, name, bname) size_t blen; int flags, maxnum, nr, num, nw, rfd, wfd, version; char *bp, *estr, *p, *pct, *slash, *t, *wfname, buf[8192]; + CHAR_T *wp; + size_t wlen; + size_t nlen; + char *d = NULL; rfd = wfd = -1; bp = estr = wfname = NULL; @@ -1084,7 +1091,8 @@ file_backup(sp, name, bname) ++bname; } else version = 0; - if (argv_exp2(sp, &cmd, bname, strlen(bname))) + CHAR2INT(sp, bname, strlen(bname) + 1, wp, wlen); + if (argv_exp2(sp, &cmd, wp, wlen - 1)) return (1); /* @@ -1109,8 +1117,12 @@ file_backup(sp, name, bname) */ if (version) { GET_SPACE_GOTO(sp, bp, blen, cmd.argv[0]->len * 2 + 50); - for (t = bp, slash = NULL, - p = cmd.argv[0]->bp; p[0] != '\0'; *t++ = *p++) + INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, + p, nlen); + d = strdup(p); + p = d; + for (t = bp, slash = NULL; + p[0] != '\0'; *t++ = *p++) if (p[0] == '%') { if (p[1] != '%') *t++ = '%'; @@ -1131,7 +1143,8 @@ file_backup(sp, name, bname) p = slash + 1; } if (dirp == NULL) { - estr = cmd.argv[0]->bp; + INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, + estr, nlen); goto err; } @@ -1145,7 +1158,8 @@ file_backup(sp, name, bname) wfname = bp; } else { bp = NULL; - wfname = cmd.argv[0]->bp; + INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, + wfname, nlen); } /* Open the backup file, avoiding lurkers. */ @@ -1205,6 +1219,8 @@ err: if (rfd != -1) } if (estr) msgq_str(sp, M_SYSERR, estr, "%s"); + if (d != NULL) + free(d); if (bp != NULL) FREE_SPACE(sp, bp, blen); return (1); diff --git a/common/exf.h b/common/exf.h index 62aa7d2b..a1b97037 100644 --- a/common/exf.h +++ b/common/exf.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: exf.h,v 10.10 2000/05/01 19:59:28 skimo Exp $ (Berkeley) $Date: 2000/05/01 19:59:28 $ + * $Id: exf.h,v 10.11 2000/07/14 14:29:15 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:15 $ */ /* Undo direction. */ /* @@ -19,7 +19,7 @@ struct _exf { /* Underlying database state. */ DB *db; /* File db structure. */ - char *c_lp; /* Cached line. */ + CHAR_T *c_lp; /* Cached line. */ size_t c_len; /* Cached line length. */ db_recno_t c_lno; /* Cached line number. */ db_recno_t c_nlines; /* Cached lines in the file. */ diff --git a/common/gs.h b/common/gs.h index a3b101ac..59127e9e 100644 --- a/common/gs.h +++ b/common/gs.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: gs.h,v 10.46 2000/07/11 22:05:09 skimo Exp $ (Berkeley) $Date: 2000/07/11 22:05:09 $ + * $Id: gs.h,v 10.47 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $ */ #define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */ @@ -106,13 +106,13 @@ struct _gs { #define MAX_FAST_KEY 255 /* Max fast check character.*/ #define KEY_LEN(sp, ch) \ - ((unsigned char)(ch) <= MAX_FAST_KEY ? \ + ((CHAR_T)(ch) <= MAX_FAST_KEY ? \ sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch)) #define KEY_NAME(sp, ch) \ - ((unsigned char)(ch) <= MAX_FAST_KEY ? \ + ((CHAR_T)(ch) <= MAX_FAST_KEY ? \ sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch)) struct { - CHAR_T name[MAX_CHARACTER_COLUMNS + 1]; + u_char name[MAX_CHARACTER_COLUMNS + 1]; u_int8_t len; } cname[MAX_FAST_KEY + 1]; /* Fast lookup table. */ @@ -137,7 +137,9 @@ struct _gs { /* Screen interface functions. */ /* Add a string to the screen. */ - int (*scr_addstr) __P((SCR *, const CHAR_T *, size_t)); + int (*scr_addstr) __P((SCR *, const char *, size_t)); + /* Add a string to the screen. */ + int (*scr_waddstr) __P((SCR *, const CHAR_T *, size_t)); /* Toggle a screen attribute. */ int (*scr_attr) __P((SCR *, scr_attr_t, int)); /* Terminal baud rate. */ @@ -147,7 +149,7 @@ struct _gs { /* Display a busy message. */ void (*scr_busy) __P((SCR *, const char *, busy_t)); /* Prepare child. */ - void (*scr_child) __P((SCR *)); + int (*scr_child) __P((SCR *)); /* Clear to the end of the line. */ int (*scr_clrtoeol) __P((SCR *)); /* Return the cursor location. */ @@ -190,7 +192,7 @@ struct _gs { /* Threading stuff */ void *th_private; - void (*run) __P((WIN *, void (*)(void*), void *)); + void (*run) __P((WIN *, void *(*)(void*), void *)); }; /* diff --git a/common/key.c b/common/key.c index ccd0f8e1..783c3415 100644 --- a/common/key.c +++ b/common/key.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: key.c,v 10.41 2000/07/10 15:28:44 skimo Exp $ (Berkeley) $Date: 2000/07/10 15:28:44 $"; +static const char sccsid[] = "$Id: key.c,v 10.42 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $"; #endif /* not lint */ #include @@ -206,7 +206,8 @@ void v_key_ilookup(sp) SCR *sp; { - CHAR_T ch, *p, *t; + CHAR_T ch; + char *p, *t; GS *gp; size_t len; @@ -240,18 +241,19 @@ v_key_len(sp, ch) * Return the string that will display the key. This routine * is the backup for the KEY_NAME() macro. * - * PUBLIC: CHAR_T *v_key_name __P((SCR *, ARG_CHAR_T)); + * PUBLIC: u_char *v_key_name __P((SCR *, ARG_CHAR_T)); */ -CHAR_T * +u_char * v_key_name(sp, ach) SCR *sp; ARG_CHAR_T ach; { static const char hexdigit[] = "0123456789abcdef"; static const char octdigit[] = "01234567"; - CHAR_T ch, *chp, mask; + CHAR_T ch, mask; size_t len; int cnt, shift; + char *chp; ch = ach; @@ -667,7 +669,7 @@ newmap: evp = &gp->i_event[gp->i_next]; /* If no map, return the character. */ if (qp == NULL) { -nomap: if (!isdigit(evp->e_c) && LF_ISSET(EC_MAPNODIGIT)) +nomap: if (!ISDIGIT(evp->e_c) && LF_ISSET(EC_MAPNODIGIT)) goto not_digit; *argp = *evp; QREM(1); @@ -679,7 +681,7 @@ nomap: if (!isdigit(evp->e_c) && LF_ISSET(EC_MAPNODIGIT)) * of the map is it, pretend we haven't seen the character. */ if (LF_ISSET(EC_MAPNODIGIT) && - qp->output != NULL && !isdigit(qp->output[0])) { + qp->output != NULL && !ISDIGIT(qp->output[0])) { not_digit: argp->e_c = CH_NOT_DIGIT; argp->e_value = K_NOTUSED; argp->e_event = E_CHARACTER; diff --git a/common/key.h b/common/key.h index b4ad8f04..ad718f63 100644 --- a/common/key.h +++ b/common/key.h @@ -6,9 +6,11 @@ * * See the LICENSE file for redistribution information. * - * $Id: key.h,v 10.24 2000/07/10 15:28:44 skimo Exp $ (Berkeley) $Date: 2000/07/10 15:28:44 $ + * $Id: key.h,v 10.25 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $ */ +#include "multibyte.h" + /* * Fundamental character types. * @@ -21,10 +23,27 @@ * * If no integral type can hold a character, don't even try the port. */ -typedef u_char CHAR_T; typedef u_int ARG_CHAR_T; #define MAX_CHAR_T 0xff #define CHAR_T_BLEN(sp,len) len +#define ROOM_FOR(name,len) CHAR_T name[len] + +#ifdef USE_WIDECHAR +#define CHAR2INT(sp,n,nlen,w,wlen) \ + sp->conv->char2int(sp->conv, n, nlen, &w, &wlen) +#define INT2CHAR(sp,w,wlen,n,nlen) \ + sp->conv->int2char(sp->conv, w, wlen, &n, &nlen) +#define CONST +#else +#define CHAR2INT(sp,n,nlen,w,wlen) \ + w = n; wlen = nlen +#define INT2CHAR(sp,w,wlen,n,nlen) \ + n = w; nlen = wlen +#define CONST const +#endif + +#define ISDIGIT(ch) \ + isdigit((u_char)(ch)) /* The maximum number of columns any character can take up on a screen. */ #define MAX_CHARACTER_COLUMNS 4 @@ -114,7 +133,7 @@ struct _event { typedef struct _keylist { e_key_t value; /* Special value. */ - CHAR_T ch; /* Key. */ + CHAR_T ch; /* Key. */ } KEYLIST; extern KEYLIST keylist[]; diff --git a/common/log.c b/common/log.c index 356e65f4..9427b1fc 100644 --- a/common/log.c +++ b/common/log.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: log.c,v 10.12 2000/04/21 21:26:19 skimo Exp $ (Berkeley) $Date: 2000/04/21 21:26:19 $"; +static const char sccsid[] = "$Id: log.c,v 10.13 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $"; #endif /* not lint */ #include @@ -251,12 +251,13 @@ log_line(sp, lno, action) */ if (action == LOG_LINE_RESET_B) { if (db_get(sp, lno, DBG_NOCACHE, &lp, &len)) { + static CHAR_T nul = 0; if (lno != 1) { db_err(sp, lno); return (1); } len = 0; - lp = ""; + lp = &nul; } } else if (db_get(sp, lno, DBG_FATAL, &lp, &len)) @@ -422,8 +423,9 @@ log_backward(sp, rp) case LOG_LINE_DELETE: didop = 1; memmove(&lno, p + sizeof(u_char), sizeof(db_recno_t)); - if (db_insert(sp, lno, p + sizeof(u_char) + - sizeof(db_recno_t), data.size - sizeof(u_char) - + if (db_insert(sp, lno, + (CHAR_T *)(p + sizeof(u_char) + + sizeof(db_recno_t)), data.size - sizeof(u_char) - sizeof(db_recno_t))) goto err; ++sp->rptlines[L_ADDED]; @@ -433,8 +435,9 @@ log_backward(sp, rp) case LOG_LINE_RESET_B: didop = 1; memmove(&lno, p + sizeof(u_char), sizeof(db_recno_t)); - if (db_set(sp, lno, p + sizeof(u_char) + - sizeof(db_recno_t), data.size - sizeof(u_char) - + if (db_set(sp, lno, + (CHAR_T *)(p + sizeof(u_char) + + sizeof(db_recno_t)), data.size - sizeof(u_char) - sizeof(db_recno_t))) goto err; if (sp->rptlchange != lno) { @@ -530,8 +533,8 @@ log_setline(sp) case LOG_LINE_RESET_B: memmove(&lno, p + sizeof(u_char), sizeof(db_recno_t)); if (lno == sp->lno && - db_set(sp, lno, p + sizeof(u_char) + - sizeof(db_recno_t), data.size - sizeof(u_char) - + db_set(sp, lno, (CHAR_T *)(p + sizeof(u_char) + + sizeof(db_recno_t)), data.size - sizeof(u_char) - sizeof(db_recno_t))) goto err; if (sp->rptlchange != lno) { @@ -617,8 +620,9 @@ log_forward(sp, rp) didop = 1; memmove(&lno, p + sizeof(u_char), sizeof(db_recno_t)); --lno; - if (db_append(sp, 1, lno, p + sizeof(u_char) + - sizeof(db_recno_t), data.size - sizeof(u_char) - + if (db_append(sp, 1, lno, + (CHAR_T *)(p + sizeof(u_char) + + sizeof(db_recno_t)), data.size - sizeof(u_char) - sizeof(db_recno_t))) goto err; ++sp->rptlines[L_ADDED]; @@ -626,8 +630,9 @@ log_forward(sp, rp) case LOG_LINE_INSERT: didop = 1; memmove(&lno, p + sizeof(u_char), sizeof(db_recno_t)); - if (db_insert(sp, lno, p + sizeof(u_char) + - sizeof(db_recno_t), data.size - sizeof(u_char) - + if (db_insert(sp, lno, + (CHAR_T *)(p + sizeof(u_char) + + sizeof(db_recno_t)), data.size - sizeof(u_char) - sizeof(db_recno_t))) goto err; ++sp->rptlines[L_ADDED]; @@ -644,8 +649,9 @@ log_forward(sp, rp) case LOG_LINE_RESET_F: didop = 1; memmove(&lno, p + sizeof(u_char), sizeof(db_recno_t)); - if (db_set(sp, lno, p + sizeof(u_char) + - sizeof(db_recno_t), data.size - sizeof(u_char) - + if (db_set(sp, lno, + (CHAR_T *)(p + sizeof(u_char) + + sizeof(db_recno_t)), data.size - sizeof(u_char) - sizeof(db_recno_t))) goto err; if (sp->rptlchange != lno) { diff --git a/common/main.c b/common/main.c index 0c1a75d9..ec97b44e 100644 --- a/common/main.c +++ b/common/main.c @@ -18,7 +18,7 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -static const char sccsid[] = "$Id: main.c,v 10.55 2000/07/07 22:29:13 skimo Exp $ (Berkeley) $Date: 2000/07/07 22:29:13 $"; +static const char sccsid[] = "$Id: main.c,v 10.56 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $"; #endif /* not lint */ #include @@ -66,6 +66,8 @@ editor(wp, argc, argv) u_int flags; int ch, flagchk, lflag, secure, startup, readonly, rval, silent; char *tag_f, *wsizearg, path[256]; + CHAR_T *w; + size_t wlen; gp = wp->gp; @@ -338,8 +340,11 @@ editor(wp, argc, argv) } /* Open a tag file if specified. */ - if (tag_f != NULL && ex_tag_first(sp, tag_f)) - goto err; + if (tag_f != NULL) { + CHAR2INT(sp, tag_f, strlen(tag_f) + 1, w, wlen); + if (ex_tag_first(sp, w)) + goto err; + } /* * Append any remaining arguments as file names. Files are recovery @@ -373,7 +378,7 @@ editor(wp, argc, argv) if ((frp = file_add(sp, NULL)) == NULL) goto err; } else { - if ((frp = file_add(sp, (CHAR_T *)sp->argv[0])) == NULL) + if ((frp = file_add(sp, sp->argv[0])) == NULL) goto err; if (F_ISSET(sp, SC_ARGRECOVER)) F_SET(frp, FR_RECOVER); diff --git a/common/mark.h b/common/mark.h index 44f62d3d..abd9812e 100644 --- a/common/mark.h +++ b/common/mark.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: mark.h,v 10.4 2000/04/21 19:00:33 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:33 $ + * $Id: mark.h,v 10.5 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $ */ /* @@ -31,6 +31,7 @@ struct _lmark { LIST_ENTRY(_lmark) q; /* Linked list of marks. */ db_recno_t lno; /* Line number. */ size_t cno; /* Column number. */ + /* XXXX Needed ? Can non ascii-chars be mark names ? */ CHAR_T name; /* Mark name. */ #define MARK_DELETED 0x01 /* Mark was deleted. */ diff --git a/common/msg.c b/common/msg.c index ea4007b2..dd282be5 100644 --- a/common/msg.c +++ b/common/msg.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: msg.c,v 10.52 2000/06/25 17:34:38 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:38 $"; +static const char sccsid[] = "$Id: msg.c,v 10.53 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $"; #endif /* not lint */ #include @@ -366,6 +366,26 @@ alloc_err: * msgq_str -- * Display a message with an embedded string. * + * PUBLIC: void msgq_wstr __P((SCR *, mtype_t, CHAR_T *, char *)); + */ +void +msgq_wstr(sp, mtype, str, fmt) + SCR *sp; + mtype_t mtype; + CHAR_T *str; + char *fmt; +{ + size_t nlen; + char *nstr; + + INT2CHAR(sp, str, v_strlen(str) + 1, nstr, nlen); + msgq_str(sp, mtype, nstr, fmt); +} + +/* + * msgq_str -- + * Display a message with an embedded string. + * * PUBLIC: void msgq_str __P((SCR *, mtype_t, char *, char *)); */ void diff --git a/common/nothread.c b/common/nothread.c index f88387ed..c73d63a9 100644 --- a/common/nothread.c +++ b/common/nothread.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: nothread.c,v 1.2 2000/07/04 21:48:53 skimo Exp $ (Berkeley) $Date: 2000/07/04 21:48:53 $"; +static const char sccsid[] = "$Id: nothread.c,v 1.3 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $"; #endif /* not lint */ #include @@ -24,7 +24,7 @@ static const char sccsid[] = "$Id: nothread.c,v 1.2 2000/07/04 21:48:53 skimo Ex #include "../common/common.h" -static void vi_nothread_run __P((WIN *wp, void (*fun)(void*), void *data)); +static void vi_nothread_run __P((WIN *wp, void *(*fun)(void*), void *data)); /* * thread_init @@ -38,7 +38,7 @@ thread_init(GS *gp) } static void -vi_nothread_run(WIN *wp, void (*fun)(void*), void *data) +vi_nothread_run(WIN *wp, void *(*fun)(void*), void *data) { fun(data); } diff --git a/common/options.c b/common/options.c index 2b750f3e..e300c7ed 100644 --- a/common/options.c +++ b/common/options.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: options.c,v 10.55 2000/06/27 17:19:04 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:04 $"; +static const char sccsid[] = "$Id: options.c,v 10.56 2000/07/14 14:29:16 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:16 $"; #endif /* not lint */ #include @@ -78,6 +78,8 @@ OPTLIST const optlist[] = { {"extended", f_recompile, OPT_0BOOL, 0}, /* O_FILEC 4.4BSD */ {"filec", NULL, OPT_STR, 0}, +/* O_FILEENCODING */ + {"fileencoding",f_fileencoding, OPT_STR, 0}, /* O_FLASH HPUX */ {"flash", NULL, OPT_1BOOL, 0}, /* O_HARDTABS 4BSD */ @@ -244,6 +246,7 @@ static OABBREV const abbrev[] = { {"eb", O_ERRORBELLS}, /* 4BSD */ {"ed", O_EDCOMPATIBLE}, /* 4BSD */ {"ex", O_EXRC}, /* System V (undocumented) */ + {"fe", O_FILEENCODING}, {"ht", O_HARDTABS}, /* 4BSD */ {"ic", O_IGNORECASE}, /* 4BSD */ {"li", O_LINES}, /* 4.4BSD */ @@ -290,9 +293,13 @@ opts_init(sp, oargs) OPTLIST const *op; u_long isset, v; int cnt, optindx; - char *s, b1[1024]; + char *s; + char b1[1024]; + CHAR_T b2[1024]; + CHAR_T *wp; + size_t wlen; - a.bp = b1; + a.bp = b2; b.bp = NULL; a.len = b.len = 0; argv[0] = &a; @@ -300,9 +307,9 @@ opts_init(sp, oargs) /* Set numeric and string default values. */ #define OI(indx, str) { \ - if (str != b1) /* GCC puts strings in text-space. */ \ - (void)strcpy(b1, str); \ - a.len = strlen(b1); \ + CHAR2INT(sp, str, strlen(str) + 1, wp, wlen); \ + a.len = wlen - 1; \ + (void)memcpy(b2 , wp, (a.len + 1) * sizeof(CHAR_T)); \ if (opts_set(sp, argv, NULL)) { \ optindx = indx; \ goto err; \ @@ -461,15 +468,19 @@ opts_set(sp, argv, usage) OPTION *spo; u_long isset, turnoff, value; int ch, equals, nf, nf2, offset, qmark, rval; - char *endp, *name, *p, *sep, *t; + CHAR_T *endp, *name, *p, *sep, *t; + char *p2, *t2; + char *np; + size_t nlen; disp = NO_DISPLAY; for (rval = 0; argv[0]->len != 0; ++argv) { + static CHAR_T all[] = {'a', 'l', 'l', 0}; /* * The historic vi dumped the options for each occurrence of * "all" in the set list. Puhleeze. */ - if (!strcmp(argv[0]->bp, "all")) { + if (!memcmp(argv[0]->bp, all, sizeof(all))) { disp = ALL_DISPLAY; continue; } @@ -498,14 +509,17 @@ opts_set(sp, argv, usage) *sep++ = '\0'; /* Search for the name, then name without any leading "no". */ - if ((op = opts_search(name)) == NULL && + INT2CHAR(sp, name, v_strlen(name) + 1, np, nlen); + if ((op = opts_search(np)) == NULL && name[0] == 'n' && name[1] == 'o') { turnoff = 1; name += 2; - op = opts_search(name); + INT2CHAR(sp, name, v_strlen(name) + 1, np, nlen); + op = opts_search(np); } if (op == NULL) { - opts_nomatch(sp, name); + INT2CHAR(sp, name, v_strlen(name) + 1, np, nlen); + opts_nomatch(sp, np); rval = 1; continue; } @@ -531,7 +545,7 @@ opts_set(sp, argv, usage) case OPT_1BOOL: /* Some options may not be reset. */ if (F_ISSET(op, OPT_NOUNSET) && turnoff) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, "291|set: the %s option may not be turned off"); rval = 1; break; @@ -539,14 +553,14 @@ opts_set(sp, argv, usage) /* Some options may not be set. */ if (F_ISSET(op, OPT_NOSET) && !turnoff) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, "313|set: the %s option may never be turned on"); rval = 1; break; } if (equals) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, "034|set: [no]%s option doesn't take a value"); rval = 1; break; @@ -589,7 +603,7 @@ opts_set(sp, argv, usage) break; case OPT_NUM: if (turnoff) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, "035|set: %s option isn't a boolean"); rval = 1; break; @@ -604,45 +618,53 @@ opts_set(sp, argv, usage) if (!isdigit(sep[0])) goto badnum; if ((nret = - nget_uslong(&value, sep, &endp, 10)) != NUM_OK) { - p = msg_print(sp, name, &nf); - t = msg_print(sp, sep, &nf2); + nget_uslong(sp, &value, sep, &endp, 10)) != NUM_OK) { + INT2CHAR(sp, name, v_strlen(name) + 1, + np, nlen); + p2 = msg_print(sp, np, &nf); + INT2CHAR(sp, sep, v_strlen(sep) + 1, + np, nlen); + t2 = msg_print(sp, np, &nf2); switch (nret) { case NUM_ERR: msgq(sp, M_SYSERR, - "036|set: %s option: %s", p, t); + "036|set: %s option: %s", p2, t2); break; case NUM_OVER: msgq(sp, M_ERR, - "037|set: %s option: %s: value overflow", p, t); + "037|set: %s option: %s: value overflow", p2, t2); break; case NUM_OK: case NUM_UNDER: abort(); } if (nf) - FREE_SPACE(sp, p, 0); + FREE_SPACE(sp, p2, 0); if (nf2) - FREE_SPACE(sp, t, 0); + FREE_SPACE(sp, t2, 0); rval = 1; break; } if (*endp && !isblank(*endp)) { -badnum: p = msg_print(sp, name, &nf); - t = msg_print(sp, sep, &nf2); +badnum: INT2CHAR(sp, name, v_strlen(name) + 1, + np, nlen); + p2 = msg_print(sp, np, &nf); + INT2CHAR(sp, sep, v_strlen(sep) + 1, + np, nlen); + t2 = msg_print(sp, np, &nf2); msgq(sp, M_ERR, - "038|set: %s option: %s is an illegal number", p, t); + "038|set: %s option: %s is an illegal number", p2, t2); if (nf) - FREE_SPACE(sp, p, 0); + FREE_SPACE(sp, p2, 0); if (nf2) - FREE_SPACE(sp, t, 0); + FREE_SPACE(sp, t2, 0); rval = 1; break; } /* Some options may never be set to zero. */ if (F_ISSET(op, OPT_NOZERO) && value == 0) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, "314|set: the %s option may never be set to 0"); rval = 1; break; @@ -657,11 +679,12 @@ badnum: p = msg_print(sp, name, &nf); break; /* Report to subsystems. */ + INT2CHAR(sp, sep, v_strlen(sep) + 1, np, nlen); if (op->func != NULL && - op->func(sp, spo, sep, &value) || - ex_optchange(sp, offset, sep, &value) || - v_optchange(sp, offset, sep, &value) || - sp->gp->scr_optchange(sp, offset, sep, &value)) { + op->func(sp, spo, np, &value) || + ex_optchange(sp, offset, np, &value) || + v_optchange(sp, offset, np, &value) || + sp->gp->scr_optchange(sp, offset, np, &value)) { rval = 1; break; } @@ -672,7 +695,7 @@ badnum: p = msg_print(sp, name, &nf); break; case OPT_STR: if (turnoff) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, "039|set: %s option isn't a boolean"); rval = 1; break; @@ -688,23 +711,24 @@ badnum: p = msg_print(sp, name, &nf); * Do nothing if the value is unchanged, the underlying * functions can be expensive. */ + INT2CHAR(sp, sep, v_strlen(sep) + 1, np, nlen); if (!F_ISSET(op, OPT_ALWAYS) && O_STR(sp, offset) != NULL && - !strcmp(O_STR(sp, offset), sep)) + !strcmp(O_STR(sp, offset), np)) break; /* Report to subsystems. */ if (op->func != NULL && - op->func(sp, spo, sep, NULL) || - ex_optchange(sp, offset, sep, NULL) || - v_optchange(sp, offset, sep, NULL) || - sp->gp->scr_optchange(sp, offset, sep, NULL)) { + op->func(sp, spo, np, NULL) || + ex_optchange(sp, offset, np, NULL) || + v_optchange(sp, offset, np, NULL) || + sp->gp->scr_optchange(sp, offset, np, NULL)) { rval = 1; break; } /* Set the value. */ - if (o_set(sp, offset, OS_STRDUP, sep, 0)) + if (o_set(sp, offset, OS_STRDUP, np, 0)) rval = 1; break; default: diff --git a/common/options_f.c b/common/options_f.c index 4de3b563..4e2a38e7 100644 --- a/common/options_f.c +++ b/common/options_f.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: options_f.c,v 10.27 2000/07/06 18:47:57 skimo Exp $ (Berkeley) $Date: 2000/07/06 18:47:57 $"; +static const char sccsid[] = "$Id: options_f.c,v 10.28 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -369,3 +369,15 @@ f_window(sp, op, str, valp) *valp = 1; return (0); } + +/* + * PUBLIC: int f_fileencoding __P((SCR *, OPTION *, char *, u_long *)); + */ +int +f_fileencoding(sp, op, str, valp) + SCR *sp; + OPTION *op; + char *str; + u_long *valp; +{ +} diff --git a/common/pthread.c b/common/pthread.c index 04a84ba1..cf2de9ff 100644 --- a/common/pthread.c +++ b/common/pthread.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: pthread.c,v 1.2 2000/07/04 21:48:54 skimo Exp $ (Berkeley) $Date: 2000/07/04 21:48:54 $"; +static const char sccsid[] = "$Id: pthread.c,v 1.3 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -26,7 +26,7 @@ static const char sccsid[] = "$Id: pthread.c,v 1.2 2000/07/04 21:48:54 skimo Exp #include "../common/common.h" -static void vi_pthread_run __P((WIN *wp, void (*fun)(void*), void *data)); +static void vi_pthread_run __P((WIN *wp, void *(*fun)(void*), void *data)); /* * thread_init @@ -40,7 +40,7 @@ thread_init(GS *gp) } static void -vi_pthread_run(WIN *wp, void (*fun)(void*), void *data) +vi_pthread_run(WIN *wp, void *(*fun)(void*), void *data) { pthread_t *t = malloc(sizeof(pthread_t)); pthread_create(t, NULL, fun, data); diff --git a/common/put.c b/common/put.c index e516f556..5ac031a5 100644 --- a/common/put.c +++ b/common/put.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: put.c,v 10.13 2000/06/27 17:19:05 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:05 $"; +static const char sccsid[] = "$Id: put.c,v 10.14 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -44,7 +44,7 @@ put(sp, cbp, namep, cp, rp, append) db_recno_t lno; size_t blen, clen, len; int rval; - char *bp, *t; + CHAR_T *bp, *t; CHAR_T *p; if (cbp == NULL) diff --git a/common/screen.c b/common/screen.c index e7796c71..cad79c38 100644 --- a/common/screen.c +++ b/common/screen.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: screen.c,v 10.17 2000/06/25 17:34:38 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:38 $"; +static const char sccsid[] = "$Id: screen.c,v 10.18 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -28,6 +28,9 @@ static const char sccsid[] = "$Id: screen.c,v 10.17 2000/06/25 17:34:38 skimo Ex #include "common.h" #include "../vi/vi.h" +CHAR_T RE_WSTART[] = {'[','[',':','<',':',']',']',0}; +CHAR_T RE_WSTOP[] = {'[','[',':','>',':',']',']',0}; + /* * screen_init -- * Do the default initialization of an SCR structure. @@ -50,9 +53,9 @@ screen_init(gp, orig, spp) sp->id = ++gp->id; sp->refcnt = 1; - sp->gp = gp; /* All ref the GS structure. */ + sp->gp = gp; /* All ref the GS structure. */ - sp->ccnt = 2; /* Anything > 1 */ + sp->ccnt = 2; /* Anything > 1 */ /* * XXX @@ -80,15 +83,15 @@ screen_init(gp, orig, spp) /* Retain searching/substitution information. */ sp->searchdir = orig->searchdir == NOTSET ? NOTSET : FORWARD; if (orig->re != NULL && (sp->re = - v_strdup(sp, orig->re, orig->re_len)) == NULL) + v_wstrdup(sp, orig->re, orig->re_len)) == NULL) goto mem; sp->re_len = orig->re_len; if (orig->subre != NULL && (sp->subre = - v_strdup(sp, orig->subre, orig->subre_len)) == NULL) + v_wstrdup(sp, orig->subre, orig->subre_len)) == NULL) goto mem; sp->subre_len = orig->subre_len; if (orig->repl != NULL && (sp->repl = - v_strdup(sp, orig->repl, orig->repl_len)) == NULL) + v_wstrdup(sp, orig->repl, orig->repl_len)) == NULL) goto mem; sp->repl_len = orig->repl_len; if (orig->newl_len) { @@ -114,6 +117,7 @@ mem: msgq(orig, M_SYSERR, NULL); if (v_screen_copy(orig, sp)) /* Vi. */ goto err; sp->cl_private = 0; /* XXX */ + conv_init(sp); /* XXX */ *spp = sp; return (0); diff --git a/common/screen.h b/common/screen.h index b621cde0..c5cc188a 100644 --- a/common/screen.h +++ b/common/screen.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: screen.h,v 10.34 2000/07/11 22:05:09 skimo Exp $ (Berkeley) $Date: 2000/07/11 22:05:09 $ + * $Id: screen.h,v 10.35 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $ */ /* @@ -51,7 +51,8 @@ struct _win { char *if_name; /* Current associated file. */ db_recno_t if_lno; /* Current associated line number. */ - CHAR_T *tmp_bp; /* Temporary buffer. */ + /* For now, can be either char or CHAR_T buffer */ + void *tmp_bp; /* Temporary buffer. */ size_t tmp_blen; /* Temporary buffer size. */ /* Flags. */ @@ -59,6 +60,8 @@ struct _win { u_int32_t flags; }; +extern CHAR_T RE_WSTART[8]; +extern CHAR_T RE_WSTOP[8]; /* * SCR -- * The screen structure. To the extent possible, all screen information @@ -114,10 +117,10 @@ struct _scr { SCRIPT *script; /* Vi: script mode information .*/ - db_recno_t defscroll; /* Vi: ^D, ^U scroll information. */ + db_recno_t defscroll; /* Vi: ^D, ^U scroll information. */ /* Display character. */ - CHAR_T cname[MAX_CHARACTER_COLUMNS + 1]; + u_char cname[MAX_CHARACTER_COLUMNS + 1]; size_t clen; /* Length of display character. */ enum { /* Vi editor mode. */ @@ -129,14 +132,18 @@ struct _scr { void *perl_private; /* Perl private area. */ void *cl_private; /* Curses private area. */ + CONV *conv; + /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */ char *alt_name; /* Ex/vi: alternate file name. */ CHAR_T at_lbuf; /* Ex/vi: Last executed at buffer. */ /* Ex/vi: re_compile flags. */ +#if 0 #define RE_WSTART "[[:<:]]" /* Ex/vi: not-in-word search pattern. */ #define RE_WSTOP "[[:>:]]" +#endif /* Ex/vi: flags to search routines. */ #define SEARCH_CSCOPE 0x000001 /* Search for a cscope pattern. */ #define SEARCH_CSEARCH 0x000002 /* Compile search replacement. */ @@ -159,12 +166,12 @@ struct _scr { /* Ex/vi: RE information. */ dir_t searchdir; /* Last file search direction. */ regex_t re_c; /* Search RE: compiled form. */ - char *re; /* Search RE: uncompiled form. */ + CHAR_T *re; /* Search RE: uncompiled form. */ size_t re_len; /* Search RE: uncompiled length. */ regex_t subre_c; /* Substitute RE: compiled form. */ - char *subre; /* Substitute RE: uncompiled form. */ + CHAR_T *subre; /* Substitute RE: uncompiled form. */ size_t subre_len; /* Substitute RE: uncompiled length). */ - char *repl; /* Substitute replacement. */ + CHAR_T *repl; /* Substitute replacement. */ size_t repl_len; /* Substitute replacement length.*/ size_t *newl; /* Newline offset array. */ size_t newl_len; /* Newline array size. */ diff --git a/common/search.c b/common/search.c index 28aa9ff6..4337054c 100644 --- a/common/search.c +++ b/common/search.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: search.c,v 10.29 2000/06/27 17:19:05 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:05 $"; +static const char sccsid[] = "$Id: search.c,v 10.30 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -30,7 +30,7 @@ static const char sccsid[] = "$Id: search.c,v 10.29 2000/06/27 17:19:05 skimo Ex typedef enum { S_EMPTY, S_EOF, S_NOPREV, S_NOTFOUND, S_SOF, S_WRAP } smsg_t; static void search_msg __P((SCR *, smsg_t)); -static int search_init __P((SCR *, dir_t, char *, size_t, char **, u_int)); +static int search_init __P((SCR *, dir_t, CHAR_T *, size_t, CHAR_T **, u_int)); /* * search_init -- @@ -40,13 +40,13 @@ static int search_init(sp, dir, ptrn, plen, epp, flags) SCR *sp; dir_t dir; - char *ptrn, **epp; + CHAR_T *ptrn, **epp; size_t plen; u_int flags; { db_recno_t lno; int delim; - char *p, *t; + CHAR_T *p, *t; /* If the file is empty, it's a fast search. */ if (sp->lno <= 1) { @@ -138,13 +138,13 @@ prev: if (sp->re == NULL) { * Do a forward search. * * PUBLIC: int f_search __P((SCR *, - * PUBLIC: MARK *, MARK *, char *, size_t, char **, u_int)); + * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); */ int f_search(sp, fm, rm, ptrn, plen, eptrn, flags) SCR *sp; MARK *fm, *rm; - char *ptrn, **eptrn; + CHAR_T *ptrn, **eptrn; size_t plen; u_int flags; { @@ -286,13 +286,13 @@ f_search(sp, fm, rm, ptrn, plen, eptrn, flags) * Do a backward search. * * PUBLIC: int b_search __P((SCR *, - * PUBLIC: MARK *, MARK *, char *, size_t, char **, u_int)); + * PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); */ int b_search(sp, fm, rm, ptrn, plen, eptrn, flags) SCR *sp; MARK *fm, *rm; - char *ptrn, **eptrn; + CHAR_T *ptrn, **eptrn; size_t plen; u_int flags; { diff --git a/common/seq.c b/common/seq.c index 9d8495b9..4754c39f 100644 --- a/common/seq.c +++ b/common/seq.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: seq.c,v 10.10 1996/03/30 13:46:57 bostic Exp $ (Berkeley) $Date: 1996/03/30 13:46:57 $"; +static const char sccsid[] = "$Id: seq.c,v 10.11 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -59,7 +59,7 @@ seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags) if (output == NULL || olen == 0) { p = NULL; olen = 0; - } else if ((p = v_strdup(sp, output, olen)) == NULL) { + } else if ((p = v_wstrdup(sp, output, olen)) == NULL) { sv_errno = errno; goto mem1; } @@ -80,14 +80,14 @@ seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags) /* Name. */ if (name == NULL || nlen == 0) qp->name = NULL; - else if ((qp->name = v_strdup(sp, name, nlen)) == NULL) { + else if ((qp->name = v_wstrdup(sp, name, nlen)) == NULL) { sv_errno = errno; goto mem2; } qp->nlen = nlen; /* Input. */ - if ((qp->input = v_strdup(sp, input, ilen)) == NULL) { + if ((qp->input = v_wstrdup(sp, input, ilen)) == NULL) { sv_errno = errno; goto mem3; } @@ -97,7 +97,7 @@ seq_set(sp, name, nlen, input, ilen, output, olen, stype, flags) if (output == NULL) { qp->output = NULL; olen = 0; - } else if ((qp->output = v_strdup(sp, output, olen)) == NULL) { + } else if ((qp->output = v_wstrdup(sp, output, olen)) == NULL) { sv_errno = errno; free(qp->input); mem3: if (qp->name != NULL) diff --git a/common/util.c b/common/util.c index 7ebda976..33bcd53e 100644 --- a/common/util.c +++ b/common/util.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: util.c,v 10.14 2000/06/27 17:19:05 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:05 $"; +static const char sccsid[] = "$Id: util.c,v 10.15 2000/07/14 14:29:17 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:17 $"; #endif /* not lint */ #include @@ -123,17 +123,39 @@ tail(path) * v_strdup -- * Strdup for wide character strings with an associated length. * - * PUBLIC: CHAR_T *v_strdup __P((SCR *, const CHAR_T *, size_t)); + * PUBLIC: char *v_strdup __P((SCR *, const char *, size_t)); */ -CHAR_T * +char * v_strdup(sp, str, len) SCR *sp; + const char *str; + size_t len; +{ + char *copy; + + MALLOC(sp, copy, char *, (len + 1)); + if (copy == NULL) + return (NULL); + memcpy(copy, str, len); + copy[len] = '\0'; + return (copy); +} + +/* + * v_strdup -- + * Strdup for wide character strings with an associated length. + * + * PUBLIC: CHAR_T *v_wstrdup __P((SCR *, const CHAR_T *, size_t)); + */ +CHAR_T * +v_wstrdup(sp, str, len) + SCR *sp; const CHAR_T *str; size_t len; { CHAR_T *copy; - MALLOC(sp, copy, CHAR_T *, len + 1); + MALLOC(sp, copy, CHAR_T *, (len + 1) * sizeof(CHAR_T)); if (copy == NULL) return (NULL); memcpy(copy, str, len * sizeof(CHAR_T)); @@ -142,20 +164,39 @@ v_strdup(sp, str, len) } /* + * PUBLIC: size_t v_strlen __P((const CHAR_T *str)); + */ +size_t +v_strlen(const CHAR_T *str) +{ + size_t len = -1; + + while(str[++len]); + return len; +} + +/* * nget_uslong -- * Get an unsigned long, checking for overflow. * - * PUBLIC: enum nresult nget_uslong __P((u_long *, const char *, char **, int)); + * PUBLIC: enum nresult nget_uslong __P((SCR *, u_long *, const CHAR_T *, CHAR_T **, int)); */ enum nresult -nget_uslong(valp, p, endp, base) +nget_uslong(sp, valp, p, endp, base) + SCR *sp; u_long *valp; - const char *p; - char **endp; + const CHAR_T *p; + CHAR_T **endp; int base; { + CONST char *np; + char *endnp; + size_t nlen; + + INT2CHAR(sp, p, v_strlen(p) + 1, np, nlen); errno = 0; - *valp = strtoul(p, endp, base); + *valp = strtoul(np, &endnp, base); + *endp = (CHAR_T*)p + (endnp - np); if (errno == 0) return (NUM_OK); if (errno == ERANGE && *valp == ULONG_MAX) @@ -167,17 +208,24 @@ nget_uslong(valp, p, endp, base) * nget_slong -- * Convert a signed long, checking for overflow and underflow. * - * PUBLIC: enum nresult nget_slong __P((long *, const char *, char **, int)); + * PUBLIC: enum nresult nget_slong __P((SCR *, long *, const CHAR_T *, CHAR_T **, int)); */ enum nresult -nget_slong(valp, p, endp, base) +nget_slong(sp, valp, p, endp, base) + SCR *sp; long *valp; - const char *p; - char **endp; + const CHAR_T *p; + CHAR_T **endp; int base; { + CONST char *np; + char *endnp; + size_t nlen; + + INT2CHAR(sp, p, v_strlen(p) + 1, np, nlen); errno = 0; - *valp = strtol(p, endp, base); + *valp = strtol(np, &endnp, base); + *endp = (CHAR_T*)p + (endnp - np); if (errno == 0) return (NUM_OK); if (errno == ERANGE) { diff --git a/dist/Makefile.am b/dist/Makefile.am index 1af9c02d..014976ed 100644 --- a/dist/Makefile.am +++ b/dist/Makefile.am @@ -3,8 +3,26 @@ visrcdir= @srcdir@/.. lib_LTLIBRARIES = libvi.la libvi_la_SOURCES = \ $(visrcdir)/common/api.c \ + $(visrcdir)/common/conv.c \ + $(visrcdir)/common/conv.h \ $(visrcdir)/common/cut.c \ $(visrcdir)/common/delete.c \ + $(visrcdir)/common/args.h \ + $(visrcdir)/common/common.h \ + $(visrcdir)/common/cut.h \ + $(visrcdir)/common/db.h \ + $(visrcdir)/common/exf.h \ + $(visrcdir)/common/gs.h \ + $(visrcdir)/common/key.h \ + $(visrcdir)/common/log.h \ + $(visrcdir)/common/mark.h \ + $(visrcdir)/common/mem.h \ + $(visrcdir)/common/msg.h \ + $(visrcdir)/common/options.h \ + $(visrcdir)/common/options_def.h \ + $(visrcdir)/common/screen.h \ + $(visrcdir)/common/seq.h \ + $(visrcdir)/common/util.h \ $(visrcdir)/ex/ex.c \ $(visrcdir)/ex/ex_abbrev.c \ $(visrcdir)/ex/ex_append.c \ @@ -54,8 +72,14 @@ libvi_la_SOURCES = \ $(visrcdir)/ex/ex_write.c \ $(visrcdir)/ex/ex_yank.c \ $(visrcdir)/ex/ex_z.c \ + $(visrcdir)/ex/ex.h \ + $(visrcdir)/ex/ex_def.h \ + $(visrcdir)/ex/script.h \ + $(visrcdir)/ex/tag.h \ + $(visrcdir)/ex/version.h \ $(visrcdir)/common/exf.c \ $(visrcdir)/vi/getc.c \ + $(visrcdir)/vi/vi.h \ $(visrcdir)/common/gs.c \ $(visrcdir)/common/key.c \ $(visrcdir)/common/db.c \ diff --git a/dist/acconfig.h b/dist/acconfig.h index d6143381..3e73008e 100644 --- a/dist/acconfig.h +++ b/dist/acconfig.h @@ -1,4 +1,4 @@ -/* $Id: acconfig.h,v 8.22 2000/07/11 12:15:34 skimo Exp $ (Berkeley) $Date: 2000/07/11 12:15:34 $ */ +/* $Id: acconfig.h,v 8.23 2000/07/14 14:29:18 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:18 $ */ /* Define to `int' if doesn't define. */ #undef ssize_t @@ -87,5 +87,8 @@ /* Define when dynamically loading DB 3 */ #undef USE_DYNAMIC_LOADING +/* Define when using wide characters */ +#undef USE_WIDECHAR + /* Define when fprintf prototype not in an obvious place */ #undef NEED_FPRINTF_PROTO diff --git a/dist/config.h.in b/dist/config.h.in index 9c87ad09..7706ec64 100644 --- a/dist/config.h.in +++ b/dist/config.h.in @@ -118,6 +118,9 @@ /* Define when dynamically loading DB 3 */ #undef USE_DYNAMIC_LOADING +/* Define when using wide characters */ +#undef USE_WIDECHAR + /* Define when fprintf prototype not in an obvious place */ #undef NEED_FPRINTF_PROTO diff --git a/dist/configure.in b/dist/configure.in index f596b97e..492cc2d8 100644 --- a/dist/configure.in +++ b/dist/configure.in @@ -207,6 +207,15 @@ if test "$no_x" != yes; then fi fi +dnl Check if the user wants widechar support. +AC_MSG_CHECKING(if --enable-widechar option specified) +AC_ARG_ENABLE(widechar, + [ --enable-widechar Build a wide char aware vi.], + [vi_cv_widechar="yes"], [vi_cv_widechar="no"]) +if test "$vi_cv_widechar" = "yes"; then + AC_DEFINE(USE_WIDECHAR) +fi + dnl If the user wants a Gtk IPC front-end for nvi, build it. AC_SUBST(vi_ipc) AC_SUBST(vi_gtk) diff --git a/ex/ex.c b/ex/ex.c index 6a954681..fc58d438 100644 --- a/ex/ex.c +++ b/ex/ex.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex.c,v 10.65 2000/07/11 22:05:10 skimo Exp $ (Berkeley) $Date: 2000/07/11 22:05:10 $"; +static const char sccsid[] = "$Id: ex.c,v 10.66 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $"; #endif /* not lint */ #include @@ -35,11 +35,11 @@ static const char sccsid[] = "$Id: ex.c,v 10.65 2000/07/11 22:05:10 skimo Exp $ static void ex_comlog __P((SCR *, EXCMD *)); #endif static EXCMDLIST const * - ex_comm_search __P((char *, size_t)); + ex_comm_search __P((SCR *, CHAR_T *, size_t)); static int ex_discard __P((SCR *)); static int ex_line __P((SCR *, EXCMD *, MARK *, int *, int *)); static int ex_load __P((SCR *)); -static void ex_unknown __P((SCR *, char *, size_t)); +static void ex_unknown __P((SCR *, CHAR_T *, size_t)); /* * ex -- @@ -124,7 +124,8 @@ ex(spp) */ tp = sp->tiq.cqh_first; if (tp->len == 0) { - wp->excmd.cp = " "; /* __TK__ why not |? */ + static CHAR_T space; + wp->excmd.cp = &space; /* __TK__ why not |? */ wp->excmd.clen = 1; } else { wp->excmd.cp = tp->lb; @@ -210,7 +211,8 @@ ex_cmd(sp) int at_found, gv_found; int ch, cnt, delim, isaddr, namelen; int newscreen, notempty, tmp, vi_address; - char *arg1, *p, *s, *t; + CHAR_T *arg1, *s, *p, *t; + char *n; gp = sp->gp; wp = sp->wp; @@ -419,7 +421,7 @@ loop: ecp = wp->ecq.lh_first; switch (p[0]) { case 'd': for (s = p, - t = cmds[C_DELETE].name; *s == *t; ++s, ++t); + n = cmds[C_DELETE].name; *s == *n; ++s, ++n); if (s[0] == 'l' || s[0] == 'p' || s[0] == '+' || s[0] == '-' || s[0] == '^' || s[0] == '#') { len = (ecp->cp - p) - (s - p); @@ -455,7 +457,7 @@ loop: ecp = wp->ecq.lh_first; * follows the 's', but we limit the choices here to "cgr" so * that we get unknown command messages for wrong combinations. */ - if ((ecp->cmd = ex_comm_search(p, namelen)) == NULL) + if ((ecp->cmd = ex_comm_search(sp, p, namelen)) == NULL) switch (p[0]) { case 'k': if (namelen == 2) { @@ -940,13 +942,13 @@ two_addr: switch (ecp->addrcnt) { } ecp->flagoff = 0; - for (p = ecp->cmd->syntax; *p != '\0'; ++p) { + for (n = ecp->cmd->syntax; *n != '\0'; ++n) { /* * The force flag is sensitive to leading whitespace, i.e. * "next !" is different from "next!". Handle it before * skipping leading s. */ - if (*p == '!') { + if (*n == '!') { if (ecp->clen > 0 && *ecp->cp == '!') { ++ecp->cp; --ecp->clen; @@ -962,7 +964,7 @@ two_addr: switch (ecp->addrcnt) { if (ecp->clen == 0) break; - switch (*p) { + switch (*n) { case '1': /* +, -, #, l, p */ /* * !!! @@ -1017,7 +1019,7 @@ end_case1: break; FL_SET(ecp->iflags, E_C_CARAT); break; case '=': - if (*p == '3') { + if (*n == '3') { FL_SET(ecp->iflags, E_C_EQUAL); break; } @@ -1037,7 +1039,7 @@ end_case23: break; */ if ((ecp->cp[0] == '+' || ecp->cp[0] == '-' || ecp->cp[0] == '^' || ecp->cp[0] == '#') && - strchr(p, '1') != NULL) + strchr(n, '1') != NULL) break; /* * !!! @@ -1053,9 +1055,9 @@ end_case23: break; } break; case 'c': /* count [01+a] */ - ++p; + ++n; /* Validate any signed value. */ - if (!isdigit(*ecp->cp) && (*p != '+' || + if (!isdigit(*ecp->cp) && (*n != '+' || (*ecp->cp != '+' && *ecp->cp != '-'))) break; /* If a signed value, set appropriate flags. */ @@ -1064,11 +1066,11 @@ end_case23: break; else if (*ecp->cp == '+') FL_SET(ecp->iflags, E_C_COUNT_POS); if ((nret = - nget_slong(<mp, ecp->cp, &t, 10)) != NUM_OK) { + nget_slong(sp, <mp, ecp->cp, &t, 10)) != NUM_OK) { ex_badaddr(sp, NULL, A_NOTSET, nret); goto err; } - if (ltmp == 0 && *p != '0') { + if (ltmp == 0 && *n != '0') { msgq(sp, M_ERR, "083|Count may not be zero"); goto err; } @@ -1084,7 +1086,7 @@ end_case23: break; * join) do different things with counts than with * line addresses. */ - if (*p == 'a') { + if (*n == 'a') { ecp->addr1 = ecp->addr2; ecp->addr2.lno = ecp->addr1.lno + ltmp - 1; } else @@ -1111,7 +1113,7 @@ end_case23: break; /* Line specifications are always required. */ if (!isaddr) { - msgq_str(sp, M_ERR, ecp->cp, + msgq_wstr(sp, M_ERR, ecp->cp, "084|%s: bad line specification"); goto err; } @@ -1191,14 +1193,14 @@ end_case23: break; case 'w': /* word */ if (argv_exp3(sp, ecp, ecp->cp, ecp->clen)) goto err; -arg_cnt_chk: if (*++p != 'N') { /* N */ +arg_cnt_chk: if (*++n != 'N') { /* N */ /* * If a number is specified, must either be * 0 or that number, if optional, and that * number, if required. */ - tmp = *p - '0'; - if ((*++p != 'o' || exp->argsoff != 0) && + tmp = *n - '0'; + if ((*++n != 'o' || exp->argsoff != 0) && exp->argsoff != tmp) goto usage; } @@ -1206,7 +1208,7 @@ arg_cnt_chk: if (*++p != 'N') { /* N */ default: msgq(sp, M_ERR, "085|Internal syntax table error (%s: %s)", - ecp->cmd->name, KEY_NAME(sp, *p)); + ecp->cmd->name, KEY_NAME(sp, *n)); } } @@ -1221,7 +1223,7 @@ arg_cnt_chk: if (*++p != 'N') { /* N */ * There shouldn't be anything left, and no more required fields, * i.e neither 'l' or 'r' in the syntax string. */ - if (ecp->clen != 0 || strpbrk(p, "lr")) { + if (ecp->clen != 0 || strpbrk(n, "lr")) { usage: msgq(sp, M_ERR, "086|Usage: %s", ecp->cmd->usage); goto err; } @@ -1827,8 +1829,8 @@ ex_line(sp, ecp, mp, isaddrp, errp) GS *gp; long total, val; int isneg; - int (*sf) __P((SCR *, MARK *, MARK *, char *, size_t, char **, u_int)); - char *endp; + int (*sf) __P((SCR *, MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int)); + CHAR_T *endp; gp = sp->gp; exp = EXP(sp); @@ -1859,7 +1861,7 @@ ex_line(sp, ecp, mp, isaddrp, errp) *isaddrp = 1; F_SET(ecp, E_ABSMARK); - if ((nret = nget_slong(&val, ecp->cp, &endp, 10)) != NUM_OK) { + if ((nret = nget_slong(sp, &val, ecp->cp, &endp, 10)) != NUM_OK) { ex_badaddr(sp, NULL, A_NOTSET, nret); *errp = 1; return (0); @@ -2023,7 +2025,7 @@ search: mp->lno = sp->lno; isneg = 0; /* Get a signed long, add it to the total. */ - if ((nret = nget_slong(&val, + if ((nret = nget_slong(sp, &val, ecp->cp, &endp, 10)) != NUM_OK || (nret = NADD_SLONG(sp, total, val)) != NUM_OK) { @@ -2194,16 +2196,16 @@ ex_discard(sp) static void ex_unknown(sp, cmd, len) SCR *sp; - char *cmd; + CHAR_T *cmd; size_t len; { size_t blen; - char *bp; + CHAR_T *bp; - GET_SPACE_GOTO(sp, bp, blen, len + 1); + GET_SPACE_GOTO(sp, bp, blen, (len + 1) * sizeof(CHAR_T)); bp[len] = '\0'; - memcpy(bp, cmd, len); - msgq_str(sp, M_ERR, bp, "098|The %s command is unknown"); + memcpy(bp, cmd, len * sizeof(CHAR_T)); + msgq_wstr(sp, M_ERR, bp, "098|The %s command is unknown"); FREE_SPACE(sp, bp, blen); alloc_err: @@ -2216,16 +2218,14 @@ alloc_err: * [un]abbreviate command, so it can turn off abbreviations. See * the usual ranting in the vi/v_txt_ev.c:txt_abbrev() routine. * - * PUBLIC: int ex_is_abbrev __P((char *, size_t)); + * PUBLIC: int ex_is_abbrev __P((SCR *, CHAR_T *, size_t)); */ int -ex_is_abbrev(name, len) - char *name; - size_t len; +ex_is_abbrev(SCR *sp, CHAR_T *name, size_t len) { EXCMDLIST const *cp; - return ((cp = ex_comm_search(name, len)) != NULL && + return ((cp = ex_comm_search(sp, name, len)) != NULL && (cp == &cmds[C_ABBR] || cp == &cmds[C_UNABBREVIATE])); } @@ -2235,12 +2235,10 @@ ex_is_abbrev(name, len) * unmap command, so it can turn off input mapping. See the usual * ranting in the vi/v_txt_ev.c:txt_unmap() routine. * - * PUBLIC: int ex_is_unmap __P((char *, size_t)); + * PUBLIC: int ex_is_unmap __P((SCR *, CHAR_T *, size_t)); */ int -ex_is_unmap(name, len) - char *name; - size_t len; +ex_is_unmap(SCR *sp, CHAR_T *name, size_t len) { EXCMDLIST const *cp; @@ -2251,7 +2249,7 @@ ex_is_unmap(name, len) if (name[len - 1] != '!') return (0); --len; - return ((cp = ex_comm_search(name, len)) != NULL && + return ((cp = ex_comm_search(sp, name, len)) != NULL && cp == &cmds[C_UNMAP]); } @@ -2260,18 +2258,20 @@ ex_is_unmap(name, len) * Search for a command name. */ static EXCMDLIST const * -ex_comm_search(name, len) - char *name; - size_t len; +ex_comm_search(SCR *sp, CHAR_T *name, size_t len) { EXCMDLIST const *cp; + size_t nlen; + char *nname; + + INT2CHAR(sp, name, len, nname, nlen); for (cp = cmds; cp->name != NULL; ++cp) { - if (cp->name[0] > name[0]) + if (cp->name[0] > nname[0]) return (NULL); - if (cp->name[0] != name[0]) + if (cp->name[0] != nname[0]) continue; - if (!memcmp(name, cp->name, len)) + if (!memcmp(nname, cp->name, len)) return (cp); } return (NULL); diff --git a/ex/ex.h b/ex/ex.h index 3de0a88a..4e472a55 100644 --- a/ex/ex.h +++ b/ex/ex.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: ex.h,v 10.26 2000/04/21 19:00:35 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:35 $ + * $Id: ex.h,v 10.27 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $ */ #define PROMPTCHAR ':' /* Prompt using a colon. */ @@ -80,10 +80,10 @@ struct _excmd { memset(&((cmdp)->cp), 0, ((char *)&(cmdp)->flags - \ (char *)&((cmdp)->cp)) + sizeof((cmdp)->flags)) - char *cp; /* Current command text. */ + CHAR_T *cp; /* Current command text. */ size_t clen; /* Current command length. */ - char *save_cmd; /* Remaining command. */ + CHAR_T *save_cmd; /* Remaining command. */ size_t save_cmdlen; /* Remaining command length. */ EXCMDLIST const *cmd; /* Command: entry in command table. */ @@ -91,7 +91,7 @@ struct _excmd { CIRCLEQ_HEAD(_rh, _range) rq; /* @/global range: linked list. */ db_recno_t range_lno; /* @/global range: set line number. */ - char *o_cp; /* Original @/global command. */ + CHAR_T *o_cp; /* Original @/global command. */ size_t o_clen; /* Original @/global command length. */ #define AGV_AT 0x01 /* @ buffer execution. */ #define AGV_AT_NORANGE 0x02 /* @ buffer execution without range. */ @@ -160,7 +160,7 @@ typedef struct _ex_private { CIRCLEQ_HEAD(_tqh, _tagq) tq; /* Tag queue. */ TAILQ_HEAD(_tagfh, _tagf) tagfq;/* Tag file list. */ LIST_HEAD(_csch, _csc) cscq; /* Cscope connection list. */ - char *tag_last; /* Saved last tag string. */ + CHAR_T *tag_last; /* Saved last tag string. */ CHAR_T *lastbcomm; /* Last bang command. */ @@ -170,7 +170,7 @@ typedef struct _ex_private { u_int32_t fdef; /* Saved E_C_* default command flags. */ - char *ibp; /* File line input buffer. */ + CHAR_T *ibp; /* File line input buffer. */ size_t ibp_len; /* File line input buffer length. */ /* diff --git a/ex/ex_abbrev.c b/ex/ex_abbrev.c index 094a42e2..92c94f06 100644 --- a/ex/ex_abbrev.c +++ b/ex/ex_abbrev.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_abbrev.c,v 10.7 1996/03/06 19:52:03 bostic Exp $ (Berkeley) $Date: 1996/03/06 19:52:03 $"; +static const char sccsid[] = "$Id: ex_abbrev.c,v 10.8 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $"; #endif /* not lint */ #include @@ -109,7 +109,7 @@ ex_unabbr(sp, cmdp) ap = cmdp->argv[0]; if (!F_ISSET(sp->gp, G_ABBREV) || seq_delete(sp, ap->bp, ap->len, SEQ_ABBREV)) { - msgq_str(sp, M_ERR, ap->bp, + msgq_wstr(sp, M_ERR, ap->bp, "109|\"%s\" is not an abbreviation"); return (1); } diff --git a/ex/ex_append.c b/ex/ex_append.c index 702ab1e9..ffc0c121 100644 --- a/ex/ex_append.c +++ b/ex/ex_append.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_append.c,v 10.31 2000/04/21 19:00:35 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:35 $"; +static const char sccsid[] = "$Id: ex_append.c,v 10.32 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $"; #endif /* not lint */ #include @@ -175,7 +175,7 @@ ex_aci(sp, cmdp, cmd) if (len != 0) { ++t; if (--len == 0 && - db_append(sp, 1, lno++, "", 0)) + db_append(sp, 1, lno++, NULL, 0)) return (1); } } diff --git a/ex/ex_args.c b/ex/ex_args.c index d1fa4585..7e2956e4 100644 --- a/ex/ex_args.c +++ b/ex/ex_args.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_args.c,v 10.16 1996/07/13 14:31:08 bostic Exp $ (Berkeley) $Date: 1996/07/13 14:31:08 $"; +static const char sccsid[] = "$Id: ex_args.c,v 10.17 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $"; #endif /* not lint */ #include @@ -50,6 +50,10 @@ ex_next(sp, cmdp) FREF *frp; int noargs; char **ap; + CHAR_T *wp; + size_t wlen; + char *np; + size_t nlen; /* Check for file to move to. */ if (cmdp->argc == 0 && (sp->cargv == NULL || sp->cargv[1] == NULL)) { @@ -60,8 +64,9 @@ ex_next(sp, cmdp) if (F_ISSET(cmdp, E_NEWSCREEN)) { /* By default, edit the next file in the old argument list. */ if (cmdp->argc == 0) { - if (argv_exp0(sp, - cmdp, sp->cargv[1], strlen(sp->cargv[1]))) + CHAR2INT(sp, sp->cargv[1], strlen(sp->cargv[1]) + 1, + wp, wlen); + if (argv_exp0(sp, cmdp, wp, wlen - 1)) return (1); return (ex_edit(sp, cmdp)); } @@ -88,10 +93,11 @@ ex_next(sp, cmdp) CALLOC_RET(sp, sp->argv, char **, cmdp->argc + 1, sizeof(char *)); for (ap = sp->argv, - argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) - if ((*ap = - v_strdup(sp, argv[0]->bp, argv[0]->len)) == NULL) + argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) { + INT2CHAR(sp, argv[0]->bp, argv[0]->len, np, nlen); + if ((*ap = v_strdup(sp, np, nlen)) == NULL) return (1); + } *ap = NULL; /* Switch to the first file. */ @@ -131,6 +137,8 @@ ex_N_next(sp, cmdp) { SCR *new; FREF *frp; + char *np; + size_t nlen; /* Get a new screen. */ if (screen_init(sp->gp, sp, &new)) @@ -141,7 +149,8 @@ ex_N_next(sp, cmdp) } /* Get a backing file. */ - if ((frp = file_add(new, cmdp->argv[0]->bp)) == NULL || + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, np, nlen); + if ((frp = file_add(new, np)) == NULL || file_init(new, frp, NULL, (FL_ISSET(cmdp->iflags, E_C_FORCE) ? FS_FORCE : 0))) { (void)vs_discard(new, NULL); @@ -174,6 +183,8 @@ ex_prev(sp, cmdp) EXCMD *cmdp; { FREF *frp; + size_t wlen; + CHAR_T *wp; if (sp->cargv == sp->argv) { msgq(sp, M_ERR, "112|No previous files to edit"); @@ -181,7 +192,9 @@ ex_prev(sp, cmdp) } if (F_ISSET(cmdp, E_NEWSCREEN)) { - if (argv_exp0(sp, cmdp, sp->cargv[-1], strlen(sp->cargv[-1]))) + CHAR2INT(sp, sp->cargv[-1], strlen(sp->cargv[-1]) + 1, + wp, wlen); + if (argv_exp0(sp, cmdp, wp, wlen - 1)) return (1); return (ex_edit(sp, cmdp)); } @@ -307,6 +320,8 @@ ex_buildargv(sp, cmdp, name) ARGS **argv; int argc; char **ap, **s_argv; + char *np; + size_t nlen; argc = cmdp == NULL ? 1 : cmdp->argc; CALLOC(sp, s_argv, char **, argc + 1, sizeof(char *)); @@ -318,10 +333,12 @@ ex_buildargv(sp, cmdp, name) return (NULL); ++ap; } else - for (argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) - if ((*ap = - v_strdup(sp, argv[0]->bp, argv[0]->len)) == NULL) + for (argv = cmdp->argv; argv[0]->len != 0; ++ap, ++argv) { + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len, + np, nlen); + if ((*ap = v_strdup(sp, np, nlen)) == NULL) return (NULL); + } *ap = NULL; return (s_argv); } diff --git a/ex/ex_argv.c b/ex/ex_argv.c index 9bd25ad0..3753e8ef 100644 --- a/ex/ex_argv.c +++ b/ex/ex_argv.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_argv.c,v 10.28 1996/12/17 14:50:33 bostic Exp $ (Berkeley) $Date: 1996/12/17 14:50:33 $"; +static const char sccsid[] = "$Id: ex_argv.c,v 10.29 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $"; #endif /* not lint */ #include @@ -31,9 +31,9 @@ static const char sccsid[] = "$Id: ex_argv.c,v 10.28 1996/12/17 14:50:33 bostic static int argv_alloc __P((SCR *, size_t)); static int argv_comp __P((const void *, const void *)); static int argv_fexp __P((SCR *, EXCMD *, - char *, size_t, char *, size_t *, char **, size_t *, int)); + CHAR_T *, size_t, CHAR_T *, size_t *, CHAR_T **, size_t *, int)); static int argv_lexp __P((SCR *, EXCMD *, char *)); -static int argv_sexp __P((SCR *, char **, size_t *, size_t *)); +static int argv_sexp __P((SCR *, CHAR_T **, size_t *, size_t *)); /* * argv_init -- @@ -61,20 +61,20 @@ argv_init(sp, excp) * argv_exp0 -- * Append a string to the argument list. * - * PUBLIC: int argv_exp0 __P((SCR *, EXCMD *, char *, size_t)); + * PUBLIC: int argv_exp0 __P((SCR *, EXCMD *, CHAR_T *, size_t)); */ int argv_exp0(sp, excp, cmd, cmdlen) SCR *sp; EXCMD *excp; - char *cmd; + CHAR_T *cmd; size_t cmdlen; { EX_PRIVATE *exp; exp = EXP(sp); argv_alloc(sp, cmdlen); - memcpy(exp->args[exp->argsoff]->bp, cmd, cmdlen); + memcpy(exp->args[exp->argsoff]->bp, cmd, cmdlen * sizeof(CHAR_T)); exp->args[exp->argsoff]->bp[cmdlen] = '\0'; exp->args[exp->argsoff]->len = cmdlen; ++exp->argsoff; @@ -88,19 +88,21 @@ argv_exp0(sp, excp, cmd, cmdlen) * Do file name expansion on a string, and append it to the * argument list. * - * PUBLIC: int argv_exp1 __P((SCR *, EXCMD *, char *, size_t, int)); + * PUBLIC: int argv_exp1 __P((SCR *, EXCMD *, CHAR_T *, size_t, int)); */ int argv_exp1(sp, excp, cmd, cmdlen, is_bang) SCR *sp; EXCMD *excp; - char *cmd; + CHAR_T *cmd; size_t cmdlen; int is_bang; { EX_PRIVATE *exp; size_t blen, len; - char *bp, *p, *t; + CHAR_T *p, *t, *bp; + size_t wlen; + CHAR_T *wp; GET_SPACE_RET(sp, bp, blen, 512); @@ -132,25 +134,30 @@ ret: FREE_SPACE(sp, bp, blen); * Do file name and shell expansion on a string, and append it to * the argument list. * - * PUBLIC: int argv_exp2 __P((SCR *, EXCMD *, char *, size_t)); + * PUBLIC: int argv_exp2 __P((SCR *, EXCMD *, CHAR_T *, size_t)); */ int argv_exp2(sp, excp, cmd, cmdlen) SCR *sp; EXCMD *excp; - char *cmd; + CHAR_T *cmd; size_t cmdlen; { size_t blen, len, n; int rval; - char *bp, *mp, *p; + CHAR_T *bp, *p; + char *mp, *np; GET_SPACE_RET(sp, bp, blen, 512); #define SHELLECHO "echo " #define SHELLOFFSET (sizeof(SHELLECHO) - 1) - memcpy(bp, SHELLECHO, SHELLOFFSET); - p = bp + SHELLOFFSET; + p = bp; + *p++ = 'e'; + *p++ = 'c'; + *p++ = 'h'; + *p++ = 'o'; + *p++ = ' '; len = SHELLOFFSET; #if defined(DEBUG) && 0 @@ -183,8 +190,8 @@ argv_exp2(sp, excp, cmd, cmdlen) if (opts_empty(sp, O_SHELL, 1) || opts_empty(sp, O_SHELLMETA, 1)) n = 0; else { - for (p = mp = O_STR(sp, O_SHELLMETA); *p != '\0'; ++p) - if (isblank(*p) || isalnum(*p)) + for (np = mp = O_STR(sp, O_SHELLMETA); *np != '\0'; ++np) + if (isblank(*np) || isalnum(*np)) break; p = bp + SHELLOFFSET; n = len - SHELLOFFSET; @@ -220,8 +227,15 @@ argv_exp2(sp, excp, cmd, cmdlen) break; case 1: if (*p == '*') { + char *np, *d; + size_t nlen; + *p = '\0'; - rval = argv_lexp(sp, excp, bp + SHELLOFFSET); + INT2CHAR(sp, bp + SHELLOFFSET, + v_strlen(bp + SHELLOFFSET) + 1, np, nlen); + d = strdup(np); + rval = argv_lexp(sp, excp, d); + free (d); break; } /* FALLTHROUGH */ @@ -244,19 +258,19 @@ err: FREE_SPACE(sp, bp, blen); * Take a string and break it up into an argv, which is appended * to the argument list. * - * PUBLIC: int argv_exp3 __P((SCR *, EXCMD *, char *, size_t)); + * PUBLIC: int argv_exp3 __P((SCR *, EXCMD *, CHAR_T *, size_t)); */ int argv_exp3(sp, excp, cmd, cmdlen) SCR *sp; EXCMD *excp; - char *cmd; + CHAR_T *cmd; size_t cmdlen; { EX_PRIVATE *exp; size_t len; int ch, off; - char *ap, *p; + CHAR_T *ap, *p; for (exp = EXP(sp); cmdlen > 0; ++exp->argsoff) { /* Skip any leading whitespace. */ @@ -319,13 +333,14 @@ static int argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang) SCR *sp; EXCMD *excp; - char *cmd, *p, **bpp; + CHAR_T *cmd, *p, **bpp; size_t cmdlen, *lenp, *blenp; int is_bang; { EX_PRIVATE *exp; - char *bp, *t; + char *t; size_t blen, len, off, tlen; + CHAR_T *bp; /* Replace file name characters. */ for (bp = *bpp, blen = *blenp, len = *lenp; cmdlen > 0; --cmdlen, ++cmd) @@ -339,7 +354,7 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang) "115|No previous command to replace \"!\""); return (1); } - len += tlen = strlen(exp->lastbcomm); + len += tlen = v_strlen(exp->lastbcomm); off = p - bp; ADD_SPACE_RET(sp, bp, blen, len); p = bp + off; @@ -512,17 +527,18 @@ argv_free(sp) * buffer. */ static int -argv_lexp(sp, excp, path) - SCR *sp; - EXCMD *excp; - char *path; +argv_lexp(SCR *sp, EXCMD *excp, char *path) { struct dirent *dp; DIR *dirp; EX_PRIVATE *exp; int off; size_t dlen, len, nlen; - char *dname, *name, *p; + char *dname, *name; + char *p; + size_t wlen; + CHAR_T *wp; + CHAR_T *n; exp = EXP(sp); @@ -566,14 +582,16 @@ argv_lexp(sp, excp, path) /* Directory + name + slash + null. */ argv_alloc(sp, dlen + len + 2); - p = exp->args[exp->argsoff]->bp; + n = exp->args[exp->argsoff]->bp; if (dlen != 0) { - memcpy(p, dname, dlen); - p += dlen; + CHAR2INT(sp, dname, dlen, wp, wlen); + memcpy(n, wp, wlen * sizeof(CHAR_T)); + n += dlen; if (dlen > 1 || dname[0] != '/') - *p++ = '/'; + *n++ = '/'; } - memcpy(p, dp->d_name, len + 1); + CHAR2INT(sp, dp->d_name, len + 1, wp, wlen); + memcpy(n, wp, wlen * sizeof(CHAR_T)); exp->args[exp->argsoff]->len = dlen + len + 1; ++exp->argsoff; excp->argv = exp->args; @@ -613,7 +631,7 @@ argv_comp(a, b) static int argv_sexp(sp, bpp, blenp, lenp) SCR *sp; - char **bpp; + CHAR_T **bpp; size_t *blenp, *lenp; { enum { SEXP_ERR, SEXP_EXPANSION_ERR, SEXP_OK } rval; @@ -621,7 +639,8 @@ argv_sexp(sp, bpp, blenp, lenp) pid_t pid; size_t blen, len; int ch, std_output[2]; - char *bp, *p, *sh, *sh_path; + CHAR_T *bp, *p; + char *sh, *sh_path; /* Secure means no shell access. */ if (O_ISSET(sp, O_SECURE)) { diff --git a/ex/ex_at.c b/ex/ex_at.c index c5f66ca9..4761b20a 100644 --- a/ex/ex_at.c +++ b/ex/ex_at.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_at.c,v 10.13 2000/06/25 17:34:39 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:39 $"; +static const char sccsid[] = "$Id: ex_at.c,v 10.14 2000/07/14 14:29:19 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:19 $"; #endif /* not lint */ #include @@ -44,7 +44,7 @@ ex_at(sp, cmdp) RANGE *rp; TEXT *tp; size_t len; - char *p; + CHAR_T *p; /* * !!! @@ -108,7 +108,7 @@ ex_at(sp, cmdp) tp != (void *)&cbp->textq; tp = tp->q.cqe_prev) len += tp->len + 1; - MALLOC_RET(sp, ecp->cp, char *, len * 2); + MALLOC_RET(sp, ecp->cp, CHAR_T *, len * 2 * sizeof(CHAR_T)); ecp->o_cp = ecp->cp; ecp->o_clen = len; ecp->cp[len] = '\0'; diff --git a/ex/ex_bang.c b/ex/ex_bang.c index 534ce128..6ef5f960 100644 --- a/ex/ex_bang.c +++ b/ex/ex_bang.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_bang.c,v 10.34 2000/04/21 19:00:35 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:35 $"; +static const char sccsid[] = "$Id: ex_bang.c,v 10.35 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -58,6 +58,8 @@ ex_bang(sp, cmdp) db_recno_t lno; int rval; const char *msg; + char *np; + size_t nlen; ap = cmdp->argv[0]; if (ap->len == 0) { @@ -69,7 +71,7 @@ ex_bang(sp, cmdp) exp = EXP(sp); if (exp->lastbcomm != NULL) free(exp->lastbcomm); - if ((exp->lastbcomm = strdup(ap->bp)) == NULL) { + if ((exp->lastbcomm = v_wstrdup(sp, ap->bp, ap->len)) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); } @@ -112,8 +114,9 @@ ex_bang(sp, cmdp) NULL); /* If we're still in a vi screen, move out explicitly. */ + INT2CHAR(sp, ap->bp, ap->len+1, np, nlen); (void)ex_exec_proc(sp, - cmdp, ap->bp, msg, !F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)); + cmdp, np, msg, !F_ISSET(sp, SC_EX | SC_SCR_EXWROTE)); } /* diff --git a/ex/ex_cd.c b/ex/ex_cd.c index 0e447e1f..6fe8b002 100644 --- a/ex/ex_cd.c +++ b/ex/ex_cd.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_cd.c,v 10.10 1996/08/12 20:23:59 bostic Exp $ (Berkeley) $Date: 1996/08/12 20:23:59 $"; +static const char sccsid[] = "$Id: ex_cd.c,v 10.11 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -43,6 +43,7 @@ ex_cd(sp, cmdp) CHAR_T savech; char *dir, *p, *t; /* XXX: END OF THE STACK, DON'T TRUST GETCWD. */ char buf[MAXPATHLEN * 2]; + size_t dlen; /* * !!! @@ -71,7 +72,8 @@ ex_cd(sp, cmdp) } break; case 1: - dir = cmdp->argv[0]->bp; + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, + dir, dlen); break; default: abort(); diff --git a/ex/ex_cscope.c b/ex/ex_cscope.c index 8a12275a..72164843 100644 --- a/ex/ex_cscope.c +++ b/ex/ex_cscope.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_cscope.c,v 10.15 2000/04/21 19:00:35 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:35 $"; +static const char sccsid[] = "$Id: ex_cscope.c,v 10.16 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -62,15 +62,15 @@ find c|d|e|f|g|i|s|t buffer|pattern\n\ s: find all uses of name\n\ t: find assignments to name" -static int cscope_add __P((SCR *, EXCMD *, char *)); -static int cscope_find __P((SCR *, EXCMD*, char *)); -static int cscope_help __P((SCR *, EXCMD *, char *)); -static int cscope_kill __P((SCR *, EXCMD *, char *)); -static int cscope_reset __P((SCR *, EXCMD *, char *)); +static int cscope_add __P((SCR *, EXCMD *, CHAR_T *)); +static int cscope_find __P((SCR *, EXCMD*, CHAR_T *)); +static int cscope_help __P((SCR *, EXCMD *, CHAR_T *)); +static int cscope_kill __P((SCR *, EXCMD *, CHAR_T *)); +static int cscope_reset __P((SCR *, EXCMD *, CHAR_T *)); typedef struct _cc { char *name; - int (*function) __P((SCR *, EXCMD *, char *)); + int (*function) __P((SCR *, EXCMD *, CHAR_T *)); char *help_msg; char *usage_msg; } CC; @@ -115,7 +115,10 @@ ex_cscope(sp, cmdp) CC const *ccp; EX_PRIVATE *exp; int i; - char *cmd, *p; + CHAR_T *cmd; + CHAR_T *p; + char *np; + size_t nlen; /* Initialize the default cscope directories. */ exp = EXP(sp); @@ -139,7 +142,8 @@ ex_cscope(sp, cmdp) for (; *p && isspace(*p); ++p); } - if ((ccp = lookup_ccmd(cmd)) == NULL) { + INT2CHAR(sp, cmd, v_strlen(cmd) + 1, np, nlen); + if ((ccp = lookup_ccmd(np)) == NULL) { usage: msgq(sp, M_ERR, "309|Use \"cscope help\" for help"); return (1); } @@ -159,6 +163,8 @@ start_cscopes(sp, cmdp) { size_t blen, len; char *bp, *cscopes, *p, *t; + CHAR_T *wp; + size_t wlen; /* * EXTENSION #1: @@ -179,8 +185,10 @@ start_cscopes(sp, cmdp) memcpy(bp, cscopes, len + 1); for (cscopes = t = bp; (p = strsep(&t, "\t :")) != NULL;) - if (*p != '\0') - (void)cscope_add(sp, cmdp, p); + if (*p != '\0') { + CHAR2INT(sp, p, strlen(p) + 1, wp, wlen); + (void)cscope_add(sp, cmdp, wp); + } FREE_SPACE(sp, bp, blen); return (0); @@ -194,7 +202,7 @@ static int cscope_add(sp, cmdp, dname) SCR *sp; EXCMD *cmdp; - char *dname; + CHAR_T *dname; { struct stat sb; EX_PRIVATE *exp; @@ -202,6 +210,8 @@ cscope_add(sp, cmdp, dname) size_t len; int cur_argc; char *dbname, path[MAXPATHLEN]; + char *np; + size_t nlen; exp = EXP(sp); @@ -211,8 +221,9 @@ cscope_add(sp, cmdp, dname) * >1 additional args: object, too many args. */ cur_argc = cmdp->argc; - if (argv_exp2(sp, cmdp, dname, strlen(dname))) + if (argv_exp2(sp, cmdp, dname, v_strlen(dname))) { return (1); + } if (cmdp->argc == cur_argc) { (void)csc_help(sp, "add"); return (1); @@ -220,10 +231,12 @@ cscope_add(sp, cmdp, dname) if (cmdp->argc == cur_argc + 1) dname = cmdp->argv[cur_argc]->bp; else { - ex_emsg(sp, dname, EXM_FILECOUNT); + ex_emsg(sp, np, EXM_FILECOUNT); return (1); } + INT2CHAR(sp, dname, v_strlen(dname)+1, np, nlen); + /* * The user can specify a specific file (so they can have multiple * Cscope databases in a single directory) or a directory. If the @@ -231,27 +244,27 @@ cscope_add(sp, cmdp, dname) * standard database file name and try again. Store the directory * name regardless so that we can use it as a base for searches. */ - if (stat(dname, &sb)) { - msgq(sp, M_SYSERR, dname); + if (stat(np, &sb)) { + msgq(sp, M_SYSERR, np); return (1); } if (S_ISDIR(sb.st_mode)) { (void)snprintf(path, sizeof(path), - "%s/%s", dname, CSCOPE_DBFILE); + "%s/%s", np, CSCOPE_DBFILE); if (stat(path, &sb)) { msgq(sp, M_SYSERR, path); return (1); } dbname = CSCOPE_DBFILE; - } else if ((dbname = strrchr(dname, '/')) != NULL) + } else if ((dbname = strrchr(np, '/')) != NULL) *dbname++ = '\0'; /* Allocate a cscope connection structure and initialize its fields. */ - len = strlen(dname); + len = strlen(np); CALLOC_RET(sp, csc, CSC *, 1, sizeof(CSC) + len); csc->dname = csc->buf; csc->dlen = len; - memcpy(csc->dname, dname, len); + memcpy(csc->dname, np, len); csc->mtime = sb.st_mtime; /* Get the search paths for the cscope. */ @@ -434,7 +447,7 @@ static int cscope_find(sp, cmdp, pattern) SCR *sp; EXCMD *cmdp; - char *pattern; + CHAR_T *pattern; { CSC *csc, *csc_next; EX_PRIVATE *exp; @@ -444,6 +457,8 @@ cscope_find(sp, cmdp, pattern) db_recno_t lno; size_t cno, search; int force, istmp, matches; + char *np = NULL; + size_t nlen; exp = EXP(sp); @@ -472,7 +487,9 @@ cscope_find(sp, cmdp, pattern) } /* Create the cscope command. */ - if ((tqp = create_cs_cmd(sp, pattern, &search)) == NULL) + INT2CHAR(sp, pattern, v_strlen(pattern) + 1, np, nlen); + np = strdup(np); + if ((tqp = create_cs_cmd(sp, np, &search)) == NULL) goto err; /* @@ -570,6 +587,8 @@ alloc_err: free(rtqp); if (rtp != NULL) free(rtp); + if (np != NULL) + free(np); return (1); } @@ -625,8 +644,8 @@ usage: (void)csc_help(sp, "find"); if (p[0] == '"' && p[1] != '\0' && p[2] == '\0') CBNAME(sp, cbp, p[1]); if (cbp != NULL) { - p = cbp->textq.cqh_first->lb; - tlen = cbp->textq.cqh_first->len; + INT2CHAR(sp, cbp->textq.cqh_first->lb, + cbp->textq.cqh_first->len, p, tlen); } else tlen = strlen(p); @@ -739,7 +758,7 @@ parse(sp, csc, tqp, matchesp) */ CALLOC_RET(sp, tp, TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 + slen + 1); - tp->fname = tp->buf; + tp->fname = (char *)tp->buf; if (dlen != 0) { memcpy(tp->fname, dname, dlen); tp->fname[dlen] = '/'; @@ -749,7 +768,7 @@ parse(sp, csc, tqp, matchesp) tp->fnlen = dlen + nlen; tp->slno = slno; if (slen != 0) { - tp->search = tp->fname + tp->fnlen + 1; + tp->search = (CHAR_T*)(tp->fname + tp->fnlen + 1); memcpy(tp->search, search, (tp->slen = slen) + 1); } CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q); @@ -809,9 +828,13 @@ static int cscope_help(sp, cmdp, subcmd) SCR *sp; EXCMD *cmdp; - char *subcmd; + CHAR_T *subcmd; { - return (csc_help(sp, subcmd)); + char *np; + size_t nlen; + + INT2CHAR(sp, subcmd, v_strlen(subcmd) + 1, np, nlen); + return (csc_help(sp, np)); } /* @@ -851,9 +874,13 @@ static int cscope_kill(sp, cmdp, cn) SCR *sp; EXCMD *cmdp; - char *cn; + CHAR_T *cn; { - return (terminate(sp, NULL, atoi(cn))); + char *np; + size_t nlen; + + INT2CHAR(sp, cn, v_strlen(cn) + 1, np, nlen); + return (terminate(sp, NULL, atoi(np))); } /* @@ -920,13 +947,15 @@ static int cscope_reset(sp, cmdp, notusedp) SCR *sp; EXCMD *cmdp; - char *notusedp; + CHAR_T *notusedp; { EX_PRIVATE *exp; - for (exp = EXP(sp); exp->cscq.lh_first != NULL;) - if (cscope_kill(sp, cmdp, "1")) + for (exp = EXP(sp); exp->cscq.lh_first != NULL;) { + static CHAR_T one[] = {'1', 0}; + if (cscope_kill(sp, cmdp, one)) return (1); + } return (0); } diff --git a/ex/ex_display.c b/ex/ex_display.c index ade90057..bb5a268e 100644 --- a/ex/ex_display.c +++ b/ex/ex_display.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_display.c,v 10.12 1996/04/10 11:31:30 bostic Exp $ (Berkeley) $Date: 1996/04/10 11:31:30 $"; +static const char sccsid[] = "$Id: ex_display.c,v 10.13 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -26,7 +26,7 @@ static const char sccsid[] = "$Id: ex_display.c,v 10.12 1996/04/10 11:31:30 bost #include "tag.h" static int bdisplay __P((SCR *)); -static void db __P((SCR *, CB *, CHAR_T *)); +static void db __P((SCR *, CB *, u_char *)); /* * ex_display -- :display b[uffers] | c[onnections] | s[creens] | t[ags] @@ -122,7 +122,7 @@ static void db(sp, cbp, name) SCR *sp; CB *cbp; - CHAR_T *name; + u_char *name; { CHAR_T *p; GS *gp; diff --git a/ex/ex_edit.c b/ex/ex_edit.c index 54de2ece..61036654 100644 --- a/ex/ex_edit.c +++ b/ex/ex_edit.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_edit.c,v 10.11 1996/10/31 09:28:56 bostic Exp $ (Berkeley) $Date: 1996/10/31 09:28:56 $"; +static const char sccsid[] = "$Id: ex_edit.c,v 10.12 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -52,6 +52,8 @@ ex_edit(sp, cmdp) { FREF *frp; int attach, setalt; + char *np; + size_t nlen; switch (cmdp->argc) { case 0: @@ -72,11 +74,13 @@ ex_edit(sp, cmdp) setalt = 0; break; case 1: - if ((frp = file_add(sp, cmdp->argv[0]->bp)) == NULL) + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, + np, nlen); + if ((frp = file_add(sp, np)) == NULL) return (1); attach = 0; setalt = 1; - set_alt_name(sp, cmdp->argv[0]->bp); + set_alt_name(sp, np); break; default: abort(); diff --git a/ex/ex_file.c b/ex/ex_file.c index eeaf536c..c9707308 100644 --- a/ex/ex_file.c +++ b/ex/ex_file.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_file.c,v 10.12 1996/07/12 20:55:26 bostic Exp $ (Berkeley) $Date: 1996/07/12 20:55:26 $"; +static const char sccsid[] = "$Id: ex_file.c,v 10.13 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -36,8 +36,10 @@ ex_file(sp, cmdp) SCR *sp; EXCMD *cmdp; { - CHAR_T *p; + char *p; FREF *frp; + char *np; + size_t nlen; NEEDFILE(sp, cmdp); @@ -48,8 +50,9 @@ ex_file(sp, cmdp) frp = sp->frp; /* Make sure can allocate enough space. */ - if ((p = v_strdup(sp, - cmdp->argv[0]->bp, cmdp->argv[0]->len)) == NULL) + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, + np, nlen); + if ((p = v_strdup(sp, np, nlen - 1)) == NULL) return (1); /* If already have a file name, it becomes the alternate. */ diff --git a/ex/ex_filter.c b/ex/ex_filter.c index fd2c6506..733c92c6 100644 --- a/ex/ex_filter.c +++ b/ex/ex_filter.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_filter.c,v 10.35 2000/04/21 19:00:36 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:36 $"; +static const char sccsid[] = "$Id: ex_filter.c,v 10.36 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -36,14 +36,14 @@ static int filter_ldisplay __P((SCR *, FILE *)); * the utility. * * PUBLIC: int ex_filter __P((SCR *, - * PUBLIC: EXCMD *, MARK *, MARK *, MARK *, char *, enum filtertype)); + * PUBLIC: EXCMD *, MARK *, MARK *, MARK *, CHAR_T *, enum filtertype)); */ int ex_filter(sp, cmdp, fm, tm, rp, cmd, ftype) SCR *sp; EXCMD *cmdp; MARK *fm, *tm, *rp; - char *cmd; + CHAR_T *cmd; enum filtertype ftype; { FILE *ifp, *ofp; @@ -51,6 +51,8 @@ ex_filter(sp, cmdp, fm, tm, rp, cmd, ftype) db_recno_t nread; int input[2], output[2], rval; char *name; + char *np; + size_t nlen; rval = 0; @@ -285,7 +287,8 @@ err: if (input[0] != -1) * Ignore errors on vi file reads, to make reads prettier. It's * completely inconsistent, and historic practice. */ -uwait: return (proc_wait(sp, (long)utility_pid, cmd, +uwait: INT2CHAR(sp, cmd, v_strlen(cmd) + 1, np, nlen); + return (proc_wait(sp, (long)utility_pid, np, ftype == FILTER_READ && F_ISSET(sp, SC_VI) ? 1 : 0, 0) || rval); } @@ -303,12 +306,16 @@ filter_ldisplay(sp, fp) FILE *fp; { size_t len; + char *np; + size_t nlen; EX_PRIVATE *exp; - for (exp = EXP(sp); !ex_getline(sp, fp, &len) && !INTERRUPTED(sp);) - if (ex_ldisplay(sp, exp->ibp, len, 0, 0)) + for (exp = EXP(sp); !ex_getline(sp, fp, &len) && !INTERRUPTED(sp);) { + INT2CHAR(sp, exp->ibp, len, np, nlen); + if (ex_ldisplay(sp, np, nlen, 0, 0)) break; + } if (ferror(fp)) msgq(sp, M_SYSERR, "filter read"); (void)fclose(fp); diff --git a/ex/ex_global.c b/ex/ex_global.c index 0ba77793..a8a08b00 100644 --- a/ex/ex_global.c +++ b/ex/ex_global.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_global.c,v 10.26 2000/06/27 17:19:05 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:05 $"; +static const char sccsid[] = "$Id: ex_global.c,v 10.27 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -175,11 +175,12 @@ usage: ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); * parsing it. */ if ((len = cmdp->argv[0]->len - (p - cmdp->argv[0]->bp)) == 0) { - p = "pp"; + static CHAR_T pp[] = {'p', 'p', 0}; + p = pp; len = 1; } - MALLOC_RET(sp, ecp->cp, char *, len * 2); + MALLOC_RET(sp, ecp->cp, CHAR_T *, (len * 2) * sizeof(CHAR_T)); ecp->o_cp = ecp->cp; ecp->o_clen = len; memcpy(ecp->cp + len, p, len); diff --git a/ex/ex_init.c b/ex/ex_init.c index 0fbd9e8d..05c4c445 100644 --- a/ex/ex_init.c +++ b/ex/ex_init.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_init.c,v 10.28 2000/06/25 17:34:39 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:39 $"; +static const char sccsid[] = "$Id: ex_init.c,v 10.29 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -61,7 +61,8 @@ ex_screen_copy(orig, sp) oexp = EXP(orig); if (oexp->lastbcomm != NULL && - (nexp->lastbcomm = strdup(oexp->lastbcomm)) == NULL) { + (nexp->lastbcomm = v_wstrdup(sp, oexp->lastbcomm, + v_strlen(oexp->lastbcomm))) == NULL) { msgq(sp, M_SYSERR, NULL); return(1); } @@ -145,6 +146,8 @@ ex_exrc(sp) { struct stat hsb, lsb; char *p, path[MAXPATHLEN]; + CHAR_T *wp; + size_t wlen; /* * Source the system, environment, $HOME and local .exrc values. @@ -187,10 +190,12 @@ ex_exrc(sp) return (0); if ((p = getenv("NEXINIT")) != NULL) { - if (ex_run_str(sp, "NEXINIT", p, strlen(p), 1, 0)) + CHAR2INT(sp, p, strlen(p) + 1, wp, wlen); + if (ex_run_str(sp, "NEXINIT", wp, wlen - 1, 1, 0)) return (1); } else if ((p = getenv("EXINIT")) != NULL) { - if (ex_run_str(sp, "EXINIT", p, strlen(p), 1, 0)) + CHAR2INT(sp, p, strlen(p) + 1, wp, wlen); + if (ex_run_str(sp, "EXINIT", wp, wlen - 1, 1, 0)) return (1); } else if ((p = getenv("HOME")) != NULL && *p) { (void)snprintf(path, sizeof(path), "%s/%s", p, _PATH_NEXRC); @@ -256,9 +261,12 @@ ex_run_file(sp, name) char *name; { EXCMD cmd; + CHAR_T *wp; + size_t wlen; ex_cinit(sp, &cmd, C_SOURCE, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, name, strlen(name)); + CHAR2INT(sp, name, strlen(name)+1, wp, wlen); + argv_exp0(sp, &cmd, wp, wlen - 1); return (ex_source(sp, &cmd)); } @@ -266,12 +274,13 @@ ex_run_file(sp, name) * ex_run_str -- * Set up a string of ex commands to run. * - * PUBLIC: int ex_run_str __P((SCR *, char *, char *, size_t, int, int)); + * PUBLIC: int ex_run_str __P((SCR *, char *, CHAR_T *, size_t, int, int)); */ int ex_run_str(sp, name, str, len, ex_flags, nocopy) SCR *sp; - char *name, *str; + char *name; + CHAR_T *str; size_t len; int ex_flags, nocopy; { @@ -291,7 +300,7 @@ ex_run_str(sp, name, str, len, ex_flags, nocopy) if (nocopy) ecp->cp = str; else - if ((ecp->cp = v_strdup(sp, str, len)) == NULL) + if ((ecp->cp = v_wstrdup(sp, str, len)) == NULL) return (1); ecp->clen = len; diff --git a/ex/ex_join.c b/ex/ex_join.c index e46708a0..ffd84fd3 100644 --- a/ex/ex_join.c +++ b/ex/ex_join.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_join.c,v 10.12 2000/06/27 17:19:06 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:06 $"; +static const char sccsid[] = "$Id: ex_join.c,v 10.13 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -39,7 +39,7 @@ ex_join(sp, cmdp) db_recno_t from, to; size_t blen, clen, len, tlen; int echar, extra, first; - char *bp, *tbp; + CHAR_T *bp, *tbp; CHAR_T *p; NEEDFILE(sp, cmdp); diff --git a/ex/ex_map.c b/ex/ex_map.c index cb508a13..b70f8e81 100644 --- a/ex/ex_map.c +++ b/ex/ex_map.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_map.c,v 10.9 1996/03/06 19:52:24 bostic Exp $ (Berkeley) $Date: 1996/03/06 19:52:24 $"; +static const char sccsid[] = "$Id: ex_map.c,v 10.10 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -113,7 +113,7 @@ ex_unmap(sp, cmdp) { if (seq_delete(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len, FL_ISSET(cmdp->iflags, E_C_FORCE) ? SEQ_INPUT : SEQ_COMMAND)) { - msgq_str(sp, M_INFO, + msgq_wstr(sp, M_INFO, cmdp->argv[0]->bp, "135|\"%s\" isn't currently mapped"); return (1); } diff --git a/ex/ex_mkexrc.c b/ex/ex_mkexrc.c index 73fab9fa..d6aa88e8 100644 --- a/ex/ex_mkexrc.c +++ b/ex/ex_mkexrc.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_mkexrc.c,v 10.11 1996/03/06 19:52:26 bostic Exp $ (Berkeley) $Date: 1996/03/06 19:52:26 $"; +static const char sccsid[] = "$Id: ex_mkexrc.c,v 10.12 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -45,13 +45,15 @@ ex_mkexrc(sp, cmdp) FILE *fp; int fd, sverrno; char *fname; + size_t flen; switch (cmdp->argc) { case 0: fname = _PATH_EXRC; break; case 1: - fname = cmdp->argv[0]->bp; + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, + fname, flen); set_alt_name(sp, fname); break; default: diff --git a/ex/ex_move.c b/ex/ex_move.c index 522f99ad..a02759bb 100644 --- a/ex/ex_move.c +++ b/ex/ex_move.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_move.c,v 10.12 2000/06/27 17:19:06 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:06 $"; +static const char sccsid[] = "$Id: ex_move.c,v 10.13 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -95,7 +95,7 @@ ex_move(sp, cmdp) db_recno_t cnt, diff, fl, tl, mfl, mtl; size_t blen, len; int mark_reset; - char *bp; + CHAR_T *bp; CHAR_T *p; NEEDFILE(sp, cmdp); diff --git a/ex/ex_preserve.c b/ex/ex_preserve.c index d08f2876..dc62fa3f 100644 --- a/ex/ex_preserve.c +++ b/ex/ex_preserve.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_preserve.c,v 10.13 2000/04/21 19:00:36 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:36 $"; +static const char sccsid[] = "$Id: ex_preserve.c,v 10.14 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -73,11 +73,14 @@ ex_recover(sp, cmdp) { ARGS *ap; FREF *frp; + char *np; + size_t nlen; ap = cmdp->argv[0]; /* Set the alternate file name. */ - set_alt_name(sp, ap->bp); + INT2CHAR(sp, ap->bp, ap->len+1, np, nlen); + set_alt_name(sp, np); /* * Check for modifications. Autowrite did not historically @@ -87,7 +90,8 @@ ex_recover(sp, cmdp) return (1); /* Get a file structure for the file. */ - if ((frp = file_add(sp, ap->bp)) == NULL) + INT2CHAR(sp, ap->bp, ap->len+1, np, nlen); + if ((frp = file_add(sp, np)) == NULL) return (1); /* Set the recover bit. */ diff --git a/ex/ex_print.c b/ex/ex_print.c index f3979967..1de09d79 100644 --- a/ex/ex_print.c +++ b/ex/ex_print.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_print.c,v 10.20 2000/06/27 17:19:06 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:06 $"; +static const char sccsid[] = "$Id: ex_print.c,v 10.21 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $"; #endif /* not lint */ #include @@ -107,8 +107,10 @@ ex_print(sp, cmdp, fp, tp, flags) GS *gp; db_recno_t from, to; size_t col, len; - CHAR_T *p; + char *p; char buf[10]; + CHAR_T *wp; + size_t wlen; NEEDFILE(sp, cmdp); @@ -136,8 +138,9 @@ ex_print(sp, cmdp, fp, tp, flags) * especially in handling end-of-line tabs, but they're almost * backward compatible. */ - if (db_get(sp, from, DBG_FATAL, &p, &len)) + if (db_get(sp, from, DBG_FATAL, &wp, &wlen)) return (1); + INT2CHAR(sp, wp, wlen, p, len); if (len == 0 && !LF_ISSET(E_C_LIST)) (void)ex_puts(sp, "\n"); @@ -186,8 +189,10 @@ ex_scprint(sp, fp, tp) SCR *sp; MARK *fp, *tp; { - CHAR_T *p; + char *p; size_t col, len; + CHAR_T *wp; + size_t wlen; col = 0; if (O_ISSET(sp, O_NUMBER)) { @@ -196,8 +201,9 @@ ex_scprint(sp, fp, tp) return (1); } - if (db_get(sp, fp->lno, DBG_FATAL, &p, &len)) + if (db_get(sp, fp->lno, DBG_FATAL, &wp, &wlen)) return (1); + INT2CHAR(sp, wp, wlen, p, len); if (ex_prchars(sp, p, &col, fp->cno, 0, ' ')) return (1); @@ -226,7 +232,8 @@ ex_prchars(sp, p, colp, len, flags, repeatc) u_int flags; int repeatc; { - CHAR_T ch, *kp; + CHAR_T ch; + char *kp; GS *gp; size_t col, tlen, ts; diff --git a/ex/ex_read.c b/ex/ex_read.c index f08f2938..73d639da 100644 --- a/ex/ex_read.c +++ b/ex/ex_read.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_read.c,v 10.39 2000/04/21 19:00:36 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:36 $"; +static const char sccsid[] = "$Id: ex_read.c,v 10.40 2000/07/14 14:29:21 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:21 $"; #endif /* not lint */ #include @@ -46,7 +46,9 @@ ex_read(sp, cmdp) { enum { R_ARG, R_EXPANDARG, R_FILTER } which; struct stat sb; - CHAR_T *arg, *name; + CHAR_T *arg; + char *name; + size_t nlen; EX_PRIVATE *exp; FILE *fp; FREF *frp; @@ -56,6 +58,7 @@ ex_read(sp, cmdp) size_t arglen; int argc, rval; char *p; + char *np; gp = sp->gp; @@ -116,7 +119,8 @@ ex_read(sp, cmdp) if (exp->lastbcomm != NULL) free(exp->lastbcomm); if ((exp->lastbcomm = - strdup(cmdp->argv[argc]->bp)) == NULL) { + v_wstrdup(sp, cmdp->argv[argc]->bp, + cmdp->argv[argc]->len)) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); } @@ -207,7 +211,8 @@ ex_read(sp, cmdp) abort(); /* NOTREACHED */ case 2: - name = cmdp->argv[1]->bp; + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, + name, nlen); /* * !!! * Historically, the read and write commands renamed @@ -216,8 +221,7 @@ ex_read(sp, cmdp) */ if (F_ISSET(sp->frp, FR_TMPFILE) && !F_ISSET(sp->frp, FR_EXNAMED)) { - if ((p = v_strdup(sp, cmdp->argv[1]->bp, - cmdp->argv[1]->len)) != NULL) { + if ((p = strdup(name)) != NULL) { free(sp->frp->name); sp->frp->name = p; } @@ -234,7 +238,9 @@ ex_read(sp, cmdp) set_alt_name(sp, name); break; default: - ex_emsg(sp, cmdp->argv[0]->bp, EXM_FILECOUNT); + INT2CHAR(sp, cmdp->argv[0]->bp, + cmdp->argv[0]->len + 1, np, nlen); + ex_emsg(sp, np, EXM_FILECOUNT); return (1); } diff --git a/ex/ex_script.c b/ex/ex_script.c index 99bb4f97..5a7b5593 100644 --- a/ex/ex_script.c +++ b/ex/ex_script.c @@ -13,7 +13,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_script.c,v 10.34 2000/07/11 19:07:18 skimo Exp $ (Berkeley) $Date: 2000/07/11 19:07:18 $"; +static const char sccsid[] = "$Id: ex_script.c,v 10.35 2000/07/14 14:29:21 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:21 $"; #endif /* not lint */ #include @@ -49,9 +49,9 @@ static void sscr_check __P((SCR *)); static int sscr_getprompt __P((SCR *)); static int sscr_init __P((SCR *)); static int sscr_insert __P((SCR *)); -static int sscr_matchprompt __P((SCR *, char *, size_t, size_t *)); +static int sscr_matchprompt __P((SCR *, CHAR_T *, size_t, size_t *)); static int sscr_pty __P((int *, int *, char *, struct termios *, void *)); -static int sscr_setprompt __P((SCR *, char *, size_t)); +static int sscr_setprompt __P((SCR *, CHAR_T *, size_t)); /* * ex_script -- : sc[ript][!] [file] @@ -307,7 +307,7 @@ sscr_exec(sp, lno) db_recno_t last_lno; size_t blen, len, last_len, tlen; int isempty, matchprompt, nw, rval; - char *bp; + CHAR_T *bp; CHAR_T *p; /* If there's a prompt on the last line, append the command. */ @@ -479,7 +479,7 @@ sscr_insert(sp) size_t blen, len, tlen; u_int value; int nr, rval; - char *bp; + CHAR_T *bp; /* Find out where the end of the file is. */ if (db_last(sp, &lno)) @@ -560,7 +560,7 @@ ret: FREE_SPACE(sp, bp, blen); static int sscr_setprompt(sp, buf, len) SCR *sp; - char *buf; + CHAR_T *buf; size_t len; { SCRIPT *sc; @@ -587,7 +587,7 @@ sscr_setprompt(sp, buf, len) static int sscr_matchprompt(sp, lp, line_len, lenp) SCR *sp; - char *lp; + CHAR_T *lp; size_t line_len, *lenp; { SCRIPT *sc; diff --git a/ex/ex_shift.c b/ex/ex_shift.c index 5b7d7588..a836c025 100644 --- a/ex/ex_shift.c +++ b/ex/ex_shift.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_shift.c,v 10.13 2000/06/27 17:19:06 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:06 $"; +static const char sccsid[] = "$Id: ex_shift.c,v 10.14 2000/07/14 14:29:21 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:21 $"; #endif /* not lint */ #include @@ -68,7 +68,7 @@ shift(sp, cmdp, rl) size_t blen, len, newcol, newidx, oldcol, oldidx, sw; int curset; CHAR_T *p; - char *bp, *tbp; + CHAR_T *bp, *tbp; NEEDFILE(sp, cmdp); diff --git a/ex/ex_source.c b/ex/ex_source.c index ff6078fd..86b52b4f 100644 --- a/ex/ex_source.c +++ b/ex/ex_source.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_source.c,v 10.12 1996/08/10 19:52:02 bostic Exp $ (Berkeley) $Date: 1996/08/10 19:52:02 $"; +static const char sccsid[] = "$Id: ex_source.c,v 10.13 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -41,9 +41,13 @@ ex_source(sp, cmdp) { struct stat sb; int fd, len; - char *bp, *name; + char *bp; + char *name; + size_t nlen; + CHAR_T *wp, *dp; + size_t wlen; - name = cmdp->argv[0]->bp; + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len + 1, name, nlen); if ((fd = open(name, O_RDONLY, 0)) < 0 || fstat(fd, &sb)) goto err; @@ -80,6 +84,9 @@ err: msgq_str(sp, M_SYSERR, name, "%s"); return (1); } + CHAR2INT(sp, bp, (size_t)sb.st_size + 1, wp, wlen); + dp = v_wstrdup(sp, wp, wlen - 1); + free(bp); /* Put it on the ex queue. */ - return (ex_run_str(sp, name, bp, (size_t)sb.st_size, 1, 1)); + return (ex_run_str(sp, name, dp, (size_t)sb.st_size, 1, 1)); } diff --git a/ex/ex_subst.c b/ex/ex_subst.c index dd81a7f8..fbad2f4a 100644 --- a/ex/ex_subst.c +++ b/ex/ex_subst.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_subst.c,v 10.42 2000/06/27 17:19:06 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:06 $"; +static const char sccsid[] = "$Id: ex_subst.c,v 10.43 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -32,12 +32,12 @@ static const char sccsid[] = "$Id: ex_subst.c,v 10.42 2000/06/27 17:19:06 skimo #define SUB_FIRST 0x01 /* The 'r' flag isn't reasonable. */ #define SUB_MUSTSETR 0x02 /* The 'r' flag is required. */ -static int re_conv __P((SCR *, char **, size_t *, int *)); -static int re_cscope_conv __P((SCR *, char **, size_t *, int *)); +static int re_conv __P((SCR *, CHAR_T **, size_t *, int *)); +static int re_cscope_conv __P((SCR *, CHAR_T **, size_t *, int *)); static int re_sub __P((SCR *, - char *, char **, size_t *, size_t *, regmatch_t [10])); -static int re_tag_conv __P((SCR *, char **, size_t *, int *)); -static int s __P((SCR *, EXCMD *, char *, regex_t *, u_int)); + CHAR_T *, CHAR_T **, size_t *, size_t *, regmatch_t [10])); +static int re_tag_conv __P((SCR *, CHAR_T **, size_t *, int *)); +static int s __P((SCR *, EXCMD *, CHAR_T *, regex_t *, u_int)); /* * ex_s -- @@ -56,7 +56,7 @@ ex_s(sp, cmdp) size_t blen, len; u_int flags; int delim; - char *bp, *ptrn, *rep, *p, *t; + CHAR_T *bp, *p, *ptrn, *rep, *t; /* * Skip leading white space. @@ -323,20 +323,20 @@ ex_subtilde(sp, cmdp) #define BUILD(sp, l, len) { \ if (lbclen + (len) > lblen) { \ lblen += MAX(lbclen + (len), 256); \ - REALLOC(sp, lb, char *, lblen); \ + REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T)); \ if (lb == NULL) { \ lbclen = 0; \ return (1); \ } \ } \ - memcpy(lb + lbclen, l, len); \ + memcpy(lb + lbclen, l, len * sizeof(CHAR_T)); \ lbclen += len; \ } #define NEEDSP(sp, len, pnt) { \ if (lbclen + (len) > lblen) { \ lblen += MAX(lbclen + (len), 256); \ - REALLOC(sp, lb, char *, lblen); \ + REALLOC(sp, lb, CHAR_T *, lblen * sizeof(CHAR_T)); \ if (lb == NULL) { \ lbclen = 0; \ return (1); \ @@ -349,7 +349,7 @@ static int s(sp, cmdp, s, re, flags) SCR *sp; EXCMD *cmdp; - char *s; + CHAR_T *s; regex_t *re; u_int flags; { @@ -357,14 +357,15 @@ s(sp, cmdp, s, re, flags) MARK from, to; TEXTH tiq; db_recno_t elno, lno, slno; + u_long ul; regmatch_t match[10]; size_t blen, cnt, last, lbclen, lblen, len, llen; size_t offset, saved_offset, scno; int cflag, lflag, nflag, pflag, rflag; int didsub, do_eol_match, eflags, empty_ok, eval; int linechanged, matched, quit, rval; - char *bp, *lb; - CHAR_T *p; + CHAR_T *p, *lb, *bp; + enum nresult nret; NEEDFILE(sp, cmdp); @@ -417,13 +418,14 @@ s(sp, cmdp, s, re, flags) if (lno != OOBLNO) goto usage; errno = 0; - lno = strtoul(s, &s, 10); + nret = nget_uslong(sp, &ul, s, &s, 10); + lno = ul; if (*s == '\0') /* Loop increment correction. */ --s; - if (errno == ERANGE) { - if (lno == LONG_MAX) + if (nret != NUM_OK) { + if (nret == NUM_OVER) msgq(sp, M_ERR, "153|Count overflow"); - else if (lno == LONG_MIN) + else if (nret == NUM_UNDER) msgq(sp, M_ERR, "154|Count underflow"); else msgq(sp, M_SYSERR, NULL); @@ -517,9 +519,9 @@ noargs: if (F_ISSET(sp, SC_VI) && sp->c_suffix && (lflag || nflag || pflag)) { */ if (sp->c_suffix) { if (bp == NULL) { - GET_SPACE_RET(sp, bp, blen, llen); + GET_SPACE_RET(sp, bp, blen, llen * sizeof(CHAR_T)); } else - ADD_SPACE_RET(sp, bp, blen, llen); + ADD_SPACE_RET(sp, bp, blen, llen * sizeof(CHAR_T)); memcpy(bp, s, llen); s = bp; } @@ -559,7 +561,7 @@ nextmatch: match[0].rm_so = 0; match[0].rm_eo = len; /* Get the next match. */ - eval = regexec(re, (char *)s + offset, 10, match, eflags); + eval = regexec(re, s + offset, 10, match, eflags); /* * There wasn't a match or if there was an error, deal with @@ -891,19 +893,19 @@ err: rval = 1; * Compile the RE. * * PUBLIC: int re_compile __P((SCR *, - * PUBLIC: char *, size_t, char **, size_t *, regex_t *, u_int)); + * PUBLIC: CHAR_T *, size_t, CHAR_T **, size_t *, regex_t *, u_int)); */ int re_compile(sp, ptrn, plen, ptrnp, lenp, rep, flags) SCR *sp; - char *ptrn, **ptrnp; + CHAR_T *ptrn, **ptrnp; size_t plen, *lenp; regex_t *rep; u_int flags; { size_t len; int reflags, replaced, rval; - char *p; + CHAR_T *p; /* Set RE flags. */ reflags = 0; @@ -978,9 +980,9 @@ iclower: for (p = ptrn, len = plen; len > 0; ++p, --len) * Regcomp isn't 8-bit clean, so the pattern is nul-terminated * for now. There's just no other solution. */ - MALLOC(sp, *ptrnp, char *, plen + 1); + MALLOC(sp, *ptrnp, CHAR_T *, (plen + 1) * sizeof(CHAR_T)); if (*ptrnp != NULL) { - memcpy(*ptrnp, ptrn, plen); + memcpy(*ptrnp, ptrn, plen * sizeof(CHAR_T)); (*ptrnp)[plen] = '\0'; } @@ -1038,13 +1040,13 @@ iclower: for (p = ptrn, len = plen; len > 0; ++p, --len) static int re_conv(sp, ptrnp, plenp, replacedp) SCR *sp; - char **ptrnp; + CHAR_T **ptrnp; size_t *plenp; int *replacedp; { size_t blen, len, needlen; int magic; - char *bp, *p, *t; + CHAR_T *bp, *p, *t; /* * First pass through, we figure out how much space we'll need. @@ -1186,13 +1188,13 @@ re_conv(sp, ptrnp, plenp, replacedp) static int re_tag_conv(sp, ptrnp, plenp, replacedp) SCR *sp; - char **ptrnp; + CHAR_T **ptrnp; size_t *plenp; int *replacedp; { size_t blen, len; int lastdollar; - char *bp, *p, *t; + CHAR_T *bp, *p, *t; len = *plenp; @@ -1255,18 +1257,23 @@ re_tag_conv(sp, ptrnp, plenp, replacedp) static int re_cscope_conv(sp, ptrnp, plenp, replacedp) SCR *sp; - char **ptrnp; + CHAR_T **ptrnp; size_t *plenp; int *replacedp; { size_t blen, len, nspaces; - char *bp, *p, *t; + CHAR_T *bp, *t; + CHAR_T *p; + CHAR_T *wp; + size_t wlen; /* * Each space in the source line printed by cscope represents an * arbitrary sequence of spaces, tabs, and comments. */ #define CSCOPE_RE_SPACE "([ \t]|/\\*([^*]|\\*/)*\\*/)*" +#define CSCOPE_LEN sizeof(CSCOPE_RE_SPACE) - 1 + CHAR2INT(sp, CSCOPE_RE_SPACE, CSCOPE_LEN, wp, wlen); for (nspaces = 0, p = *ptrnp, len = *plenp; len > 0; ++p, --len) if (*p == ' ') ++nspaces; @@ -1279,27 +1286,27 @@ re_cscope_conv(sp, ptrnp, plenp, replacedp) */ *replacedp = 1; len = (p - *ptrnp) * 2 + (nspaces + 2) * sizeof(CSCOPE_RE_SPACE) + 3; - GET_SPACE_RET(sp, bp, blen, len); + GET_SPACE_RET(sp, bp, blen, len * sizeof(CHAR_T)); p = *ptrnp; t = bp; *t++ = '^'; - memcpy(t, CSCOPE_RE_SPACE, sizeof(CSCOPE_RE_SPACE) - 1); - t += sizeof(CSCOPE_RE_SPACE) - 1; + memcpy(t, wp, wlen * sizeof(CHAR_T)); + t += wlen; for (len = *plenp; len > 0; ++p, --len) if (*p == ' ') { - memcpy(t, CSCOPE_RE_SPACE, sizeof(CSCOPE_RE_SPACE) - 1); - t += sizeof(CSCOPE_RE_SPACE) - 1; + memcpy(t, wp, wlen * sizeof(CHAR_T)); + t += wlen; } else { if (strchr("\\^.[]$*+?()|{}", *p)) *t++ = '\\'; *t++ = *p; } - memcpy(t, CSCOPE_RE_SPACE, sizeof(CSCOPE_RE_SPACE) - 1); - t += sizeof(CSCOPE_RE_SPACE) - 1; + memcpy(t, wp, wlen * sizeof(CHAR_T)); + t += wlen; *t++ = '$'; *ptrnp = bp; @@ -1339,8 +1346,8 @@ re_error(sp, errcode, preg) static int re_sub(sp, ip, lbp, lbclenp, lblenp, match) SCR *sp; - char *ip; /* Input line. */ - char **lbp; + CHAR_T *ip; /* Input line. */ + CHAR_T **lbp; size_t *lbclenp, *lblenp; regmatch_t match[10]; { @@ -1348,11 +1355,11 @@ re_sub(sp, ip, lbp, lbclenp, lblenp, match) size_t lbclen, lblen; /* Local copies. */ size_t mlen; /* Match length. */ size_t rpl; /* Remaining replacement length. */ - char *rp; /* Replacement pointer. */ + CHAR_T *rp; /* Replacement pointer. */ int ch; int no; /* Match replacement offset. */ - char *p, *t; /* Buffer pointers. */ - char *lb; /* Local copies. */ + CHAR_T *p, *t; /* Buffer pointers. */ + CHAR_T *lb; /* Local copies. */ lb = *lbp; /* Get local copies. */ lbclen = *lbclenp; diff --git a/ex/ex_tag.c b/ex/ex_tag.c index 3d754439..baa552cf 100644 --- a/ex/ex_tag.c +++ b/ex/ex_tag.c @@ -13,7 +13,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_tag.c,v 10.44 2000/07/12 12:23:29 skimo Exp $ (Berkeley) $Date: 2000/07/12 12:23:29 $"; +static const char sccsid[] = "$Id: ex_tag.c,v 10.45 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -45,9 +45,9 @@ static const char sccsid[] = "$Id: ex_tag.c,v 10.44 2000/07/12 12:23:29 skimo Ex static char *binary_search __P((char *, char *, char *)); static int compare __P((char *, char *, char *)); static void ctag_file __P((SCR *, TAGF *, char *, char **, size_t *)); -static int ctag_search __P((SCR *, char *, size_t, char *)); +static int ctag_search __P((SCR *, CHAR_T *, size_t, char *)); static int ctag_sfile __P((SCR *, TAGF *, TAGQ *, char *)); -static TAGQ *ctag_slist __P((SCR *, char *)); +static TAGQ *ctag_slist __P((SCR *, CHAR_T *)); static char *linear_search __P((char *, char *, char *)); static int tag_copy __P((SCR *, TAG *, TAG **)); static int tag_pop __P((SCR *, TAGQ *, int)); @@ -59,18 +59,18 @@ static int tagq_copy __P((SCR *, TAGQ *, TAGQ **)); * ex_tag_first -- * The tag code can be entered from main, e.g., "vi -t tag". * - * PUBLIC: int ex_tag_first __P((SCR *, char *)); + * PUBLIC: int ex_tag_first __P((SCR *, CHAR_T *)); */ int ex_tag_first(sp, tagarg) SCR *sp; - char *tagarg; + CHAR_T *tagarg; { EXCMD cmd; /* Build an argument for the ex :tag command. */ ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, tagarg, strlen(tagarg)); + argv_exp0(sp, &cmd, tagarg, v_strlen(tagarg)); /* * XXX @@ -111,14 +111,15 @@ ex_tag_push(sp, cmdp) if (exp->tag_last != NULL) free(exp->tag_last); - if ((exp->tag_last = strdup(cmdp->argv[0]->bp)) == NULL) { + if ((exp->tag_last = v_wstrdup(sp, cmdp->argv[0]->bp, + cmdp->argv[0]->len)) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); } /* Taglength may limit the number of characters. */ if ((tl = - O_VAL(sp, O_TAGLENGTH)) != 0 && strlen(exp->tag_last) > tl) + O_VAL(sp, O_TAGLENGTH)) != 0 && v_strlen(exp->tag_last) > tl) exp->tag_last[tl] = '\0'; break; case 0: @@ -156,6 +157,8 @@ ex_tag_next(sp, cmdp) EX_PRIVATE *exp; TAG *tp; TAGQ *tqp; + char *np; + size_t nlen; exp = EXP(sp); if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) { @@ -174,8 +177,11 @@ ex_tag_next(sp, cmdp) (void)cscope_search(sp, tqp, tp); else (void)ctag_search(sp, tp->search, tp->slen, tqp->tag); - if (tqp->current->msg) - msgq(sp, M_INFO, tqp->current->msg); + if (tqp->current->msg) { + INT2CHAR(sp, tqp->current->msg, tqp->current->mlen + 1, + np, nlen); + msgq(sp, M_INFO, np); + } return (0); } @@ -193,6 +199,8 @@ ex_tag_prev(sp, cmdp) EX_PRIVATE *exp; TAG *tp; TAGQ *tqp; + char *np; + size_t nlen; exp = EXP(sp); if ((tqp = exp->tq.cqh_first) == (void *)&exp->tq) { @@ -211,8 +219,11 @@ ex_tag_prev(sp, cmdp) (void)cscope_search(sp, tqp, tp); else (void)ctag_search(sp, tp->search, tp->slen, tqp->tag); - if (tqp->current->msg) - msgq(sp, M_INFO, tqp->current->msg); + if (tqp->current->msg) { + INT2CHAR(sp, tqp->current->msg, tqp->current->mlen + 1, + np, nlen); + msgq(sp, M_INFO, np); + } return (0); } @@ -326,6 +337,7 @@ ex_tag_pop(sp, cmdp) size_t arglen; long off; char *arg, *p, *t; + size_t nlen; /* Check for an empty stack. */ exp = EXP(sp); @@ -340,7 +352,8 @@ ex_tag_pop(sp, cmdp) dtqp = exp->tq.cqh_first; break; case 1: /* Name or number. */ - arg = cmdp->argv[0]->bp; + INT2CHAR(sp, cmdp->argv[0]->bp, cmdp->argv[0]->len+1, + arg, nlen); off = strtol(arg, &p, 10); if (*p != '\0') goto filearg; @@ -595,7 +608,8 @@ ex_tag_copy(orig, sp) /* Copy the last tag. */ if (oexp->tag_last != NULL && - (nexp->tag_last = strdup(oexp->tag_last)) == NULL) { + (nexp->tag_last = v_wstrdup(sp, oexp->tag_last, + v_strlen(oexp->tag_last))) == NULL) { msgq(sp, M_SYSERR, NULL); return (1); } @@ -674,7 +688,7 @@ tag_copy(sp, otp, tpp) memcpy(tp, otp, len); if (otp->fname != NULL) - tp->fname = tp->buf; + tp->fname = (char *)tp->buf; if (otp->search != NULL) tp->search = tp->buf + (otp->search - otp->buf); if (otp->msg != NULL) @@ -748,6 +762,8 @@ tagq_push(sp, tqp, new_screen, force) db_recno_t lno; size_t cno; int istmp; + char *np; + size_t nlen; exp = EXP(sp); @@ -806,8 +822,11 @@ tagq_push(sp, tqp, new_screen, force) (void)ctag_search(sp, tqp->current->search, tqp->current->slen, tqp->tag); - if (tqp->current->msg) - msgq(sp, M_INFO, tqp->current->msg); + if (tqp->current->msg) { + INT2CHAR(sp, tqp->current->msg, tqp->current->mlen + 1, + np, nlen); + msgq(sp, M_INFO, np); + } /* * Move the current context from the temporary save area into the @@ -943,11 +962,14 @@ ex_tag_free(sp) static int ctag_search(sp, search, slen, tag) SCR *sp; - char *search, *tag; + CHAR_T *search; + char *tag; size_t slen; { MARK m; char *p; + char *np; + size_t nlen; /* * !!! @@ -956,7 +978,8 @@ ctag_search(sp, search, slen, tag) * people are still using the format. POSIX 1003.2 permits it. */ if (isdigit(search[0])) { - m.lno = atoi(search); + INT2CHAR(sp, search, slen+1, np, nlen); + m.lno = atoi(np); if (!db_exist(sp, m.lno)) { tag_msg(sp, TAG_BADLNO, tag); return (1); @@ -970,9 +993,10 @@ ctag_search(sp, search, slen, tag) m.cno = 0; if (f_search(sp, &m, &m, search, slen, NULL, - SEARCH_FIRST | SEARCH_TAG | SEARCH_PARSE)) - if ((p = strrchr(search, '(')) != NULL) { - slen = p - search; + SEARCH_FIRST | SEARCH_TAG | SEARCH_PARSE)) { + INT2CHAR(sp, search, slen, np, nlen); + if ((p = strrchr(np, '(')) != NULL) { + slen = p - np; if (f_search(sp, &m, &m, search, slen, NULL, SEARCH_FIRST | SEARCH_TAG)) goto notfound; @@ -980,6 +1004,7 @@ ctag_search(sp, search, slen, tag) notfound: tag_msg(sp, TAG_SEARCH, tag); return (1); } + } /* * !!! * Historically, tags set the search direction if it wasn't @@ -1006,22 +1031,25 @@ notfound: tag_msg(sp, TAG_SEARCH, tag); static TAGQ * ctag_slist(sp, tag) SCR *sp; - char *tag; + CHAR_T *tag; { EX_PRIVATE *exp; TAGF *tfp; TAGQ *tqp; size_t len; int echk; + char *np; + size_t nlen; exp = EXP(sp); /* Allocate and initialize the tag queue structure. */ - len = strlen(tag); + INT2CHAR(sp, tag, v_strlen(tag) + 1, np, nlen); + len = nlen - 1; CALLOC_GOTO(sp, tqp, TAGQ *, 1, sizeof(TAGQ) + len + 1); CIRCLEQ_INIT(&tqp->tagq); tqp->tag = tqp->buf; - memcpy(tqp->tag, tag, (tqp->tlen = len) + 1); + memcpy(tqp->tag, np, (tqp->tlen = len) + 1); /* * Find the tag, only display missing file messages once, and @@ -1029,7 +1057,7 @@ ctag_slist(sp, tag) */ for (echk = 0, tfp = exp->tagfq.tqh_first; tfp != NULL; tfp = tfp->q.tqe_next) - if (ctag_sfile(sp, tfp, tqp, tag)) { + if (ctag_sfile(sp, tfp, tqp, tqp->tag)) { echk = 1; F_SET(tfp, TAGF_ERR); } else @@ -1037,7 +1065,7 @@ ctag_slist(sp, tag) /* Check to see if we found anything. */ if (tqp->tagq.cqh_first == (void *)&tqp->tagq) { - msgq_str(sp, M_ERR, tag, "162|%s: tag not found"); + msgq_str(sp, M_ERR, tqp->tag, "162|%s: tag not found"); if (echk) for (tfp = exp->tagfq.tqh_first; tfp != NULL; tfp = tfp->q.tqe_next) @@ -1178,7 +1206,7 @@ corrupt: p = msg_print(sp, tname, &nf1); CALLOC_GOTO(sp, tp, TAG *, 1, sizeof(TAG) + dlen + 2 + nlen + 1 + slen + 1); - tp->fname = tp->buf; + tp->fname = (char *)tp->buf; if (dlen != 0) { memcpy(tp->fname, dname, dlen); tp->fname[dlen] = '/'; @@ -1186,7 +1214,7 @@ corrupt: p = msg_print(sp, tname, &nf1); } memcpy(tp->fname + dlen, name, nlen + 1); tp->fnlen = dlen + nlen; - tp->search = tp->fname + tp->fnlen + 1; + tp->search = (CHAR_T*)(tp->fname + tp->fnlen + 1); memcpy(tp->search, search, (tp->slen = slen) + 1); CIRCLEQ_INSERT_TAIL(&tqp->tagq, tp, q); } diff --git a/ex/ex_util.c b/ex/ex_util.c index d1728dd2..d3b36b02 100644 --- a/ex/ex_util.c +++ b/ex/ex_util.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_util.c,v 10.26 2000/04/21 19:00:38 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:38 $"; +static const char sccsid[] = "$Id: ex_util.c,v 10.27 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -66,7 +66,7 @@ ex_getline(sp, fp, lenp) EX_PRIVATE *exp; size_t off; int ch; - char *p; + CHAR_T *p; exp = EXP(sp); for (errno = 0, off = 0, p = exp->ibp;;) { diff --git a/ex/ex_visual.c b/ex/ex_visual.c index 010bbe5e..541c153f 100644 --- a/ex/ex_visual.c +++ b/ex/ex_visual.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_visual.c,v 10.13 1996/06/28 15:28:41 bostic Exp $ (Berkeley) $Date: 1996/06/28 15:28:41 $"; +static const char sccsid[] = "$Id: ex_visual.c,v 10.14 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -42,6 +42,8 @@ ex_visual(sp, cmdp) size_t len; int pos; char buf[256]; + size_t wlen; + CHAR_T *wp; /* If open option off, disallow visual command. */ if (!O_ISSET(sp, O_OPEN)) { @@ -84,7 +86,8 @@ ex_visual(sp, cmdp) "%luz%c%lu", sp->lno, pos, cmdp->count); else len = snprintf(buf, sizeof(buf), "%luz%c", sp->lno, pos); - (void)v_event_push(sp, NULL, buf, len, CH_NOMAP | CH_QUOTED); + CHAR2INT(sp, buf, len, wp, wlen); + (void)v_event_push(sp, NULL, wp, wlen, CH_NOMAP | CH_QUOTED); /* * !!! diff --git a/ex/ex_write.c b/ex/ex_write.c index 241daca6..7c4060b7 100644 --- a/ex/ex_write.c +++ b/ex/ex_write.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ex_write.c,v 10.32 2000/06/27 17:19:07 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:07 $"; +static const char sccsid[] = "$Id: ex_write.c,v 10.33 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -138,7 +138,10 @@ exwr(sp, cmdp, cmd) { MARK rm; int flags; - char *name, *p; + char *name; + CHAR_T *p; + size_t nlen; + char *n; NEEDFILE(sp, cmdp); @@ -165,7 +168,7 @@ exwr(sp, cmdp, cmd) ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE); return (1); } - if (argv_exp1(sp, cmdp, p, strlen(p), 1)) + if (argv_exp1(sp, cmdp, p, v_strlen(p), 1)) return (1); /* @@ -210,7 +213,7 @@ exwr(sp, cmdp, cmd) &cmdp->addr1, &cmdp->addr2, NULL, flags)); /* Build an argv so we get an argument count and file expansion. */ - if (argv_exp2(sp, cmdp, p, strlen(p))) + if (argv_exp2(sp, cmdp, p, v_strlen(p))) return (1); /* @@ -228,7 +231,8 @@ exwr(sp, cmdp, cmd) abort(); /* NOTREACHED */ case 2: - name = cmdp->argv[1]->bp; + INT2CHAR(sp, cmdp->argv[1]->bp, cmdp->argv[1]->len+1, + name, nlen); /* * !!! @@ -238,10 +242,9 @@ exwr(sp, cmdp, cmd) */ if (F_ISSET(sp->frp, FR_TMPFILE) && !F_ISSET(sp->frp, FR_EXNAMED)) { - if ((p = v_strdup(sp, - cmdp->argv[1]->bp, cmdp->argv[1]->len)) != NULL) { + if ((n = v_strdup(sp, name, nlen - 1)) != NULL) { free(sp->frp->name); - sp->frp->name = p; + sp->frp->name = n; } /* * The file has a real name, it's no longer a @@ -261,7 +264,8 @@ exwr(sp, cmdp, cmd) set_alt_name(sp, name); break; default: - ex_emsg(sp, p, EXM_FILECOUNT); + INT2CHAR(sp, p, v_strlen(p) + 1, n, nlen); + ex_emsg(sp, n, EXM_FILECOUNT); return (1); } diff --git a/ex/tag.h b/ex/tag.h index c15cec59..64db0a41 100644 --- a/ex/tag.h +++ b/ex/tag.h @@ -8,7 +8,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: tag.h,v 10.7 2000/07/12 12:23:29 skimo Exp $ (Berkeley) $Date: 2000/07/12 12:23:29 $ + * $Id: tag.h,v 10.8 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $ */ /* @@ -84,12 +84,12 @@ struct _tag { /* Tag list. */ char *fname; /* Filename. */ size_t fnlen; /* Filename length. */ db_recno_t slno; /* Search line number. */ - char *search; /* Search string. */ + CHAR_T *search; /* Search string. */ size_t slen; /* Search string length. */ - char *msg; /* Message string. */ + CHAR_T *msg; /* Message string. */ size_t mlen; /* Message string length. */ - char buf[1]; /* Variable length buffer. */ + CHAR_T buf[1]; /* Variable length buffer. */ }; struct _tagq { /* Tag queue. */ diff --git a/gtk/gtkviwindow.c b/gtk/gtkviwindow.c index 8f37c8ba..49a6a5d4 100644 --- a/gtk/gtkviwindow.c +++ b/gtk/gtkviwindow.c @@ -1,6 +1,5 @@ /* change further to gtkviwindow have no knowledge of ipvi */ -#include "../common/common.h" -#include "../ipc/ip.h" +#include "config.h" #include #include @@ -8,6 +7,10 @@ #include #include #endif + +#include "../common/common.h" +#include "../ipc/ip.h" + #include "gtkvi.h" #include "gtkviscreen.h" #include "gtkviwindow.h" diff --git a/ip/ip_funcs.c b/ip/ip_funcs.c index 4b73e08d..7f51b047 100644 --- a/ip/ip_funcs.c +++ b/ip/ip_funcs.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ip_funcs.c,v 8.19 2000/07/11 19:07:19 skimo Exp $ (Berkeley) $Date: 2000/07/11 19:07:19 $"; +static const char sccsid[] = "$Id: ip_funcs.c,v 8.20 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -29,14 +29,33 @@ static const char sccsid[] = "$Id: ip_funcs.c,v 8.19 2000/07/11 19:07:19 skimo E * ip_addstr -- * Add len bytes from the string at the cursor, advancing the cursor. * - * PUBLIC: int ip_addstr __P((SCR *, const CHAR_T *, size_t)); + * PUBLIC: int ip_waddstr __P((SCR *, const CHAR_T *, size_t)); */ int -ip_addstr(sp, str, len) +ip_waddstr(sp, str, len) SCR *sp; const CHAR_T *str; size_t len; { + CONST char *np; + size_t nlen; + + INT2CHAR(sp, str, len, np, nlen); + ip_addstr(sp, np, nlen); +} + +/* + * ip_addstr -- + * Add len bytes from the string at the cursor, advancing the cursor. + * + * PUBLIC: int ip_addstr __P((SCR *, const char *, size_t)); + */ +int +ip_addstr(sp, str, len) + SCR *sp; + const char *str; + size_t len; +{ IP_BUF ipb; IP_PRIVATE *ipp; int iv, rval; @@ -175,6 +194,7 @@ ip_child(sp) dup2(ipp->t_fd, 2); close(ipp->t_fd); } + return 0; } /* diff --git a/ip/ip_main.c b/ip/ip_main.c index 7610ed80..94cc5d7e 100644 --- a/ip/ip_main.c +++ b/ip/ip_main.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: ip_main.c,v 8.21 2000/07/11 22:05:11 skimo Exp $ (Berkeley) $Date: 2000/07/11 22:05:11 $"; +static const char sccsid[] = "$Id: ip_main.c,v 8.22 2000/07/14 14:29:22 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:22 $"; #endif /* not lint */ #include @@ -36,7 +36,7 @@ static void perr __P((char *, char *)); static int get_fds __P((char *ip_arg, int *i_fd, int *o_fd)); static int get_connection __P((WIN *wp, int main_ifd, int main_ofd, int *i_fd, int *o_fd, int *, int can_pass)); -static void run_editor __P((void * vp)); +static void *run_editor __P((void * vp)); /* * ip_main -- @@ -116,7 +116,7 @@ main(argc, argv) exit (rval); } -static void +static void * run_editor(void * vp) { GS *gp; @@ -170,6 +170,7 @@ run_editor(void * vp) #if defined(DEBUG) || defined(PURIFY) || defined(LIBRARY) free(ipp); #endif + return NULL; } /* @@ -277,6 +278,7 @@ ip_func_std(gp) GS *gp; { gp->scr_addstr = ip_addstr; + gp->scr_waddstr = ip_waddstr; gp->scr_attr = ip_attr; gp->scr_baud = ip_baud; gp->scr_bell = ip_bell; diff --git a/ipc/ip.h b/ipc/ip.h index bdbe81cd..b949f483 100644 --- a/ipc/ip.h +++ b/ipc/ip.h @@ -4,7 +4,7 @@ * * See the LICENSE file for redistribution information. * - * $Id: ip.h,v 8.27 2000/07/11 19:07:19 skimo Exp $ (Berkeley) $Date: 2000/07/11 19:07:19 $ + * $Id: ip.h,v 8.28 2000/07/14 14:29:23 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:23 $ */ #include @@ -36,7 +36,7 @@ typedef struct _ip_private { size_t iskip; /* Returned input buffer. */ char ibuf[256]; /* Input buffer. */ - char tbuf[256]; /* Input keys. */ + CHAR_T tbuf[256]; /* Input keys. */ #define IP_IN_EX 0x0001 /* Currently running ex. */ #define IP_ON_ALTERNATE 0x0002 /* Alternate on. */ diff --git a/regex/regcomp.c b/regex/regcomp.c index d224caf9..75425f5e 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -178,7 +178,7 @@ static int never = 0; /* for use in asserts; shuts lint up */ int /* 0 success, otherwise REG_something */ regcomp(preg, pattern, cflags) regex_t *preg; -const char *pattern; +const CHAR_T *pattern; int cflags; { struct parse pa; diff --git a/regex/regex.h b/regex/regex.h index 6438f7e1..9a7f81d6 100644 --- a/regex/regex.h +++ b/regex/regex.h @@ -43,6 +43,7 @@ #ifdef __REGEX_PRIVATE #include "config.h" #include "port.h" +#include "../common/multibyte.h" #endif /* types */ @@ -51,7 +52,7 @@ typedef off_t regoff_t; typedef struct { int re_magic; size_t re_nsub; /* number of parenthesized subexpressions */ - const char *re_endp; /* end pointer for REG_PEND */ + const CHAR_T *re_endp; /* end pointer for REG_PEND */ struct re_guts *re_g; /* none of your business :-) */ } regex_t; @@ -98,10 +99,10 @@ typedef struct { #define REG_LARGE 01000 /* force large representation */ #define REG_BACKR 02000 /* force use of backref code */ -int regcomp __P((regex_t *, const char *, int)); +int regcomp __P((regex_t *, const CHAR_T *, int)); size_t regerror __P((int, const regex_t *, char *, size_t)); int regexec __P((const regex_t *, - const char *, size_t, regmatch_t [], int)); + const CHAR_T *, size_t, regmatch_t [], int)); void regfree __P((regex_t *)); #endif /* !_REGEX_H_ */ diff --git a/regex/regexec.c b/regex/regexec.c index 348a442d..8d183b6b 100644 --- a/regex/regexec.c +++ b/regex/regexec.c @@ -155,7 +155,7 @@ static int nope = 0; /* for use in asserts; shuts lint up */ int /* 0 success, REG_NOMATCH failure */ regexec(preg, string, nmatch, pmatch, eflags) const regex_t *preg; -const char *string; +const CHAR_T *string; size_t nmatch; regmatch_t pmatch[]; int eflags; diff --git a/vi/v_at.c b/vi/v_at.c index 07d05e29..542ccf48 100644 --- a/vi/v_at.c +++ b/vi/v_at.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_at.c,v 10.8 1996/04/27 11:40:33 bostic Exp $ (Berkeley) $Date: 1996/04/27 11:40:33 $"; +static const char sccsid[] = "$Id: v_at.c,v 10.9 2000/07/14 14:29:23 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:23 $"; #endif /* not lint */ #include @@ -41,6 +41,9 @@ v_at(sp, vp) TEXT *tp; size_t len; char nbuf[20]; + CHAR_T wbuf[20]; + CHAR_T *wp; + size_t wlen; /* * !!! @@ -88,12 +91,14 @@ v_at(sp, vp) * logging code to be available. */ for (tp = cbp->textq.cqh_last; - tp != (void *)&cbp->textq; tp = tp->q.cqe_prev) + tp != (void *)&cbp->textq; tp = tp->q.cqe_prev) { + static CHAR_T nl[] = { '\n', 0 }; if ((F_ISSET(cbp, CB_LMODE) || tp->q.cqe_next != (void *)&cbp->textq) && - v_event_push(sp, NULL, "\n", 1, 0) || + v_event_push(sp, NULL, nl, 1, 0) || v_event_push(sp, NULL, tp->lb, tp->len, 0)) return (1); + } /* * !!! @@ -102,7 +107,9 @@ v_at(sp, vp) */ if (F_ISSET(vp, VC_C1SET)) { len = snprintf(nbuf, sizeof(nbuf), "%lu", vp->count); - if (v_event_push(sp, NULL, nbuf, len, 0)) + CHAR2INT(sp, nbuf, len, wp, wlen); + memcpy(wbuf, wp, wlen * sizeof(CHAR_T)); + if (v_event_push(sp, NULL, wp, wlen, 0)) return (1); } return (0); diff --git a/vi/v_event.c b/vi/v_event.c index d82733f7..12eeef9a 100644 --- a/vi/v_event.c +++ b/vi/v_event.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_event.c,v 8.17 2000/07/04 21:48:54 skimo Exp $ (Berkeley) $Date: 2000/07/04 21:48:54 $"; +static const char sccsid[] = "$Id: v_event.c,v 8.18 2000/07/14 14:29:23 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:23 $"; #endif /* not lint */ #include @@ -99,11 +99,19 @@ v_editopt(sp, vp) VICMD *vp; { int rval; - - rval = api_opts_set(sp, - vp->ev.e_str1, vp->ev.e_str2, vp->ev.e_val1, vp->ev.e_val1); + char *np; + size_t nlen; + char *p1, *p2; + + INT2CHAR(sp, vp->ev.e_str1, v_strlen(vp->ev.e_str1), np, nlen); + p1 = strdup(np); + INT2CHAR(sp, vp->ev.e_str2, v_strlen(vp->ev.e_str2), np, nlen); + p2 = strdup(np); + rval = api_opts_set(sp, p1, p2, vp->ev.e_val1, vp->ev.e_val1); if (sp->gp->scr_reply != NULL) (void)sp->gp->scr_reply(sp, rval, NULL); + free(p1); + free(p2); return (rval); } @@ -139,7 +147,7 @@ v_tag(sp, vp) return (1); ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, VIP(sp)->keyw, strlen(VIP(sp)->keyw)); + argv_exp0(sp, &cmd, VIP(sp)->keyw, v_strlen(VIP(sp)->keyw)); return (v_exec_ex(sp, vp, &cmd)); } @@ -175,7 +183,7 @@ v_tagsplit(sp, vp) ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, OOBLNO, 0); F_SET(&cmd, E_NEWSCREEN); - argv_exp0(sp, &cmd, VIP(sp)->keyw, strlen(VIP(sp)->keyw)); + argv_exp0(sp, &cmd, VIP(sp)->keyw, v_strlen(VIP(sp)->keyw)); return (v_exec_ex(sp, vp, &cmd)); } diff --git a/vi/v_ex.c b/vi/v_ex.c index e7cb6f92..ad7e2c05 100644 --- a/vi/v_ex.c +++ b/vi/v_ex.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_ex.c,v 10.47 2000/06/27 17:19:07 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:07 $"; +static const char sccsid[] = "$Id: v_ex.c,v 10.48 2000/07/14 14:29:23 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:23 $"; #endif /* not lint */ #include @@ -44,9 +44,10 @@ v_again(sp, vp) VICMD *vp; { EXCMD cmd; + static CHAR_T nul[] = { 0 }; ex_cinit(sp, &cmd, C_SUBAGAIN, 2, vp->m_start.lno, vp->m_start.lno, 1); - argv_exp0(sp, &cmd, "", 1); + argv_exp0(sp, &cmd, nul, 1); return (v_exec_ex(sp, vp, &cmd)); } @@ -131,9 +132,10 @@ v_shiftl(sp, vp) VICMD *vp; { EXCMD cmd; + static CHAR_T lt[] = {'<', 0}; ex_cinit(sp, &cmd, C_SHIFTL, 2, vp->m_start.lno, vp->m_stop.lno, 0); - argv_exp0(sp, &cmd, "<", 2); + argv_exp0(sp, &cmd, lt, 2); return (v_exec_ex(sp, vp, &cmd)); } @@ -149,9 +151,10 @@ v_shiftr(sp, vp) VICMD *vp; { EXCMD cmd; + static CHAR_T gt[] = {'>', 0}; ex_cinit(sp, &cmd, C_SHIFTR, 2, vp->m_start.lno, vp->m_stop.lno, 0); - argv_exp0(sp, &cmd, ">", 2); + argv_exp0(sp, &cmd, gt, 2); return (v_exec_ex(sp, vp, &cmd)); } @@ -167,9 +170,10 @@ v_suspend(sp, vp) VICMD *vp; { EXCMD cmd; + static CHAR_T suspend[] = {'s', 'u', 's', 'p', 'e', 'n', 'd', 0}; ex_cinit(sp, &cmd, C_STOP, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, "suspend", sizeof("suspend")); + argv_exp0(sp, &cmd, suspend, sizeof(suspend)/sizeof(CHAR_T)); return (v_exec_ex(sp, vp, &cmd)); } @@ -186,6 +190,8 @@ v_switch(sp, vp) { EXCMD cmd; char *name; + CHAR_T *wp; + size_t wlen; /* * Try the alternate file name, then the previous file @@ -201,7 +207,8 @@ v_switch(sp, vp) return (1); ex_cinit(sp, &cmd, C_EDIT, 0, OOBLNO, OOBLNO, 0); - argv_exp0(sp, &cmd, name, strlen(name) + 1); + CHAR2INT(sp, name, strlen(name) + 1, wp, wlen); + argv_exp0(sp, &cmd, wp, wlen); return (v_exec_ex(sp, vp, &cmd)); } @@ -219,7 +226,7 @@ v_tagpush(sp, vp) EXCMD cmd; ex_cinit(sp, &cmd, C_TAG, 0, OOBLNO, 0, 0); - argv_exp0(sp, &cmd, VIP(sp)->keyw, strlen(VIP(sp)->keyw) + 1); + argv_exp0(sp, &cmd, VIP(sp)->keyw, v_strlen(VIP(sp)->keyw) + 1); return (v_exec_ex(sp, vp, &cmd)); } @@ -275,11 +282,12 @@ v_filter(sp, vp) */ if (F_ISSET(vp, VC_ISDOT) || ISCMD(vp->rkp, 'N') || ISCMD(vp->rkp, 'n')) { + static CHAR_T bang[] = {'!', 0}; ex_cinit(sp, &cmd, C_BANG, 2, vp->m_start.lno, vp->m_stop.lno, 0); EXP(sp)->argsoff = 0; /* XXX */ - if (argv_exp1(sp, &cmd, "!", 1, 1)) + if (argv_exp1(sp, &cmd, bang, 1, 1)) return (1); cmd.argc = EXP(sp)->argsoff; /* XXX */ cmd.argv = EXP(sp)->args; /* XXX */ diff --git a/vi/v_increment.c b/vi/v_increment.c index e3ab9794..37673651 100644 --- a/vi/v_increment.c +++ b/vi/v_increment.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_increment.c,v 10.13 2000/06/27 17:19:07 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:07 $"; +static const char sccsid[] = "$Id: v_increment.c,v 10.14 2000/07/14 14:29:23 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:23 $"; #endif /* not lint */ #include @@ -59,8 +59,8 @@ v_increment(sp, vp) long change, ltmp, lval; size_t beg, blen, end, len, nlen, wlen; int base, isempty, rval; - char *bp, *ntype, *t, nbuf[100]; - CHAR_T *p; + char *ntype, nbuf[100]; + CHAR_T *bp, *p, *t; /* Validate the operator. */ if (vp->character == '#') @@ -189,7 +189,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number"); * in signed longs. */ if (base == 10) { - if ((nret = nget_slong(&lval, t, NULL, 10)) != NUM_OK) + if ((nret = nget_slong(sp, &lval, t, NULL, 10)) != NUM_OK) goto err; ltmp = vp->character == '-' ? -change : change; if (lval > 0 && ltmp > 0 && !NPFITS(LONG_MAX, lval, ltmp)) { @@ -206,7 +206,7 @@ nonum: msgq(sp, M_ERR, "181|Cursor not in a number"); ntype = fmt[DEC]; nlen = snprintf(nbuf, sizeof(nbuf), ntype, lval); } else { - if ((nret = nget_uslong(&ulval, t, NULL, base)) != NUM_OK) + if ((nret = nget_uslong(sp, &ulval, t, NULL, base)) != NUM_OK) goto err; if (vp->character == '+') { if (!NPFITS(ULONG_MAX, ulval, change)) { diff --git a/vi/v_itxt.c b/vi/v_itxt.c index 0a87d834..7158b464 100644 --- a/vi/v_itxt.c +++ b/vi/v_itxt.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_itxt.c,v 10.18 2000/06/27 17:19:07 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:07 $"; +static const char sccsid[] = "$Id: v_itxt.c,v 10.19 2000/07/14 14:29:23 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:23 $"; #endif /* not lint */ #include @@ -227,7 +227,8 @@ io(sp, vp, cmd) len = 0; ai_line = OOBLNO; } else { -insert: p = ""; + static CHAR_T nul = 0; +insert: p = &nul; sp->cno = 0; LOG_CORRECT; @@ -265,7 +266,7 @@ v_change(sp, vp) size_t blen, len; u_int32_t flags; int isempty, lmode, rval; - char *bp; + CHAR_T *bp; CHAR_T *p; /* diff --git a/vi/v_replace.c b/vi/v_replace.c index f39123c9..dd1d9c2d 100644 --- a/vi/v_replace.c +++ b/vi/v_replace.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_replace.c,v 10.19 2000/06/27 17:19:08 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:08 $"; +static const char sccsid[] = "$Id: v_replace.c,v 10.20 2000/07/14 14:29:24 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:24 $"; #endif /* not lint */ #include @@ -53,7 +53,7 @@ v_replace(sp, vp) size_t blen, len; u_long cnt; int quote, rval; - char *bp; + CHAR_T *bp; CHAR_T *p; vip = VIP(sp); diff --git a/vi/v_search.c b/vi/v_search.c index 38c9128d..debf16a5 100644 --- a/vi/v_search.c +++ b/vi/v_search.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_search.c,v 10.24 2000/06/25 17:34:41 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:41 $"; +static const char sccsid[] = "$Id: v_search.c,v 10.25 2000/07/14 14:29:24 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:24 $"; #endif /* not lint */ #include @@ -30,7 +30,7 @@ static const char sccsid[] = "$Id: v_search.c,v 10.24 2000/06/25 17:34:41 skimo #include "../ipc/ip.h" static int v_exaddr __P((SCR *, VICMD *, dir_t)); -static int v_search __P((SCR *, VICMD *, char *, size_t, u_int, dir_t)); +static int v_search __P((SCR *, VICMD *, CHAR_T *, size_t, u_int, dir_t)); /* * v_srch -- [count]?RE[? offset] @@ -77,7 +77,11 @@ v_exaddr(sp, vp, dir) db_recno_t s_lno; size_t len, s_cno, tlen; int err, nb, type; - char *cmd, *t, buf[20]; + char buf[20]; + CHAR_T *cmd, *t; + static CHAR_T plus[] = { '+', 0 }; + CHAR_T *w; + size_t wlen; /* * !!! @@ -246,7 +250,7 @@ v_exaddr(sp, vp, dir) /* Default to z+. */ if (!type && - v_event_push(sp, NULL, "+", 1, CH_NOMAP | CH_QUOTED)) + v_event_push(sp, NULL, plus, 1, CH_NOMAP | CH_QUOTED)) return (1); /* Push the user's command. */ @@ -256,7 +260,8 @@ v_exaddr(sp, vp, dir) /* Push line number so get correct z display. */ tlen = snprintf(buf, sizeof(buf), "%lu", (u_long)vp->m_stop.lno); - if (v_event_push(sp, NULL, buf, tlen, CH_NOMAP | CH_QUOTED)) + CHAR2INT(sp, buf, tlen, w, wlen); + if (v_event_push(sp, NULL, w, wlen, CH_NOMAP | CH_QUOTED)) return (1); /* Don't refresh until after 'z' happens. */ @@ -332,11 +337,15 @@ v_searchw(sp, vp) { size_t blen, len; int rval; - char *bp; + CHAR_T *bp, *p; len = VIP(sp)->klen + sizeof(RE_WSTART) + sizeof(RE_WSTOP); - GET_SPACE_RET(sp, bp, blen, len); - len = snprintf(bp, blen, "%s%s%s", RE_WSTART, VIP(sp)->keyw, RE_WSTOP); + GET_SPACE_RET(sp, bp, blen, len * sizeof(CHAR_T)); + memcpy(bp, RE_WSTART, sizeof(RE_WSTART)); + p = bp + sizeof(RE_WSTART)/sizeof(CHAR_T) - 1; + memcpy(p, VIP(sp)->keyw, VIP(sp)->klen * sizeof(CHAR_T)); + p += VIP(sp)->klen; + memcpy(bp, RE_WSTOP, sizeof(RE_WSTOP)); rval = v_search(sp, vp, bp, len, SEARCH_SET, FORWARD); @@ -387,7 +396,7 @@ v_search(sp, vp, ptrn, plen, flags, dir) SCR *sp; VICMD *vp; u_int flags; - char *ptrn; + CHAR_T *ptrn; size_t plen; dir_t dir; { diff --git a/vi/v_txt.c b/vi/v_txt.c index 1246d458..32f2e0be 100644 --- a/vi/v_txt.c +++ b/vi/v_txt.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_txt.c,v 10.95 2000/07/10 15:28:45 skimo Exp $ (Berkeley) $Date: 2000/07/10 15:28:45 $"; +static const char sccsid[] = "$Id: v_txt.c,v 10.96 2000/07/14 14:29:24 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:24 $"; #endif /* not lint */ #include @@ -242,14 +242,14 @@ txt_map_end(sp) * Vi text input. * * PUBLIC: int v_txt __P((SCR *, VICMD *, MARK *, - * PUBLIC: const char *, size_t, ARG_CHAR_T, db_recno_t, u_long, u_int32_t)); + * PUBLIC: const CHAR_T *, size_t, ARG_CHAR_T, db_recno_t, u_long, u_int32_t)); */ int v_txt(sp, vp, tm, lp, len, prompt, ai_line, rcount, flags) SCR *sp; VICMD *vp; MARK *tm; /* To MARK. */ - const char *lp; /* Input line. */ + const CHAR_T *lp; /* Input line. */ size_t len; /* Input line length. */ ARG_CHAR_T prompt; /* Prompt to display. */ db_recno_t ai_line; /* Line number to use for autoindent count. */ @@ -281,7 +281,7 @@ v_txt(sp, vp, tm, lp, len, prompt, ai_line, rcount, flags) int showmatch; /* Showmatch set on this character. */ int wm_set, wm_skip; /* Wrapmargin happened, blank skip flags. */ int max, tmp; - char *p; + CHAR_T *p; gp = sp->gp; vip = VIP(sp); @@ -665,6 +665,7 @@ replay: if (LF_ISSET(TXT_REPLAY)) { case K_NL: /* New line. */ /* Return in script windows and the command line. */ k_cr: if (LF_ISSET(TXT_CR)) { + static CHAR_T cr[] = { '\r', 0 }; /* * If this was a map, we may have not displayed * the line. Display it, just in case. @@ -676,7 +677,7 @@ k_cr: if (LF_ISSET(TXT_CR)) { if (vs_change(sp, tp->lno, LINE_RESET)) goto err; } else if (F_ISSET(sp, SC_SCRIPT)) - (void)v_event_push(sp, NULL, "\r", 1, CH_NOMAP); + (void)v_event_push(sp, NULL, cr, 1, CH_NOMAP); /* Set term condition: if empty. */ if (tp->cno <= tp->offset) @@ -1565,7 +1566,7 @@ txt_abbrev(sp, tp, pushcp, isinfoline, didsubp, turnoffp) */ search: if (isinfoline) if (off == tp->ai || off == tp->offset) - if (ex_is_abbrev(p, len)) { + if (ex_is_abbrev(sp, p, len)) { *turnoffp = 1; return (0); } else @@ -1644,7 +1645,7 @@ txt_unmap(sp, tp, ec_flagsp) u_int32_t *ec_flagsp; { size_t len, off; - char *p; + CHAR_T *p; /* Find the beginning of this "word". */ for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --p, --off) { @@ -1670,7 +1671,7 @@ txt_unmap(sp, tp, ec_flagsp) * if the user erases the line and starts another command, we go ahead * an turn mapping back on. */ - if ((off == tp->ai || off == tp->offset) && ex_is_unmap(p, len)) + if ((off == tp->ai || off == tp->offset) && ex_is_unmap(sp, p, len)) FL_CLR(*ec_flagsp, EC_MAPINPUT); else FL_SET(*ec_flagsp, EC_MAPINPUT); @@ -2018,6 +2019,8 @@ txt_fc(sp, tp, redrawp) size_t indx, len, nlen, off; int argc, trydir; CHAR_T *p, *t; + char *np; + size_t nplen; trydir = 0; *redrawp = 0; @@ -2073,13 +2076,15 @@ retry: for (len = 0, return (0); case 1: /* One match. */ /* If something changed, do the exchange. */ - nlen = strlen(cmd.argv[0]->bp); - if (len != nlen || memcmp(cmd.argv[0]->bp, p, len)) + nlen = v_strlen(cmd.argv[0]->bp); + if (len != nlen || memcmp(cmd.argv[0]->bp, p, len * sizeof(CHAR_T))) break; /* If haven't done a directory test, do it now. */ + INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, + np, nplen); if (!trydir && - !stat(cmd.argv[0]->bp, &sb) && S_ISDIR(sb.st_mode)) { + !stat(np, &sb) && S_ISDIR(sb.st_mode)) { p += len; goto isdir; } @@ -2129,19 +2134,20 @@ retry: for (len = 0, tp->len += nlen; if (tp->insert != 0) - (void)memmove(p + nlen, p, tp->insert); + (void)memmove(p + nlen, p, tp->insert * sizeof(CHAR_T)); while (nlen--) *p++ = *t++; } /* If a single match and it's a directory, retry it. */ - if (argc == 1 && !stat(cmd.argv[0]->bp, &sb) && S_ISDIR(sb.st_mode)) { + INT2CHAR(sp, cmd.argv[0]->bp, cmd.argv[0]->len + 1, np, nplen); + if (argc == 1 && !stat(np, &sb) && S_ISDIR(sb.st_mode)) { isdir: if (tp->owrite == 0) { off = p - tp->lb; BINC_RET(sp, tp->lb, tp->lb_len, tp->len + 1); p = tp->lb + off; if (tp->insert != 0) - (void)memmove(p + 1, p, tp->insert); + (void)memmove(p + 1, p, tp->insert * sizeof(CHAR_T)); ++tp->len; } else --tp->owrite; @@ -2170,17 +2176,21 @@ txt_fc_col(sp, argc, argv) GS *gp; size_t base, cnt, col, colwidth, numrows, numcols, prefix, row; int ac, nf, reset; + char *np, *pp; + size_t nlen; gp = sp->gp; /* Trim any directory prefix common to all of the files. */ - if ((p = strrchr(argv[0]->bp, '/')) == NULL) + INT2CHAR(sp, argv[0]->bp, argv[0]->len + 1, np, nlen); + if ((pp = strrchr(np, '/')) == NULL) prefix = 0; else { - prefix = (p - argv[0]->bp) + 1; + prefix = (pp - np) + 1; for (ac = argc - 1, av = argv + 1; ac > 0; --ac, ++av) if (av[0]->len < prefix || - memcmp(av[0]->bp, argv[0]->bp, prefix)) { + memcmp(av[0]->bp, argv[0]->bp, + prefix * sizeof(CHAR_T))) { prefix = 0; break; } @@ -2218,8 +2228,10 @@ txt_fc_col(sp, argc, argv) /* If the largest file name is too large, just print them. */ if (colwidth > sp->cols) { for (ac = argc, av = argv; ac > 0; --ac, ++av) { - p = msg_print(sp, av[0]->bp + prefix, &nf); - (void)ex_printf(sp, "%s\n", p); + INT2CHAR(sp, av[0]->bp+prefix, av[0]->len+1-prefix, + np, nlen); + pp = msg_print(sp, np, &nf); + (void)ex_printf(sp, "%s\n", pp); if (F_ISSET(gp, G_INTERRUPTED)) break; } @@ -2239,8 +2251,10 @@ txt_fc_col(sp, argc, argv) /* Display the files in sorted order. */ for (row = 0; row < numrows; ++row) { for (base = row, col = 0; col < numcols; ++col) { - p = msg_print(sp, argv[base]->bp + prefix, &nf); - cnt = ex_printf(sp, "%s", p); + INT2CHAR(sp, argv[base]->bp+prefix, + argv[base]->len+1-prefix, np, nlen); + pp = msg_print(sp, np, &nf); + cnt = ex_printf(sp, "%s", pp); if (nf) FREE_SPACE(sp, p, 0); CHK_INTR; @@ -2277,9 +2291,10 @@ txt_emark(sp, tp, cno) TEXT *tp; size_t cno; { - CHAR_T ch, *kp; + CHAR_T ch; + char *kp; size_t chlen, nlen, olen; - char *p; + CHAR_T *p; ch = CH_ENDMARK; @@ -2299,7 +2314,7 @@ txt_emark(sp, tp, cno) * to fix it up. */ if (olen > nlen) { - BINC_RET(sp, tp->lb, tp->lb_len, tp->len + olen); + BINC_RET(sp, tp->lb, tp->lb_len, (tp->len + olen) * sizeof(CHAR_T)); chlen = olen - nlen; if (tp->insert != 0) memmove(tp->lb + cno + 1 + chlen, @@ -2367,7 +2382,9 @@ txt_hex(sp, tp) CHAR_T savec; size_t len, off; u_long value; - char *p, *wp; + CHAR_T *p, *wp; + char *np; + size_t nlen; /* * Null-terminate the string. Since nul isn't a legal hex value, @@ -2394,7 +2411,8 @@ txt_hex(sp, tp) /* Get the value. */ errno = 0; - value = strtol(wp, NULL, 16); + INT2CHAR(sp, wp, v_strlen(wp)+1, np, nlen); + value = strtol(np, NULL, 16); if (errno || value > MAX_CHAR_T) { nothex: tp->lb[tp->cno] = savec; return (0); @@ -2410,12 +2428,14 @@ nothex: tp->lb[tp->cno] = savec; /* Copy down any overwrite characters. */ if (tp->owrite) - memmove(tp->lb + tp->cno, tp->lb + tp->cno + len, tp->owrite); + memmove(tp->lb + tp->cno, tp->lb + tp->cno + len, + tp->owrite * sizeof(CHAR_T)); /* Copy down any insert characters. */ if (tp->insert) memmove(tp->lb + tp->cno + tp->owrite, - tp->lb + tp->cno + tp->owrite + len, tp->insert); + tp->lb + tp->cno + tp->owrite + len, + tp->insert * sizeof(CHAR_T)); return (0); } @@ -2446,9 +2466,10 @@ txt_insch(sp, tp, chp, flags) CHAR_T *chp; u_int flags; { - CHAR_T *kp, savech; + char *kp; + CHAR_T savech; size_t chlen, cno, copydown, olen, nlen; - char *p; + CHAR_T *p; /* * The 'R' command does one-for-one replacement, because there's @@ -2500,10 +2521,11 @@ txt_insch(sp, tp, chp, flags) nlen -= olen; } else { BINC_RET(sp, - tp->lb, tp->lb_len, tp->len + olen); + tp->lb, tp->lb_len, (tp->len + olen) * sizeof(CHAR_T)); chlen = olen - nlen; memmove(tp->lb + cno + 1 + chlen, - tp->lb + cno + 1, tp->owrite + tp->insert); + tp->lb + cno + 1, + (tp->owrite + tp->insert) * sizeof(CHAR_T)); tp->len += chlen; tp->owrite += chlen; @@ -2814,7 +2836,7 @@ txt_margin(sp, tp, wmtp, didbreak, flags) { VI_PRIVATE *vip; size_t len, off; - char *p, *wp; + CHAR_T *p, *wp; /* Find the nearest previous blank. */ for (off = tp->cno - 1, p = tp->lb + off, len = 0;; --off, --p, ++len) { diff --git a/vi/v_ulcase.c b/vi/v_ulcase.c index a123d561..d0e145de 100644 --- a/vi/v_ulcase.c +++ b/vi/v_ulcase.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_ulcase.c,v 10.8 2000/04/21 19:00:41 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:41 $"; +static const char sccsid[] = "$Id: v_ulcase.c,v 10.9 2000/07/14 14:29:24 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:24 $"; #endif /* not lint */ #include @@ -54,7 +54,7 @@ v_ulcase(sp, vp) db_recno_t lno; size_t cno, lcnt, len; u_long cnt; - char *p; + CHAR_T *p; lno = vp->m_start.lno; cno = vp->m_start.cno; @@ -154,7 +154,7 @@ ulcase(sp, lno, lp, len, scno, ecno) size_t blen; int change, rval; CHAR_T ch, *p, *t; - char *bp; + CHAR_T *bp; GET_SPACE_RET(sp, bp, blen, len); memmove(bp, lp, len); diff --git a/vi/v_util.c b/vi/v_util.c index cb4527bf..3372f28b 100644 --- a/vi/v_util.c +++ b/vi/v_util.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: v_util.c,v 10.12 2000/04/21 19:00:41 skimo Exp $ (Berkeley) $Date: 2000/04/21 19:00:41 $"; +static const char sccsid[] = "$Id: v_util.c,v 10.13 2000/07/14 14:29:25 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:25 $"; #endif /* not lint */ #include @@ -125,11 +125,11 @@ v_sol(sp) * v_isempty -- * Return if the line contains nothing but white-space characters. * - * PUBLIC: int v_isempty __P((char *, size_t)); + * PUBLIC: int v_isempty __P((CHAR_T *, size_t)); */ int v_isempty(p, len) - char *p; + CHAR_T *p; size_t len; { for (; len--; ++p) diff --git a/vi/vi.c b/vi/vi.c index bd43dd3e..82213df0 100644 --- a/vi/vi.c +++ b/vi/vi.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: vi.c,v 10.68 2000/07/11 22:05:11 skimo Exp $ (Berkeley) $Date: 2000/07/11 22:05:11 $"; +static const char sccsid[] = "$Id: vi.c,v 10.69 2000/07/14 14:29:25 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:25 $"; #endif /* not lint */ #include @@ -521,7 +521,7 @@ v_cmd(sp, dp, vp, ismotion, comcountp, mappedp) * a command. When a count is specified, the dot command behaves * differently, pass the information back. */ - if (isdigit(key) && key != '0') { + if (ISDIGIT(key) && key != '0') { if (v_count(sp, vp, key, &vp->count)) return (GC_ERR); @@ -685,7 +685,7 @@ usage: if (ismotion == NULL) /* Special case: 'z' command. */ if (vp->key == 'z') { KEY(vp->character, 0); - if (isdigit(vp->character)) { + if (ISDIGIT(vp->character)) { if (v_count(sp, vp, vp->character, &vp->count2)) return (GC_ERR); F_SET(vp, VC_C2SET); @@ -1170,7 +1170,7 @@ v_count(sp, vp, fkey, countp) if (v_key(sp, vp, 0, EC_MAPCOMMAND | EC_MAPNODIGIT) != GC_OK) return (1); - } while (isdigit(vp->ev.e_c)); + } while (ISDIGIT(vp->ev.e_c)); msgq(sp, M_ERR, "235|Number larger than %lu", ULONG_MAX); return (1); @@ -1178,7 +1178,7 @@ v_count(sp, vp, fkey, countp) count = tc; if (v_key(sp, vp, 0, EC_MAPCOMMAND | EC_MAPNODIGIT) != GC_OK) return (1); - } while (isdigit(vp->ev.e_c)); + } while (ISDIGIT(vp->ev.e_c)); *countp = count; return (0); } diff --git a/vi/vs_line.c b/vi/vs_line.c index 1798f3f1..ee40d479 100644 --- a/vi/vs_line.c +++ b/vi/vs_line.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: vs_line.c,v 10.22 2000/06/27 17:19:08 skimo Exp $ (Berkeley) $Date: 2000/06/27 17:19:08 $"; +static const char sccsid[] = "$Id: vs_line.c,v 10.23 2000/07/14 14:29:25 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:25 $"; #endif /* not lint */ #include @@ -43,7 +43,7 @@ vs_line(sp, smp, yp, xp) SMAP *smp; size_t *xp, *yp; { - CHAR_T *kp; + char *kp; GS *gp; SMAP *tsmp; size_t chlen, cno_cnt, cols_per_screen, len, nlen; diff --git a/vi/vs_msg.c b/vi/vs_msg.c index f62160ce..31fe5291 100644 --- a/vi/vs_msg.c +++ b/vi/vs_msg.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: vs_msg.c,v 10.81 2000/07/12 19:52:00 skimo Exp $ (Berkeley) $Date: 2000/07/12 19:52:00 $"; +static const char sccsid[] = "$Id: vs_msg.c,v 10.82 2000/07/14 14:29:25 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:25 $"; #endif /* not lint */ #include @@ -157,15 +157,15 @@ vs_home(sp) * vs_update -- * Update a command. * - * PUBLIC: void vs_update __P((SCR *, const char *, const char *)); + * PUBLIC: void vs_update __P((SCR *, const char *, const CHAR_T *)); */ void -vs_update(sp, m1, m2) - SCR *sp; - const char *m1, *m2; +vs_update(SCR *sp, const char *m1, const CHAR_T *m2) { GS *gp; size_t len, mlen, oldx, oldy; + CONST char *np; + size_t nlen; gp = sp->gp; @@ -178,8 +178,10 @@ vs_update(sp, m1, m2) * expanded, and by the ex substitution confirmation prompt. */ if (F_ISSET(sp, SC_SCR_EXWROTE)) { + if (m2 != NULL) + INT2CHAR(sp, m2, v_strlen(m2) + 1, np, nlen); (void)ex_printf(sp, - "%s\n", m1 == NULL? "" : m1, m2 == NULL ? "" : m2); + "%s\n", m1 == NULL? "" : m1, m2 == NULL ? "" : np); (void)ex_fflush(sp); } @@ -205,10 +207,10 @@ vs_update(sp, m1, m2) } else len = 0; if (m2 != NULL) { - mlen = strlen(m2); + mlen = v_strlen(m2); if (len + mlen > sp->cols - 2) mlen = (sp->cols - 2) - len; - (void)gp->scr_addstr(sp, m2, mlen); + (void)gp->scr_waddstr(sp, m2, mlen); } (void)gp->scr_move(sp, oldy, oldx); @@ -400,7 +402,7 @@ vs_output(sp, mtype, line, llen) const char *line; int llen; { - CHAR_T *kp; + char *kp; GS *gp; VI_PRIVATE *vip; size_t chlen, notused; diff --git a/vi/vs_split.c b/vi/vs_split.c index 2a993fe3..525598e9 100644 --- a/vi/vs_split.c +++ b/vi/vs_split.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: vs_split.c,v 10.37 2000/06/25 17:34:42 skimo Exp $ (Berkeley) $Date: 2000/06/25 17:34:42 $"; +static const char sccsid[] = "$Id: vs_split.c,v 10.38 2000/07/14 14:29:25 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:25 $"; #endif /* not lint */ #include @@ -628,20 +628,23 @@ vs_fg(sp, nspp, name, newscreen) GS *gp; WIN *wp; SCR *nsp; + char *np; + size_t nlen; gp = sp->gp; wp = sp->wp; + INT2CHAR(sp, name, v_strlen(name) + 1, np, nlen); if (newscreen) /* Get the specified background screen. */ - nsp = vs_getbg(sp, name); + nsp = vs_getbg(sp, np); else /* Swap screens. */ - if (vs_swap(sp, &nsp, name)) + if (vs_swap(sp, &nsp, np)) return (1); if ((*nspp = nsp) == NULL) { - msgq_str(sp, M_ERR, name, + msgq_wstr(sp, M_ERR, name, name == NULL ? "223|There are no background screens" : "224|There's no background screen editing a file named %s"); -- 2.11.4.GIT