]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/comp_parse.c
ncurses 5.9 - patch 20110925
[ncurses.git] / ncurses / tinfo / comp_parse.c
index a00eea0d99d797023dbd5bd4997d9ffe5c0887bf..95a71ed05774a5dec75c3af7264ef29478cfee33 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2010,2011 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            *
 /*
  *     comp_parse.c -- parser driver loop and use handling.
  *
- *     _nc_read_entry_source(FILE *, literal, bool, bool (*hook)())
- *     _nc_resolve_uses2(void)
- *     _nc_free_entries(void)
- *
  *     Use this code by calling _nc_read_entry_source() on as many source
  *     files as you like (either terminfo or termcap syntax).  If you
  *     want use-resolution, call _nc_resolve_uses2().  To free the list
  *     storage, do _nc_free_entries().
- *
  */
 
 #include <curses.priv.h>
@@ -51,9 +46,8 @@
 #include <ctype.h>
 
 #include <tic.h>
-#include <term_entry.h>
 
-MODULE_ID("$Id: comp_parse.c,v 1.70 2009/07/18 20:38:52 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.75 2011/08/13 19:37:17 tom Exp $")
 
 static void sanity_check2(TERMTYPE *, bool);
 NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
@@ -62,6 +56,8 @@ NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanit
 static void sanity_check(TERMTYPE *);
 NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
 
+static void fixup_acsc(TERMTYPE *, bool);
+
 static void
 enqueue(ENTRY * ep)
 /* add an entry to the in-core list */
@@ -94,6 +90,19 @@ force_bar(char *dst, char *src)
 }
 #define ForceBar(dst, src) ((strchr(src, '|') == 0) ? force_bar(dst, src) : src)
 
+#if USE_TERMCAP && NCURSES_XNAMES
+static char *
+skip_index(char *name)
+{
+    char *bar = strchr(name, '|');
+
+    if (bar != 0 && (bar - name) == 2)
+       name = bar + 1;
+
+    return name;
+}
+#endif
+
 NCURSES_EXPORT(bool)
 _nc_entry_match(char *n1, char *n2)
 /* do any of the aliases in a pair of terminal names match? */
@@ -105,6 +114,13 @@ _nc_entry_match(char *n1, char *n2)
     n1 = ForceBar(nc1, n1);
     n2 = ForceBar(nc2, n2);
 
+#if USE_TERMCAP && NCURSES_XNAMES
+    if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) {
+       n1 = skip_index(n1);
+       n2 = skip_index(n2);
+    }
+#endif
+
     for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1)
        for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1)
            if ((pend - pstart == qend - qstart)
@@ -275,7 +291,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
                unresolved++;
                total_unresolved++;
 
-               _nc_curr_line = lookline;
+               _nc_curr_line = (int) lookline;
                _nc_warning("resolution of use=%s failed", lookfor);
                qp->uses[i].link = 0;
            }
@@ -377,9 +393,9 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
        if (_nc_check_termtype != 0) {
            _nc_curr_col = -1;
            for_entry_list(qp) {
-               _nc_curr_line = qp->startline;
+               _nc_curr_line = (int) qp->startline;
                _nc_set_type(_nc_first_name(qp->tterm.term_names));
-               _nc_check_termtype2(&qp->tterm, literal);
+               fixup_acsc(&qp->tterm, literal);
            }
            DEBUG(2, ("SANITY CHECK FINISHED"));
        }
@@ -403,6 +419,17 @@ _nc_resolve_uses(bool fullresolve)
 #undef CUR
 #define CUR tp->
 
+static void
+fixup_acsc(TERMTYPE *tp, bool literal)
+{
+    if (!literal) {
+       if (acs_chars == 0
+           && enter_alt_charset_mode != 0
+           && exit_alt_charset_mode != 0)
+           acs_chars = strdup(VT_ACSC);
+    }
+}
+
 static void
 sanity_check2(TERMTYPE *tp, bool literal)
 {
@@ -429,10 +456,7 @@ sanity_check2(TERMTYPE *tp, bool literal)
      * prefer to bypass it...
      */
     if (!literal) {
-       if (acs_chars == 0
-           && enter_alt_charset_mode != 0
-           && exit_alt_charset_mode != 0)
-           acs_chars = strdup(VT_ACSC);
+       fixup_acsc(tp, literal);
        ANDMISSING(enter_alt_charset_mode, acs_chars);
        ANDMISSING(exit_alt_charset_mode, acs_chars);
     }
@@ -475,7 +499,6 @@ _nc_leaks_tic(void)
 {
     _nc_alloc_entry_leaks();
     _nc_captoinfo_leaks();
-    _nc_comp_captab_leaks();
     _nc_comp_scan_leaks();
 #if BROKEN_LINKER || USE_REENTRANT
     _nc_names_leaks();