Re: [PATCH] vi remove custom perr from cl_main

2015-12-28 Thread Martijn van Duren
End there's also this monstrosity that removes localization support from 
vi, in contrast to nvi2, which switched from custom db2 functions to 
catgets(3): http://marc.info/?l=openbsd-tech&m=144908525123080&w=2


On 12/28/15 20:37, Michael McConville wrote:

Todd C. Miller wrote:

On Sun, 27 Dec 2015 10:12:23 +0100, Martijn van Duren wrote:


This patch has been accepted by the nvi2 project.[1] There are more
patches, but I'm waiting till these have been reviewed by nvi2.


Committed, thanks.


Thanks for taking care of this.

There's a lot more where that came from. Martijn, Michael Reed, and I
have been chipping away at nvi2 lately. I may be soon be looking for
ok's on diffs that we got committed upstream.





Re: [PATCH] vi remove custom perr from cl_main

2015-12-28 Thread Michael McConville
Todd C. Miller wrote:
> On Sun, 27 Dec 2015 10:12:23 +0100, Martijn van Duren wrote:
> 
> > This patch has been accepted by the nvi2 project.[1] There are more
> > patches, but I'm waiting till these have been reviewed by nvi2.
> 
> Committed, thanks.

Thanks for taking care of this.

There's a lot more where that came from. Martijn, Michael Reed, and I
have been chipping away at nvi2 lately. I may be soon be looking for
ok's on diffs that we got committed upstream.



Re: [PATCH] vi remove custom perr from cl_main

2015-12-28 Thread Todd C. Miller
On Sun, 27 Dec 2015 10:12:23 +0100, Martijn van Duren wrote:

> This patch has been accepted by the nvi2 project.[1]
> There are more patches, but I'm waiting till these have been reviewed by 
> nvi2.

Committed, thanks.

 - todd



[PATCH] vi remove custom perr from cl_main

2015-12-27 Thread Martijn van Duren

Hello tech@,

This patch has been accepted by the nvi2 project.[1]
There are more patches, but I'm waiting till these have been reviewed by 
nvi2.


Sincerely,

Martijn van Duren

[1] https://github.com/lichray/nvi2/pull/43
Index: cl/cl_main.c
===
RCS file: /cvs/src/usr.bin/./vi/cl/cl_main.c,v
retrieving revision 1.27
diff -u -p -r1.27 cl_main.c
--- cl/cl_main.c	7 Dec 2015 20:39:19 -	1.27
+++ cl/cl_main.c	27 Dec 2015 09:09:17 -
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,7 +37,6 @@ sigset_t __sigblockset;/* GLOBAL: Bl
 static void	   cl_func_std(GS *);
 static CL_PRIVATE *cl_init(GS *);
 static GS	  *gs_init(char *);
-static void	   perr(char *, char *);
 static int	   setsig(int, struct sigaction *, void (*)(int));
 static void	   sig_end(GS *);
 static void	   term_init(char *, char *);
@@ -78,7 +78,7 @@ main(int argc, char *argv[])
 	/* Add the terminal type to the global structure. */
 	if ((OG_D_STR(gp, GO_TERM) =
 	OG_STR(gp, GO_TERM) = strdup(ttype)) == NULL)
-		perr(gp->progname, NULL);
+		err(1, NULL);
 
 	/* Figure out how big the screen is. */
 	if (cl_ssize(NULL, 0, &rows, &cols, NULL))
@@ -153,7 +153,7 @@ gs_init(char *name)
 	/* Allocate the global structure. */
 	CALLOC_NOMSG(NULL, gp, 1, sizeof(GS));
 	if (gp == NULL)
-		perr(name, NULL);
+		err(1, NULL);
 
 
 	gp->progname = name;
@@ -173,7 +173,7 @@ cl_init(GS *gp)
 	/* Allocate the CL private structure. */
 	CALLOC_NOMSG(NULL, clp, 1, sizeof(CL_PRIVATE));
 	if (clp == NULL)
-		perr(gp->progname, NULL);
+		err(1, NULL);
 	gp->cl_private = clp;
 
 	/*
@@ -195,10 +195,8 @@ cl_init(GS *gp)
 		if (tcgetattr(STDIN_FILENO, &clp->orig) == -1)
 			goto tcfail;
 	} else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) {
-		if (tcgetattr(fd, &clp->orig) == -1) {
-tcfail:			perr(gp->progname, "tcgetattr");
-			exit (1);
-		}
+		if (tcgetattr(fd, &clp->orig) == -1)
+tcfail:			err(1, "tcgetattr");
 		(void)close(fd);
 	}
 
@@ -292,7 +290,7 @@ sig_init(GS *gp, SCR *sp)
 		sigaddset(&__sigblockset, SIGWINCH) ||
 		setsig(SIGWINCH, &clp->oact[INDX_WINCH], h_winch)
 		) {
-			perr(gp->progname, NULL);
+			err(1, NULL);
 			return (1);
 		}
 	} else
@@ -372,18 +370,4 @@ cl_func_std(GS *gp)
 	gp->scr_screen = cl_screen;
 	gp->scr_suspend = cl_suspend;
 	gp->scr_usage = cl_usage;
-}
-
-/*
- * perr --
- *	Print system error.
- */
-static void
-perr(char *name, char *msg)
-{
-	(void)fprintf(stderr, "%s:", name);
-	if (msg != NULL)
-		(void)fprintf(stderr, "%s:", msg);
-	(void)fprintf(stderr, "%s\n", strerror(errno));
-	exit(1);
 }