Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Implement POSIX curses use_env function.



details:   https://anonhg.NetBSD.org/src/rev/02c695567c66
branches:  trunk
changeset: 820139:02c695567c66
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Dec 31 17:46:35 2016 +0000

description:
Implement POSIX curses use_env function.

diffstat:

 distrib/sets/lists/comp/mi    |   5 ++++-
 lib/libcurses/Makefile        |   5 +++--
 lib/libcurses/curses.h        |   3 ++-
 lib/libcurses/curses_screen.3 |  20 ++++++++++++++++++--
 lib/libcurses/setterm.c       |  22 ++++++++++++++++------
 5 files changed, 43 insertions(+), 12 deletions(-)

diffs (171 lines):

diff -r 1247be7d8322 -r 02c695567c66 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Sat Dec 31 15:41:39 2016 +0000
+++ b/distrib/sets/lists/comp/mi        Sat Dec 31 17:46:35 2016 +0000
@@ -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
diff -r 1247be7d8322 -r 02c695567c66 lib/libcurses/Makefile
--- a/lib/libcurses/Makefile    Sat Dec 31 15:41:39 2016 +0000
+++ b/lib/libcurses/Makefile    Sat Dec 31 17:46:35 2016 +0000
@@ -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 @@
         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 \
diff -r 1247be7d8322 -r 02c695567c66 lib/libcurses/curses.h
--- a/lib/libcurses/curses.h    Sat Dec 31 15:41:39 2016 +0000
+++ b/lib/libcurses/curses.h    Sat Dec 31 17:46:35 2016 +0000
@@ -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     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);
diff -r 1247be7d8322 -r 02c695567c66 lib/libcurses/curses_screen.3
--- a/lib/libcurses/curses_screen.3     Sat Dec 31 15:41:39 2016 +0000
+++ b/lib/libcurses/curses_screen.3     Sat Dec 31 17:46:35 2016 +0000
@@ -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 (blymn%NetBSD.org@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -34,8 +34,9 @@
 .Dt CURSES_SCREEN 3
 .Os
 .Sh NAME
+.Nm curses_screen ,
 .Nm filter ,
-.Nm curses_screen ,
+.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 @@
 .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
diff -r 1247be7d8322 -r 02c695567c66 lib/libcurses/setterm.c
--- a/lib/libcurses/setterm.c   Sat Dec 31 15:41:39 2016 +0000
+++ b/lib/libcurses/setterm.c   Sat Dec 31 17:46:35 2016 +0000
@@ -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 @@
 
 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 @@
 #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)



Home | Main Index | Thread Index | Old Index