X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftoe.c;h=f3856f049c112d43c69cf330290b4e57ab2dd9a8;hp=06840455393d6909dc2d8286605374ea892c1292;hb=61790aa3ac9e0dff2b443ac567b174fc4d235b86;hpb=e2d7d0028f4298dca2b0edaf2dc8ce30518d9218;ds=inline diff --git a/progs/toe.c b/progs/toe.c index 06840455..f3856f04 100644 --- a/progs/toe.c +++ b/progs/toe.c @@ -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 #endif -MODULE_ID("$Id: toe.c,v 1.71 2013/03/09 22:45:23 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, "..")) @@ -232,9 +233,9 @@ make_db_name(char *dst, const char *src, unsigned limit) static const char suffix[] = DBM_SUFFIX; bool result = FALSE; - unsigned lens = sizeof(suffix) - 1; - unsigned size = strlen(src); - unsigned need = lens + size; + size_t lens = sizeof(suffix) - 1; + size_t size = strlen(src); + size_t need = lens + size; if (need <= limit) { if (size >= lens @@ -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(); @@ -323,11 +324,11 @@ sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE *tp) data->description = strmalloc(term_description(tp)); } -#if USE_TERMCAP +#if NCURSES_USE_TERMCAP 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; @@ -350,7 +351,7 @@ show_termcap(int db_index, int db_limit, char *buffer, DescHook hook) } #endif -#if USE_DATABASE +#if NCURSES_USE_DATABASE static char * copy_entryname(DIRENT * src) { @@ -367,14 +368,14 @@ copy_entryname(DIRENT * src) static int typelist(int eargc, char *eargv[], - bool verbosity, + int verbosity, DescHook hook) /* apply a function to each entry in given terminfo directories */ { int i; for (i = 0; i < eargc; i++) { -#if USE_DATABASE +#if NCURSES_USE_DATABASE if (_nc_is_dir_path(eargv[i])) { char *cwd_buf = 0; DIR *termdir; @@ -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, <erm); } - _nc_free_termtype(<erm); + _nc_free_termtype2(<erm); 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, <erm); - _nc_free_termtype(<erm); + _nc_free_termtype2(<erm); } } code = _nc_db_next(capdbp, &key, &data); @@ -500,9 +498,9 @@ typelist(int eargc, char *eargv[], } } } -#endif -#endif -#if USE_TERMCAP +#endif /* USE_HASHED_DB */ +#endif /* NCURSES_USE_DATABASE */ +#if NCURSES_USE_TERMCAP #if HAVE_BSD_CGETENT { CGETENT_CONST char *db_array[2]; @@ -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); } @@ -721,14 +721,15 @@ main(int argc, char *argv[]) DBDIRS state; int offset; const char *path; - char **eargv = allocArgv(2); + char **eargv = allocArgv((size_t) 2); size_t count = 0; if (eargv == 0) 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);