CVS commit: src/external/bsd/nvi/dist/ex

2018-08-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Aug  7 11:41:23 UTC 2018

Modified Files:
src/external/bsd/nvi/dist/ex: ex_script.c

Log Message:
Use wp and wlen instead of ip and ilen for consistency.
No binary changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/nvi/dist/ex/ex_script.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/ex/ex_script.c
diff -u src/external/bsd/nvi/dist/ex/ex_script.c:1.8 src/external/bsd/nvi/dist/ex/ex_script.c:1.9
--- src/external/bsd/nvi/dist/ex/ex_script.c:1.8	Mon Nov  6 03:27:34 2017
+++ src/external/bsd/nvi/dist/ex/ex_script.c	Tue Aug  7 11:41:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_script.c,v 1.8 2017/11/06 03:27:34 rin Exp $ */
+/*	$NetBSD: ex_script.c,v 1.9 2018/08/07 11:41:23 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -19,7 +19,7 @@
 static const char sccsid[] = "Id: ex_script.c,v 10.38 2001/06/25 15:19:19 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:19 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_script.c,v 1.8 2017/11/06 03:27:34 rin Exp $");
+__RCSID("$NetBSD: ex_script.c,v 1.9 2018/08/07 11:41:23 rin Exp $");
 #endif
 
 #include 
@@ -262,17 +262,17 @@ sscr_exec(SCR *sp, db_recno_t lno)
 	ssize_t nw;
 	char *bp = NULL;
 	const char *p;
-	const CHAR_T *ip;
-	size_t ilen;
+	const CHAR_T *wp;
+	size_t wlen;
 
 	sc = sp->script;
 
 	/* If there's a prompt on the last line, append the command. */
 	if (db_last(sp, _lno))
 		return (1);
-	if (db_get(sp, last_lno, DBG_FATAL, __UNCONST(), ))
+	if (db_get(sp, last_lno, DBG_FATAL, __UNCONST(), ))
 		return (1);
-	INT2CHAR(sp, ip, ilen, p, last_len);
+	INT2CHAR(sp, wp, wlen, p, last_len);
 	if (last_len == sc->sh_prompt_len &&
 	memcmp(p, sc->sh_prompt, last_len) == 0) {
 		matchprompt = 1;
@@ -282,16 +282,16 @@ sscr_exec(SCR *sp, db_recno_t lno)
 		matchprompt = 0;
 
 	/* Get something to execute. */
-	if (db_eget(sp, lno, __UNCONST(), , )) {
+	if (db_eget(sp, lno, __UNCONST(), , )) {
 		if (isempty)
 			goto empty;
 		goto err1;
 	}
 
 	/* Empty lines aren't interesting. */
-	if (ilen == 0)
+	if (wlen == 0)
 		goto empty;
-	INT2CHAR(sp, ip, ilen, p, len);
+	INT2CHAR(sp, wp, wlen, p, len);
 
 	/* Delete any prompt. */
 	if (len >= sc->sh_prompt_len &&
@@ -318,8 +318,8 @@ err2:		if (nw == 0)
 	if (matchprompt) {
 		ADD_SPACE_GOTO(sp, char, bp, blen, last_len + len);
 		memmove(bp + last_len, p, len);
-		CHAR2INT(sp, bp, last_len + len, ip, ilen);
-		if (db_set(sp, last_lno, ip, ilen))
+		CHAR2INT(sp, bp, last_len + len, wp, wlen);
+		if (db_set(sp, last_lno, wp, wlen))
 err1:			rval = 1;
 	}
 	if (matchprompt)
@@ -432,8 +432,8 @@ sscr_insert(SCR *sp)
 	size_t len;
 	ssize_t nr;
 	char bp[1024];
-	const CHAR_T *ip;
-	size_t ilen = 0;
+	const CHAR_T *wp;
+	size_t wlen = 0;
 
 	/* Find out where the end of the file is. */
 	if (db_last(sp, ))
@@ -459,8 +459,8 @@ more:	switch (nr = read(sc->sh_master, e
 	for (p = t = bp; p < endp; ++p) {
 		if (*p == '\r' || *p == '\n') {
 			len = p - t;
-			if (CHAR2INT(sp, t, len, ip, ilen) ||
-			db_append(sp, 1, lno++, ip, ilen))
+			if (CHAR2INT(sp, t, len, wp, wlen) ||
+			db_append(sp, 1, lno++, wp, wlen))
 return (1);
 			t = p + 1;
 		}
@@ -481,8 +481,8 @@ more:	switch (nr = read(sc->sh_master, e
 		FD_SET(sc->sh_master, );
 		if (select(sc->sh_master + 1, , NULL, NULL, ) == 1) {
 			if (len == sizeof(bp)) {
-if (CHAR2INT(sp, t, len, ip, ilen) ||
-db_append(sp, 1, lno++, ip, ilen))
+if (CHAR2INT(sp, t, len, wp, wlen) ||
+db_append(sp, 1, lno++, wp, wlen))
 	return (1);
 endp = bp;
 			} else {
@@ -497,10 +497,10 @@ more:	switch (nr = read(sc->sh_master, e
 
 	/* Append the remains into the file, and the cursor moves to EOF. */
 	if (len > 0) {
-		if (CHAR2INT(sp, t, len, ip, ilen) ||
-		db_append(sp, 1, lno++, ip, ilen))
+		if (CHAR2INT(sp, t, len, wp, wlen) ||
+		db_append(sp, 1, lno++, wp, wlen))
 			return (1);
-		sp->cno = ilen - 1;
+		sp->cno = wlen - 1;
 	} else
 		sp->cno = 0;
 	sp->lno = lno;



CVS commit: src/external/bsd/nvi/dist/ex

2017-12-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec  1 20:01:31 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex_usage.c

Log Message:
Compare ap->len wide chars, not ap->len bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_usage.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/ex/ex_usage.c
diff -u src/external/bsd/nvi/dist/ex/ex_usage.c:1.3 src/external/bsd/nvi/dist/ex/ex_usage.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_usage.c:1.3	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_usage.c	Fri Dec  1 20:01:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_usage.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_usage.c,v 1.4 2017/12/01 20:01:31 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_usage.c,v 10.15 2001/06/25 15:19:21 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:21 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_usage.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: ex_usage.c,v 1.4 2017/12/01 20:01:31 rin Exp $");
 #endif
 
 #include 
@@ -78,7 +78,7 @@ ex_usage(SCR *sp, EXCMD *cmdp)
 		} else
 			newscreen = 0;
 		for (cp = cmds; cp->name != NULL &&
-		memcmp(ap->bp, cp->name, ap->len); ++cp);
+		MEMCMP(ap->bp, cp->name, ap->len); ++cp);
 		if (cp->name == NULL ||
 		(newscreen && !F_ISSET(cp, E_NEWSCREEN))) {
 			const char *nstr;



CVS commit: src/external/bsd/nvi/dist/ex

2017-12-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec  1 18:39:49 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex_print.c

Log Message:
Check format strings for ex_printf.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/ex/ex_print.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/ex/ex_print.c
diff -u src/external/bsd/nvi/dist/ex/ex_print.c:1.5 src/external/bsd/nvi/dist/ex/ex_print.c:1.6
--- src/external/bsd/nvi/dist/ex/ex_print.c:1.5	Sun Nov 12 15:27:53 2017
+++ src/external/bsd/nvi/dist/ex/ex_print.c	Fri Dec  1 18:39:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_print.c,v 1.5 2017/11/12 15:27:53 rin Exp $ */
+/*	$NetBSD: ex_print.c,v 1.6 2017/12/01 18:39:49 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_print.c,v 10.24 2001/07/29 19:07:29 skimo Exp  (Berkeley) Date: 2001/07/29 19:07:29 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_print.c,v 1.5 2017/11/12 15:27:53 rin Exp $");
+__RCSID("$NetBSD: ex_print.c,v 1.6 2017/12/01 18:39:49 rin Exp $");
 #endif
 
 #include 
@@ -264,7 +264,7 @@ intr:	*colp = col;
  * ex_printf --
  *	Ex's version of printf.
  *
- * PUBLIC: int ex_printf __P((SCR *, const char *, ...));
+ * PUBLIC: int ex_printf __P((SCR *, const char *, ...)) __printflike(2, 3);
  */
 int
 #ifdef __STDC__



CVS commit: src/external/bsd/nvi/dist/ex

2017-11-22 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Nov 22 13:13:18 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex.c

Log Message:
Fix backward memcpy in :e +cmd, taken from nvi2 (and OpenBSD):
https://github.com/lichray/nvi2/commit/7ab02500a2d89bc45db383cb3dcd10f3c4301a8c
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/vi/ex/ex.c#rev1.21


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/ex/ex.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/ex/ex.c
diff -u src/external/bsd/nvi/dist/ex/ex.c:1.6 src/external/bsd/nvi/dist/ex/ex.c:1.7
--- src/external/bsd/nvi/dist/ex/ex.c:1.6	Mon Nov 13 01:40:37 2017
+++ src/external/bsd/nvi/dist/ex/ex.c	Wed Nov 22 13:13:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex.c,v 1.6 2017/11/13 01:40:37 rin Exp $ */
+/*	$NetBSD: ex.c,v 1.7 2017/11/22 13:13:18 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex.c,v 10.75 2004/03/16 14:13:35 skimo Exp  (Berkeley) Date: 2004/03/16 14:13:35 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex.c,v 1.6 2017/11/13 01:40:37 rin Exp $");
+__RCSID("$NetBSD: ex.c,v 1.7 2017/11/22 13:13:18 rin Exp $");
 #endif
 
 #include 
@@ -1512,7 +1512,7 @@ addr_verify:
 
 		ecp->save_cmd -= arg1_len;
 		ecp->save_cmdlen += arg1_len;
-		MEMCPYW(ecp->save_cmd, arg1, arg1_len);
+		MEMMOVEW(ecp->save_cmd, arg1, arg1_len);
 
 		/*
 		 * Any commands executed from a +cmd are executed starting at



CVS commit: src/external/bsd/nvi/dist/ex

2017-11-20 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Nov 21 07:48:07 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex_join.c

Log Message:
Use ISMULTIWIDTH() macro. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/ex/ex_join.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/ex/ex_join.c
diff -u src/external/bsd/nvi/dist/ex/ex_join.c:1.4 src/external/bsd/nvi/dist/ex/ex_join.c:1.5
--- src/external/bsd/nvi/dist/ex/ex_join.c:1.4	Fri Nov 10 14:53:00 2017
+++ src/external/bsd/nvi/dist/ex/ex_join.c	Tue Nov 21 07:48:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_join.c,v 1.4 2017/11/10 14:53:00 rin Exp $ */
+/*	$NetBSD: ex_join.c,v 1.5 2017/11/21 07:48:07 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_join.c,v 10.17 2004/03/16 14:14:04 skimo Exp  (Berkeley) Date: 2004/03/16 14:14:04 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_join.c,v 1.4 2017/11/10 14:53:00 rin Exp $");
+__RCSID("$NetBSD: ex_join.c,v 1.5 2017/11/21 07:48:07 rin Exp $");
 #endif
 
 #include 
@@ -118,9 +118,8 @@ ex_join(SCR *sp, EXCMD *cmdp)
 			 *	single-width	multi-width	1 spc ins'ed
 			 *	single-width	single-width	original
 			 */
-			if (INTISWIDE(echar) && CHAR_WIDTH(sp, echar) > 1) {
-if (INTISWIDE(p[0])
-&& CHAR_WIDTH(sp, p[0]) > 1) {
+			if (ISMULTIWIDTH(sp, echar)) {
+if (ISMULTIWIDTH(sp, p[0])) {
 	; /* nothing */
 } else {
 	*tbp++ = ' ';
@@ -128,8 +127,7 @@ ex_join(SCR *sp, EXCMD *cmdp)
 	for (; len && ISBLANK((UCHAR_T)*p);
 	--len, ++p);
 }
-			} else if (INTISWIDE(p[0])
-   && CHAR_WIDTH(sp, p[0]) > 1) {
+			} else if (ISMULTIWIDTH(sp, p[0])) {
 *tbp++ = ' ';
 ++clen;
 			} else if (ISBLANK(echar))



CVS commit: src/external/bsd/nvi/dist/ex

2017-11-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Nov 12 15:27:53 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex_print.c

Log Message:
db_recno_t aka recno_t is uint32_t


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/ex/ex_print.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/ex/ex_print.c
diff -u src/external/bsd/nvi/dist/ex/ex_print.c:1.4 src/external/bsd/nvi/dist/ex/ex_print.c:1.5
--- src/external/bsd/nvi/dist/ex/ex_print.c:1.4	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_print.c	Sun Nov 12 15:27:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_print.c,v 1.4 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_print.c,v 1.5 2017/11/12 15:27:53 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_print.c,v 10.24 2001/07/29 19:07:29 skimo Exp  (Berkeley) Date: 2001/07/29 19:07:29 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_print.c,v 1.4 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: ex_print.c,v 1.5 2017/11/12 15:27:53 rin Exp $");
 #endif
 
 #include 
@@ -119,7 +119,7 @@ ex_print(SCR *sp, EXCMD *cmdp, MARK *fp,
 		 */
 		if (LF_ISSET(E_C_HASH)) {
 			if (from <= 99) {
-SPRINTF(buf, SIZE(buf), L("%6ld  "), from);
+SPRINTF(buf, SIZE(buf), L("%6u  "), from);
 p = buf;
 			} else
 p = L("TOOBIG  ");



CVS commit: src/external/bsd/nvi/dist/ex

2017-11-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Nov 12 15:22:09 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex_cscope.c

Log Message:
Add missing encoding conversion before printing it.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/nvi/dist/ex/ex_cscope.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/ex/ex_cscope.c
diff -u src/external/bsd/nvi/dist/ex/ex_cscope.c:1.7 src/external/bsd/nvi/dist/ex/ex_cscope.c:1.8
--- src/external/bsd/nvi/dist/ex/ex_cscope.c:1.7	Tue Aug 26 15:19:38 2014
+++ src/external/bsd/nvi/dist/ex/ex_cscope.c	Sun Nov 12 15:22:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_cscope.c,v 1.7 2014/08/26 15:19:38 aymeric Exp $ */
+/*	$NetBSD: ex_cscope.c,v 1.8 2017/11/12 15:22:09 rin Exp $ */
 /*-
  * Copyright (c) 1994, 1996
  *	Rob Mayoff.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_cscope.c,v 10.21 2003/11/05 17:11:54 skimo Exp  (Berkeley) Date: 2003/11/05 17:11:54 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_cscope.c,v 1.7 2014/08/26 15:19:38 aymeric Exp $");
+__RCSID("$NetBSD: ex_cscope.c,v 1.8 2017/11/12 15:22:09 rin Exp $");
 #endif
 
 #include 
@@ -232,6 +232,7 @@ cscope_add(SCR *sp, EXCMD *cmdp, const C
 	if (cmdp->argc == cur_argc + 1)
 		dname = cmdp->argv[cur_argc]->bp;
 	else {
+		INT2CHAR(sp, dname, STRLEN(dname)+1, np, nlen);
 		ex_emsg(sp, np, EXM_FILECOUNT);
 		return (1);
 	}



CVS commit: src/external/bsd/nvi/dist/ex

2017-11-10 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 10 14:53:00 UTC 2017

Modified Files:
src/external/bsd/nvi/dist/ex: ex_join.c

Log Message:
Change the behavior of join command in accordance with nvi-m17n, as proposed on
tech-userlevel@; when the last and first chars in joined lines are multi-width,
do not insert a white space.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_join.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/ex/ex_join.c
diff -u src/external/bsd/nvi/dist/ex/ex_join.c:1.3 src/external/bsd/nvi/dist/ex/ex_join.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_join.c:1.3	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_join.c	Fri Nov 10 14:53:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_join.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_join.c,v 1.4 2017/11/10 14:53:00 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_join.c,v 10.17 2004/03/16 14:14:04 skimo Exp  (Berkeley) Date: 2004/03/16 14:14:04 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_join.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: ex_join.c,v 1.4 2017/11/10 14:53:00 rin Exp $");
 #endif
 
 #include 
@@ -109,7 +109,30 @@ ex_join(SCR *sp, EXCMD *cmdp)
 		 */
 		extra = 0;
 		if (!first && !FL_ISSET(cmdp->iflags, E_C_FORCE)) {
-			if (ISBLANK(echar))
+			/*
+			 * Here we implement behavior just based on nvi-m17n.
+			 *	last char	first char	behavior
+			 *	---		---		---
+			 *	multi-width	multi-width	nothing ins'ed
+			 *	multi-width	single-width	1 spc ins'ed
+			 *	single-width	multi-width	1 spc ins'ed
+			 *	single-width	single-width	original
+			 */
+			if (INTISWIDE(echar) && CHAR_WIDTH(sp, echar) > 1) {
+if (INTISWIDE(p[0])
+&& CHAR_WIDTH(sp, p[0]) > 1) {
+	; /* nothing */
+} else {
+	*tbp++ = ' ';
+	++clen;
+	for (; len && ISBLANK((UCHAR_T)*p);
+	--len, ++p);
+}
+			} else if (INTISWIDE(p[0])
+   && CHAR_WIDTH(sp, p[0]) > 1) {
+*tbp++ = ' ';
+++clen;
+			} else if (ISBLANK(echar))
 for (; len && ISBLANK((UCHAR_T)*p); --len, ++p);
 			else if (p[0] != ')') {
 if (STRCHR(L(".?!"), echar)) {



CVS commit: src/external/bsd/nvi/dist/ex

2016-12-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 19 17:51:40 UTC 2016

Modified Files:
src/external/bsd/nvi/dist/ex: ex_script.c

Log Message:
improve logic related to sh_prompt:
- sscr_insert(): sh_prompt should be compared with t, not p
- replace strnstr(3) with memcmp(3)
now, nvi is free from strnstr(3); it can be safely pulled-up into netbsd-7


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/ex/ex_script.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/ex/ex_script.c
diff -u src/external/bsd/nvi/dist/ex/ex_script.c:1.6 src/external/bsd/nvi/dist/ex/ex_script.c:1.7
--- src/external/bsd/nvi/dist/ex/ex_script.c:1.6	Sun Nov 29 17:09:33 2015
+++ src/external/bsd/nvi/dist/ex/ex_script.c	Mon Dec 19 17:51:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_script.c,v 1.6 2015/11/29 17:09:33 christos Exp $ */
+/*	$NetBSD: ex_script.c,v 1.7 2016/12/19 17:51:40 rin Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -19,7 +19,7 @@
 static const char sccsid[] = "Id: ex_script.c,v 10.38 2001/06/25 15:19:19 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:19 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_script.c,v 1.6 2015/11/29 17:09:33 christos Exp $");
+__RCSID("$NetBSD: ex_script.c,v 1.7 2016/12/19 17:51:40 rin Exp $");
 #endif
 
 #include 
@@ -274,7 +274,7 @@ sscr_exec(SCR *sp, db_recno_t lno)
 		return (1);
 	INT2CHAR(sp, ip, ilen, p, last_len);
 	if (last_len == sc->sh_prompt_len &&
-	strnstr(p, sc->sh_prompt, last_len) == p) {
+	memcmp(p, sc->sh_prompt, last_len) == 0) {
 		matchprompt = 1;
 		GET_SPACE_RETC(sp, bp, blen, last_len + 128);
 		memmove(bp, p, last_len);
@@ -294,7 +294,8 @@ sscr_exec(SCR *sp, db_recno_t lno)
 	INT2CHAR(sp, ip, ilen, p, len);
 
 	/* Delete any prompt. */
-	if (strnstr(p, sc->sh_prompt, len) == p) {
+	if (len >= sc->sh_prompt_len &&
+	memcmp(p, sc->sh_prompt, sc->sh_prompt_len) == 0) {
 		len -= sc->sh_prompt_len;
 		if (len == 0) {
 empty:			msgq(sp, M_BERR, "151|No command to execute");
@@ -473,7 +474,7 @@ more:	switch (nr = read(sc->sh_master, e
 	 */
 	len = p - t;
 	if (sc->sh_prompt == NULL || len != sc->sh_prompt_len ||
-	strnstr(p, sc->sh_prompt, len) == NULL) {
+	memcmp(t, sc->sh_prompt, len) != 0) {
 		tv.tv_sec = 0;
 		tv.tv_usec = 10;
 		FD_ZERO();
@@ -509,7 +510,7 @@ more:	switch (nr = read(sc->sh_master, e
 /*
  * sscr_setprompt --
  *
- * Set the prompt to the last line we got from the shell.
+ * Set the prompt in external ("char") encoding.
  *
  */
 static int



CVS commit: src/external/bsd/nvi/dist/ex

2016-03-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 17 00:19:36 UTC 2016

Modified Files:
src/external/bsd/nvi/dist/ex: ex_map.c

Log Message:
add default: to appease gcc.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_map.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/ex/ex_map.c
diff -u src/external/bsd/nvi/dist/ex/ex_map.c:1.3 src/external/bsd/nvi/dist/ex/ex_map.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_map.c:1.3	Sun Jan 26 16:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_map.c	Wed Mar 16 20:19:36 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_map.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_map.c,v 1.4 2016/03/17 00:19:36 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = "Id: ex_map.c,v 10.11 2001/06/25 15:19:17 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:17 ";
 #endif /* not lint */
 #else
-__RCSID("$NetBSD: ex_map.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
+__RCSID("$NetBSD: ex_map.c,v 1.4 2016/03/17 00:19:36 christos Exp $");
 #endif
 
 #include 
@@ -99,6 +99,8 @@ nofunc:	if (stype == SEQ_COMMAND && inpu
 			"134|The %s character may not be remapped",
 			KEY_NAME(sp, input[0]));
 			return (1);
+		default:
+			break;
 		}
 	return (seq_set(sp, NULL, 0, input, cmdp->argv[0]->len,
 	cmdp->argv[1]->bp, cmdp->argv[1]->len, stype, SEQ_USERDEF));



CVS commit: src/external/bsd/nvi/dist/ex

2014-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 27 20:00:10 UTC 2014

Modified Files:
src/external/bsd/nvi/dist/ex: ex_mkexrc.c

Log Message:
exrc expects 1 argument.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_mkexrc.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/ex/ex_mkexrc.c
diff -u src/external/bsd/nvi/dist/ex/ex_mkexrc.c:1.3 src/external/bsd/nvi/dist/ex/ex_mkexrc.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_mkexrc.c:1.3	Sun Jan 26 16:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_mkexrc.c	Thu Nov 27 15:00:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_mkexrc.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_mkexrc.c,v 1.4 2014/11/27 20:00:09 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = Id: ex_mkexrc.c,v 10.13 2001/06/25 15:19:17 skimo Exp  (Berkeley) Date: 2001/06/25 15:19:17 ;
 #endif /* not lint */
 #else
-__RCSID($NetBSD: ex_mkexrc.c,v 1.3 2014/01/26 21:43:45 christos Exp $);
+__RCSID($NetBSD: ex_mkexrc.c,v 1.4 2014/11/27 20:00:09 christos Exp $);
 #endif
 
 #include sys/types.h
@@ -52,7 +52,7 @@ ex_mkexrc(SCR *sp, EXCMD *cmdp)
 	size_t flen;
 
 	switch (cmdp-argc) {
-	case 0:
+	case 1:
 		fname = _PATH_EXRC;
 		INT2CHAR(sp, cmdp-argv[0]-bp, cmdp-argv[0]-len + 1, 
 			fname, flen);



CVS commit: src/external/bsd/nvi/dist/ex

2014-08-26 Thread Aymeric Vincent
Module Name:src
Committed By:   aymeric
Date:   Tue Aug 26 15:19:38 UTC 2014

Modified Files:
src/external/bsd/nvi/dist/ex: ex_cscope.c

Log Message:
missed setting TAG_IS_LINKED in a special case in my previous commit.
Bug reported by Brad Harder, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/ex/ex_cscope.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/ex/ex_cscope.c
diff -u src/external/bsd/nvi/dist/ex/ex_cscope.c:1.6 src/external/bsd/nvi/dist/ex/ex_cscope.c:1.7
--- src/external/bsd/nvi/dist/ex/ex_cscope.c:1.6	Fri Aug 22 21:28:20 2014
+++ src/external/bsd/nvi/dist/ex/ex_cscope.c	Tue Aug 26 15:19:38 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_cscope.c,v 1.6 2014/08/22 21:28:20 aymeric Exp $ */
+/*	$NetBSD: ex_cscope.c,v 1.7 2014/08/26 15:19:38 aymeric Exp $ */
 /*-
  * Copyright (c) 1994, 1996
  *	Rob Mayoff.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = Id: ex_cscope.c,v 10.21 2003/11/05 17:11:54 skimo Exp  (Berkeley) Date: 2003/11/05 17:11:54 ;
 #endif /* not lint */
 #else
-__RCSID($NetBSD: ex_cscope.c,v 1.6 2014/08/22 21:28:20 aymeric Exp $);
+__RCSID($NetBSD: ex_cscope.c,v 1.7 2014/08/26 15:19:38 aymeric Exp $);
 #endif
 
 #include sys/param.h
@@ -542,6 +542,7 @@ cscope_find(SCR *sp, EXCMD *cmdp, const 
 	 */
 	if (TAILQ_EMPTY(exp-tq)) {
 		TAILQ_INSERT_HEAD(exp-tq, rtqp, q);
+		F_SET(rtqp, TAG_IS_LINKED);
 	} else {
 		free(rtqp);
 		rtqp = TAILQ_FIRST(exp-tq);



CVS commit: src/external/bsd/nvi/dist/ex

2014-08-22 Thread Aymeric Vincent
Module Name:src
Committed By:   aymeric
Date:   Fri Aug 22 21:28:20 UTC 2014

Modified Files:
src/external/bsd/nvi/dist/ex: ex_cscope.c ex_tag.c tag.h

Log Message:
In tagq_free(), fix the test checking whether a TAGQ should be removed from
its tailq. This required introducing a new flag in the TAGQ structure to
avoid reverting to poking under the hood of the queue.h API.

The concrete bug it solves is that using tags would make vi crash reliably
on exit.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/ex/ex_cscope.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/nvi/dist/ex/ex_tag.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/tag.h

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/ex/ex_cscope.c
diff -u src/external/bsd/nvi/dist/ex/ex_cscope.c:1.5 src/external/bsd/nvi/dist/ex/ex_cscope.c:1.6
--- src/external/bsd/nvi/dist/ex/ex_cscope.c:1.5	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_cscope.c	Fri Aug 22 21:28:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_cscope.c,v 1.5 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_cscope.c,v 1.6 2014/08/22 21:28:20 aymeric Exp $ */
 /*-
  * Copyright (c) 1994, 1996
  *	Rob Mayoff.  All rights reserved.
@@ -16,7 +16,7 @@
 static const char sccsid[] = Id: ex_cscope.c,v 10.21 2003/11/05 17:11:54 skimo Exp  (Berkeley) Date: 2003/11/05 17:11:54 ;
 #endif /* not lint */
 #else
-__RCSID($NetBSD: ex_cscope.c,v 1.5 2014/01/26 21:43:45 christos Exp $);
+__RCSID($NetBSD: ex_cscope.c,v 1.6 2014/08/22 21:28:20 aymeric Exp $);
 #endif
 
 #include sys/param.h
@@ -549,6 +549,7 @@ cscope_find(SCR *sp, EXCMD *cmdp, const 
 
 	/* Link the current TAGQ structure into place. */
 	TAILQ_INSERT_HEAD(exp-tq, tqp, q);
+	F_SET(tqp, TAG_IS_LINKED);
 
 	(void)cscope_search(sp, tqp, tqp-current);
 

Index: src/external/bsd/nvi/dist/ex/ex_tag.c
diff -u src/external/bsd/nvi/dist/ex/ex_tag.c:1.11 src/external/bsd/nvi/dist/ex/ex_tag.c:1.12
--- src/external/bsd/nvi/dist/ex/ex_tag.c:1.11	Sun Jan 26 21:43:45 2014
+++ src/external/bsd/nvi/dist/ex/ex_tag.c	Fri Aug 22 21:28:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_tag.c,v 1.11 2014/01/26 21:43:45 christos Exp $ */
+/*	$NetBSD: ex_tag.c,v 1.12 2014/08/22 21:28:20 aymeric Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -19,7 +19,7 @@
 static const char sccsid[] = Id: ex_tag.c,v 10.50 2004/03/16 14:09:11 skimo Exp  (Berkeley) Date: 2004/03/16 14:09:11 ;
 #endif /* not lint */
 #else
-__RCSID($NetBSD: ex_tag.c,v 1.11 2014/01/26 21:43:45 christos Exp $);
+__RCSID($NetBSD: ex_tag.c,v 1.12 2014/08/22 21:28:20 aymeric Exp $);
 #endif
 
 #include sys/param.h
@@ -606,6 +606,7 @@ ex_tag_copy(SCR *orig, SCR *sp)
 			TAILQ_INSERT_TAIL(tqp-tagq, tp, q);
 		}
 		TAILQ_INSERT_TAIL(nexp-tq, tqp, q);
+		F_SET(tqp, TAG_IS_LINKED);
 	}
 
 	/* Copy list of tag files. */
@@ -740,7 +741,7 @@ tagq_free(SCR *sp, TAGQ *tqp)
 	 * If allocated and then the user failed to switch files, the TAGQ
 	 * structure was never attached to any list.
 	 */
-	if (TAILQ_NEXT(tqp, q) != NULL)
+	if (F_ISSET(tqp, TAG_IS_LINKED))
 		TAILQ_REMOVE(exp-tq, tqp, q);
 	free(tqp);
 	return (0);
@@ -810,6 +811,7 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_sc
 	 */
 	if (TAILQ_EMPTY(exp-tq)) {
 		TAILQ_INSERT_HEAD(exp-tq, rtqp, q);
+		F_SET(rtqp, TAG_IS_LINKED);
 	} else {
 		free(rtqp);
 		rtqp = TAILQ_FIRST(exp-tq);
@@ -817,6 +819,7 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_sc
 
 	/* Link the new TAGQ structure into place. */
 	TAILQ_INSERT_HEAD(exp-tq, tqp, q);
+	F_SET(tqp, TAG_IS_LINKED);
 
 	(void)ctag_search(sp,
 	tqp-current-search, tqp-current-slen, tqp-tag);

Index: src/external/bsd/nvi/dist/ex/tag.h
diff -u src/external/bsd/nvi/dist/ex/tag.h:1.3 src/external/bsd/nvi/dist/ex/tag.h:1.4
--- src/external/bsd/nvi/dist/ex/tag.h:1.3	Mon Nov 25 22:43:46 2013
+++ src/external/bsd/nvi/dist/ex/tag.h	Fri Aug 22 21:28:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: tag.h,v 1.3 2013/11/25 22:43:46 christos Exp $	*/
+/*	$NetBSD: tag.h,v 1.4 2014/08/22 21:28:20 aymeric Exp $	*/
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -104,6 +104,7 @@ struct _tagq {			/* Tag queue. */
 	size_t	 tlen;		/* Tag string length. */
 
 #define	TAG_CSCOPE	0x01	/* Cscope tag. */
+#define	TAG_IS_LINKED	0x02	/* Tag was inserted into linked list */
 	u_int8_t flags;
 
 	char	 buf[1];	/* Variable length buffer. */



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 18:08:06 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_tag.c

Log Message:
CID 1132771: Fix memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_tag.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/ex/ex_tag.c
diff -u src/external/bsd/nvi/dist/ex/ex_tag.c:1.3 src/external/bsd/nvi/dist/ex/ex_tag.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_tag.c:1.3	Mon Nov 25 17:43:46 2013
+++ src/external/bsd/nvi/dist/ex/ex_tag.c	Wed Nov 27 13:08:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_tag.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/*	$NetBSD: ex_tag.c,v 1.4 2013/11/27 18:08:06 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -810,8 +810,10 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_sc
 	 */
 	if (TAILQ_EMPTY(exp-tq)) {
 		TAILQ_INSERT_HEAD(exp-tq, rtqp, q);
-	} else
+	} else {
+		free(rtqp);
 		rtqp = TAILQ_FIRST(exp-tq);
+	}
 
 	/* Link the new TAGQ structure into place. */
 	TAILQ_INSERT_HEAD(exp-tq, tqp, q);



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 18:09:06 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_tag.c

Log Message:
CID 1132770: Fix memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/nvi/dist/ex/ex_tag.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/ex/ex_tag.c
diff -u src/external/bsd/nvi/dist/ex/ex_tag.c:1.4 src/external/bsd/nvi/dist/ex/ex_tag.c:1.5
--- src/external/bsd/nvi/dist/ex/ex_tag.c:1.4	Wed Nov 27 13:08:06 2013
+++ src/external/bsd/nvi/dist/ex/ex_tag.c	Wed Nov 27 13:09:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_tag.c,v 1.4 2013/11/27 18:08:06 christos Exp $ */
+/*	$NetBSD: ex_tag.c,v 1.5 2013/11/27 18:09:06 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -1130,6 +1130,7 @@ gtag_slist(SCR *sp, CHAR_T *tag, int ref
 	return (tqp);
 
 alloc_err:
+	free(tqp);
 	return (NULL);
 }
 #endif



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 18:11:00 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_cscope.c

Log Message:
CID 1132769: Fix memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_cscope.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/ex/ex_cscope.c
diff -u src/external/bsd/nvi/dist/ex/ex_cscope.c:1.3 src/external/bsd/nvi/dist/ex/ex_cscope.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_cscope.c:1.3	Mon Nov 25 17:43:46 2013
+++ src/external/bsd/nvi/dist/ex/ex_cscope.c	Wed Nov 27 13:11:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_cscope.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/*	$NetBSD: ex_cscope.c,v 1.4 2013/11/27 18:11:00 christos Exp $ */
 /*-
  * Copyright (c) 1994, 1996
  *	Rob Mayoff.  All rights reserved.
@@ -503,14 +503,14 @@ cscope_find(SCR *sp, EXCMD *cmdp, const 
 
 		/* Read the output. */
 		if (parse(sp, csc, tqp, matches)) {
-			if (rtqp != NULL)
-free(rtqp);
+			free(rtqp);
 			tagq_free(sp, tqp);
 			return (1);
 		}
 	}
 
 	if (matches == 0) {
+		free(rtqp);
 		msgq(sp, M_INFO, 278|No matches for query);
 		return (0);
 	}
@@ -537,8 +537,10 @@ cscope_find(SCR *sp, EXCMD *cmdp, const 
 	 */
 	if (TAILQ_EMPTY(exp-tq)) {
 		TAILQ_INSERT_HEAD(exp-tq, rtqp, q);
-	} else
+	} else {
+		free(rtqp);
 		rtqp = TAILQ_FIRST(exp-tq);
+	}
 
 	/* Link the current TAGQ structure into place. */
 	TAILQ_INSERT_HEAD(exp-tq, tqp, q);
@@ -568,12 +570,9 @@ cscope_find(SCR *sp, EXCMD *cmdp, const 
 
 err:
 alloc_err:
-	if (rtqp != NULL)
-		free(rtqp);
-	if (rtp != NULL)
-		free(rtp);
-	if (np != NULL)
-		free(__UNCONST(np));
+	free(rtqp);
+	free(rtp);
+	free(__UNCONST(np));
 	return (1);
 }
 



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 20:45:33 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_tag.c

Log Message:
CID 1132760: Remove dead code


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/nvi/dist/ex/ex_tag.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/ex/ex_tag.c
diff -u src/external/bsd/nvi/dist/ex/ex_tag.c:1.5 src/external/bsd/nvi/dist/ex/ex_tag.c:1.6
--- src/external/bsd/nvi/dist/ex/ex_tag.c:1.5	Wed Nov 27 13:09:06 2013
+++ src/external/bsd/nvi/dist/ex/ex_tag.c	Wed Nov 27 15:45:33 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_tag.c,v 1.5 2013/11/27 18:09:06 christos Exp $ */
+/*	$NetBSD: ex_tag.c,v 1.6 2013/11/27 20:45:33 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -409,8 +409,6 @@ filearg:	arglen = strlen(arg);
 	160|No file %s on the tags stack to return to; use :display t[ags]);
 			return (1);
 		}
-		if (tqp == NULL)
-			return (0);
 		break;
 	default:
 		abort();



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 21:13:16 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_at.c

Log Message:
CID 1062357: Plug memory leak


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_at.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/ex/ex_at.c
diff -u src/external/bsd/nvi/dist/ex/ex_at.c:1.3 src/external/bsd/nvi/dist/ex/ex_at.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_at.c:1.3	Mon Nov 25 17:43:46 2013
+++ src/external/bsd/nvi/dist/ex/ex_at.c	Wed Nov 27 16:13:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_at.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/*	$NetBSD: ex_at.c,v 1.4 2013/11/27 21:13:16 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -107,7 +107,7 @@ ex_at(SCR *sp, EXCMD *cmdp)
 	tp != NULL; tp = TAILQ_PREV(tp, _texth, q))
 		len += tp-len + 1;
 
-	MALLOC_RET(sp, ecp-cp, CHAR_T *, len * 2 * sizeof(CHAR_T));
+	MALLOC_GOTO(sp, ecp-cp, CHAR_T *, len * 2 * sizeof(CHAR_T));
 	ecp-o_cp = ecp-cp;
 	ecp-o_clen = len;
 	ecp-cp[len] = '\0';
@@ -122,4 +122,7 @@ ex_at(SCR *sp, EXCMD *cmdp)
 
 	LIST_INSERT_HEAD(sp-wp-ecq, ecp, q);
 	return (0);
+alloc_err:
+	free(ecp);
+	return 1;
 }



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 21:16:10 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_global.c

Log Message:
CID 1062355: Fix resource leak


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_global.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/ex/ex_global.c
diff -u src/external/bsd/nvi/dist/ex/ex_global.c:1.3 src/external/bsd/nvi/dist/ex/ex_global.c:1.4
--- src/external/bsd/nvi/dist/ex/ex_global.c:1.3	Mon Nov 25 17:43:46 2013
+++ src/external/bsd/nvi/dist/ex/ex_global.c	Wed Nov 27 16:16:10 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_global.c,v 1.3 2013/11/25 22:43:46 christos Exp $ */
+/*	$NetBSD: ex_global.c,v 1.4 2013/11/27 21:16:10 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -171,7 +171,7 @@ usage:		ex_emsg(sp, cmdp-cmd-usage, EX
 		len = 1;
 	}
 
-	MALLOC_RET(sp, ecp-cp, CHAR_T *, (len * 2) * sizeof(CHAR_T));
+	MALLOC_GOTO(sp, ecp-cp, CHAR_T *, (len * 2) * sizeof(CHAR_T));
 	ecp-o_cp = ecp-cp;
 	ecp-o_clen = len;
 	MEMCPYW(ecp-cp + len, p, len);
@@ -241,6 +241,9 @@ usage:		ex_emsg(sp, cmdp-cmd-usage, EX
 	}
 	search_busy(sp, BUSY_OFF);
 	return (0);
+alloc_err:
+	free(ecp);
+	return 1;
 }
 
 /*



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 28 03:15:02 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_tag.c

Log Message:
use more list macros


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/nvi/dist/ex/ex_tag.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/ex/ex_tag.c
diff -u src/external/bsd/nvi/dist/ex/ex_tag.c:1.6 src/external/bsd/nvi/dist/ex/ex_tag.c:1.7
--- src/external/bsd/nvi/dist/ex/ex_tag.c:1.6	Wed Nov 27 15:45:33 2013
+++ src/external/bsd/nvi/dist/ex/ex_tag.c	Wed Nov 27 22:15:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_tag.c,v 1.6 2013/11/27 20:45:33 christos Exp $ */
+/*	$NetBSD: ex_tag.c,v 1.7 2013/11/28 03:15:02 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -541,8 +541,7 @@ ex_tag_display(SCR *sp)
 	 */
 	for (cnt = 1, tqp = TAILQ_FIRST(exp-tq); !INTERRUPTED(sp) 
 	tqp != NULL; ++cnt, tqp = TAILQ_NEXT(tqp, q))
-		for (tp = TAILQ_FIRST(tqp-tagq);
-		tp != NULL; tp = TAILQ_NEXT(tp, q)) {
+		TAILQ_FOREACH(tp, tqp-tagq, q) {
 			if (tp == TAILQ_FIRST(tqp-tagq))
 (void)ex_printf(sp, %2d , cnt);
 			else
@@ -590,12 +589,10 @@ ex_tag_copy(SCR *orig, SCR *sp)
 	nexp = EXP(sp);
 
 	/* Copy tag queue and tags stack. */
-	for (aqp = TAILQ_FIRST(oexp-tq);
-	aqp != NULL; aqp = TAILQ_NEXT(aqp, q)) {
+	TAILQ_FOREACH(aqp, oexp-tq, q) {
 		if (tagq_copy(sp, aqp, tqp))
 			return (1);
-		for (ap = TAILQ_FIRST(aqp-tagq);
-		ap != NULL; ap = TAILQ_NEXT(ap, q)) {
+		TAILQ_FOREACH(ap, aqp-tagq, q) {
 			if (tag_copy(sp, ap, tp))
 return (1);
 			/* Set the current pointer. */
@@ -607,8 +604,8 @@ ex_tag_copy(SCR *orig, SCR *sp)
 	}
 
 	/* Copy list of tag files. */
-	for (atfp = oexp-tagfq.tqh_first;
-	atfp != NULL; atfp = atfp-q.tqe_next) {
+
+	TAILQ_FOREACH(atfp, oexp-tagfq, q) {
 		if (tagf_copy(sp, atfp, tfp))
 			return (1);
 		TAILQ_INSERT_TAIL(nexp-tagfq, tfp, q);
@@ -895,7 +892,7 @@ ex_tagf_alloc(SCR *sp, const char *str)
 
 	/* Free current queue. */
 	exp = EXP(sp);
-	while ((tfp = exp-tagfq.tqh_first) != NULL)
+	while ((tfp = TAILQ_FIRST(exp-tagfq)) != NULL)
 		tagf_free(sp, tfp);
 
 	/* Create new queue. */
@@ -1162,8 +1159,8 @@ ctag_slist(SCR *sp, CHAR_T *tag)
 	 * Find the tag, only display missing file messages once, and
 	 * then only if we didn't find the tag.
 	 */
-	for (echk = 0,
-	tfp = exp-tagfq.tqh_first; tfp != NULL; tfp = tfp-q.tqe_next)
+	echk = 0;
+	TAILQ_FOREACH(tfp, exp-tagfq, q)
 		if (ctag_sfile(sp, tfp, tqp, tqp-tag)) {
 			echk = 1;
 			F_SET(tfp, TAGF_ERR);
@@ -1174,8 +1171,7 @@ ctag_slist(SCR *sp, CHAR_T *tag)
 	if (TAILQ_EMPTY(tqp-tagq)) {
 		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)
+			TAILQ_FOREACH(tfp, exp-tagfq, q)
 if (F_ISSET(tfp, TAGF_ERR) 
 !F_ISSET(tfp, TAGF_ERR_WARN)) {
 	errno = tfp-errnum;



CVS commit: src/external/bsd/nvi/dist/ex

2013-11-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 26 16:32:04 UTC 2013

Modified Files:
src/external/bsd/nvi/dist/ex: ex_print.c

Log Message:
avoid NULL deref.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/nvi/dist/ex/ex_print.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/ex/ex_print.c
diff -u src/external/bsd/nvi/dist/ex/ex_print.c:1.2 src/external/bsd/nvi/dist/ex/ex_print.c:1.3
--- src/external/bsd/nvi/dist/ex/ex_print.c:1.2	Fri Nov 22 10:52:05 2013
+++ src/external/bsd/nvi/dist/ex/ex_print.c	Tue Nov 26 11:32:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ex_print.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
+/*	$NetBSD: ex_print.c,v 1.3 2013/11/26 16:32:04 christos Exp $ */
 /*-
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -332,7 +332,7 @@ ex_fflush(SCR *sp)
 
 	exp = EXP(sp);
 
-	if (exp-obp_len != 0) {
+	if (exp  exp-obp_len != 0) {
 		sp-wp-scr_msg(sp, M_NONE, exp-obp, exp-obp_len);
 		exp-obp_len = 0;
 	}