aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/progs/tic.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/progs/tic.c')
-rw-r--r--contrib/ncurses/progs/tic.c77
1 files changed, 65 insertions, 12 deletions
diff --git a/contrib/ncurses/progs/tic.c b/contrib/ncurses/progs/tic.c
index 28292e6ece29..2fb34df53968 100644
--- a/contrib/ncurses/progs/tic.c
+++ b/contrib/ncurses/progs/tic.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2001,2002 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 *
@@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ * and: Thomas E. Dickey 1996 on *
****************************************************************************/
/*
@@ -44,7 +45,7 @@
#include <term_entry.h>
#include <transform.h>
-MODULE_ID("$Id: tic.c,v 1.92 2001/06/18 18:44:01 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.96 2002/06/01 20:42:53 tom Exp $")
const char *_nc_progname = "tic";
@@ -822,8 +823,8 @@ expected_params(const char *name)
{ "sgr1", 6 },
{ "slength", 1 },
{ "slines", 1 },
- { "smgbp", 2 },
- { "smglp", 2 },
+ { "smgbp", 1 }, /* 2 if smgtp is not given */
+ { "smglp", 1 },
{ "smglr", 2 },
{ "smgrp", 1 },
{ "smgtb", 2 },
@@ -863,6 +864,10 @@ check_params(TERMTYPE * tp, const char *name, char *value)
bool params[10];
char *s = value;
+ if (!strcmp(name, "smgbp")
+ && set_top_margin_parm == 0)
+ expected = 2;
+
for (n = 0; n < 10; n++)
params[n] = FALSE;
@@ -901,6 +906,14 @@ check_params(TERMTYPE * tp, const char *name, char *value)
}
}
+static char *
+skip_delay(char *s)
+{
+ while (*s == '/' || isdigit(UChar(*s)))
+ ++s;
+ return s;
+}
+
/*
* An sgr string may contain several settings other than the one we're
* interested in, essentially sgr0 + rmacs + whatever. As long as the
@@ -908,8 +921,25 @@ check_params(TERMTYPE * tp, const char *name, char *value)
* sanity check.
*/
static bool
-similar_sgr(char *a, char *b)
+similar_sgr(int num, char *a, char *b)
{
+ static const char *names[] =
+ {
+ "none"
+ ,"standout"
+ ,"underline"
+ ,"reverse"
+ ,"blink"
+ ,"dim"
+ ,"bold"
+ ,"invis"
+ ,"protect"
+ ,"altcharset"
+ };
+ char *base_a = a;
+ char *base_b = b;
+ int delaying = 0;
+
while (*b != 0) {
while (*a != *b) {
if (*a == 0) {
@@ -917,11 +947,31 @@ similar_sgr(char *a, char *b)
&& b[1] == '<') {
_nc_warning("Did not find delay %s", _nc_visbuf(b));
} else {
- _nc_warning("Unmatched portion %s", _nc_visbuf(b));
+ _nc_warning("checking sgr(%s) %s\n\tcompare to %s\n\tunmatched %s",
+ names[num], _nc_visbuf2(1, base_a),
+ _nc_visbuf2(2, base_b),
+ _nc_visbuf2(3, b));
}
return FALSE;
+ } else if (delaying) {
+ a = skip_delay(a);
+ b = skip_delay(b);
+ } else {
+ a++;
}
- a++;
+ }
+ switch (*a) {
+ case '$':
+ if (delaying == 0)
+ delaying = 1;
+ break;
+ case '<':
+ if (delaying == 1)
+ delaying = 2;
+ break;
+ default:
+ delaying = 0;
+ break;
}
a++;
b++;
@@ -945,9 +995,11 @@ check_sgr(TERMTYPE * tp, char *zero, int num, char *cap, const char *name)
tparm_errs += _nc_tparm_err;
if (test != 0) {
if (PRESENT(cap)) {
- if (!similar_sgr(test, cap)) {
- _nc_warning("%s differs from sgr(%d): %s", name, num,
- _nc_visbuf(test));
+ if (!similar_sgr(num, test, cap)) {
+ _nc_warning("%s differs from sgr(%d)\n\t%s=%s\n\tsgr(%d)=%s",
+ name, num,
+ name, _nc_visbuf2(1, cap),
+ num, _nc_visbuf2(2, test));
}
} else if (strcmp(test, zero)) {
_nc_warning("sgr(%d) present, but not %s", num, name);
@@ -1018,8 +1070,9 @@ check_termtype(TERMTYPE * tp)
* non-ANSI strings are misused.
*/
if ((max_colors > 0) != (max_pairs > 0)
- || (max_colors > max_pairs))
- _nc_warning("inconsistent values for max_colors and max_pairs");
+ || ((max_colors > max_pairs) && (initialize_pair == 0)))
+ _nc_warning("inconsistent values for max_colors (%d) and max_pairs (%d)",
+ max_colors, max_pairs);
PAIRED(set_foreground, set_background);
PAIRED(set_a_foreground, set_a_background);