+
+ /*
+ * Counting "%p" markers does not account for termcap expressions which
+ * may not have been fully translated. Also, tparm does its own analysis.
+ * Report differences here.
+ */
+ _nc_reset_tparm(NULL);
+ if (actual >= 0) {
+ char *p_is_s[NUM_PARM];
+ int popcount;
+ int analyzed = _nc_tparm_analyze(NULL, value, p_is_s, &popcount);
+ if (analyzed < popcount) {
+ analyzed = popcount;
+ }
+ if (actual != analyzed && expected != analyzed) {
+#if NCURSES_XNAMES
+ int user_cap = is_user_capability(name);
+ if ((user_cap == analyzed) && using_extensions) {
+ ; /* ignore */
+ } else if (user_cap >= 0) {
+ _nc_warning("tparm will use %d parameters for %s, expected %d",
+ analyzed, name, user_cap);
+ } else
+#endif
+ {
+ _nc_warning("tparm analyzed %d parameters for %s, expected %d",
+ analyzed, name, actual);
+ }
+ } else if (expected > 0
+ && actual == expected
+ && guess_tparm_type(expected, p_is_s) == Numbers) {
+ int limit = 1;
+
+ if (!strcmp(name, "setf")
+ || !strcmp(name, "setb")
+ || !strcmp(name, "setaf")
+ || !strcmp(name, "setab")) {
+ if ((limit = max_colors) > 256)
+ limit = 256;
+ } else if (line_capability(name)) {
+ limit = 24;
+ } else if (is_user_capability(name) < 0) {
+ limit = 80;
+ }
+ for (n = 0; n < limit; ++n) {
+ _nc_reset_tparm(NULL);
+ (void) TPARM_9(value, n, n, n, n, n, n, n, n, n);
+ if (_nc_tparm_err) {
+ _nc_warning("problem%s in tparm(%s, %d, ...)",
+ (_nc_tparm_err == 1) ? "" : "s",
+ name, n);
+ if (debug_level < 2)
+ break;
+ }
+ }
+ }
+ }
+}
+
+/*
+ * Check for DEC VT100 private mode for reverse video.
+ */
+static const char *
+skip_DECSCNM(const char *value, int *flag)
+{
+ *flag = -1;
+ if (value != 0) {
+ int skip = csi_length(value);
+ if (skip > 0 &&
+ value[skip++] == '?' &&
+ value[skip++] == '5') {
+ if (value[skip] == 'h') {
+ *flag = 1;
+ } else if (value[skip] == 'l') {
+ *flag = 0;
+ }
+ value += skip + 1;
+ }
+ }
+ return value;
+}
+
+static void
+check_delays(TERMTYPE2 *tp, const char *name, const char *value)
+{
+ const char *p, *q;
+ const char *first = 0;
+ const char *last = 0;
+
+ for (p = value; *p != '\0'; ++p) {
+ if (p[0] == '$' && p[1] == '<') {
+ const char *base = p + 2;
+ const char *mark = 0;
+ bool mixed = FALSE;
+ int proportional = 0;
+ int mandatory = 0;
+
+ first = p;
+
+ for (q = base; *q != '\0'; ++q) {
+ if (*q == '>') {
+ if (mark == NULL)
+ mark = q;
+ break;
+ } else if (*q == '*' || *q == '/') {
+ if (*q == '*')
+ ++proportional;
+ if (*q == '/')
+ ++mandatory;
+ if (mark == NULL)
+ mark = q;
+ } else if (!(isalnum(UChar(*q)) || strchr("+-.", *q) != 0)) {
+ break;
+ } else if (proportional || mandatory) {
+ mixed = TRUE;
+ }
+ }
+ last = *q ? (q + 1) : q;
+ if (*q != '\0') {
+ float check_f;
+ char check_c;
+ int rc = sscanf(base, "%f%c", &check_f, &check_c);
+ 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') {
+ _nc_warning("function-key %s has delay", name);
+ } else if (proportional && !line_capability(name)) {
+ _nc_warning("non-line capability using proportional delay: %s", name);
+ } else if (!xon_xoff &&
+ !mandatory &&
+ strchr(_nc_first_name(tp->term_names), '+') == NULL) {
+ _nc_warning("%s in %s is used since no xon/xoff",
+ (proportional
+ ? "proportional delay"
+ : "delay"),
+ name);
+ }
+ } else {
+ p = q - 1; /* restart scan */
+ }
+ }
+ }
+
+ if (!strcmp(name, "flash") ||
+ !strcmp(name, "beep")) {
+
+ if (first != 0) {
+ if (first == value || *last == 0) {
+ /*
+ * Delay is on one end or the other.
+ */
+ _nc_warning("expected delay embedded within %s", name);
+ }
+ } else {
+ int flag;
+
+ /*
+ * Check for missing delay when using VT100 reverse-video.
+ * A real VT100 might not need this, but terminal emulators do.
+ */
+ if ((p = skip_DECSCNM(value, &flag)) != 0 &&
+ flag > 0 &&
+ skip_DECSCNM(p, &flag) != 0 &&
+ flag == 0) {
+ _nc_warning("expected a delay in %s", name);
+ }
+ }
+ }