X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftic.c;h=b08f30f63b5452c793e0f1f76cf9e64d7e42ec66;hp=ae172ece9fc93f4f17617f3a381cbb5f8e818592;hb=6830dca51a4e50d41e7bd114bdbaa857b42a46f4;hpb=790a85dbd4a81d5f5d8dd02a44d84f01512ef443 diff --git a/progs/tic.c b/progs/tic.c index ae172ece..b08f30f6 100644 --- a/progs/tic.c +++ b/progs/tic.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2017,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -49,7 +49,7 @@ #include #include -MODULE_ID("$Id: tic.c,v 1.286 2020/05/31 21:05:44 tom Exp $") +MODULE_ID("$Id: tic.c,v 1.293 2021/03/20 20:51:01 tom Exp $") #define STDIN_NAME "" @@ -1711,6 +1711,7 @@ check_screen(TERMTYPE2 *tp) int have_bce = back_color_erase; bool have_kmouse = FALSE; bool use_sgr_39_49 = FALSE; + const char *name_39_49 = "orig_pair or orig_colors"; char *name = _nc_first_name(tp->term_names); bool is_screen = !strncmp(name, "screen", 6); bool screen_base = (is_screen @@ -1728,10 +1729,15 @@ check_screen(TERMTYPE2 *tp) if (VALID_STRING(key_mouse)) { have_kmouse = !strcmp("\033[M", key_mouse); } - if (VALID_STRING(orig_colors)) { - use_sgr_39_49 = uses_SGR_39_49(orig_colors); - } else if (VALID_STRING(orig_pair)) { - use_sgr_39_49 = uses_SGR_39_49(orig_pair); + if (have_bce) { + if (VALID_STRING(orig_pair)) { + name_39_49 = "orig_pair"; + use_sgr_39_49 = uses_SGR_39_49(orig_pair); + } + if (!use_sgr_39_49 && VALID_STRING(orig_colors)) { + name_39_49 = "orig_colors"; + use_sgr_39_49 = uses_SGR_39_49(orig_colors); + } } if (have_XM && have_XT) { @@ -1746,10 +1752,14 @@ check_screen(TERMTYPE2 *tp) _nc_warning("expected kmous capability with XT"); } } - if (!have_bce && max_colors > 0) - _nc_warning("expected bce capability with XT"); - if (!use_sgr_39_49 && have_bce && max_colors > 0) - _nc_warning("expected orig_colors capability with XT to have 39/49 parameters"); + if (max_colors > 0) { + if (!have_bce) { + _nc_warning("expected bce capability with XT"); + } else if (!use_sgr_39_49) { + _nc_warning("expected %s capability with XT " + "to have 39/49 parameters", name_39_49); + } + } if (VALID_STRING(to_status_line)) _nc_warning("\"tsl\" capability is redundant, given XT"); } else { @@ -2087,7 +2097,6 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value) if (p[0] == '$' && p[1] == '<') { const char *base = p + 2; const char *mark = 0; - bool maybe = TRUE; bool mixed = FALSE; int proportional = 0; int mandatory = 0; @@ -2107,20 +2116,17 @@ check_delays(TERMTYPE2 *tp, const char *name, const char *value) if (mark == 0) mark = q; } else if (!(isalnum(UChar(*q)) || strchr("+-.", *q) != 0)) { - maybe = FALSE; break; } else if (proportional || mandatory) { mixed = TRUE; } } last = *q ? (q + 1) : q; - if (*q == '\0') { - maybe = FALSE; /* just an isolated "$<" */ - } else if (maybe) { + if (*q != '\0') { float check_f; char check_c; int rc = sscanf(base, "%f%c", &check_f, &check_c); - if ((rc != 2) || (check_c != *mark) || mixed) { + if ((rc != 2) || (mark != NULL && (check_c != *mark)) || mixed) { _nc_warning("syntax error in %s delay '%.*s'", name, (int) (q - base), base); } else if (*name == 'k') { @@ -2180,6 +2186,9 @@ check_1_infotocap(const char *name, NCURSES_CONST char *value, int count) char *result; char blob[NUM_PARM * 10]; char *next = blob; + TParams expect; + TParams actual; + int nparam; *next++ = '\0'; for (k = 1; k <= NUM_PARM; k++) { @@ -2191,7 +2200,16 @@ check_1_infotocap(const char *name, NCURSES_CONST char *value, int count) next += strlen(next) + 1; } - switch (tparm_type(name)) { + expect = tparm_type(name); + nparam = _nc_tparm_analyze(value, p_is_s, &ignored); + actual = guess_tparm_type(nparam, p_is_s); + + if (expect != actual) { + _nc_warning("%s has mismatched parameters", name); + actual = Other; + } + + switch (actual) { case Num_Str: result = TPARM_2(value, numbers[1], strings[2]); break; @@ -2212,8 +2230,8 @@ check_1_infotocap(const char *name, NCURSES_CONST char *value, int count) myParam(9)); #undef myParam break; + case Other: default: - (void) _nc_tparm_analyze(value, p_is_s, &ignored); #define myParam(n) (p_is_s[n - 1] != 0 ? ((TPARM_ARG) strings[n]) : numbers[n]) result = TPARM_9(value, myParam(1), @@ -2360,14 +2378,13 @@ check_infotocap(TERMTYPE2 *tp, int i, const char *value) ? parametrized[i] : ((*value == 'k') ? 0 - : has_params(value))); - int to_char = 0; - char *ti_value; + : has_params(value, FALSE))); + char *ti_value = NULL; char *tc_value; bool embedded; assert(SIZEOF(parametrized) == STRCOUNT); - if ((ti_value = _nc_tic_expand(value, TRUE, to_char)) == ABSENT_STRING) { + if (!VALID_STRING(value) || (ti_value = strdup(value)) == NULL) { _nc_warning("tic-expansion of %s failed", name); } else if ((tc_value = _nc_infotocap(name, ti_value, params)) == ABSENT_STRING) { _nc_warning("tic-conversion of %s failed", name); @@ -2390,12 +2407,14 @@ check_infotocap(TERMTYPE2 *tp, int i, const char *value) if (strcmp(ti_check, tc_check)) { if (first) { fprintf(stderr, "check_infotocap(%s)\n", name); - fprintf(stderr, "...ti '%s'\n", ti_value); - fprintf(stderr, "...tc '%s'\n", tc_value); + fprintf(stderr, "...ti '%s'\n", _nc_visbuf2(0, ti_value)); + fprintf(stderr, "...tc '%s'\n", _nc_visbuf2(0, tc_value)); first = FALSE; } _nc_warning("tparm-conversion of %s(%d) differs between\n\tterminfo %s\n\ttermcap %s", - name, count, ti_check, tc_check); + name, count, + _nc_visbuf2(0, ti_check), + _nc_visbuf2(1, tc_check)); } free(ti_check); free(tc_check); @@ -2408,6 +2427,7 @@ check_infotocap(TERMTYPE2 *tp, int i, const char *value) name, ti_value, tc_value); } } + free(ti_value); } static char * @@ -2530,6 +2550,13 @@ similar_sgr(int num, char *a, char *b) return ((num != 0) || (*a == 0)); } +static void +check_tparm_err(int num) +{ + if (_nc_tparm_err) + _nc_warning("tparam error in sgr(%d): %s", num, sgr_names[num]); +} + static char * check_sgr(TERMTYPE2 *tp, char *zero, int num, char *cap, const char *name) { @@ -2560,8 +2587,7 @@ check_sgr(TERMTYPE2 *tp, char *zero, int num, char *cap, const char *name) } else if (PRESENT(cap)) { _nc_warning("sgr(%d) missing, but %s present", num, name); } - if (_nc_tparm_err) - _nc_warning("stack error in sgr(%d) string", num); + check_tparm_err(num); return test; } @@ -2995,8 +3021,7 @@ check_termtype(TERMTYPE2 *tp, bool literal) } else { zero = strdup(TIPARM_9(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0)); } - if (_nc_tparm_err) - _nc_warning("stack error in sgr(0) string"); + check_tparm_err(0); if (zero != 0) { CHECK_SGR(1, enter_standout_mode);