+static char *
+next_name(char *name)
+{
+ if (*name != '\0')
+ ++name;
+ return name;
+}
+
+static char *
+name_ending(char *name)
+{
+ if (*name == '\0') {
+ name = 0;
+ } else {
+ while (*name != '\0' && *name != '|')
+ ++name;
+ }
+ return name;
+}
+
+/*
+ * Essentially, find the conflict reported in check_collisions() and remove
+ * it from the second name, unless that happens to be the last alias.
+ */
+static bool
+remove_collision(char *n1, char *n2)
+{
+ char *p2 = n2;
+ char *pstart, *qstart, *pend, *qend;
+ bool removed = FALSE;
+
+#if NCURSES_USE_TERMCAP && NCURSES_XNAMES
+ if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) {
+ n1 = skip_index(n1);
+ p2 = n2 = skip_index(n2);
+ }
+#endif
+
+ for (pstart = n1; (pend = name_ending(pstart)); pstart = next_name(pend)) {
+ for (qstart = n2; (qend = name_ending(qstart)); qstart = next_name(qend)) {
+ if ((pend - pstart == qend - qstart)
+ && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0) {
+ if (qstart != p2 || *qend == '|') {
+ if (*qend == '|')
+ ++qend;
+ while ((*qstart++ = *qend++) != '\0') ;
+ fprintf(stderr, "...now\t%s\n", p2);
+ } else {
+ fprintf(stderr, "Cannot remove alias '%.*s'\n",
+ (int) (qend - qstart), qstart);
+ }
+ removed = TRUE;
+ break;
+ }
+ }
+ }
+
+ return removed;
+}
+
+/* do any of the aliases in a pair of terminal names match? */
+NCURSES_EXPORT(bool)
+_nc_entry_match(char *n1, char *n2)
+{
+ return check_collisions(n1, n2, 0);
+}
+