+
+ /*
+ * 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.
+ */
+ if (actual >= 0) {
+ char *p_is_s[NUM_PARM];
+ int popcount;
+ int analyzed = _nc_tparm_analyze(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);
+ }
+ }
+ }
+}
+
+static bool
+line_capability(const char *name)
+{
+ bool result = FALSE;
+ static const char *table[] =
+ {
+ "csr", /* change_scroll_region */
+ "clear", /* clear_screen */
+ "ed", /* clr_eos */
+ "cwin", /* create_window */
+ "cup", /* cursor_address */
+ "cud1", /* cursor_down */
+ "home", /* cursor_home */
+ "mrcup", /* cursor_mem_address */
+ "ll", /* cursor_to_ll */
+ "cuu1", /* cursor_up */
+ "dl1", /* delete_line */
+ "hd", /* down_half_line */
+ "flash", /* flash_screen */
+ "ff", /* form_feed */
+ "il1", /* insert_line */
+ "nel", /* newline */
+ "dl", /* parm_delete_line */
+ "cud", /* parm_down_cursor */
+ "indn", /* parm_index */
+ "il", /* parm_insert_line */
+ "rin", /* parm_rindex */
+ "cuu", /* parm_up_cursor */
+ "mc0", /* print_screen */
+ "vpa", /* row_address */
+ "ind", /* scroll_forward */
+ "ri", /* scroll_reverse */
+ "hu", /* up_half_line */
+ };
+ size_t n;
+ for (n = 0; n < SIZEOF(table); ++n) {
+ if (!strcmp(name, table[n])) {
+ result = TRUE;
+ break;
+ }
+ }
+ return result;
+}
+
+/*
+ * 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 maybe = TRUE;
+ bool mixed = FALSE;
+ int proportional = 0;
+ int mandatory = 0;
+
+ first = p;
+
+ for (q = base; *q != '\0'; ++q) {
+ if (*q == '>') {
+ if (mark == 0)
+ mark = q;
+ break;
+ } else if (*q == '*' || *q == '/') {
+ if (*q == '*')
+ ++proportional;
+ if (*q == '/')
+ ++mandatory;
+ 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) {
+ float check_f;
+ char check_c;
+ int rc = sscanf(base, "%f%c", &check_f, &check_c);
+ if ((rc != 2) || (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), '+') == 0) {
+ _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 &&
+ (q = skip_DECSCNM(p, &flag)) != 0 &&
+ flag == 0) {
+ _nc_warning("expected a delay in %s", name);
+ }
+ }
+ }