Skip to content

Commit

Permalink
Fix an issue with editor segfaulting in ex mode on Darwin and suppres…
Browse files Browse the repository at this point in the history
…s benign stderr output regarding locale. Reported in joyent/pkgsrc/issues/402, patch provided by @bjcooke in joyent/pkgsrc/pull/463. Bump PKGREVISION.
  • Loading branch information
fhajny committed Apr 4, 2017
1 parent 8b9e7d7 commit f840acb
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 16 deletions.
4 changes: 2 additions & 2 deletions editors/nvi/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.49 2015/09/07 12:02:05 jperkin Exp $
# $NetBSD: Makefile,v 1.50 2017/04/04 07:53:23 fhajny Exp $

DISTNAME= nvi-1.81.6
PKGREVISION= 10
PKGREVISION= 11
CATEGORIES= editors
MASTER_SITES= ${HOMEPAGE:Q}
EXTRACT_SUFX= .tar.bz2
Expand Down
6 changes: 4 additions & 2 deletions editors/nvi/distinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.22 2015/11/03 03:32:19 agc Exp $
$NetBSD: distinfo,v 1.23 2017/04/04 07:53:23 fhajny Exp $

SHA1 (nvi-1.81.6.tar.bz2) = d3445ed69166102735335a2ff60d092d9a9143c6
RMD160 (nvi-1.81.6.tar.bz2) = 0db8568bea96392d9a027044177c60317c8ade36
Expand Down Expand Up @@ -34,9 +34,11 @@ SHA1 (patch-ba) = 57edce2dafc630d7e948a5b528242bdcff334228
SHA1 (patch-bb) = 5110c239cd1cc82cdd1eaeba6ceedb11ee797b26
SHA1 (patch-bc) = 6ac8377ae6f2fc513c058c0bf7f5ad18e97141a8
SHA1 (patch-bd) = 9a04f7a247fe6bf800469e81f7a83ffddd45b4b5
SHA1 (patch-cl_funcs__termh.c) = 27a974bf865c8006c6929fa20fde44a4cf53182b
SHA1 (patch-cl_screen__termh.c) = 55d9214a0e1cd740a065ae58defee6f0fa4d4204
SHA1 (patch-common_conv.c) = efb2dabf226523a493fc1172013adc8021f4c2b9
SHA1 (patch-common_key.h) = 29f8b89b41b087ff7c2e9a5483fb9e6d2291c750
SHA1 (patch-common_msg.c) = 73c6e8df0d5c85f4fee1316ea65de9da1876340b
SHA1 (patch-common_msg.c) = b1c7662b195a7438a73bffee86ab2b10f7fe1487
SHA1 (patch-dist_Makefile.am) = ebae821ce659df003f5f2043f754e325c0863aff
SHA1 (patch-dist_config.h.in) = 21568929b165d1e774e59d6c648e0af7b17760da
SHA1 (patch-dist_configure.in) = c7b70b1a93889f41d949a3ede034f30abc063b7b
Expand Down
20 changes: 20 additions & 0 deletions editors/nvi/patches/patch-cl_funcs__termh.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$NetBSD: patch-cl_funcs__termh.c,v 1.1 2017/04/04 07:53:23 fhajny Exp $

- Suppress compile time warning on Linux and prevent segfault on Darwin when
run as nex.
- Original patch was found in release 13 of nvi 1.81.6 for debian under the
name 19include_term_h.patch.

##From: <[email protected]>
##Subject: Add <term.h> to the include list to suppress a few warnings.

--- cl/cl_funcs.c.orig 2007-11-18 17:41:42.000000000 +0100
+++ cl/cl_funcs.c 2008-05-01 18:23:08.000000000 +0200
@@ -18,6 +18,7 @@
#include <sys/time.h>

#include <bitstring.h>
+#include <term.h>
#include <ctype.h>
#include <signal.h>
#include <stdio.h>
20 changes: 20 additions & 0 deletions editors/nvi/patches/patch-cl_screen__termh.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$NetBSD: patch-cl_screen__termh.c,v 1.1 2017/04/04 07:53:23 fhajny Exp $

- Suppress compile time warning on Linux and prevent segfault on Darwin when
run as nex.
- Original patch was found in release 13 of nvi 1.81.6 for debian under the
name 19include_term_h.patch.

##From: <[email protected]>
##Subject: Add <term.h> to the include list to suppress a few warnings.

--- cl/cl_screen.c.orig 2007-11-18 17:41:42.000000000 +0100
+++ cl/cl_screen.c 2008-05-01 18:23:02.000000000 +0200
@@ -17,6 +17,7 @@
#include <sys/queue.h>

#include <bitstring.h>
+#include <term.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
80 changes: 68 additions & 12 deletions editors/nvi/patches/patch-common_msg.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,70 @@
$NetBSD: patch-common_msg.c,v 1.1 2015/05/11 08:43:44 enami Exp $
$NetBSD: patch-common_msg.c,v 1.2 2017/04/04 07:53:23 fhajny Exp $

--- common/msg.c.orig 2007-11-18 16:41:42.000000000 +0000
--- common/msg.c.orig 2017-04-03 15:17:07.396452540 +0000
+++ common/msg.c
@@ -640,7 +640,8 @@ msgq_status(SCR *sp, db_recno_t lno, u_i
p += len;
} else {
t = msg_cat(sp, "027|line %lu of %lu [%ld%%]", &len);
- (void)sprintf(p, t, lno, last, (lno * 100) / last);
+ (void)sprintf(p, t, (u_long)lno, (u_long)last,
+ (long)((lno * 100) / last));
p += strlen(p);
}
} else {
@@ -716,7 +716,7 @@ msg_open(SCR *sp, char *file)
DB *db;
DBT data, key;
db_recno_t msgno;
- char *p, *t, buf[MAXPATHLEN];
+ char *p, *p2, *t, buf[MAXPATHLEN];

if ((p = strrchr(file, '/')) != NULL && p[1] == '\0' &&
(((t = getenv("LC_MESSAGES")) != NULL && t[0] != '\0') ||
@@ -725,16 +725,15 @@ msg_open(SCR *sp, char *file)
p = buf;
} else
p = file;
- if ((sp->db_error = db_create(&db, 0, 0)) != 0 ||
- (sp->db_error = db->set_re_source(db, p)) != 0 ||
- (sp->db_error = db_open(db, NULL, DB_RECNO, 0, 0)) != 0) {
- if (first) {
- first = 0;
- return (1);
- }
- msgq_str(sp, M_DBERR, p, "%s");
- return (1);
- }
+
+ p2 = "%s";
+ if ((sp->db_error = db_create(&db, 0, 0)) == 0 &&
+ (sp->db_error = db->set_re_source(db, p)) == 0) {
+ db->set_errcall(db, 0);
+ if ((sp->db_error = db_open(db, NULL, DB_RECNO, 0, 0)) != 0)
+ goto err;
+ } else
+ goto err;

/*
* Test record 1 for the magic string. The msgq call is here so
@@ -750,13 +749,8 @@ msg_open(SCR *sp, char *file)
data.size != sizeof(VMC) - 1 ||
memcmp(data.data, VMC, sizeof(VMC) - 1)) {
(void)db->close(db, DB_NOSYNC);
- if (first) {
- first = 0;
- return (1);
- }
- msgq_str(sp, M_DBERR, p,
- "030|The file %s is not a message catalog");
- return (1);
+ p2 = "030|The file %s is not a message catalog";
+ goto err;
}
first = 0;

@@ -764,6 +758,14 @@ msg_open(SCR *sp, char *file)
(void)sp->gp->msg->close(sp->gp->msg, DB_NOSYNC);
sp->gp->msg = db;
return (0);
+
+err:
+ if (first) {
+ first = 0;
+ return (1);
+ }
+ msgq_str(sp, M_DBERR, p, p2);
+ return (1);
}

/*

0 comments on commit f840acb

Please sign in to comment.