diff options
author | Peter Wemm <peter@FreeBSD.org> | 2013-08-11 20:03:12 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 2013-08-11 20:03:12 +0000 |
commit | f0957ccae4f402b93cf27b125542343d28b53109 (patch) | |
tree | 7c1ae67d07b93aea05bfea51c590c1112b65042b /contrib/nvi/ex/ex_move.c | |
parent | ebe2785690e3a82421eac98f089a934901731af5 (diff) | |
parent | be3e4646eef6a3abcf58590dac24a5dfe54540f6 (diff) |
Update nvi-1.79 to 2.1.1-4334a8297f
This is the gsoc-2011 project to clean up and backport multibyte support
from other nvi forks in a form we can use.
USE_WIDECHAR is on unless building for the rescue crunchgen. This should
allow editing in the native locale encoding.
USE_ICONV depends on make.conf having 'WITH_ICONV=YES' for now. This
adds the ability to do things like edit a KOI8-R file while having $LANG
set to (say) en_US.UTF-8. iconv is used to transcode the characters for
display.
Other points:
* It uses gencat and catopen/etc instead of homegrown msg catalog stuff.
* A lot of stuff has been trimmed out, eg: the perl and tcl bindings which
we could never use in base anyway.
* It uses ncursesw when in widechar mode. This could be interesting.
GSoC info: http://www.google-melange.com/gsoc/proposal/review/google/gsoc2011/zy/1
Repo at: https://github.com/lichray/nvi2
Obtained from: Zhihao Yuan <lichray@gmail.com>
Notes
Notes:
svn path=/head/; revision=254225
Diffstat (limited to 'contrib/nvi/ex/ex_move.c')
-rw-r--r-- | contrib/nvi/ex/ex_move.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/contrib/nvi/ex/ex_move.c b/contrib/nvi/ex/ex_move.c index d6e45c373964..c2499fd79a8f 100644 --- a/contrib/nvi/ex/ex_move.c +++ b/contrib/nvi/ex/ex_move.c @@ -10,11 +10,12 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)ex_move.c 10.10 (Berkeley) 9/15/96"; +static const char sccsid[] = "$Id: ex_move.c,v 10.16 2012/02/11 15:52:33 zy Exp $"; #endif /* not lint */ #include <sys/types.h> #include <sys/queue.h> +#include <sys/time.h> #include <bitstring.h> #include <limits.h> @@ -31,11 +32,9 @@ static const char sccsid[] = "@(#)ex_move.c 10.10 (Berkeley) 9/15/96"; * PUBLIC: int ex_copy __P((SCR *, EXCMD *)); */ int -ex_copy(sp, cmdp) - SCR *sp; - EXCMD *cmdp; +ex_copy(SCR *sp, EXCMD *cmdp) { - CB cb; + CB cb = {{ 0 }}; MARK fm1, fm2, m, tm; recno_t cnt; int rval; @@ -51,10 +50,9 @@ ex_copy(sp, cmdp) */ fm1 = cmdp->addr1; fm2 = cmdp->addr2; - memset(&cb, 0, sizeof(cb)); - CIRCLEQ_INIT(&cb.textq); + TAILQ_INIT(cb.textq); for (cnt = fm1.lno; cnt <= fm2.lno; ++cnt) - if (cut_line(sp, cnt, 0, 0, &cb)) { + if (cut_line(sp, cnt, 0, ENTIRE_LINE, &cb)) { rval = 1; goto err; } @@ -75,7 +73,7 @@ ex_copy(sp, cmdp) sp->lno = m.lno + (cnt - 1); sp->cno = 0; } -err: text_lfree(&cb.textq); +err: text_lfree(cb.textq); return (rval); } @@ -86,16 +84,15 @@ err: text_lfree(&cb.textq); * PUBLIC: int ex_move __P((SCR *, EXCMD *)); */ int -ex_move(sp, cmdp) - SCR *sp; - EXCMD *cmdp; +ex_move(SCR *sp, EXCMD *cmdp) { LMARK *lmp; MARK fm1, fm2; recno_t cnt, diff, fl, tl, mfl, mtl; size_t blen, len; int mark_reset; - char *bp, *p; + CHAR_T *bp; + CHAR_T *p; NEEDFILE(sp, cmdp); @@ -126,7 +123,7 @@ ex_move(sp, cmdp) /* Log the old positions of the marks. */ mark_reset = 0; - for (lmp = sp->ep->marks.lh_first; lmp != NULL; lmp = lmp->q.le_next) + SLIST_FOREACH(lmp, sp->ep->marks, q) if (lmp->name != ABSMARK1 && lmp->lno >= fl && lmp->lno <= tl) { mark_reset = 1; @@ -135,7 +132,7 @@ ex_move(sp, cmdp) } /* Get memory for the copy. */ - GET_SPACE_RET(sp, bp, blen, 256); + GET_SPACE_RETW(sp, bp, blen, 256); /* Move the lines. */ diff = (fm2.lno - fm1.lno) + 1; @@ -145,13 +142,12 @@ ex_move(sp, cmdp) for (cnt = diff; cnt--;) { if (db_get(sp, fl, DBG_FATAL, &p, &len)) return (1); - BINC_RET(sp, bp, blen, len); - memcpy(bp, p, len); + BINC_RETW(sp, bp, blen, len); + MEMCPY(bp, p, len); if (db_append(sp, 1, tl, bp, len)) return (1); if (mark_reset) - for (lmp = sp->ep->marks.lh_first; - lmp != NULL; lmp = lmp->q.le_next) + SLIST_FOREACH(lmp, sp->ep->marks, q) if (lmp->name != ABSMARK1 && lmp->lno == fl) lmp->lno = tl + 1; @@ -164,13 +160,12 @@ ex_move(sp, cmdp) for (cnt = diff; cnt--;) { if (db_get(sp, fl, DBG_FATAL, &p, &len)) return (1); - BINC_RET(sp, bp, blen, len); - memcpy(bp, p, len); + BINC_RETW(sp, bp, blen, len); + MEMCPY(bp, p, len); if (db_append(sp, 1, tl++, bp, len)) return (1); if (mark_reset) - for (lmp = sp->ep->marks.lh_first; - lmp != NULL; lmp = lmp->q.le_next) + SLIST_FOREACH(lmp, sp->ep->marks, q) if (lmp->name != ABSMARK1 && lmp->lno == fl) lmp->lno = tl; @@ -179,15 +174,14 @@ ex_move(sp, cmdp) return (1); } } - FREE_SPACE(sp, bp, blen); + FREE_SPACEW(sp, bp, blen); sp->lno = tl; /* Last line moved. */ sp->cno = 0; /* Log the new positions of the marks. */ if (mark_reset) - for (lmp = sp->ep->marks.lh_first; - lmp != NULL; lmp = lmp->q.le_next) + SLIST_FOREACH(lmp, sp->ep->marks, q) if (lmp->name != ABSMARK1 && lmp->lno >= mfl && lmp->lno <= mtl) (void)log_mark(sp, lmp); |