X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Ftoe.c;h=8fd98d006c2706a70c4633e0c3f6d5b6bcac4acb;hp=030230dcea31061e68b23f564c4c77403afbd4b6;hb=7f4b9f390624835ceb0849965a7f6ff2dcb39d00;hpb=5e1e572b71ae31a6071daa24e2460a68a6f1003c diff --git a/progs/toe.c b/progs/toe.c index 030230dc..8fd98d00 100644 --- a/progs/toe.c +++ b/progs/toe.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2013,2017 Free Software Foundation, Inc. * + * Copyright 2018-2020,2021 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.75 2017/04/05 23:19:24 tom Exp $") +MODULE_ID("$Id: toe.c,v 1.81 2021/04/03 22:54:52 tom Exp $") #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, "..")) @@ -63,7 +64,7 @@ static size_t len_termdata; /* allocated size of ptr_termdata[] */ #if NO_LEAKS #undef ExitProgram -static void ExitProgram(int code) GCC_NORETURN; +static GCC_NORETURN void ExitProgram(int code); static void ExitProgram(int code) { @@ -72,7 +73,7 @@ ExitProgram(int code) } #endif -static void failed(const char *) GCC_NORETURN; +static GCC_NORETURN void failed(const char *); static void failed(const char *msg) @@ -126,12 +127,15 @@ compare_termdata(const void *a, const void *b) static void show_termdata(int eargc, char **eargv) { - int j, k; - size_t n; - if (use_termdata) { + size_t n; + if (eargc > 1) { + int j; + for (j = 0; j < eargc; ++j) { + int k; + for (k = 0; k <= j; ++k) { printf("--"); } @@ -148,7 +152,7 @@ show_termdata(int eargc, char **eargv) */ if (eargc > 1) { unsigned long check = 0; - k = 0; + int k = 0; for (;;) { for (; k < ptr_termdata[n].db_index; ++k) { printf("--"); @@ -440,11 +444,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 */ @@ -489,7 +490,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,8 +501,8 @@ typelist(int eargc, char *eargv[], } } } -#endif -#endif +#endif /* USE_HASHED_DB */ +#endif /* NCURSES_USE_DATABASE */ #if NCURSES_USE_TERMCAP #if HAVE_BSD_CGETENT { @@ -572,7 +573,6 @@ main(int argc, char *argv[]) bool invert_dependencies = FALSE; bool header = FALSE; char *report_file = 0; - unsigned i; int code; int this_opt, last_opt = '?'; unsigned v_opt = 0; @@ -660,11 +660,13 @@ main(int argc, char *argv[]) /* maybe we want a reverse-dependency listing? */ if (invert_dependencies) { ENTRY *qp, *rp; - int matchcount; for_entry_list(qp) { - matchcount = 0; + int matchcount = 0; + for_entry_list(rp) { + unsigned i; + if (rp->nuses == 0) continue; @@ -694,15 +696,17 @@ main(int argc, char *argv[]) DBDIRS state; int offset; int pass; - const char *path; char **eargv = 0; code = EXIT_FAILURE; for (pass = 0; pass < 2; ++pass) { size_t count = 0; + const char *path; _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 +732,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);