diff options
author | peter <peter@FreeBSD.org> | 2013-08-11 20:03:12 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2013-08-11 20:03:12 +0000 |
commit | 5f2a1d653696ec5457bfd044f0ebcd873bfc3c80 (patch) | |
tree | 7c1ae67d07b93aea05bfea51c590c1112b65042b /contrib/nvi/common/screen.c | |
parent | 324febaf01918418f99998aa5537126ac98c9df0 (diff) | |
download | FreeBSD-src-5f2a1d653696ec5457bfd044f0ebcd873bfc3c80.zip FreeBSD-src-5f2a1d653696ec5457bfd044f0ebcd873bfc3c80.tar.gz |
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>
Diffstat (limited to 'contrib/nvi/common/screen.c')
-rw-r--r-- | contrib/nvi/common/screen.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/contrib/nvi/common/screen.c b/contrib/nvi/common/screen.c index ba9e287..9ff6845 100644 --- a/contrib/nvi/common/screen.c +++ b/contrib/nvi/common/screen.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)screen.c 10.15 (Berkeley) 9/15/96"; +static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -35,9 +35,10 @@ static const char sccsid[] = "@(#)screen.c 10.15 (Berkeley) 9/15/96"; * PUBLIC: int screen_init __P((GS *, SCR *, SCR **)); */ int -screen_init(gp, orig, spp) - GS *gp; - SCR *orig, **spp; +screen_init( + GS *gp, + SCR *orig, + SCR **spp) { SCR *sp; size_t len; @@ -50,9 +51,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 @@ -60,7 +61,7 @@ screen_init(gp, orig, spp) * we don't have the option information yet. */ - CIRCLEQ_INIT(&sp->tiq); + TAILQ_INIT(sp->tiq); /* PARTIALLY OR COMPLETELY COPIED FROM PREVIOUS SCREEN. */ if (orig == NULL) { @@ -80,15 +81,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) { @@ -113,6 +114,8 @@ mem: msgq(orig, M_SYSERR, NULL); goto err; if (v_screen_copy(orig, sp)) /* Vi. */ goto err; + sp->cl_private = 0; /* XXX */ + conv_init(orig, sp); /* XXX */ *spp = sp; return (0); @@ -129,8 +132,7 @@ err: screen_end(sp); * PUBLIC: int screen_end __P((SCR *)); */ int -screen_end(sp) - SCR *sp; +screen_end(SCR *sp) { int rval; @@ -144,17 +146,13 @@ screen_end(sp) * If a created screen failed during initialization, it may not * be linked into the chain. */ - if (sp->q.cqe_next != NULL) - CIRCLEQ_REMOVE(&sp->gp->dq, sp, q); + if (TAILQ_ENTRY_ISVALID(sp, q)) + TAILQ_REMOVE(sp->gp->dq, sp, q); /* The screen is no longer real. */ F_CLR(sp, SC_SCR_EX | SC_SCR_VI); rval = 0; -#ifdef HAVE_PERL_INTERP - if (perl_screen_end(sp)) /* End perl. */ - rval = 1; -#endif if (v_screen_end(sp)) /* End vi. */ rval = 1; if (ex_screen_end(sp)) /* End ex. */ @@ -170,8 +168,8 @@ screen_end(sp) } /* Free any text input. */ - if (sp->tiq.cqh_first != NULL) - text_lfree(&sp->tiq); + if (!TAILQ_EMPTY(sp->tiq)) + text_lfree(sp->tiq); /* Free alternate file name. */ if (sp->alt_name != NULL) @@ -191,6 +189,9 @@ screen_end(sp) if (sp->newl != NULL) free(sp->newl); + /* Free the iconv environment */ + conv_end(sp); + /* Free all the options */ opts_free(sp); @@ -207,26 +208,24 @@ screen_end(sp) * PUBLIC: SCR *screen_next __P((SCR *)); */ SCR * -screen_next(sp) - SCR *sp; +screen_next(SCR *sp) { GS *gp; SCR *next; /* Try the display queue, without returning the current screen. */ gp = sp->gp; - for (next = gp->dq.cqh_first; - next != (void *)&gp->dq; next = next->q.cqe_next) + TAILQ_FOREACH(next, gp->dq, q) if (next != sp) break; - if (next != (void *)&gp->dq) + if (next != NULL) return (next); /* Try the hidden queue; if found, move screen to the display queue. */ - if (gp->hq.cqh_first != (void *)&gp->hq) { - next = gp->hq.cqh_first; - CIRCLEQ_REMOVE(&gp->hq, next, q); - CIRCLEQ_INSERT_HEAD(&gp->dq, next, q); + if (!TAILQ_EMPTY(gp->hq)) { + next = TAILQ_FIRST(gp->hq); + TAILQ_REMOVE(gp->hq, next, q); + TAILQ_INSERT_HEAD(gp->dq, next, q); return (next); } return (NULL); |