]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/toe.c
ncurses 6.2 - patch 20200718
[ncurses.git] / progs / toe.c
index 0d299b457dfb9d61c555cef71897f8f04325a076..f3856f049c112d43c69cf330290b4e57ab2dd9a8 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2013,2017 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            *
@@ -44,7 +45,7 @@
 #include <hashed_db.h>
 #endif
 
-MODULE_ID("$Id: toe.c,v 1.74 2013/12/15 01:08:28 tom Exp $")
+MODULE_ID("$Id: toe.c,v 1.79 2020/02/02 23:34:34 tom Exp $")
 
 #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, ".."))
 
@@ -252,10 +253,10 @@ make_db_name(char *dst, const char *src, unsigned limit)
 typedef void (DescHook) (int /* db_index */ ,
                         int /* db_limit */ ,
                         const char * /* term_name */ ,
-                        TERMTYPE * /* term */ );
+                        TERMTYPE2 * /* term */ );
 
 static const char *
-term_description(TERMTYPE *tp)
+term_description(TERMTYPE2 *tp)
 {
     const char *desc;
 
@@ -270,7 +271,7 @@ term_description(TERMTYPE *tp)
 
 /* display a description for the type */
 static void
-deschook(int db_index, int db_limit, const char *term_name, TERMTYPE *tp)
+deschook(int db_index, int db_limit, const char *term_name, TERMTYPE2 *tp)
 {
     (void) db_index;
     (void) db_limit;
@@ -294,7 +295,7 @@ string_sum(const char *value)
 }
 
 static unsigned long
-checksum_of(TERMTYPE *tp)
+checksum_of(TERMTYPE2 *tp)
 {
     unsigned long result = string_sum(tp->term_names);
     unsigned i;
@@ -313,7 +314,7 @@ checksum_of(TERMTYPE *tp)
 
 /* collect data, to sort before display */
 static void
-sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE *tp)
+sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE2 *tp)
 {
     TERMDATA *data = new_termdata();
 
@@ -327,7 +328,7 @@ sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE *tp)
 static void
 show_termcap(int db_index, int db_limit, char *buffer, DescHook hook)
 {
-    TERMTYPE data;
+    TERMTYPE2 data;
     char *next = strchr(buffer, ':');
     char *last;
     char *list = buffer;
@@ -424,7 +425,7 @@ typelist(int eargc, char *eargv[],
                }
                while ((entry = readdir(entrydir)) != 0) {
                    char *name_2;
-                   TERMTYPE lterm;
+                   TERMTYPE2 lterm;
                    char *cn;
                    int status;
 
@@ -440,11 +441,8 @@ typelist(int eargc, char *eargv[],
                        (void) fprintf(stderr,
                                       "%s: couldn't open terminfo file %s.\n",
                                       _nc_progname, name_2);
-                       free(cwd_buf);
                        free(name_2);
-                       closedir(entrydir);
-                       closedir(termdir);
-                       return (EXIT_FAILURE);
+                       continue;
                    }
 
                    /* only visit things once, by primary name */
@@ -453,7 +451,7 @@ typelist(int eargc, char *eargv[],
                        /* apply the selected hook function */
                        hook(i, eargc, cn, &lterm);
                    }
-                   _nc_free_termtype(&lterm);
+                   _nc_free_termtype2(&lterm);
                    free(name_2);
                }
                closedir(entrydir);
@@ -478,7 +476,7 @@ typelist(int eargc, char *eargv[],
 
                    code = _nc_db_first(capdbp, &key, &data);
                    while (code == 0) {
-                       TERMTYPE lterm;
+                       TERMTYPE2 lterm;
                        int used;
                        char *have;
                        char *cn;
@@ -489,7 +487,7 @@ typelist(int eargc, char *eargv[],
                                cn = _nc_first_name(lterm.term_names);
                                /* apply the selected hook function */
                                hook(i, eargc, cn, &lterm);
-                               _nc_free_termtype(&lterm);
+                               _nc_free_termtype2(&lterm);
                            }
                        }
                        code = _nc_db_next(capdbp, &key, &data);
@@ -500,8 +498,8 @@ typelist(int eargc, char *eargv[],
                }
            }
        }
-#endif
-#endif
+#endif /* USE_HASHED_DB */
+#endif /* NCURSES_USE_DATABASE */
 #if NCURSES_USE_TERMCAP
 #if HAVE_BSD_CGETENT
        {
@@ -703,6 +701,8 @@ main(int argc, char *argv[])
 
            _nc_first_db(&state, &offset);
            while ((path = _nc_next_db(&state, &offset)) != 0) {
+               if (quick_prefix(path))
+                   continue;
                if (pass) {
                    eargv[count] = strmalloc(path);
                }
@@ -728,7 +728,8 @@ main(int argc, char *argv[])
            failed("eargv");
        _nc_first_db(&state, &offset);
        if ((path = _nc_next_db(&state, &offset)) != 0) {
-           eargv[count++] = strmalloc(path);
+           if (!quick_prefix(path))
+               eargv[count++] = strmalloc(path);
        }
 
        code = typelist((int) count, eargv, header, hook);