X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;ds=sidebyside;f=test%2Fncurses.c;h=2aa78b2299b961845311fba7a0f4ebc14a6a5600;hb=2ef2f5486df4a90e2aa9d7544c79b42bca961066;hp=c813123acdfbb2aefb5ed5ea91eb710ef0ed0f78;hpb=8890c8f28a1db5995ef17f52a7d8c0b9cf574210;p=ncurses.git diff --git a/test/ncurses.c b/test/ncurses.c index c813123a..2aa78b22 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc. * + * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -40,7 +41,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.520 2019/12/07 19:04:52 tom Exp $ +$Id: ncurses.c,v 1.528 2022/02/26 22:41:02 tom Exp $ ***************************************************************************/ @@ -165,7 +166,7 @@ static RGB_DATA *all_colors; #endif static void main_menu(bool); -static void failed(const char *s) GCC_NORETURN; +static GCC_NORETURN void failed(const char *s); static void failed(const char *s) @@ -489,7 +490,7 @@ ShellOut(bool message) addstr("Shelling out..."); def_prog_mode(); endwin(); -#ifdef _WIN32 +#ifdef _NC_WINDOWS system("cmd.exe"); #else IGNORE_RC(system("sh")); @@ -854,7 +855,7 @@ wgetch_test(unsigned level, WINDOW *win, int delay) setup_getch(win, flags); wgetch_help(win, flags); } else if (c == 'g') { - waddstr(win, "getstr test: "); + waddstr(win, "wgetnstr test: "); echo(); c = wgetnstr(win, buf, sizeof(buf) - 1); noecho(); @@ -1112,7 +1113,7 @@ wget_wch_test(unsigned level, WINDOW *win, int delay) setup_getch(win, flags); wgetch_help(win, flags); } else if (c == 'g') { - waddstr(win, "getstr test: "); + waddstr(win, "wgetn_str test: "); echo(); code = wgetn_wstr(win, wint_buf, BUFSIZ - 1); noecho(); @@ -2884,6 +2885,10 @@ init_all_colors(bool xterm_colors, char *palette_file) while (fgets(buffer, sizeof(buffer), fp) != 0) { if (sscanf(buffer, "scale:%d", &c) == 1) { scale = c; + if (scale < 100) + scale = 100; + if (scale > 1000) + scale = 1000; } else if (sscanf(buffer, "%d:%d %d %d", &c, &red, @@ -5530,7 +5535,7 @@ panner_legend(int line) "Number repeats. Toggle legend:? filler:a timer:t scrollmark:s." }; int n = ((int) SIZEOF(legend) - (LINES - line)); - if (n >= 0) { + if (n >= 0 && n < (int) SIZEOF(legend)) { if (move(line, 0) != ERR) { if (show_panner_legend) printw("%s", legend[n]); @@ -6231,7 +6236,7 @@ tracetrace(unsigned tlevel) } _nc_SPRINTF(buf, _nc_SLIMIT(need) "0x%02x = {", tlevel); if (tlevel == 0) { - _nc_STRCAT(buf, t_tbl[0].name, need); + _nc_STRCAT(buf, t_tbl[0].name ? t_tbl[0].name : "", need); _nc_STRCAT(buf, ", ", need); } else { for (n = 1; t_tbl[n].name != 0; n++) @@ -7235,11 +7240,11 @@ overlap_test(bool recur GCC_UNUSED) overlap_test_0(win2, win1); break; - case 'c': /* fill window A so it's visible */ + case 'c': /* fill window A so it is visible */ overlap_test_1(flavor[otBASE_fill], 0, win1, 'A'); break; - case 'd': /* fill window B so it's visible */ + case 'd': /* fill window B so it is visible */ overlap_test_1(flavor[otBASE_fill], 1, win2, 'B'); break; @@ -7329,7 +7334,7 @@ overlap_test(bool recur GCC_UNUSED) delwin(win2); delwin(win1); erase(); - exit_curses(); + stop_curses(); return OK; } @@ -7435,11 +7440,11 @@ x_overlap_test(bool recur GCC_UNUSED) overlap_test_0(win2, win1); break; - case 'c': /* fill window A so it's visible */ + case 'c': /* fill window A so it is visible */ x_overlap_test_1(flavor[otBASE_fill], 0, win1, WIDE_A); break; - case 'd': /* fill window B so it's visible */ + case 'd': /* fill window B so it is visible */ x_overlap_test_1(flavor[otBASE_fill], 1, win2, WIDE_B); break; @@ -7529,7 +7534,7 @@ x_overlap_test(bool recur GCC_UNUSED) delwin(win2); delwin(win1); erase(); - exit_curses(); + stop_curses(); return OK; } #endif /* USE_WIDEC_SUPPORT */ @@ -7617,9 +7622,13 @@ settings_test(bool recur GCC_UNUSED) #if HAVE_COLOR_CONTENT show_boolean_setting("can_change_color", can_change_color()); #endif + show_setting_name("LINES"); + printw("%d\n", LINES); + show_setting_name("COLS"); + printw("%d\n", COLS); Pause(); erase(); - exit_curses(); + stop_curses(); return OK; } @@ -7658,7 +7667,7 @@ usage(void) #if USE_LIBPANEL ," -s msec specify nominal time for panel-demo (default: 1, to hold)" #endif -#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(_WIN32) +#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(_NC_WINDOWS) ," -T call use_tioctl(TRUE) to allow SIGWINCH to override environment" #endif #ifdef TRACE @@ -7785,7 +7794,6 @@ main_menu(bool top) int (*doit) (bool); char command; unsigned n; - do { printf("This is the ncurses main menu (uppercase for wide-characters)\n"); for (n = 0; n < SIZEOF(cmds); ++n) { @@ -7851,7 +7859,7 @@ main_menu(bool top) if (doit != NULL && doit(FALSE) == OK) { /* - * This may be overkill; it's intended to reset everything back + * This may be overkill; it is intended to reset everything back * to the initial terminal modes so that tests don't get in * each other's way. */ @@ -7961,7 +7969,7 @@ main(int argc, char *argv[]) nap_msec = (int) atol(optarg); break; #endif -#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(_WIN32) +#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20120714) && !defined(_NC_WINDOWS) case 'T': use_tioctl(TRUE); break;