Module Name:    src
Committed By:   roy
Date:           Fri Dec 30 22:38:39 UTC 2016

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/lib/libcurses: Makefile curses.h curses_private.h curses_screen.3
            screen.c setterm.c

Log Message:
Add the POSIX filter() function to libcurses.


To generate a diff of this commit:
cvs rdiff -u -r1.2083 -r1.2084 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.71 -r1.72 src/lib/libcurses/Makefile
cvs rdiff -u -r1.107 -r1.108 src/lib/libcurses/curses.h
cvs rdiff -u -r1.51 -r1.52 src/lib/libcurses/curses_private.h
cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/curses_screen.3
cvs rdiff -u -r1.24 -r1.25 src/lib/libcurses/screen.c
cvs rdiff -u -r1.54 -r1.55 src/lib/libcurses/setterm.c

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2083 src/distrib/sets/lists/comp/mi:1.2084
--- src/distrib/sets/lists/comp/mi:1.2083	Thu Dec 22 16:32:31 2016
+++ src/distrib/sets/lists/comp/mi	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2083 2016/12/22 16:32:31 maya Exp $
+#	$NetBSD: mi,v 1.2084 2016/12/30 22:38:38 roy Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.comp				comp-sys-root
@@ -6380,6 +6380,7 @@
 ./usr/share/man/cat3/field_type.0		comp-c-catman		.cat
 ./usr/share/man/cat3/field_userptr.0		comp-c-catman		.cat
 ./usr/share/man/cat3/fileno.0			comp-c-catman		.cat
+./usr/share/man/cat3/filter.0			comp-c-catman		.cat
 ./usr/share/man/cat3/finite.0			comp-c-catman		.cat
 ./usr/share/man/cat3/finitef.0			comp-c-catman		.cat
 ./usr/share/man/cat3/flags_to_string.0		comp-c-catman		.cat
@@ -13720,6 +13721,7 @@
 ./usr/share/man/html3/field_type.html		comp-c-htmlman		html
 ./usr/share/man/html3/field_userptr.html	comp-c-htmlman		html
 ./usr/share/man/html3/fileno.html		comp-c-htmlman		html
+./usr/share/man/html3/filter.html		comp-c-htmlman		html
 ./usr/share/man/html3/finite.html		comp-c-htmlman		html
 ./usr/share/man/html3/finitef.html		comp-c-htmlman		html
 ./usr/share/man/html3/flags_to_string.html	comp-c-htmlman		html
@@ -20973,6 +20975,7 @@
 ./usr/share/man/man3/field_type.3		comp-c-man		.man
 ./usr/share/man/man3/field_userptr.3		comp-c-man		.man
 ./usr/share/man/man3/fileno.3			comp-c-man		.man
+./usr/share/man/man3/filter.3			comp-c-man		.man
 ./usr/share/man/man3/finite.3			comp-c-man		.man
 ./usr/share/man/man3/finitef.3			comp-c-man		.man
 ./usr/share/man/man3/flags_to_string.3		comp-c-man		.man

Index: src/lib/libcurses/Makefile
diff -u src/lib/libcurses/Makefile:1.71 src/lib/libcurses/Makefile:1.72
--- src/lib/libcurses/Makefile:1.71	Sat Jul  5 22:31:32 2014
+++ src/lib/libcurses/Makefile	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.71 2014/07/05 22:31:32 dholland Exp $
+#	$NetBSD: Makefile,v 1.72 2016/12/30 22:38:38 roy Exp $
 #	@(#)Makefile	8.2 (Berkeley) 1/2/94
 
 .include <bsd.own.mk>
@@ -75,7 +75,7 @@ MLINKS+= curses_addch.3 addch.3 curses_a
 	 curses_refresh.3 doupdate.3 curses_window.3 dupwin.3 \
 	 curses_tty.3 echo.3 curses_echochar.3 echochar.3 \
 	 curses_screen.3 endwin.3 curses_clear.3 erase.3 \
-	 curses_tty.3 erasechar.3 \
+	 curses_tty.3 erasechar.3 curses_screen.3 filter.3 \
 	 curses_tty.3 flash.3 curses_tty.3 flushinp.3 \
 	 curses_refresh.3 flushok.3 \
 	 curses_termcap.3 fullname.3 curses_attributes.3 getattrs.3  \

Index: src/lib/libcurses/curses.h
diff -u src/lib/libcurses/curses.h:1.107 src/lib/libcurses/curses.h:1.108
--- src/lib/libcurses/curses.h:1.107	Mon Jun  8 12:38:57 2015
+++ src/lib/libcurses/curses.h	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses.h,v 1.107 2015/06/08 12:38:57 joerg Exp $	*/
+/*	$NetBSD: curses.h,v 1.108 2016/12/30 22:38:38 roy Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -638,6 +638,7 @@ int	 doupdate(void);
 int	 echo(void);
 int	 endwin(void);
 char     erasechar(void);
+void	 filter(void);
 int	 flash(void);
 int	 flushinp(void);
 int	 flushok(WINDOW *, bool);

Index: src/lib/libcurses/curses_private.h
diff -u src/lib/libcurses/curses_private.h:1.51 src/lib/libcurses/curses_private.h:1.52
--- src/lib/libcurses/curses_private.h:1.51	Sun Oct 23 21:20:56 2016
+++ src/lib/libcurses/curses_private.h	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: curses_private.h,v 1.51 2016/10/23 21:20:56 christos Exp $	*/
+/*	$NetBSD: curses_private.h,v 1.52 2016/12/30 22:38:38 roy Exp $	*/
 
 /*-
  * Copyright (c) 1998-2000 Brett Lymn
@@ -252,6 +252,7 @@ struct __screen {
 	int resized;
 	wchar_t *unget_list;
 	int unget_len, unget_pos;
+	int filtered;
 #ifdef HAVE_WCHAR
 #define MB_LEN_MAX 8
 #define MAX_CBUF_SIZE MB_LEN_MAX

Index: src/lib/libcurses/curses_screen.3
diff -u src/lib/libcurses/curses_screen.3:1.15 src/lib/libcurses/curses_screen.3:1.16
--- src/lib/libcurses/curses_screen.3:1.15	Sat Apr 21 12:27:28 2012
+++ src/lib/libcurses/curses_screen.3	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: curses_screen.3,v 1.15 2012/04/21 12:27:28 roy Exp $
+.\"	$NetBSD: curses_screen.3,v 1.16 2016/12/30 22:38:38 roy Exp $
 .\"
 .\" Copyright (c) 2002
 .\"	Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au)
@@ -30,10 +30,11 @@
 .\" SUCH DAMAGE.
 .\"
 .\"
-.Dd April 5, 2012
+.Dd December 30, 2016
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
+.Nm filter ,
 .Nm curses_screen ,
 .Nm newterm ,
 .Nm set_term ,
@@ -48,6 +49,8 @@
 .Lb libcurses
 .Sh SYNOPSIS
 .In curses.h
+.Ft void
+.Fn filter "void"
 .Ft SCREEN *
 .Fn newterm "char *type" "FILE *outfd" "FILE *infd"
 .Ft SCREEN *
@@ -170,6 +173,23 @@ The
 argument must be a valid name or alias in the
 .Xr terminfo 5
 database for this function to succeed.
+.Pp
+The
+.Fn filter
+function changes the way the terminal is initialised.
+A subsequent call to
+.Fn initscr
+or
+.Fn newterm
+performs the following additonal actions:
+.Bl -bullet -compact
+.It
+Disable use of clear, cud, cud1, cup, cuu, cuu1 and vpa.
+.It
+Set the value of the home string to the value of the cr string.
+.It
+Set lines equal to 1.
+.El
 .Sh RETURN VALUES
 Functions returning pointers will return
 .Dv NULL

Index: src/lib/libcurses/screen.c
diff -u src/lib/libcurses/screen.c:1.24 src/lib/libcurses/screen.c:1.25
--- src/lib/libcurses/screen.c:1.24	Thu Nov 26 01:05:08 2015
+++ src/lib/libcurses/screen.c	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: screen.c,v 1.24 2015/11/26 01:05:08 christos Exp $	*/
+/*	$NetBSD: screen.c,v 1.25 2016/12/30 22:38:38 roy Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)screen.c	8.2 (blymn) 11/27/2001";
 #else
-__RCSID("$NetBSD: screen.c,v 1.24 2015/11/26 01:05:08 christos Exp $");
+__RCSID("$NetBSD: screen.c,v 1.25 2016/12/30 22:38:38 roy Exp $");
 #endif
 #endif					/* not lint */
 
@@ -43,6 +43,18 @@ __RCSID("$NetBSD: screen.c,v 1.24 2015/1
 #include "curses.h"
 #include "curses_private.h"
 
+static int filtered;
+
+/*
+ * filter has to be called before either initscr or newterm.
+ */
+void
+filter(void)
+{
+
+	filtered = TRUE;
+}
+
 /*
  * set_term --
  *      Change the term to the given screen.
@@ -128,6 +140,8 @@ newterm(char *type, FILE *outfd, FILE *i
 	new_screen->outfd = outfd;
 	new_screen->echoit = new_screen->nl = 1;
 	new_screen->pfast = new_screen->rawmode = new_screen->noqch = 0;
+	new_screen->filtered = filtered;
+	filtered = FALSE; /* filter() must preceed each newterm() */
 	new_screen->nca = A_NORMAL;
 	new_screen->color_type = COLOR_NONE;
 	new_screen->COLOR_PAIRS = 0;

Index: src/lib/libcurses/setterm.c
diff -u src/lib/libcurses/setterm.c:1.54 src/lib/libcurses/setterm.c:1.55
--- src/lib/libcurses/setterm.c:1.54	Sat Jan  9 19:05:13 2016
+++ src/lib/libcurses/setterm.c	Fri Dec 30 22:38:38 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: setterm.c,v 1.54 2016/01/09 19:05:13 jdc Exp $	*/
+/*	$NetBSD: setterm.c,v 1.55 2016/12/30 22:38:38 roy Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setterm.c	8.8 (Berkeley) 10/25/94";
 #else
-__RCSID("$NetBSD: setterm.c,v 1.54 2016/01/09 19:05:13 jdc Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.55 2016/12/30 22:38:38 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -99,8 +99,27 @@ _cursesi_setterm(char *type, SCREEN *scr
 		}
 	}
 
+	if (screen->filtered) {
+		/* Disable use of clear, cud, cud1, cup, cuu1 and vpa. */
+		screen->term->strs[TICODE_clear] = NULL;
+		screen->term->strs[TICODE_cud] = NULL;
+		screen->term->strs[TICODE_cud1] = NULL;
+		screen->term->strs[TICODE_cup] = NULL;
+		screen->term->strs[TICODE_cuu] = NULL;
+		screen->term->strs[TICODE_cuu1] = NULL;
+		screen->term->strs[TICODE_vpa] = NULL;
+		/* Set the value of the home string to the value of
+		 * the cr string. */
+		screen->term->strs[TICODE_home] = screen->term->strs[TICODE_cr];
+		/* Set lines equal to 1. */
+		screen->LINES = 1;
+	}
+#ifdef DEBUG
+	__CTRACE(__CTRACE_INIT, "setterm: filtered %d", screen->filtered);
+#endif
+
 	/* POSIX 1003.2 requires that the environment override. */
-	if ((p = getenv("LINES")) != NULL)
+	if (!screen->filtered && (p = getenv("LINES")) != NULL)
 		screen->LINES = (int) strtol(p, NULL, 0);
 	if ((p = getenv("COLUMNS")) != NULL)
 		screen->COLS = (int) strtol(p, NULL, 0);

Reply via email to