Module Name:    src
Committed By:   christos
Date:           Sun Dec  1 02:34:54 UTC 2013

Modified Files:
        src/external/bsd/nvi/dist/common: exf.c gs.c main.c screen.c
        src/external/bsd/nvi/dist/ex: ex_edit.c ex_tag.c
        src/external/bsd/nvi/dist/vi: v_ex.c vi.c vs_msg.c vs_refresh.c
            vs_split.c

Log Message:
Revert all previous TAILQ_NEXT() = NULL, changes, checks against
NULL vip's and removal of screens from queues. Instead introduce
a new screen_end1() function that can be used to clean screens that
are not associated with queues yet. Pointed out by chuq@


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/common/exf.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/common/gs.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/common/main.c \
    src/external/bsd/nvi/dist/common/screen.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/ex/ex_edit.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/ex/ex_tag.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/vi/v_ex.c \
    src/external/bsd/nvi/dist/vi/vi.c src/external/bsd/nvi/dist/vi/vs_msg.c \
    src/external/bsd/nvi/dist/vi/vs_refresh.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/vi/vs_split.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/nvi/dist/common/exf.c
diff -u src/external/bsd/nvi/dist/common/exf.c:1.6 src/external/bsd/nvi/dist/common/exf.c:1.7
--- src/external/bsd/nvi/dist/common/exf.c:1.6	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/common/exf.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exf.c,v 1.6 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: exf.c,v 1.7 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -402,7 +402,6 @@ no_lock:
 
 	/* Switch... */
 	++ep->refcnt;
-	TAILQ_NEXT(sp, q) = NULL;
 	TAILQ_INSERT_HEAD(&ep->scrq, sp, eq);
 	sp->ep = ep;
 	sp->frp = frp;
@@ -692,7 +691,6 @@ file_end(SCR *sp, EXF *ep, int force)
 		if ((sp->db_error = db_close(ep->db)) != 0 && 
 		    !force) {
 			msgq_str(sp, M_DBERR, frp->name, "241|%s: close");
-			TAILQ_NEXT(sp, q) = NULL;
 			TAILQ_INSERT_HEAD(&ep->scrq, sp, eq);
 			++ep->refcnt;
 			return (1);

Index: src/external/bsd/nvi/dist/common/gs.c
diff -u src/external/bsd/nvi/dist/common/gs.c:1.3 src/external/bsd/nvi/dist/common/gs.c:1.4
--- src/external/bsd/nvi/dist/common/gs.c:1.3	Mon Nov 25 17:43:46 2013
+++ src/external/bsd/nvi/dist/common/gs.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: gs.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/*	$NetBSD: gs.c,v 1.4 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 2000
  *	Sven Verdoolaege.  All rights reserved.
@@ -112,10 +112,8 @@ win_end(WIN *wp)
 		(void)file_end(wp->ccl_sp, NULL, 1);
 		(void)screen_end(wp->ccl_sp);
 	}
-	while ((sp = TAILQ_FIRST(&wp->scrq)) != NULL) {
-		TAILQ_REMOVE(&wp->scrq, sp, q);
+	while ((sp = TAILQ_FIRST(&wp->scrq)) != NULL)
 		(void)screen_end(sp);
-	}
 
 	/* Free key input queue. */
 	if (wp->i_event != NULL)
@@ -150,14 +148,10 @@ gs_end(GS *gp)
 	WIN *wp;
 
 	/* If there are any remaining screens, kill them off. */
-	while ((wp = TAILQ_FIRST(&gp->dq)) != NULL) {
-		TAILQ_REMOVE(&gp->dq, wp, q);
+	while ((wp = TAILQ_FIRST(&gp->dq)) != NULL)
 		(void)win_end(wp);
-	}
-	while ((sp = TAILQ_FIRST(&gp->hq)) != NULL) {
-		TAILQ_REMOVE(&gp->hq, sp, q);
+	while ((sp = TAILQ_FIRST(&gp->hq)) != NULL)
 		(void)screen_end(sp);
-	}
 
 #ifdef HAVE_PERL_INTERP
 	perl_end(gp);

Index: src/external/bsd/nvi/dist/common/main.c
diff -u src/external/bsd/nvi/dist/common/main.c:1.4 src/external/bsd/nvi/dist/common/main.c:1.5
--- src/external/bsd/nvi/dist/common/main.c:1.4	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/common/main.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.4 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: main.c,v 1.5 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -233,14 +233,12 @@ editor(WIN *wp, int argc, char **argv)
 	 */
 	if (screen_init(gp, NULL, &sp)) {
 		if (sp != NULL) {
-			TAILQ_NEXT(sp, q) = NULL;
 			TAILQ_INSERT_HEAD(&wp->scrq, sp, q);
 			sp->wp = wp;
 		}
 		goto err;
 	}
 	F_SET(sp, SC_EX);
-	TAILQ_NEXT(sp, q) = NULL;
 	TAILQ_INSERT_HEAD(&wp->scrq, sp, q);
 	sp->wp = wp;
 
Index: src/external/bsd/nvi/dist/common/screen.c
diff -u src/external/bsd/nvi/dist/common/screen.c:1.4 src/external/bsd/nvi/dist/common/screen.c:1.5
--- src/external/bsd/nvi/dist/common/screen.c:1.4	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/common/screen.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: screen.c,v 1.4 2013/11/28 23:19:43 christos Exp $	*/
+/*	$NetBSD: screen.c,v 1.5 2013/12/01 02:34:54 christos Exp $	*/
 /*-
  * Copyright (c) 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -29,6 +29,7 @@ static const char sccsid[] = "Id: screen
 #include "common.h"
 #include "../vi/vi.h"
 
+static int screen_end1(SCR *, int);
 /*
  * screen_init --
  *	Do the default initialization of an SCR structure.
@@ -120,25 +121,18 @@ mem:				msgq(orig, M_SYSERR, NULL);
 	*spp = sp;
 	return (0);
 
-err:	screen_end(sp);
+err:	screen_end1(sp, 0);
 	return (1);
 }
 
-/*
- * screen_end --
- *	Release a screen, no matter what had (and had not) been
- *	initialized.
- *
- * PUBLIC: int screen_end __P((SCR *));
- */
-int
-screen_end(SCR *sp)
+static int
+screen_end1(SCR *sp, int init)
 {
 	int rval;
 
 	/* If multiply referenced, just decrement the count and return. */
-	 if (--sp->refcnt != 0)
-		 return (0);
+	if (--sp->refcnt != 0)
+		return (0);
 
 	/*
 	 * Remove the screen from the displayed queue.
@@ -146,7 +140,7 @@ screen_end(SCR *sp)
 	 * If a created screen failed during initialization, it may not
 	 * be linked into the chain.
 	 */
-	if (TAILQ_NEXT(sp, q) != NULL)
+	if (init)
 		TAILQ_REMOVE(&sp->wp->scrq, sp, q);
 
 	/* The screen is no longer real. */
@@ -203,6 +197,19 @@ screen_end(SCR *sp)
 }
 
 /*
+ * screen_end --
+ *	Release a screen, no matter what had (and had not) been
+ *	initialized.
+ *
+ * PUBLIC: int screen_end __P((SCR *));
+ */
+int
+screen_end(SCR *sp)
+{
+	return screen_end1(sp, 1);
+}
+
+/*
  * screen_next --
  *	Return the next screen in the queue.
  *
@@ -227,7 +234,6 @@ screen_next(SCR *sp)
 	/* Try the hidden queue; if found, move screen to the display queue. */
 	if ((next = TAILQ_FIRST(&gp->hq)) != NULL) {
 		TAILQ_REMOVE(&gp->hq, next, q);
-		TAILQ_NEXT(next, q) = NULL;
 		TAILQ_INSERT_HEAD(&wp->scrq, next, q);
 		next->wp = sp->wp;
 		return (next);

Index: src/external/bsd/nvi/dist/ex/ex_edit.c
diff -u src/external/bsd/nvi/dist/ex/ex_edit.c:1.4 src/external/bsd/nvi/dist/ex/ex_edit.c:1.5
--- src/external/bsd/nvi/dist/ex/ex_edit.c:1.4	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/ex/ex_edit.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_edit.c,v 1.4 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: ex_edit.c,v 1.5 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -129,7 +129,6 @@ ex_N_edit(SCR *sp, EXCMD *cmdp, FREF *fr
 		/* Copy file state, keep the screen and cursor the same. */
 		new->ep = sp->ep;
 		++new->ep->refcnt;
-		TAILQ_NEXT(new, eq) = NULL;
 		TAILQ_INSERT_HEAD(&new->ep->scrq, new, eq);
 
 		new->frp = frp;

Index: src/external/bsd/nvi/dist/ex/ex_tag.c
diff -u src/external/bsd/nvi/dist/ex/ex_tag.c:1.8 src/external/bsd/nvi/dist/ex/ex_tag.c:1.9
--- src/external/bsd/nvi/dist/ex/ex_tag.c:1.8	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/ex/ex_tag.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_tag.c,v 1.8 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: ex_tag.c,v 1.9 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -311,7 +311,6 @@ ex_tag_Nswitch(SCR *sp, TAG *tp, int for
 		/* Copy file state. */
 		new->ep = sp->ep;
 		++new->ep->refcnt;
-		TAILQ_NEXT(new, eq) = NULL;
 		TAILQ_INSERT_HEAD(&new->ep->scrq, new, eq);
 
 		new->frp = tp->frp;

Index: src/external/bsd/nvi/dist/vi/v_ex.c
diff -u src/external/bsd/nvi/dist/vi/v_ex.c:1.4 src/external/bsd/nvi/dist/vi/v_ex.c:1.5
--- src/external/bsd/nvi/dist/vi/v_ex.c:1.4	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/vi/v_ex.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: v_ex.c,v 1.4 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: v_ex.c,v 1.5 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -523,7 +523,6 @@ v_ecl(SCR *sp)
 	/* Attach to the screen. */
 	new->ep = wp->ccl_sp->ep;
 	++new->ep->refcnt;
-	TAILQ_NEXT(new, eq) = NULL;
 	TAILQ_INSERT_HEAD(&new->ep->scrq, new, eq);
 
 	new->frp = wp->ccl_sp->frp;
Index: src/external/bsd/nvi/dist/vi/vi.c
diff -u src/external/bsd/nvi/dist/vi/vi.c:1.4 src/external/bsd/nvi/dist/vi/vi.c:1.5
--- src/external/bsd/nvi/dist/vi/vi.c:1.4	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/vi/vi.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vi.c,v 1.4 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: vi.c,v 1.5 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -1033,7 +1033,6 @@ v_dtoh(SCR *sp)
 			_HMAP(tsp) = NULL;
 		}
 		TAILQ_REMOVE(&wp->scrq, tsp, q);
-		TAILQ_NEXT(tsp, q) = NULL;
 		TAILQ_INSERT_TAIL(&gp->hq, tsp, q);
 		/* XXXX Change if hidden screens per window */
 		tsp->wp = 0;
@@ -1042,7 +1041,6 @@ v_dtoh(SCR *sp)
 
 	/* Move current screen back to the display queue. */
 	TAILQ_REMOVE(&gp->hq, sp, q);
-	TAILQ_NEXT(sp, q) = NULL;
 	TAILQ_INSERT_TAIL(&wp->scrq, sp, q);
 	sp->wp = wp;
 
Index: src/external/bsd/nvi/dist/vi/vs_msg.c
diff -u src/external/bsd/nvi/dist/vi/vs_msg.c:1.4 src/external/bsd/nvi/dist/vi/vs_msg.c:1.5
--- src/external/bsd/nvi/dist/vi/vs_msg.c:1.4	Tue Nov 26 11:48:01 2013
+++ src/external/bsd/nvi/dist/vi/vs_msg.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs_msg.c,v 1.4 2013/11/26 16:48:01 christos Exp $ */
+/*	$NetBSD: vs_msg.c,v 1.5 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -661,8 +661,6 @@ vs_resolve(SCR *sp, SCR *csp, int forcew
 	gp = sp->gp;
 	wp = sp->wp;
 	vip = VIP(sp);
-	if (vip == NULL)
-		return 0;
 	if (csp == NULL)
 		csp = sp;
 
Index: src/external/bsd/nvi/dist/vi/vs_refresh.c
diff -u src/external/bsd/nvi/dist/vi/vs_refresh.c:1.4 src/external/bsd/nvi/dist/vi/vs_refresh.c:1.5
--- src/external/bsd/nvi/dist/vi/vs_refresh.c:1.4	Tue Nov 26 11:48:01 2013
+++ src/external/bsd/nvi/dist/vi/vs_refresh.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs_refresh.c,v 1.4 2013/11/26 16:48:01 christos Exp $ */
+/*	$NetBSD: vs_refresh.c,v 1.5 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -81,8 +81,7 @@ vs_refresh(SCR *sp, int forcepaint)
 			(void)vs_paint(tsp,
 			    (F_ISSET(VIP(tsp), VIP_CUR_INVALID) ?
 			    UPDATE_CURSOR : 0) | UPDATE_SCREEN);
-			if (VIP(sp))
-				F_SET(VIP(sp), VIP_CUR_INVALID);
+			F_SET(VIP(sp), VIP_CUR_INVALID);
 		}
 
 	/*

Index: src/external/bsd/nvi/dist/vi/vs_split.c
diff -u src/external/bsd/nvi/dist/vi/vs_split.c:1.5 src/external/bsd/nvi/dist/vi/vs_split.c:1.6
--- src/external/bsd/nvi/dist/vi/vs_split.c:1.5	Thu Nov 28 18:19:43 2013
+++ src/external/bsd/nvi/dist/vi/vs_split.c	Sat Nov 30 21:34:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs_split.c,v 1.5 2013/11/28 23:19:43 christos Exp $ */
+/*	$NetBSD: vs_split.c,v 1.6 2013/12/01 02:34:54 christos Exp $ */
 /*-
  * Copyright (c) 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -317,7 +317,6 @@ vs_insert(SCR *sp, WIN *wp)
 	 * If we reached the end, this screen goes there.  Otherwise,
 	 * put it before or after the screen where we stopped.
 	 */
-	TAILQ_NEXT(sp, q) = NULL;
 	if (tsp == NULL) {
 		TAILQ_INSERT_TAIL(&wp->scrq, sp, q);
 	} else if (tsp->roff < sp->roff ||
@@ -782,7 +781,6 @@ vs_swap(SCR *sp, SCR **nspp, const char 
 	 * code will move the old one to the background queue.
 	 */
 	TAILQ_REMOVE(&gp->hq, nsp, q);
-	TAILQ_NEXT(nsp, q) = NULL;
 	TAILQ_INSERT_AFTER(&wp->scrq, sp, nsp, q);
 
 	/*

Reply via email to