Module Name:    src
Committed By:   roy
Date:           Thu Mar 12 15:50:12 UTC 2020

Modified Files:
        src/lib/libcurses: initscr.c

Log Message:
curses: use perror rather than err in initscr

libhack lacks err and perror is more portable.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libcurses/initscr.c

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

Modified files:

Index: src/lib/libcurses/initscr.c
diff -u src/lib/libcurses/initscr.c:1.34 src/lib/libcurses/initscr.c:1.35
--- src/lib/libcurses/initscr.c:1.34	Wed Mar 11 21:33:38 2020
+++ src/lib/libcurses/initscr.c	Thu Mar 12 15:50:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $	*/
+/*	$NetBSD: initscr.c,v 1.35 2020/03/12 15:50:11 roy Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,11 +34,10 @@
 #if 0
 static char sccsid[] = "@(#)initscr.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: initscr.c,v 1.34 2020/03/11 21:33:38 roy Exp $");
+__RCSID("$NetBSD: initscr.c,v 1.35 2020/03/12 15:50:11 roy Exp $");
 #endif
 #endif	/* not lint */
 
-#include <err.h>
 #include <stdlib.h>
 
 #include "curses.h"
@@ -66,8 +65,15 @@ initscr(void)
 		sp = Def_term;
 
 	/* LINTED const castaway; newterm does not modify sp! */
-	if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL)
-		errx(EXIT_FAILURE, "initscr"); /* POSIX says exit on failure */
+	if ((_cursesi_screen = newterm((char *) sp, stdout, stdin)) == NULL) {
+		/*
+		 * POSIX says we should write a diagnostic and exit on error.
+		 * As such some applications don't bother checking the return
+		 * value at all.
+		 */
+		perror("initscr");
+		exit(EXIT_FAILURE);
+	}
 
 	set_term(_cursesi_screen);
 	wrefresh(curscr);

Reply via email to