diff options
author | michaels <michaels@cvs.openbsd.org> | 1996-09-17 17:19:12 +0000 |
---|---|---|
committer | michaels <michaels@cvs.openbsd.org> | 1996-09-17 17:19:12 +0000 |
commit | fed417a38b95b13128c9588fd9f104da9b06bf41 (patch) | |
tree | 9591de9a563efff93cad28ba39dc4faf29aa4d92 | |
parent | 8cb1a1f6c9600981e4080fa44207d08d8c080e8f (diff) |
nvi 1.76:
+ Fix bug where ^V didn't keep input mapping from happening.
+ Fix a core dump bug in the R command.
+ Give up on licensing: no more shareware, adware, whatever.
+ Fix cursor positioning bug for C, S and c$ in an empty file.
30 files changed, 140 insertions, 163 deletions
diff --git a/usr.bin/vi/LICENSE b/usr.bin/vi/LICENSE index 1c54e6f4daa..78e8f4a40e1 100644 --- a/usr.bin/vi/LICENSE +++ b/usr.bin/vi/LICENSE @@ -1,6 +1,14 @@ +The vi program is freely redistributable. You are welcome to copy, modify +and share it with others under the conditions listed in this file. If any +company (not any individual!) finds vi sufficiently useful that you would +have purchased it, or if any company wishes to redistribute it, contributions +to the authors would be appreciated. + /*- * Copyright (c) 1991, 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. + * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996 + * Keith Bostic. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,25 +38,3 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - -/* - * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996 - * Keith Bostic. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following message. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following message in the - * documentation and/or other materials provided with the distribution. - * 3. For permission to redistribute this program under conditions other - * than these, contact Keith Bostic. - * - * The vi program is freely redistributable. You are welcome to copy, - * modify and share it with others under the conditions listed in the - * LICENSE file. If any company (not individual!) finds vi sufficiently - * useful that you would have purchased it, or if any company wishes to - * redistribute it, contributions to the authors would be appreciated. - */ diff --git a/usr.bin/vi/cl/cl.h b/usr.bin/vi/cl/cl.h index e711e95161f..d69108911e8 100644 --- a/usr.bin/vi/cl/cl.h +++ b/usr.bin/vi/cl/cl.h @@ -6,7 +6,7 @@ * * See the LICENSE file for redistribution information. * - * @(#)cl.h 10.17 (Berkeley) 7/12/96 + * @(#)cl.h 10.18 (Berkeley) 9/15/96 */ typedef struct _cl_private { @@ -24,8 +24,6 @@ typedef struct _cl_private { char *rmso, *smso; /* Inverse video terminal strings. */ char *smcup, *rmcup; /* Terminal start/stop strings. */ - int in_ex; /* XXX: Currently running ex. */ - int killersig; /* Killer signal. */ #define INDX_HUP 0 #define INDX_INT 1 @@ -40,14 +38,15 @@ typedef struct _cl_private { enum { /* Terminal initialization strings. */ TE_SENT=0, TI_SENT } ti_te; -#define CL_RENAME 0x001 /* X11 xterm icon/window renamed. */ -#define CL_RENAME_OK 0x002 /* User wants the windows renamed. */ -#define CL_SCR_EX_INIT 0x004 /* Ex screen initialized. */ -#define CL_SCR_VI_INIT 0x008 /* Vi screen initialized. */ -#define CL_SIGHUP 0x010 /* SIGHUP arrived. */ -#define CL_SIGINT 0x020 /* SIGINT arrived. */ -#define CL_SIGTERM 0x040 /* SIGTERM arrived. */ -#define CL_SIGWINCH 0x080 /* SIGWINCH arrived. */ +#define CL_IN_EX 0x0001 /* Currently running ex. */ +#define CL_RENAME 0x0002 /* X11 xterm icon/window renamed. */ +#define CL_RENAME_OK 0x0004 /* User wants the windows renamed. */ +#define CL_SCR_EX_INIT 0x0008 /* Ex screen initialized. */ +#define CL_SCR_VI_INIT 0x0010 /* Vi screen initialized. */ +#define CL_SIGHUP 0x0020 /* SIGHUP arrived. */ +#define CL_SIGINT 0x0040 /* SIGINT arrived. */ +#define CL_SIGTERM 0x0080 /* SIGTERM arrived. */ +#define CL_SIGWINCH 0x0100 /* SIGWINCH arrived. */ u_int32_t flags; } CL_PRIVATE; @@ -60,14 +59,6 @@ typedef enum { INP_OK=0, INP_EOF, INP_ERR, INP_INTR, INP_TIMEOUT } input_t; /* The screen line relative to a specific window. */ #define RLNO(sp, lno) (sp)->woff + (lno) -/* Some functions can be safely ignored until the screen is running. */ -#define VI_INIT_IGNORE(sp) \ - if (F_ISSET(sp, SC_VI) && !F_ISSET(sp, SC_SCR_VI)) \ - return (0); -#define EX_INIT_IGNORE(sp) \ - if (F_ISSET(sp, SC_EX) && !F_ISSET(sp, SC_SCR_EX)) \ - return (0); - /* X11 xterm escape sequence to rename the icon/window. */ #define XTERM_RENAME "\033]0;%s\007" diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c index 1efc0fa61ac..9d8d9811a21 100644 --- a/usr.bin/vi/cl/cl_screen.c +++ b/usr.bin/vi/cl/cl_screen.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)cl_screen.c 10.47 (Berkeley) 7/30/96"; +static const char sccsid[] = "@(#)cl_screen.c 10.48 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -102,8 +102,7 @@ cl_screen(sp, flags) if (LF_ISSET(SC_EX)) { if (cl_ex_init(sp)) return (1); - clp->in_ex = 1; - F_SET(clp, CL_SCR_EX_INIT); + F_SET(clp, CL_IN_EX | CL_SCR_EX_INIT); /* * If doing an ex screen for ex mode, move to the last line @@ -115,7 +114,7 @@ cl_screen(sp, flags) } else { if (cl_vi_init(sp)) return (1); - clp->in_ex = 0; + F_CLR(clp, CL_IN_EX); F_SET(clp, CL_SCR_VI_INIT); } return (0); @@ -398,7 +397,7 @@ cl_vi_end(gp) * Move to the bottom of the window (some endwin implementations don't * do this for you). */ - if (!clp->in_ex) { + if (!F_ISSET(clp, CL_IN_EX)) { (void)move(0, 0); (void)deleteln(); (void)move(LINES - 1, 0); diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c index 0e34628c597..e4007403870 100644 --- a/usr.bin/vi/cl/cl_term.c +++ b/usr.bin/vi/cl/cl_term.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)cl_term.c 10.21 (Berkeley) 7/12/96"; +static const char sccsid[] = "@(#)cl_term.c 10.22 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -183,8 +183,11 @@ cl_fmap(sp, stype, from, flen, to, tlen) CHAR_T *from, *to; size_t flen, tlen; { - EX_INIT_IGNORE(sp); - VI_INIT_IGNORE(sp); + /* Ignore until the screen is running, do the real work then. */ + if (F_ISSET(sp, SC_VI) && !F_ISSET(sp, SC_SCR_VI)) + return (0); + if (F_ISSET(sp, SC_EX) && !F_ISSET(sp, SC_SCR_EX)) + return (0); return (cl_pfmap(sp, stype, from, flen, to, tlen)); } diff --git a/usr.bin/vi/common/api.c b/usr.bin/vi/common/api.c index 9314fe6d047..62f61d0256b 100644 --- a/usr.bin/vi/common/api.c +++ b/usr.bin/vi/common/api.c @@ -12,7 +12,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)api.c 8.22 (Berkeley) 8/10/96"; +static const char sccsid[] = "@(#)api.c 8.23 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -21,7 +21,6 @@ static const char sccsid[] = "@(#)api.c 8.22 (Berkeley) 8/10/96"; #include <bitstring.h> #include <limits.h> -#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.bin/vi/common/cut.c b/usr.bin/vi/common/cut.c index 320dcfa2bdc..faceecd1116 100644 --- a/usr.bin/vi/common/cut.c +++ b/usr.bin/vi/common/cut.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)cut.c 10.9 (Berkeley) 3/30/96"; +static const char sccsid[] = "@(#)cut.c 10.10 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -266,7 +266,7 @@ cut_line(sp, lno, fcno, clen, cbp) if (len != 0) { if (clen == 0) clen = len - fcno; - memmove(tp->lb, p + fcno, clen); + memcpy(tp->lb, p + fcno, clen); tp->len = clen; } @@ -328,7 +328,7 @@ text_init(sp, p, len, total_len) return (NULL); } if (p != NULL && len != 0) - memmove(tp->lb, p, len); + memcpy(tp->lb, p, len); } tp->len = len; return (tp); diff --git a/usr.bin/vi/common/delete.c b/usr.bin/vi/common/delete.c index e6229c0cc2f..2c60b341a38 100644 --- a/usr.bin/vi/common/delete.c +++ b/usr.bin/vi/common/delete.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)delete.c 10.10 (Berkeley) 3/6/96"; +static const char sccsid[] = "@(#)delete.c 10.11 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -81,7 +81,7 @@ delete(sp, fm, tm, lmode) if (db_get(sp, fm->lno, DBG_FATAL, &p, &len)) return (1); GET_SPACE_RET(sp, bp, blen, fm->cno); - memmove(bp, p, fm->cno); + memcpy(bp, p, fm->cno); if (db_set(sp, fm->lno, bp, fm->cno)) return (1); goto done; @@ -94,8 +94,8 @@ delete(sp, fm, tm, lmode) return (1); GET_SPACE_RET(sp, bp, blen, len); if (fm->cno != 0) - memmove(bp, p, fm->cno); - memmove(bp + fm->cno, p + (tm->cno + 1), len - (tm->cno + 1)); + memcpy(bp, p, fm->cno); + memcpy(bp + fm->cno, p + (tm->cno + 1), len - (tm->cno + 1)); if (db_set(sp, fm->lno, bp, len - ((tm->cno - fm->cno) + 1))) goto err; @@ -111,7 +111,7 @@ delete(sp, fm, tm, lmode) if (db_get(sp, fm->lno, DBG_FATAL, &p, NULL)) return (1); GET_SPACE_RET(sp, bp, blen, tlen + 256); - memmove(bp, p, tlen); + memcpy(bp, p, tlen); } /* Copy the end partial line into place. */ @@ -134,7 +134,7 @@ delete(sp, fm, tm, lmode) } else ADD_SPACE_RET(sp, bp, blen, nlen); - memmove(bp + tlen, p + (tm->cno + 1), len - (tm->cno + 1)); + memcpy(bp + tlen, p + (tm->cno + 1), len - (tm->cno + 1)); tlen += len - (tm->cno + 1); } diff --git a/usr.bin/vi/common/line.c b/usr.bin/vi/common/line.c index 1639cc79026..bcb9e0c86bc 100644 --- a/usr.bin/vi/common/line.c +++ b/usr.bin/vi/common/line.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)line.c 10.20 (Berkeley) 4/27/96"; +static const char sccsid[] = "@(#)line.c 10.21 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -20,7 +20,6 @@ static const char sccsid[] = "@(#)line.c 10.20 (Berkeley) 4/27/96"; #include <bitstring.h> #include <errno.h> #include <limits.h> -#include <signal.h> #include <stdio.h> #include <string.h> @@ -521,7 +520,7 @@ db_last(sp, lnop) } /* Fill the cache. */ - memmove(&lno, key.data, sizeof(lno)); + memcpy(&lno, key.data, sizeof(lno)); ep->c_nlines = ep->c_lno = lno; ep->c_len = data.size; ep->c_lp = data.data; diff --git a/usr.bin/vi/common/msg.c b/usr.bin/vi/common/msg.c index f973f7231cc..2b18082c7ab 100644 --- a/usr.bin/vi/common/msg.c +++ b/usr.bin/vi/common/msg.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)msg.c 10.46 (Berkeley) 8/19/96"; +static const char sccsid[] = "@(#)msg.c 10.48 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/param.h> @@ -477,13 +477,13 @@ mod_rpt(sp) tlen += len; t = msg_cat(sp, lines[sp->rptlines[cnt] == 1 ? 0 : 1], &len); - memmove(p, t, len); + memcpy(p, t, len); p += len; tlen += len; *p++ = ' '; ++tlen; t = msg_cat(sp, *ap, &len); - memmove(p, t, len); + memcpy(p, t, len); p += len; tlen += len; sp->rptlines[cnt] = 0; @@ -629,27 +629,8 @@ msgq_status(sp, lno, flags) (void)sprintf(p, " (pid %lu)", (u_long)getpid()); p += strlen(p); #endif - len = p - bp; - - /* - * Poison. - * - * This message may not be altered in any way, without the written - * permission of Keith Bostic. See the LICENSE file for further - * information. - */ -#define POISON " UNLICENSED" - if (!poisoned && len < sp->cols - ((sizeof(POISON) - 1) + 1)) { - memset(p, ' ', sp->cols - len); - p = (bp + sp->cols) - ((sizeof(POISON) - 1) + 1); - memcpy(p, POISON, sizeof(POISON) - 1); - p = (bp + sp->cols) - 1; - len = p - bp; - poisoned = 1; - } - *p++ = '\n'; - ++len; + len = p - bp; /* * There's a nasty problem with long path names. Cscope and tags files diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c index 9dea74ddff3..8b5468e45ff 100644 --- a/usr.bin/vi/common/options.c +++ b/usr.bin/vi/common/options.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)options.c 10.48 (Berkeley) 8/10/96"; +static const char sccsid[] = "@(#)options.c 10.49 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -1072,7 +1072,7 @@ opts_copy(orig, sp) int cnt, rval; /* Copy most everything without change. */ - memmove(sp->opts, orig->opts, sizeof(orig->opts)); + memcpy(sp->opts, orig->opts, sizeof(orig->opts)); /* Copy the string edit options. */ for (cnt = rval = 0; cnt < O_OPTIONCOUNT; ++cnt) { diff --git a/usr.bin/vi/common/put.c b/usr.bin/vi/common/put.c index 76623e479d3..66e40a410ba 100644 --- a/usr.bin/vi/common/put.c +++ b/usr.bin/vi/common/put.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)put.c 10.9 (Berkeley) 3/6/96"; +static const char sccsid[] = "@(#)put.c 10.10 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -125,13 +125,13 @@ put(sp, cbp, namep, cp, rp, append) /* Original line, left of the split. */ if (len > 0 && (clen = cp->cno + (append ? 1 : 0)) > 0) { - memmove(bp, p, clen); + memcpy(bp, p, clen); p += clen; t += clen; } /* First line from the CB. */ - memmove(t, tp->lb, tp->len); + memcpy(t, tp->lb, tp->len); t += tp->len; /* Calculate length left in the original line. */ @@ -161,7 +161,7 @@ put(sp, cbp, namep, cp, rp, append) */ if (tp->q.cqe_next == (void *)&cbp->textq) { if (clen > 0) { - memmove(t, p, clen); + memcpy(t, p, clen); t += clen; } if (db_set(sp, lno, bp, t - bp)) @@ -187,9 +187,9 @@ put(sp, cbp, namep, cp, rp, append) t = bp + len; /* Add in last part of the CB. */ - memmove(t, ltp->lb, ltp->len); + memcpy(t, ltp->lb, ltp->len); if (clen) - memmove(t + ltp->len, p, clen); + memcpy(t + ltp->len, p, clen); clen += ltp->len; /* diff --git a/usr.bin/vi/common/recover.c b/usr.bin/vi/common/recover.c index 10702cc384f..f3abaab5a53 100644 --- a/usr.bin/vi/common/recover.c +++ b/usr.bin/vi/common/recover.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)recover.c 10.20 (Berkeley) 6/20/96"; +static const char sccsid[] = "@(#)recover.c 10.21 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/param.h> @@ -31,7 +31,6 @@ static const char sccsid[] = "@(#)recover.c 10.20 (Berkeley) 6/20/96"; #include <fcntl.h> #include <limits.h> #include <pwd.h> -#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.bin/vi/common/screen.c b/usr.bin/vi/common/screen.c index dfc4e40473b..ba9e287b648 100644 --- a/usr.bin/vi/common/screen.c +++ b/usr.bin/vi/common/screen.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)screen.c 10.14 (Berkeley) 7/19/96"; +static const char sccsid[] = "@(#)screen.c 10.15 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -100,7 +100,7 @@ mem: msgq(orig, M_SYSERR, NULL); } sp->newl_len = orig->newl_len; sp->newl_cnt = orig->newl_cnt; - memmove(sp->newl, orig->newl, len); + memcpy(sp->newl, orig->newl, len); } if (opts_copy(orig, sp)) diff --git a/usr.bin/vi/common/util.c b/usr.bin/vi/common/util.c index 1fb95bf898e..5a4422a2c42 100644 --- a/usr.bin/vi/common/util.c +++ b/usr.bin/vi/common/util.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)util.c 10.10 (Berkeley) 3/6/96"; +static const char sccsid[] = "@(#)util.c 10.11 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -136,7 +136,7 @@ v_strdup(sp, str, len) MALLOC(sp, copy, CHAR_T *, len + 1); if (copy == NULL) return (NULL); - memmove(copy, str, len * sizeof(CHAR_T)); + memcpy(copy, str, len * sizeof(CHAR_T)); copy[len] = '\0'; return (copy); } diff --git a/usr.bin/vi/docs/changelog b/usr.bin/vi/docs/changelog index b864a202108..ce2b35f6e48 100644 --- a/usr.bin/vi/docs/changelog +++ b/usr.bin/vi/docs/changelog @@ -1,3 +1,8 @@ +1.75 -> 1.76 (09/15/96) + + Fix bug where ^V didn't keep input mapping from happening. + + Fix a core dump bug in the R command. + + Give up on licensing: no more shareware, adware, whatever. + + Fix cursor positioning bug for C, S and c$ in an empty file. 1.74 -> 1.75 (08/22/96) + Add French to the error message translations. + Move the UNLICENSED message to the end of the message line. diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c index ca6872b332b..df456ce0117 100644 --- a/usr.bin/vi/ex/ex.c +++ b/usr.bin/vi/ex/ex.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex.c 10.53 (Berkeley) 8/11/96"; +static const char sccsid[] = "@(#)ex.c 10.54 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -1472,7 +1472,7 @@ addr_verify: ecp->save_cmd -= arg1_len; ecp->save_cmdlen += arg1_len; - memmove(ecp->save_cmd, arg1, arg1_len); + memcpy(ecp->save_cmd, arg1, arg1_len); /* * Any commands executed from a +cmd are executed starting at @@ -2121,7 +2121,7 @@ ex_load(sp) * so we have play games. */ ecp->cp = ecp->o_cp; - memmove(ecp->cp, ecp->cp + ecp->o_clen, ecp->o_clen); + memcpy(ecp->cp, ecp->cp + ecp->o_clen, ecp->o_clen); ecp->clen = ecp->o_clen; ecp->range_lno = sp->lno = rp->start++; @@ -2176,7 +2176,7 @@ ex_unknown(sp, cmd, len) GET_SPACE_GOTO(sp, bp, blen, len + 1); bp[len] = '\0'; - memmove(bp, cmd, len); + memcpy(bp, cmd, len); msgq_str(sp, M_ERR, bp, "098|The %s command is unknown"); FREE_SPACE(sp, bp, blen); diff --git a/usr.bin/vi/ex/ex_at.c b/usr.bin/vi/ex/ex_at.c index 630c11d8507..e9c6c592d60 100644 --- a/usr.bin/vi/ex/ex_at.c +++ b/usr.bin/vi/ex/ex_at.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_at.c 10.11 (Berkeley) 6/30/96"; +static const char sccsid[] = "@(#)ex_at.c 10.12 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -116,7 +116,7 @@ ex_at(sp, cmdp) /* Copy the buffer into the command space. */ for (p = ecp->cp + len, tp = cbp->textq.cqh_last; tp != (void *)&cbp->textq; tp = tp->q.cqe_prev) { - memmove(p, tp->lb, tp->len); + memcpy(p, tp->lb, tp->len); p += tp->len; *p++ = '\n'; } diff --git a/usr.bin/vi/ex/ex_cscope.c b/usr.bin/vi/ex/ex_cscope.c index 2676e104ac6..c2fa0a5c454 100644 --- a/usr.bin/vi/ex/ex_cscope.c +++ b/usr.bin/vi/ex/ex_cscope.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_cscope.c 10.12 (Berkeley) 8/11/96"; +static const char sccsid[] = "@(#)ex_cscope.c 10.13 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/param.h> @@ -25,7 +25,6 @@ static const char sccsid[] = "@(#)ex_cscope.c 10.12 (Berkeley) 8/11/96"; #include <errno.h> #include <fcntl.h> #include <limits.h> -#include <signal.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.bin/vi/ex/ex_join.c b/usr.bin/vi/ex/ex_join.c index d423d30491b..c26c4243178 100644 --- a/usr.bin/vi/ex/ex_join.c +++ b/usr.bin/vi/ex/ex_join.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_join.c 10.9 (Berkeley) 3/6/96"; +static const char sccsid[] = "@(#)ex_join.c 10.10 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -126,7 +126,7 @@ ex_join(sp, cmdp) } if (len != 0) { - memmove(tbp, p, len); + memcpy(tbp, p, len); tbp += len; clen += len; echar = p[len - 1]; diff --git a/usr.bin/vi/ex/ex_move.c b/usr.bin/vi/ex/ex_move.c index 5e28984c2be..d6e45c37396 100644 --- a/usr.bin/vi/ex/ex_move.c +++ b/usr.bin/vi/ex/ex_move.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_move.c 10.9 (Berkeley) 3/6/96"; +static const char sccsid[] = "@(#)ex_move.c 10.10 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -146,7 +146,7 @@ ex_move(sp, cmdp) if (db_get(sp, fl, DBG_FATAL, &p, &len)) return (1); BINC_RET(sp, bp, blen, len); - memmove(bp, p, len); + memcpy(bp, p, len); if (db_append(sp, 1, tl, bp, len)) return (1); if (mark_reset) @@ -165,7 +165,7 @@ ex_move(sp, cmdp) if (db_get(sp, fl, DBG_FATAL, &p, &len)) return (1); BINC_RET(sp, bp, blen, len); - memmove(bp, p, len); + memcpy(bp, p, len); if (db_append(sp, 1, tl++, bp, len)) return (1); if (mark_reset) diff --git a/usr.bin/vi/ex/ex_perl.c b/usr.bin/vi/ex/ex_perl.c index 501bb53f6fc..e620352ab51 100644 --- a/usr.bin/vi/ex/ex_perl.c +++ b/usr.bin/vi/ex/ex_perl.c @@ -14,7 +14,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_perl.c 8.9 (Berkeley) 7/19/96"; +static const char sccsid[] = "@(#)ex_perl.c 8.10 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -24,7 +24,6 @@ static const char sccsid[] = "@(#)ex_perl.c 8.9 (Berkeley) 7/19/96"; #include <bitstring.h> #include <ctype.h> #include <limits.h> -#include <signal.h> #include <stdio.h> #include <string.h> #include <termios.h> diff --git a/usr.bin/vi/ex/ex_shift.c b/usr.bin/vi/ex/ex_shift.c index e81aa9585bf..83bd36d12a7 100644 --- a/usr.bin/vi/ex/ex_shift.c +++ b/usr.bin/vi/ex/ex_shift.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_shift.c 10.10 (Berkeley) 3/6/96"; +static const char sccsid[] = "@(#)ex_shift.c 10.11 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -146,7 +146,7 @@ shift(sp, cmdp, rl) *tbp++ = ' '; /* Add the original line. */ - memmove(tbp, p + oldidx, len - oldidx); + memcpy(tbp, p + oldidx, len - oldidx); /* Set the replacement line. */ if (db_set(sp, from, bp, (tbp + (len - oldidx)) - bp)) { diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c index 16fd3345dc3..0ebb81dd58e 100644 --- a/usr.bin/vi/ex/ex_subst.c +++ b/usr.bin/vi/ex/ex_subst.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_subst.c 10.36 (Berkeley) 8/20/96"; +static const char sccsid[] = "@(#)ex_subst.c 10.37 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -222,7 +222,7 @@ subagain: return (ex_subagain(sp, cmdp)); } } else if (p[0] == '~' && O_ISSET(sp, O_MAGIC)) { tilde: ++p; - memmove(t, sp->repl, sp->repl_len); + memcpy(t, sp->repl, sp->repl_len); t += sp->repl_len; len += sp->repl_len; continue; @@ -238,7 +238,7 @@ tilde: ++p; FREE_SPACE(sp, bp, blen); return (1); } - memmove(sp->repl, bp, len); + memcpy(sp->repl, bp, len); } FREE_SPACE(sp, bp, blen); } @@ -327,7 +327,7 @@ ex_subtilde(sp, cmdp) return (1); \ } \ } \ - memmove(lb + lbclen, l, len); \ + memcpy(lb + lbclen, l, len); \ lbclen += len; \ } @@ -516,7 +516,7 @@ noargs: if (F_ISSET(sp, SC_VI) && sp->c_suffix && (lflag || nflag || pflag)) { GET_SPACE_RET(sp, bp, blen, llen); } else ADD_SPACE_RET(sp, bp, blen, llen); - memmove(bp, s, llen); + memcpy(bp, s, llen); s = bp; } @@ -750,7 +750,7 @@ skip: offset += match[0].rm_eo; if (db_get(sp, lno, DBG_FATAL, &s, &llen)) goto err; ADD_SPACE_RET(sp, bp, blen, llen) - memmove(bp, s, llen); + memcpy(bp, s, llen); s = bp; len = llen - offset; diff --git a/usr.bin/vi/ex/ex_tag.c b/usr.bin/vi/ex/ex_tag.c index 3d0c60e94cf..461b1526ef0 100644 --- a/usr.bin/vi/ex/ex_tag.c +++ b/usr.bin/vi/ex/ex_tag.c @@ -13,7 +13,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_tag.c 10.35 (Berkeley) 6/30/96"; +static const char sccsid[] = "@(#)ex_tag.c 10.36 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/param.h> @@ -869,7 +869,7 @@ ex_tagf_alloc(sp, str) free(tfp); return (1); } - memmove(tfp->name, t, len); + memcpy(tfp->name, t, len); tfp->name[len] = '\0'; tfp->flags = 0; TAILQ_INSERT_TAIL(&exp->tagfq, tfp, q); diff --git a/usr.bin/vi/ex/ex_tcl.c b/usr.bin/vi/ex/ex_tcl.c index a03f10e9903..06736a78100 100644 --- a/usr.bin/vi/ex/ex_tcl.c +++ b/usr.bin/vi/ex/ex_tcl.c @@ -12,7 +12,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_tcl.c 8.9 (Berkeley) 4/28/96"; +static const char sccsid[] = "@(#)ex_tcl.c 8.10 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -20,7 +20,6 @@ static const char sccsid[] = "@(#)ex_tcl.c 8.9 (Berkeley) 4/28/96"; #include <bitstring.h> #include <limits.h> -#include <signal.h> #include <stdio.h> #include <string.h> #include <termios.h> diff --git a/usr.bin/vi/ex/ex_txt.c b/usr.bin/vi/ex/ex_txt.c index 399a7c958d8..09471c2938a 100644 --- a/usr.bin/vi/ex/ex_txt.c +++ b/usr.bin/vi/ex/ex_txt.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_txt.c 10.14 (Berkeley) 6/30/96"; +static const char sccsid[] = "@(#)ex_txt.c 10.15 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -292,7 +292,7 @@ notlast: CIRCLEQ_REMOVE(tiqh, tp, q); ait.lb = NULL; ait.lb_len = 0; BINC_GOTO(sp, ait.lb, ait.lb_len, tp->ai); - memmove(ait.lb, tp->lb, tp->ai); + memcpy(ait.lb, tp->lb, tp->ai); ait.ai = ait.len = tp->ai; carat_st = C_NOCHANGE; diff --git a/usr.bin/vi/ex/version.h b/usr.bin/vi/ex/version.h index dc8109190f5..badc55d163b 100644 --- a/usr.bin/vi/ex/version.h +++ b/usr.bin/vi/ex/version.h @@ -1,2 +1,2 @@ #define VI_VERSION \ - "Version 1.75 (8/22/96) The CSRG, University of California, Berkeley." + "Version 1.76 (9/15/96) The CSRG, University of California, Berkeley." diff --git a/usr.bin/vi/vi/v_itxt.c b/usr.bin/vi/vi/v_itxt.c index 954eaa5957d..347629d5202 100644 --- a/usr.bin/vi/vi/v_itxt.c +++ b/usr.bin/vi/vi/v_itxt.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)v_itxt.c 10.13 (Berkeley) 4/27/96"; +static const char sccsid[] = "@(#)v_itxt.c 10.14 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -268,6 +268,15 @@ v_change(sp, vp) char *bp, *p; /* + * 'c' can be combined with motion commands that set the resulting + * cursor position, i.e. "cG". Clear the VM_RCM flags and make the + * resulting cursor position stick, inserting text has its own rules + * for cursor positioning. + */ + F_CLR(vp, VM_RCM_MASK); + F_SET(vp, VM_RCM_SET); + + /* * Find out if the file is empty, it's easier to handle it as a * special case. */ @@ -303,15 +312,6 @@ v_change(sp, vp) LOG_CORRECT; /* - * 'c' can be combined with motion commands that set the resulting - * cursor position, i.e. "cG". Clear the VM_RCM flags and make the - * resulting cursor position stick, inserting text has its own rules - * for cursor positioning. - */ - F_CLR(vp, VM_RCM_MASK); - F_SET(vp, VM_RCM_SET); - - /* * If not in line mode and changing within a single line, copy the * text and overwrite it. */ diff --git a/usr.bin/vi/vi/v_txt.c b/usr.bin/vi/vi/v_txt.c index 18b837a174d..d4068f4a296 100644 --- a/usr.bin/vi/vi/v_txt.c +++ b/usr.bin/vi/vi/v_txt.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)v_txt.c 10.80 (Berkeley) 8/13/96"; +static const char sccsid[] = "@(#)v_txt.c 10.83 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -628,6 +628,8 @@ replay: if (LF_ISSET(TXT_REPLAY)) */ if (quote == Q_BTHIS || quote == Q_VTHIS) { FL_CLR(ec_flags, EC_QUOTED); + if (LF_ISSET(TXT_MAPINPUT)) + FL_SET(ec_flags, EC_MAPINPUT); if (quote == Q_BTHIS && (evp->e_value == K_VERASE || evp->e_value == K_VKILL)) { @@ -709,8 +711,13 @@ k_cr: if (LF_ISSET(TXT_CR)) { abb = AB_NOTWORD; \ if (UNMAP_TST) \ txt_unmap(sp, tp, &ec_flags); \ - /* Delete any appended cursor. */ \ - if (LF_ISSET(TXT_APPENDEOL)) { \ + /* \ + * Delete any appended cursor. It's possible to get in \ + * situations where TXT_APPENDEOL is set but tp->insert \ + * is 0 when using the R command and all the characters \ + * are tp->owrite characters. \ + */ \ + if (LF_ISSET(TXT_APPENDEOL) && tp->insert > 0) { \ --tp->len; \ --tp->insert; \ } \ @@ -719,7 +726,7 @@ k_cr: if (LF_ISSET(TXT_CR)) { /* * Save the current line information for restoration in - * txt_backup(). Set the new line length. + * txt_backup(), and set the line final length. */ tp->sv_len = tp->len; tp->sv_cno = tp->cno; @@ -755,10 +762,18 @@ k_cr: if (LF_ISSET(TXT_CR)) { owrite = 0; } - /* Set up bookkeeping for the new line. */ + /* + * !!! + * Create a new line and insert the new TEXT into the queue. + * DON'T insert until the old line has been updated, or the + * inserted line count in line.c:db_get() will be wrong. + */ if ((ntp = text_init(sp, p, insert + owrite, insert + owrite + 32)) == NULL) goto err; + CIRCLEQ_INSERT_TAIL(&sp->tiq, ntp, q); + + /* Set up bookkeeping for the new line. */ ntp->insert = insert; ntp->owrite = owrite; ntp->lno = tp->lno + 1; @@ -813,18 +828,8 @@ k_cr: if (LF_ISSET(TXT_CR)) { ++ntp->len; } - /* - * Swap old and new TEXT's, and insert the new TEXT into the - * queue. - * - * !!! - * DON'T insert until the old line has been updated, or the - * inserted line count in line.c:db_get() will be wrong. - */ + /* Swap old and new TEXT's, and update the new line. */ tp = ntp; - CIRCLEQ_INSERT_TAIL(&sp->tiq, tp, q); - - /* Update the new line. */ if (vs_change(sp, tp->lno, LINE_INSERT)) goto err; @@ -1223,7 +1228,14 @@ leftmargin: tp->lb[tp->cno - 1] = ' '; case K_VLNEXT: /* Quote next character. */ evp->e_c = '^'; quote = Q_VNEXT; + /* + * Turn on the quote flag so that the underlying routines + * quote the next character where it's possible. Turn off + * the input mapbiting flag so that we don't remap the next + * character. + */ FL_SET(ec_flags, EC_QUOTED); + FL_CLR(ec_flags, EC_MAPINPUT); /* * !!! diff --git a/usr.bin/vi/vi/vs_refresh.c b/usr.bin/vi/vi/vs_refresh.c index e4c5e9247a7..e8bcddea9c0 100644 --- a/usr.bin/vi/vi/vs_refresh.c +++ b/usr.bin/vi/vi/vs_refresh.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)vs_refresh.c 10.39 (Berkeley) 8/17/96"; +static const char sccsid[] = "@(#)vs_refresh.c 10.41 (Berkeley) 9/15/96"; #endif /* not lint */ #include <sys/types.h> @@ -87,10 +87,10 @@ vs_refresh(sp, forcepaint) * XXX * This is fairly evil. Status lines are written using the vi message * mechanism, since we have no idea how long they are. Since we may be - * painting screens other than the current one, we don't want want to - * make the user wait. We depend heavily on there not being any other - * lines currently waiting to be displayed and the message truncation - * code in the msgq_status routine working. + * painting screens other than the current one, we don't want to make + * the user wait. We depend heavily on there not being any other lines + * currently waiting to be displayed and the message truncation code in + * the msgq_status routine working. */ for (tsp = sp->gp->dq.cqh_first; tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next) @@ -669,13 +669,19 @@ paint: for (smp = HMAP; smp <= TMAP; ++smp) didpaint = 1; done_cursor: -#ifdef DEBUG /* * Sanity checking. When the repainting code messes up, the usual - * result is we don't repaint the cursor. Die now. + * result is we don't repaint the cursor and so sc_smap will be + * NULL. If we're debugging, die, otherwise restart from scratch. */ +#ifdef DEBUG if (vip->sc_smap == NULL) abort(); +#else + if (vip->sc_smap == NULL) { + F_SET(sp, SC_SCR_REFORMAT); + return (vs_paint(sp, flags)); + } #endif /* |