X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_ti.c;h=5cb77b850dd77f33c1816a53a8c35b143b24dff2;hp=76001d2c11acb39b539aa31668ebee47a4a5d4a6;hb=9b4c4abadc0a29999c5ddad5aa8d769fee28d687;hpb=ccb812c9ce7d5859d06b01ce88b331b2a70ad520 diff --git a/ncurses/tinfo/lib_ti.c b/ncurses/tinfo/lib_ti.c index 76001d2c..5cb77b85 100644 --- a/ncurses/tinfo/lib_ti.c +++ b/ncurses/tinfo/lib_ti.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. * + * Copyright 2018,2020 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 * @@ -34,10 +35,9 @@ #include -#include #include -MODULE_ID("$Id: lib_ti.c,v 1.26 2009/07/11 18:14:21 tom Exp $") +MODULE_ID("$Id: lib_ti.c,v 1.34 2020/02/02 23:34:34 tom Exp $") #if 0 static bool @@ -51,16 +51,16 @@ same_name(const char *a, const char *b) #endif NCURSES_EXPORT(int) -NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str) +NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx const char *str) { int result = ABSENT_BOOLEAN; - int i, j; - T((T_CALLED("tigetflag(%p, %s)"), SP_PARM, str)); + T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM, str)); if (HasTInfoTerminal(SP_PARM)) { - TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); struct name_table_entry const *entry_ptr; + int j = -1; entry_ptr = _nc_find_type_entry(str, BOOLEAN, FALSE); if (entry_ptr != 0) { @@ -68,7 +68,7 @@ NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str) } #if NCURSES_XNAMES else { - j = -1; + int i; for_each_ext_boolean(i, tp) { const char *capname = ExtBoolname(tp, i, boolnames); if (same_name(str, capname)) { @@ -89,23 +89,23 @@ NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx NCURSES_CONST char *str) #if NCURSES_SP_FUNCS NCURSES_EXPORT(int) -tigetflag(NCURSES_CONST char *str) +tigetflag(const char *str) { return NCURSES_SP_NAME(tigetflag) (CURRENT_SCREEN, str); } #endif NCURSES_EXPORT(int) -NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str) +NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx const char *str) { - int i, j; int result = CANCELLED_NUMERIC; /* Solaris returns a -1 on error */ - T((T_CALLED("tigetnum(%p, %s)"), SP_PARM, str)); + T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM, str)); if (HasTInfoTerminal(SP_PARM)) { - TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); struct name_table_entry const *entry_ptr; + int j = -1; entry_ptr = _nc_find_type_entry(str, NUMBER, FALSE); if (entry_ptr != 0) { @@ -113,7 +113,7 @@ NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str) } #if NCURSES_XNAMES else { - j = -1; + int i; for_each_ext_number(i, tp) { const char *capname = ExtNumname(tp, i, numnames); if (same_name(str, capname)) { @@ -123,10 +123,12 @@ NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str) } } #endif - if (j >= 0 && VALID_NUMERIC(tp->Numbers[j])) - result = tp->Numbers[j]; - else - result = ABSENT_NUMERIC; + if (j >= 0) { + if (VALID_NUMERIC(tp->Numbers[j])) + result = tp->Numbers[j]; + else + result = ABSENT_NUMERIC; + } } returnCode(result); @@ -134,23 +136,23 @@ NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx NCURSES_CONST char *str) #if NCURSES_SP_FUNCS NCURSES_EXPORT(int) -tigetnum(NCURSES_CONST char *str) +tigetnum(const char *str) { return NCURSES_SP_NAME(tigetnum) (CURRENT_SCREEN, str); } #endif NCURSES_EXPORT(char *) -NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str) +NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx const char *str) { char *result = CANCELLED_STRING; - int i, j; - T((T_CALLED("tigetstr(%p, %s)"), SP_PARM, str)); + T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM, str)); if (HasTInfoTerminal(SP_PARM)) { - TERMTYPE *tp = &(TerminalOf(SP_PARM)->type); + TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM)); struct name_table_entry const *entry_ptr; + int j = -1; entry_ptr = _nc_find_type_entry(str, STRING, FALSE); if (entry_ptr != 0) { @@ -158,7 +160,7 @@ NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str) } #if NCURSES_XNAMES else { - j = -1; + int i; for_each_ext_string(i, tp) { const char *capname = ExtStrname(tp, i, strnames); if (same_name(str, capname)) { @@ -179,7 +181,7 @@ NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str) #if NCURSES_SP_FUNCS NCURSES_EXPORT(char *) -tigetstr(NCURSES_CONST char *str) +tigetstr(const char *str) { return NCURSES_SP_NAME(tigetstr) (CURRENT_SCREEN, str); }