diff options
Diffstat (limited to 'ncurses/tty')
| -rwxr-xr-x | ncurses/tty/MKexpanded.sh | 11 | ||||
| -rw-r--r-- | ncurses/tty/hardscroll.c | 16 | ||||
| -rw-r--r-- | ncurses/tty/hashmap.c | 26 | ||||
| -rw-r--r-- | ncurses/tty/lib_mvcur.c | 84 | ||||
| -rw-r--r-- | ncurses/tty/lib_tstp.c | 16 | ||||
| -rw-r--r-- | ncurses/tty/lib_twait.c | 12 | ||||
| -rw-r--r-- | ncurses/tty/lib_vidattr.c | 12 | ||||
| -rw-r--r-- | ncurses/tty/tty_update.c | 48 |
8 files changed, 119 insertions, 106 deletions
diff --git a/ncurses/tty/MKexpanded.sh b/ncurses/tty/MKexpanded.sh index 0072be2cd35d..576959958020 100755 --- a/ncurses/tty/MKexpanded.sh +++ b/ncurses/tty/MKexpanded.sh @@ -1,6 +1,6 @@ #! /bin/sh ############################################################################## -# Copyright 2019-2020,2021 Thomas E. Dickey # +# Copyright 2019-2021,2024 Thomas E. Dickey # # Copyright 1998-2015,2017 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # @@ -30,7 +30,7 @@ # # Author: Thomas E. Dickey, 1997-on # -# $Id: MKexpanded.sh,v 1.24 2022/02/05 17:27:18 tom Exp $ +# $Id: MKexpanded.sh,v 1.25 2024/12/07 20:48:46 tom Exp $ # # Script to generate 'expanded.c', a dummy source that contains functions # corresponding to complex macros used in this library. By making functions, @@ -127,7 +127,12 @@ _nc_UpdateAttrs (CARG_CH_T c) EOF $preprocessor $TMP 2>/dev/null | \ - sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#[ ]*if_/#if /' -e "s,$TMP,expanded.c," + sed -e '1,/^IGNORE$/d' \ + -e 's/^@/#/' \ + -e 's/^#[ ]*if_/#if /' \ + -e "s,$TMP,expanded.c," \ + -e 's/[ ][ ]*$//' \ + -e '/^#[ ]*[0-9]/d' cat <<EOF #else /* ! NCURSES_EXPANDED */ diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c index 2b1f079e4b9e..767b97097db3 100644 --- a/ncurses/tty/hardscroll.c +++ b/ncurses/tty/hardscroll.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2023 Thomas E. Dickey * + * Copyright 2020-2024,2025 Thomas E. Dickey * * Copyright 1998-2015,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -107,7 +107,7 @@ be moved out of order. THE ALGORITHM The scrolling is done in two passes. The first pass is from top to bottom -scroling hunks UP. The second one is from bottom to top scrolling hunks DOWN. +scrolling hunks UP. The second one is from bottom to top scrolling hunks DOWN. Obviously enough, no lines to be scrolled will be destroyed. (lav) HOW TO TEST THIS: @@ -148,7 +148,7 @@ AUTHOR #include <curses.priv.h> -MODULE_ID("$Id: hardscroll.c,v 1.58 2023/09/09 16:04:08 Nicholas.Marriott Exp $") +MODULE_ID("$Id: hardscroll.c,v 1.61 2025/02/15 15:12:54 tom Exp $") #if defined(SCROLLDEBUG) || defined(HASHDEBUG) @@ -169,7 +169,7 @@ extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from somewhere. */ NCURSES_EXPORT_VAR (int *) - _nc_oldnums = 0; /* obsolete: keep for ABI compat */ + _nc_oldnums = NULL; /* obsolete: keep for ABI compat */ # if USE_HASHMAP # define oldnums(sp) (sp)->_oldnum_list @@ -196,7 +196,7 @@ NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_DCL0) /* get enough storage */ assert(OLDNUM_SIZE(SP_PARM) >= 0); assert(screen_lines(SP_PARM) > 0); - if ((oldnums(SP_PARM) == 0) + if ((oldnums(SP_PARM) == NULL) || (OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM))) { int need_lines = ((OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM)) ? screen_lines(SP_PARM) @@ -308,11 +308,11 @@ NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_DCL0) /* dump the state of the real and virtual oldnum fields */ { if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) { - char *buf = 0; + char *buf = NULL; size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4; (void) SP_PARM; - if ((buf = typeMalloc(char, want)) != 0) { + if ((buf = typeMalloc(char, want)) != NULL) { int n; *buf = '\0'; @@ -371,7 +371,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) do { oldnums[n++] = atoi(st); } while - ((st = strtok((char *) NULL, " ")) != 0); + ((st = strtok((char *) NULL, " ")) != NULL); /* display it */ (void) fputs("Initial input:\n", stderr); diff --git a/ncurses/tty/hashmap.c b/ncurses/tty/hashmap.c index e50b63847b99..1498f5fdee28 100644 --- a/ncurses/tty/hashmap.c +++ b/ncurses/tty/hashmap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020,2023 Thomas E. Dickey * + * Copyright 2019-2024,2025 Thomas E. Dickey * * Copyright 1998-2015,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -74,7 +74,7 @@ AUTHOR #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: hashmap.c,v 1.71 2023/09/16 16:28:53 tom Exp $") +MODULE_ID("$Id: hashmap.c,v 1.75 2025/07/26 19:48:34 tom Exp $") #ifdef HASHDEBUG @@ -120,15 +120,14 @@ static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH(sp)]; static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT); static NCURSES_INLINE unsigned long -hash(SCREEN *sp, NCURSES_CH_T *text) +hash(SCREEN *sp, const NCURSES_CH_T *text) { int i; - NCURSES_CH_T ch; unsigned long result = 0; (void) sp; for (i = TEXTWIDTH(sp); i > 0; i--) { - ch = *text++; + NCURSES_CH_T ch = *text++; result += (result << 5) + (unsigned long) HASH_VAL(ch); } return result; @@ -312,10 +311,10 @@ NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0) } } else { /* re-hash all */ - if (oldhash(SP_PARM) == 0) + if (oldhash(SP_PARM) == NULL) oldhash(SP_PARM) = typeCalloc(unsigned long, (size_t) screen_lines(SP_PARM)); - if (newhash(SP_PARM) == 0) + if (newhash(SP_PARM) == NULL) newhash(SP_PARM) = typeCalloc(unsigned long, (size_t) screen_lines(SP_PARM)); if (!oldhash(SP_PARM) || !newhash(SP_PARM)) { @@ -504,7 +503,8 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) for (n = 0; n < screen_lines(sp); n++) { reallines[n] = n; oldnums[n] = _NEWINDEX; - CharOf(oldtext[n][0]) = CharOf(newtext[n][0]) = '.'; + SetChar(oldtext[n][0], '.', A_NORMAL); + SetChar(newtext[n][0], '.', A_NORMAL); } if (NC_ISATTY(fileno(stdin))) @@ -533,27 +533,27 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) do { oldnums[n++] = atoi(st); } while - ((st = strtok((char *) NULL, " ")) != 0); + ((st = strtok((char *) NULL, " ")) != NULL); break; case 'n': /* use following letters as text of new lines */ for (n = 0; n < screen_lines(sp); n++) - CharOf(newtext[n][0]) = '.'; + SetChar(newtext[n][0], '.', A_NORMAL); for (n = 0; n < screen_lines(sp); n++) if (line[n + 1] == '\n') break; else - CharOf(newtext[n][0]) = line[n + 1]; + SetChar(newtext[n][0], line[n + 1], A_NORMAL); break; case 'o': /* use following letters as text of old lines */ for (n = 0; n < screen_lines(sp); n++) - CharOf(oldtext[n][0]) = '.'; + SetChar(oldtext[n][0], '.', A_NORMAL); for (n = 0; n < screen_lines(sp); n++) if (line[n + 1] == '\n') break; else - CharOf(oldtext[n][0]) = line[n + 1]; + SetChar(oldtext[n][0], line[n + 1], A_NORMAL); break; case 'd': /* dump state of test arrays */ diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c index 8fad93c727ae..bddccc56a4e2 100644 --- a/ncurses/tty/lib_mvcur.c +++ b/ncurses/tty/lib_mvcur.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2022,2023 Thomas E. Dickey * + * Copyright 2018-2024,2025 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -160,7 +160,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_mvcur.c,v 1.161 2023/09/16 16:29:02 tom Exp $") +MODULE_ID("$Id: lib_mvcur.c,v 1.167 2025/12/27 12:34:03 tom Exp $") #define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x] /* desired state */ @@ -222,8 +222,8 @@ NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_DCLx const char *const cap, int affcnt) /* compute the cost of a given operation */ { - if (cap == 0) - return (INFINITY); + if (cap == NULL) + return (NC_INFINITY); else { const char *cp; float cum_cost = 0.0; @@ -287,7 +287,7 @@ normalized_cost(NCURSES_SP_DCLx const char *const cap, int affcnt) /* compute the effective character-count for an operation (round up) */ { int cost = NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_ARGx cap, affcnt); - if (cost != INFINITY) + if (cost != NC_INFINITY) cost = (cost + SP_PARM->_char_padding - 1) / SP_PARM->_char_padding; return cost; } @@ -364,14 +364,14 @@ NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0) SP_PARM->_home_cost = CostOf(cursor_home, 0); SP_PARM->_ll_cost = CostOf(cursor_to_ll, 0); #if USE_HARD_TABS - if (getenv("NCURSES_NO_HARD_TABS") == 0 + if (getenv("NCURSES_NO_HARD_TABS") == NULL && dest_tabs_magic_smso == 0 && HasHardTabs()) { SP_PARM->_ht_cost = CostOf(tab, 0); SP_PARM->_cbt_cost = CostOf(back_tab, 0); } else { - SP_PARM->_ht_cost = INFINITY; - SP_PARM->_cbt_cost = INFINITY; + SP_PARM->_ht_cost = NC_INFINITY; + SP_PARM->_cbt_cost = NC_INFINITY; } #endif /* USE_HARD_TABS */ SP_PARM->_cub1_cost = CostOf(cursor_left, 0); @@ -461,12 +461,12 @@ NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0) * nested on the various terminals (vt100, xterm, etc.) which use this * feature. */ - if (save_cursor != 0 - && enter_ca_mode != 0 - && strstr(enter_ca_mode, save_cursor) != 0) { + if (save_cursor != NULL + && enter_ca_mode != NULL + && strstr(enter_ca_mode, save_cursor) != NULL) { T(("...suppressed sc/rc capability due to conflict with smcup/rmcup")); - save_cursor = 0; - restore_cursor = 0; + save_cursor = NULL; + restore_cursor = NULL; } /* @@ -543,12 +543,12 @@ repeated_append(string_desc * target, int total, int num, int repeat, const char if (_nc_safe_strcat(target, src)) { total += num; } else { - total = INFINITY; + total = NC_INFINITY; break; } } } else { - total = INFINITY; + total = NC_INFINITY; } return total; } @@ -578,9 +578,9 @@ relative_move(NCURSES_SP_DCLx (void) _nc_str_copy(&save, target); if (to_y != from_y) { - vcost = INFINITY; + vcost = NC_INFINITY; - if (row_address != 0 + if (row_address != NULL && _nc_safe_strcat(target, TIPARM_1(row_address, to_y))) { vcost = SP_PARM->_vpa_cost; } @@ -617,8 +617,8 @@ relative_move(NCURSES_SP_DCLx } } - if (vcost == INFINITY) - return (INFINITY); + if (vcost == NC_INFINITY) + return (NC_INFINITY); } save = *target; @@ -627,7 +627,7 @@ relative_move(NCURSES_SP_DCLx char str[OPT_SIZE]; string_desc check; - hcost = INFINITY; + hcost = NC_INFINITY; if (column_address && _nc_safe_strcat(_nc_str_copy(target, &save), @@ -658,7 +658,7 @@ relative_move(NCURSES_SP_DCLx for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) { lhcost = repeated_append(&check, lhcost, SP_PARM->_ht_cost, 1, tab); - if (lhcost == INFINITY) + if (lhcost == NC_INFINITY) break; } @@ -751,7 +751,7 @@ relative_move(NCURSES_SP_DCLx lhcost = repeated_append(&check, lhcost, SP_PARM->_cbt_cost, 1, back_tab); - if (lhcost == INFINITY) + if (lhcost == NC_INFINITY) break; } @@ -770,8 +770,8 @@ relative_move(NCURSES_SP_DCLx } } - if (hcost == INFINITY) - return (INFINITY); + if (hcost == NC_INFINITY) + return (NC_INFINITY); } return (vcost + hcost); @@ -798,7 +798,7 @@ onscreen_mvcur(NCURSES_SP_DCLx { string_desc result; char buffer[OPT_SIZE]; - int tactic = 0, newcost, usecost = INFINITY; + int tactic = 0, newcost, usecost = NC_INFINITY; int t5_cr_cost; #if defined(MAIN) || defined(NCURSES_TEST) @@ -846,7 +846,7 @@ onscreen_mvcur(NCURSES_SP_DCLx && ((newcost = relative_move(NCURSES_SP_ARGx NullResult, yold, xold, - ynew, xnew, ovw)) != INFINITY) + ynew, xnew, ovw)) != NC_INFINITY) && newcost < usecost) { tactic = 1; usecost = newcost; @@ -857,7 +857,7 @@ onscreen_mvcur(NCURSES_SP_DCLx && ((newcost = relative_move(NCURSES_SP_ARGx NullResult, yold, 0, - ynew, xnew, ovw)) != INFINITY) + ynew, xnew, ovw)) != NC_INFINITY) && SP_PARM->_cr_cost + newcost < usecost) { tactic = 2; usecost = SP_PARM->_cr_cost + newcost; @@ -868,7 +868,7 @@ onscreen_mvcur(NCURSES_SP_DCLx && ((newcost = relative_move(NCURSES_SP_ARGx NullResult, 0, 0, - ynew, xnew, ovw)) != INFINITY) + ynew, xnew, ovw)) != NC_INFINITY) && SP_PARM->_home_cost + newcost < usecost) { tactic = 3; usecost = SP_PARM->_home_cost + newcost; @@ -879,7 +879,7 @@ onscreen_mvcur(NCURSES_SP_DCLx && ((newcost = relative_move(NCURSES_SP_ARGx NullResult, screen_lines(SP_PARM) - 1, 0, - ynew, xnew, ovw)) != INFINITY) + ynew, xnew, ovw)) != NC_INFINITY) && SP_PARM->_ll_cost + newcost < usecost) { tactic = 4; usecost = SP_PARM->_ll_cost + newcost; @@ -895,7 +895,7 @@ onscreen_mvcur(NCURSES_SP_DCLx && ((newcost = relative_move(NCURSES_SP_ARGx NullResult, yold - 1, screen_columns(SP_PARM) - 1, - ynew, xnew, ovw)) != INFINITY) + ynew, xnew, ovw)) != NC_INFINITY) && t5_cr_cost + SP_PARM->_cub1_cost + newcost < usecost) { tactic = 5; usecost = t5_cr_cost + SP_PARM->_cub1_cost + newcost; @@ -948,15 +948,15 @@ onscreen_mvcur(NCURSES_SP_DCLx nonlocal: #if defined(MAIN) || defined(NCURSES_TEST) gettimeofday(&after, NULL); - diff = after.tv_usec - before.tv_usec - + (after.tv_sec - before.tv_sec) * 1000000; + diff = (float) (after.tv_usec - before.tv_usec + + (after.tv_sec - before.tv_sec) * 1000000); if (!profiling) (void) fprintf(stderr, "onscreen: %d microsec, %f 28.8Kbps char-equivalents\n", (int) diff, diff / 288); #endif /* MAIN */ - if (usecost != INFINITY) { + if (usecost != NC_INFINITY) { TR(TRACE_MOVE, ("mvcur tactic %d", tactic)); TPUTS_TRACE("mvcur"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx @@ -984,7 +984,7 @@ _nc_real_mvcur(NCURSES_SP_DCLx TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("_nc_real_mvcur(%p,%d,%d,%d,%d)"), (void *) SP_PARM, yold, xold, ynew, xnew)); - if (SP_PARM == 0) { + if (SP_PARM == NULL) { code = ERR; } else if (yold == ynew && xold == xnew) { code = OK; @@ -1079,7 +1079,7 @@ NCURSES_SP_NAME(_nc_mvcur) (NCURSES_SP_DCLx * external calls. Flush the output if the screen has not been * initialized, e.g., when used from low-level terminfo programs. */ - if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial)) + if ((SP_PARM != NULL) && (SP_PARM->_endwin == ewInitial)) NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); return rc; } @@ -1093,7 +1093,7 @@ _nc_mvcur(int yold, int xold, } #endif -#if defined(USE_TERM_DRIVER) +#if USE_TERM_DRIVER /* * The terminal driver does not support the external "mvcur()". */ @@ -1106,7 +1106,7 @@ TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew) ynew, xnew, NCURSES_SP_NAME(_nc_outch), TRUE); - if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial)) + if ((SP_PARM != NULL) && (SP_PARM->_endwin == ewInitial)) NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG); return rc; @@ -1227,7 +1227,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) if (fputs("> ", stdout) == EOF) break; - if (fgets(buf, sizeof(buf), stdin) == 0) + if (fgets(buf, sizeof(buf), stdin) == NULL) break; #define PUTS(s) (void) puts(s) @@ -1307,7 +1307,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) } else if (buf[0] == 'i') { dump_init(NULL, F_TERMINFO, S_TERMINFO, FALSE, 70, 0, 0, FALSE, FALSE, 0); - dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, 0); + dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, NULL); putchar('\n'); } else if (buf[0] == 'o') { if (_nc_optimize_enable & OPTIMIZE_MVCUR) { @@ -1338,7 +1338,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) * is winning. */ else if (sscanf(buf, "t %d", &n) == 1) { - float cumtime = 0.0, perchar; + double cumtime = 0.0, perchar; int speeds[] = {2400, 9600, 14400, 19200, 28800, 38400, 0}; @@ -1384,14 +1384,14 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) * transmission both. Transmission time is an estimate * assuming 9 bits/char, 8 bits + 1 stop bit. */ - float totalest = cumtime + xmits * 9 * 1e6 / speeds[i]; + double totalest = cumtime + (double) xmits * 9 * 1e6 / speeds[i]; /* * Per-character optimization overhead in character transmits * at the current speed. Round this to the nearest integer * to figure COMPUTE_OVERHEAD for the speed. */ - float overhead = speeds[i] * perchar / 1e6; + double overhead = speeds[i] * perchar / 1e6; (void) printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n", diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c index dd925c7efd12..3bd872c1dcf1 100644 --- a/ncurses/tty/lib_tstp.c +++ b/ncurses/tty/lib_tstp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020-2021,2022 Thomas E. Dickey * + * Copyright 2020-2024,2025 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -43,7 +43,7 @@ #include <SigAction.h> -MODULE_ID("$Id: lib_tstp.c,v 1.54 2022/12/24 22:22:10 tom Exp $") +MODULE_ID("$Id: lib_tstp.c,v 1.59 2025/02/15 14:52:13 tom Exp $") #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) #define USE_SIGTSTP 1 @@ -159,7 +159,7 @@ handle_SIGTSTP(int dummy GCC_UNUSED) * * Don't do this if we're not in curses - */ - if (sp != 0 && (sp->_endwin == ewRunning)) + if (sp != NULL && (sp->_endwin == ewRunning)) #if HAVE_TCGETPGRP if (tcgetpgrp(STDIN_FILENO) == getpgrp()) #endif @@ -269,7 +269,7 @@ handle_SIGINT(int sig) { SCREEN *scan; for (each_screen(scan)) { - if (scan->_ofp != 0 + if (scan->_ofp != NULL && NC_ISATTY(fileno(scan->_ofp))) { scan->_outch = NCURSES_SP_NAME(_nc_outch); } @@ -294,7 +294,7 @@ _nc_set_read_thread(bool enable) # endif _nc_globals.read_thread = pthread_self(); } else { - _nc_globals.read_thread = 0; + _nc_globals.read_thread = (pthread_t) 0; } _nc_unlock_global(curses); } @@ -310,7 +310,7 @@ handle_SIGWINCH(int sig GCC_UNUSED) if (_nc_globals.read_thread) { if (!pthread_equal(pthread_self(), _nc_globals.read_thread)) pthread_kill(_nc_globals.read_thread, SIGWINCH); - _nc_globals.read_thread = 0; + _nc_globals.read_thread = (pthread_t) 0; } # endif } @@ -367,8 +367,8 @@ CatchIfDefault(int sig, void (*handler) (int)) result = FALSE; } #endif - T(("CatchIfDefault - will %scatch %s", - result ? "" : "not ", signal_name(sig))); + T(("CatchIfDefault - will%s catch %s", + result ? "" : " not", signal_name(sig))); return result; } diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c index 6fa73eedb4ce..8bb7d129977e 100644 --- a/ncurses/tty/lib_twait.c +++ b/ncurses/tty/lib_twait.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2023 Thomas E. Dickey * + * Copyright 2018-2024,2025 Thomas E. Dickey * * Copyright 1998-2015,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -76,7 +76,7 @@ #endif #undef CUR -MODULE_ID("$Id: lib_twait.c,v 1.81 2023/09/16 16:30:40 tom Exp $") +MODULE_ID("$Id: lib_twait.c,v 1.85 2025/03/01 17:07:19 tom Exp $") /* * Returns an elapsed time, in milliseconds (if possible). @@ -120,7 +120,7 @@ _nc_eventlist_timeout(_nc_eventlist * evl) { int event_delay = -1; - if (evl != 0) { + if (evl != NULL) { int n; for (n = 0; n < evl->count; ++n) { @@ -168,7 +168,7 @@ _nc_eventlist_timeout(_nc_eventlist * evl) * descriptors. */ NCURSES_EXPORT(int) -_nc_timed_wait(SCREEN *sp MAYBE_UNUSED, +_nc_timed_wait(const SCREEN *sp MAYBE_UNUSED, int mode MAYBE_UNUSED, int milliseconds, int *timeleft @@ -242,7 +242,7 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED, if ((mode & TW_EVENT) && evl) { if (fds == fd_list) fds = typeMalloc(struct pollfd, MIN_FDS + evl->count); - if (fds == 0) + if (fds == NULL) return TW_NONE; } #endif @@ -273,7 +273,7 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED, } #endif - result = poll(fds, (size_t) count, milliseconds); + result = (int) poll(fds, (size_t) count, milliseconds); #ifdef NCURSES_WGETCH_EVENTS if ((mode & TW_EVENT) && evl) { diff --git a/ncurses/tty/lib_vidattr.c b/ncurses/tty/lib_vidattr.c index 2c7a0b27bd6d..860ef86fd4ef 100644 --- a/ncurses/tty/lib_vidattr.c +++ b/ncurses/tty/lib_vidattr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2023 Thomas E. Dickey * + * Copyright 2018-2024,2025 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -70,7 +70,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_vidattr.c,v 1.79 2023/04/28 20:59:26 tom Exp $") +MODULE_ID("$Id: lib_vidattr.c,v 1.81 2025/12/27 12:41:23 tom Exp $") #define doPut(mode) \ TPUTS_TRACE(#mode); \ @@ -114,9 +114,9 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx attr_t turn_on, turn_off; int pair; bool reverse = FALSE; - bool can_color = (SP_PARM == 0 || SP_PARM->_coloron); + bool can_color = (SP_PARM == NULL || SP_PARM->_coloron); #if NCURSES_EXT_FUNCS - bool fix_pair0 = (SP_PARM != 0 && SP_PARM->_coloron && !SP_PARM->_default_color); + bool fix_pair0 = (SP_PARM != NULL && SP_PARM->_coloron && !SP_PARM->_default_color); #else #define fix_pair0 FALSE #endif @@ -134,7 +134,7 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(PreviousAttr))); - if ((SP_PARM != 0) + if ((SP_PARM != NULL) && (magic_cookie_glitch > 0)) { #if USE_XMC_SUPPORT static const chtype table[] = @@ -380,7 +380,7 @@ NCURSES_SP_NAME(termattrs) (NCURSES_SP_DCL0) T((T_CALLED("termattrs(%p)"), (void *) SP_PARM)); if (HasTerminal(SP_PARM)) { -#ifdef USE_TERM_DRIVER +#if USE_TERM_DRIVER attrs = CallDriver(SP_PARM, td_conattr); #else /* ! USE_TERM_DRIVER */ diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c index 0427024cb084..93dd5971f162 100644 --- a/ncurses/tty/tty_update.c +++ b/ncurses/tty/tty_update.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2023,2024 Thomas E. Dickey * + * Copyright 2018-2024,2025 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -85,7 +85,13 @@ #include <ctype.h> -MODULE_ID("$Id: tty_update.c,v 1.316 2024/02/04 00:09:34 tom Exp $") +#if USE_WIDEC_SUPPORT +#if HAVE_WCTYPE_H +#include <wctype.h> +#endif +#endif + +MODULE_ID("$Id: tty_update.c,v 1.323 2025/12/27 12:34:03 tom Exp $") /* * This define controls the line-breakout optimization. Every once in a @@ -211,7 +217,7 @@ GoTo(NCURSES_SP_DCLx int const row, int const col) } #if !NCURSES_WCWIDTH_GRAPHICS -#define is_wacs_value(ch) (_nc_wacs_width(ch) == 1 && wcwidth(ch) > 1) +#define is_wacs_value(ch) (_nc_wacs_width((wchar_t) ch) == 1 && wcwidth(ch) > 1) #endif /* !NCURSES_WCWIDTH_GRAPHICS */ static NCURSES_INLINE void @@ -256,13 +262,15 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) * not checked. */ if (is8bits(CharOf(CHDEREF(ch))) - && (!is7bits(CharOf(CHDEREF(ch))) && _nc_unicode_locale()) && (isprint(CharOf(CHDEREF(ch))) +#if USE_WIDEC_SUPPORT + || iswprint((wint_t) CharOf(CHDEREF(ch))) +#endif || (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160) || (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128) || (AttrOf(attr) & A_ALTCHARSET && ((CharOfD(ch) < ACS_LEN - && SP_PARM->_acs_map != 0 + && SP_PARM->_acs_map != NULL && SP_PARM->_acs_map[CharOfD(ch)] != 0) || (CharOfD(ch) >= 128))))) { ; @@ -275,7 +283,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) #endif if ((AttrOf(attr) & A_ALTCHARSET) - && SP_PARM->_acs_map != 0 + && SP_PARM->_acs_map != NULL && ((CharOfD(ch) < ACS_LEN) #if !NCURSES_WCWIDTH_GRAPHICS || is_wacs_value(CharOfD(ch)) @@ -283,7 +291,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) )) { int c8; my_ch = CHDEREF(ch); /* work around const param */ - c8 = CharOf(my_ch); + c8 = (int) CharOf(my_ch); #if USE_WIDEC_SUPPORT /* * This is crude & ugly, but works most of the time. It checks if the @@ -331,7 +339,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch) * drawing flavors are integrated. */ if (AttrOf(attr) & A_ALTCHARSET) { - int j = CharOfD(ch); + int j = (int) CharOfD(ch); chtype temp = UChar(SP_PARM->_acs_map[j]); if (temp != 0) { @@ -621,7 +629,7 @@ EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T *ntext, int num) } else { return 1; /* cursor stays in the middle */ } - } else if (repeat_char != 0 && + } else if (repeat_char != NULL && #if BSD_TPUTS !isdigit(UChar(CharOf(ntext0))) && #endif @@ -643,7 +651,7 @@ EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T *ntext, int num) UpdateAttrs(SP_PARM, ntext0); temp = ntext0; if ((AttrOf(temp) & A_ALTCHARSET) && - SP_PARM->_acs_map != 0 && + SP_PARM->_acs_map != NULL && (SP_PARM->_acs_map[CharOf(temp)] & A_CHARTEXT) != 0) { SetChar(temp, (SP_PARM->_acs_map[CharOf(ntext0)] & A_CHARTEXT), @@ -745,7 +753,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0) _nc_lock_global(update); - if (SP_PARM == 0) { + if (SP_PARM == NULL) { _nc_unlock_global(update); returnCode(ERR); } @@ -762,7 +770,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0) if (SP_PARM == CURRENT_SCREEN) { #endif #define SyncScreens(internal,exported) \ - if (internal == 0) internal = exported; \ + if (internal == NULL) internal = exported; \ if (internal != exported) exported = internal SyncScreens(CurScreen(SP_PARM), curscr); @@ -773,9 +781,9 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0) #endif #endif /* !USE_REENTRANT */ - if (CurScreen(SP_PARM) == 0 - || NewScreen(SP_PARM) == 0 - || StdScreen(SP_PARM) == 0) { + if (CurScreen(SP_PARM) == NULL + || NewScreen(SP_PARM) == NULL + || StdScreen(SP_PARM) == NULL) { _nc_unlock_global(update); returnCode(ERR); } @@ -1091,7 +1099,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0) returnCode(OK); } -#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER) +#if NCURSES_SP_FUNCS && !USE_TERM_DRIVER NCURSES_EXPORT(int) doupdate(void) { @@ -1132,7 +1140,7 @@ static void ClrUpdate(NCURSES_SP_DCL0) { TR(TRACE_UPDATE, (T_CALLED("ClrUpdate"))); - if (0 != SP_PARM) { + if (NULL != SP_PARM) { int i; NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); int nonempty = Min(screen_lines(SP_PARM), @@ -1159,7 +1167,7 @@ ClrUpdate(NCURSES_SP_DCL0) static void ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear) { - if (CurScreen(SP_PARM) != 0 + if (CurScreen(SP_PARM) != NULL && SP_PARM->_cursrow >= 0) { int j; @@ -2223,7 +2231,7 @@ _nc_screen_init(void) NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0) { - if (SP_PARM != 0) { + if (SP_PARM != NULL) { UpdateAttrs(SP_PARM, normal); #if NCURSES_EXT_FUNCS @@ -2265,7 +2273,7 @@ _nc_screen_wrap(void) NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch) (NCURSES_SP_DCLx attr_t previous) { - if (SP_PARM != 0) { + if (SP_PARM != NULL) { attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP_PARM))); while (chg != 0) { |
