diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-08-25 07:41:15 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-08-25 07:41:15 +0000 |
| commit | 0e7e6efe8f3488c7cf56d81cbae0bbc4ef942891 (patch) | |
| tree | 0f831d6e60fec7fe347401fc745922a06067a8c0 /lib/libncurses/lib_initscr.c | |
| parent | 05c5fed8f5039bfcff6374723263a24b33c2430c (diff) | |
Notes
Diffstat (limited to 'lib/libncurses/lib_initscr.c')
| -rw-r--r-- | lib/libncurses/lib_initscr.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/libncurses/lib_initscr.c b/lib/libncurses/lib_initscr.c index 5c9dfc3326ee..1c2d9e374123 100644 --- a/lib/libncurses/lib_initscr.c +++ b/lib/libncurses/lib_initscr.c @@ -15,17 +15,26 @@ WINDOW *initscr() { +static bool initialized = FALSE; +char *name; #ifdef TRACE _init_trace(); T(("initscr() called")); #endif - if (newterm(getenv("TERM"), stdout, stdin) == NULL) - return NULL; - else { - def_shell_mode(); + /* Portable applications must not call initscr() more than once */ + if (!initialized) { + initialized = TRUE; + + if ((name = getenv("TERM")) == 0) + name = "unknown"; + if (newterm(name, stdout, stdin) == 0) { + fprintf(stderr, "Error opening terminal: %s.\n", name); + exit(1); + } + /* def_shell_mode - done in newterm */ def_prog_mode(); - return(stdscr); } + return(stdscr); } |
