]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/read_termcap.c
ncurses 5.9 - patch 20111022
[ncurses.git] / ncurses / tinfo / read_termcap.c
index 700dd77db46e78dd9a6d1ccda134f10063314e48..29a9800b188e748f49d1a89575aca0fa5df1ec90 100644 (file)
@@ -56,7 +56,7 @@
 #include <sys/types.h>
 #include <tic.h>
 
 #include <sys/types.h>
 #include <tic.h>
 
-MODULE_ID("$Id: read_termcap.c,v 1.79 2011/07/29 00:25:02 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.84 2011/09/26 22:52:50 tom Exp $")
 
 #if !PURE_TERMINFO
 
 
 #if !PURE_TERMINFO
 
@@ -73,7 +73,7 @@ get_termpath(void)
 
     if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
        result = TERMPATH;
 
     if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
        result = TERMPATH;
-    T(("TERMPATH is %s", result));
+    TR(TRACE_DATABASE, ("TERMPATH is %s", result));
     return result;
 }
 
     return result;
 }
 
@@ -383,7 +383,14 @@ _nc_getent(
                        c = *bp++;
                        if (c == '\n') {
                            lineno++;
                        c = *bp++;
                        if (c == '\n') {
                            lineno++;
-                           if (rp == record || *(rp - 1) != '\\')
+                           /*
+                            * Unlike BSD 4.3, this ignores a backslash at the
+                            * end of a comment-line.  That makes it consistent
+                            * with the rest of ncurses -TD
+                            */
+                           if (rp == record
+                               || *record == '#'
+                               || *(rp - 1) != '\\')
                                break;
                        }
                        *rp++ = c;
                                break;
                        }
                        *rp++ = c;
@@ -702,8 +709,6 @@ _nc_nfcmp(const char *nf, char *rec)
 #define        PVECSIZ         32      /* max number of names in path */
 #define TBUFSIZ (2048*2)
 
 #define        PVECSIZ         32      /* max number of names in path */
 #define TBUFSIZ (2048*2)
 
-static char *tbuf;
-
 /*
  * On entry, srcp points to a non ':' character which is the beginning of the
  * token, if any.  We'll try to return a string that doesn't end with a ':'.
 /*
  * On entry, srcp points to a non ':' character which is the beginning of the
  * token, if any.  We'll try to return a string that doesn't end with a ':'.
@@ -781,18 +786,18 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
     register char *p;
     register char *cp;
     char *dummy = NULL;
     register char *p;
     register char *cp;
     char *dummy = NULL;
-    char **fname;
+    CGETENT_CONST char **fname;
     char *home;
     int i;
     char pathbuf[PBUFSIZ];     /* holds raw path of filenames */
     char *home;
     int i;
     char pathbuf[PBUFSIZ];     /* holds raw path of filenames */
-    char *pathvec[PVECSIZ];    /* to point to names in pathbuf */
-    char **pvec;               /* holds usable tail of path vector */
+    CGETENT_CONST char *pathvec[PVECSIZ];      /* point to names in pathbuf */
+    CGETENT_CONST char **pvec; /* holds usable tail of path vector */
     NCURSES_CONST char *termpath;
     string_desc desc;
 
     NCURSES_CONST char *termpath;
     string_desc desc;
 
+    *lineno = 1;
     fname = pathvec;
     pvec = pathvec;
     fname = pathvec;
     pvec = pathvec;
-    tbuf = bp;
     p = pathbuf;
     cp = use_terminfo_vars()? getenv("TERMCAP") : NULL;
 
     p = pathbuf;
     cp = use_terminfo_vars()? getenv("TERMCAP") : NULL;
 
@@ -861,6 +866,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
      * empty fields, and mistakenly use the last valid cap entry instead of
      * the first (breaks tc= includes)
      */
      * empty fields, and mistakenly use the last valid cap entry instead of
      * the first (breaks tc= includes)
      */
+    *bp = '\0';
     if (i >= 0) {
        char *pd, *ps, *tok;
        int endflag = FALSE;
     if (i >= 0) {
        char *pd, *ps, *tok;
        int endflag = FALSE;
@@ -940,7 +946,7 @@ add_tc(char *termpaths[], char *path, int count)
     if (count < MAXPATHS
        && _nc_access(path, R_OK) == 0) {
        termpaths[count++] = path;
     if (count < MAXPATHS
        && _nc_access(path, R_OK) == 0) {
        termpaths[count++] = path;
-       T(("Adding termpath %s", path));
+       TR(TRACE_DATABASE, ("Adding termpath %s", path));
     }
     termpaths[count] = 0;
     if (save != 0)
     }
     termpaths[count] = 0;
     if (save != 0)
@@ -964,13 +970,13 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
     static char *source;
     static int lineno;
 
     static char *source;
     static int lineno;
 
-    T(("read termcap entry for %s", tn));
+    TR(TRACE_DATABASE, ("read termcap entry for %s", tn));
 
     if (strlen(tn) == 0
        || strcmp(tn, ".") == 0
        || strcmp(tn, "..") == 0
        || _nc_pathlast(tn) != 0) {
 
     if (strlen(tn) == 0
        || strcmp(tn, ".") == 0
        || strcmp(tn, "..") == 0
        || _nc_pathlast(tn) != 0) {
-       T(("illegal or missing entry name '%s'", tn));
+       TR(TRACE_DATABASE, ("illegal or missing entry name '%s'", tn));
        return TGETENT_NO;
     }
 
        return TGETENT_NO;
     }
 
@@ -1083,7 +1089,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
            }
        }
        if (omit) {
            }
        }
        if (omit) {
-           T(("Path %s is a duplicate", termpaths[j]));
+           TR(TRACE_DATABASE, ("Path %s is a duplicate", termpaths[j]));
            for (k = j + 1; k < filecount; k++) {
                termpaths[k - 1] = termpaths[k];
                test_stat[k - 1] = test_stat[k];
            for (k = j + 1; k < filecount; k++) {
                termpaths[k - 1] = termpaths[k];
                test_stat[k - 1] = test_stat[k];
@@ -1108,7 +1114,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
 
        for (i = 0; i < filecount; i++) {
 
 
        for (i = 0; i < filecount; i++) {
 
-           T(("Looking for %s in %s", tn, termpaths[i]));
+           TR(TRACE_DATABASE, ("Looking for %s in %s", tn, termpaths[i]));
            if (_nc_access(termpaths[i], R_OK) == 0
                && (fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
                _nc_set_source(termpaths[i]);
            if (_nc_access(termpaths[i], R_OK) == 0
                && (fp = fopen(termpaths[i], "r")) != (FILE *) 0) {
                _nc_set_source(termpaths[i]);