Module Name: src Committed By: roy Date: Sat Dec 31 17:46:35 UTC 2016
Modified Files: src/distrib/sets/lists/comp: mi src/lib/libcurses: Makefile curses.h curses_screen.3 setterm.c Log Message: Implement POSIX curses use_env function. To generate a diff of this commit: cvs rdiff -u -r1.2085 -r1.2086 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.73 -r1.74 src/lib/libcurses/Makefile cvs rdiff -u -r1.109 -r1.110 src/lib/libcurses/curses.h cvs rdiff -u -r1.16 -r1.17 src/lib/libcurses/curses_screen.3 cvs rdiff -u -r1.55 -r1.56 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.2085 src/distrib/sets/lists/comp/mi:1.2086 --- src/distrib/sets/lists/comp/mi:1.2085 Sat Dec 31 13:50:16 2016 +++ src/distrib/sets/lists/comp/mi Sat Dec 31 17:46:35 2016 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2085 2016/12/31 13:50:16 roy Exp $ +# $NetBSD: mi,v 1.2086 2016/12/31 17:46:35 roy Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.comp comp-sys-root @@ -9493,6 +9493,7 @@ ./usr/share/man/cat3/unsetenv.0 comp-c-catman .cat ./usr/share/man/cat3/untouchwin.0 comp-c-catman .cat ./usr/share/man/cat3/unvis.0 comp-c-catman .cat +./usr/share/man/cat3/use_env.0 comp-c-catman .cat ./usr/share/man/cat3/update_panels.0 comp-c-catman .cat ./usr/share/man/cat3/updlastlogx.0 comp-c-catman .cat ./usr/share/man/cat3/updwtmpx.0 comp-c-catman .cat @@ -16761,6 +16762,7 @@ ./usr/share/man/html3/unsetenv.html comp-c-htmlman html ./usr/share/man/html3/untouchwin.html comp-c-htmlman html ./usr/share/man/html3/unvis.html comp-c-htmlman html +./usr/share/man/html3/use_env.html comp-c-htmlman html ./usr/share/man/html3/update_panels.html comp-c-htmlman html ./usr/share/man/html3/updlastlogx.html comp-c-htmlman html ./usr/share/man/html3/updwtmpx.html comp-c-htmlman html @@ -24092,6 +24094,7 @@ ./usr/share/man/man3/unsetenv.3 comp-c-man .man ./usr/share/man/man3/untouchwin.3 comp-c-man .man ./usr/share/man/man3/unvis.3 comp-c-man .man +./usr/share/man/man3/use_env.3 comp-c-man .man ./usr/share/man/man3/update_panels.3 comp-c-man .man ./usr/share/man/man3/updlastlogx.3 comp-c-man .man ./usr/share/man/man3/updwtmpx.3 comp-c-man .man Index: src/lib/libcurses/Makefile diff -u src/lib/libcurses/Makefile:1.73 src/lib/libcurses/Makefile:1.74 --- src/lib/libcurses/Makefile:1.73 Sat Dec 31 13:50:16 2016 +++ src/lib/libcurses/Makefile Sat Dec 31 17:46:35 2016 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.73 2016/12/31 13:50:16 roy Exp $ +# $NetBSD: Makefile,v 1.74 2016/12/31 17:46:35 roy Exp $ # @(#)Makefile 8.2 (Berkeley) 1/2/94 .include <bsd.own.mk> @@ -152,7 +152,8 @@ MLINKS+= curses_addch.3 addch.3 curses_a curses_touch.3 touchwin.3 curses_print.3 unctrl.3 \ curses_underscore.3 underend.3 curses_underscore.3 underscore.3 \ curses_input.3 ungetch.3 curses_touch.3 untouchwin.3 \ - curses_default_colors.3 use_default_colors.3 curses_line.3 vline.3 \ + curses_default_colors.3 use_default_colors.3 \ + curses_screen.3 use_env.3 curses_line.3 vline.3 \ curses_addch.3 waddch.3 curses_addchstr.3 waddchnstr.3 \ curses_addchstr.3 waddchstr.3 curses_addstr.3 waddnstr.3 \ curses_addstr.3 waddstr.3 \ Index: src/lib/libcurses/curses.h diff -u src/lib/libcurses/curses.h:1.109 src/lib/libcurses/curses.h:1.110 --- src/lib/libcurses/curses.h:1.109 Sat Dec 31 13:50:16 2016 +++ src/lib/libcurses/curses.h Sat Dec 31 17:46:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: curses.h,v 1.109 2016/12/31 13:50:16 roy Exp $ */ +/* $NetBSD: curses.h,v 1.110 2016/12/31 17:46:35 roy Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -753,6 +753,7 @@ int touchwin(WINDOW *); int ungetch(int); int untouchwin(WINDOW *); int use_default_colors(void); +void use_env(bool); int vline(chtype, int); int vw_printw(WINDOW *, const char *, __va_list) __printflike(2, 0); int vw_scanw(WINDOW *, const char *, __va_list) __scanflike(2, 0); Index: src/lib/libcurses/curses_screen.3 diff -u src/lib/libcurses/curses_screen.3:1.16 src/lib/libcurses/curses_screen.3:1.17 --- src/lib/libcurses/curses_screen.3:1.16 Fri Dec 30 22:38:38 2016 +++ src/lib/libcurses/curses_screen.3 Sat Dec 31 17:46:35 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: curses_screen.3,v 1.16 2016/12/30 22:38:38 roy Exp $ +.\" $NetBSD: curses_screen.3,v 1.17 2016/12/31 17:46:35 roy Exp $ .\" .\" Copyright (c) 2002 .\" Brett Lymn (bl...@netbsd.org, brett_l...@yahoo.com.au) @@ -34,8 +34,9 @@ .Dt CURSES_SCREEN 3 .Os .Sh NAME -.Nm filter , .Nm curses_screen , +.Nm filter , +.Nm use_env , .Nm newterm , .Nm set_term , .Nm delscreen , @@ -51,6 +52,8 @@ .In curses.h .Ft void .Fn filter "void" +.Ft void +.Fn use_env "bool value" .Ft SCREEN * .Fn newterm "char *type" "FILE *outfd" "FILE *infd" .Ft SCREEN * @@ -190,6 +193,19 @@ Set the value of the home string to the .It Set lines equal to 1. .El +.Pp +The +.Fn use_env +function determines whether the environment variables LINES and COLUMNS +override the normal values. +The default is true. +Any call to +.Fn use_env +must precede calls to +.Fn initscr , +.Fn newterm +or +.Fn setupterm . .Sh RETURN VALUES Functions returning pointers will return .Dv NULL Index: src/lib/libcurses/setterm.c diff -u src/lib/libcurses/setterm.c:1.55 src/lib/libcurses/setterm.c:1.56 --- src/lib/libcurses/setterm.c:1.55 Fri Dec 30 22:38:38 2016 +++ src/lib/libcurses/setterm.c Sat Dec 31 17:46:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: setterm.c,v 1.55 2016/12/30 22:38:38 roy Exp $ */ +/* $NetBSD: setterm.c,v 1.56 2016/12/31 17:46:35 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.55 2016/12/30 22:38:38 roy Exp $"); +__RCSID("$NetBSD: setterm.c,v 1.56 2016/12/31 17:46:35 roy Exp $"); #endif #endif /* not lint */ @@ -50,9 +50,17 @@ __RCSID("$NetBSD: setterm.c,v 1.55 2016/ static int does_esc_m(const char *cap); static int does_ctrl_o(const char *exit_cap, const char *acs_cap); +static bool __use_env = true; attr_t __mask_op, __mask_me, __mask_ue, __mask_se; +void +use_env(bool value) +{ + + __use_env = value; +} + int setterm(char *type) { @@ -119,10 +127,12 @@ _cursesi_setterm(char *type, SCREEN *scr #endif /* POSIX 1003.2 requires that the environment override. */ - 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); + if (__use_env) { + 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); + } if ((p = getenv("ESCDELAY")) != NULL) ESCDELAY = (int) strtol(p, NULL, 0); if ((p = getenv("TABSIZE")) != NULL)