xref: /freebsd/contrib/ncurses/ncurses/report_hashing.c (revision 7a65641922f404b84e9a249d48593de84d8e8d17)
1*7a656419SBaptiste Daroussin /****************************************************************************
2*7a656419SBaptiste Daroussin  * Copyright 2020 Thomas E. Dickey                                          *
3*7a656419SBaptiste Daroussin  *                                                                          *
4*7a656419SBaptiste Daroussin  * Permission is hereby granted, free of charge, to any person obtaining a  *
5*7a656419SBaptiste Daroussin  * copy of this software and associated documentation files (the            *
6*7a656419SBaptiste Daroussin  * "Software"), to deal in the Software without restriction, including      *
7*7a656419SBaptiste Daroussin  * without limitation the rights to use, copy, modify, merge, publish,      *
8*7a656419SBaptiste Daroussin  * distribute, distribute with modifications, sublicense, and/or sell       *
9*7a656419SBaptiste Daroussin  * copies of the Software, and to permit persons to whom the Software is    *
10*7a656419SBaptiste Daroussin  * furnished to do so, subject to the following conditions:                 *
11*7a656419SBaptiste Daroussin  *                                                                          *
12*7a656419SBaptiste Daroussin  * The above copyright notice and this permission notice shall be included  *
13*7a656419SBaptiste Daroussin  * in all copies or substantial portions of the Software.                   *
14*7a656419SBaptiste Daroussin  *                                                                          *
15*7a656419SBaptiste Daroussin  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16*7a656419SBaptiste Daroussin  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17*7a656419SBaptiste Daroussin  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18*7a656419SBaptiste Daroussin  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19*7a656419SBaptiste Daroussin  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20*7a656419SBaptiste Daroussin  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21*7a656419SBaptiste Daroussin  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22*7a656419SBaptiste Daroussin  *                                                                          *
23*7a656419SBaptiste Daroussin  * Except as contained in this notice, the name(s) of the above copyright   *
24*7a656419SBaptiste Daroussin  * holders shall not be used in advertising or otherwise to promote the     *
25*7a656419SBaptiste Daroussin  * sale, use or other dealings in this Software without prior written       *
26*7a656419SBaptiste Daroussin  * authorization.                                                           *
27*7a656419SBaptiste Daroussin  ****************************************************************************/
28*7a656419SBaptiste Daroussin 
29*7a656419SBaptiste Daroussin /****************************************************************************
30*7a656419SBaptiste Daroussin  *  Author: Thomas E. Dickey                                                *
31*7a656419SBaptiste Daroussin  ****************************************************************************/
32*7a656419SBaptiste Daroussin 
33*7a656419SBaptiste Daroussin #include <curses.priv.h>
34*7a656419SBaptiste Daroussin #include <tic.h>
35*7a656419SBaptiste Daroussin 
36*7a656419SBaptiste Daroussin MODULE_ID("$Id: report_hashing.c,v 1.3 2020/02/02 23:34:34 tom Exp $")
37*7a656419SBaptiste Daroussin 
38*7a656419SBaptiste Daroussin static void
check_names(const char * name,NCURSES_CONST char * const * table,int termcap)39*7a656419SBaptiste Daroussin check_names(const char *name, NCURSES_CONST char *const *table, int termcap)
40*7a656419SBaptiste Daroussin {
41*7a656419SBaptiste Daroussin     int errs = 0;
42*7a656419SBaptiste Daroussin     int n;
43*7a656419SBaptiste Daroussin     struct name_table_entry const *entry_ptr;
44*7a656419SBaptiste Daroussin     const HashValue *hash_table = _nc_get_hash_table(termcap);
45*7a656419SBaptiste Daroussin 
46*7a656419SBaptiste Daroussin     printf("%s:\n", name);
47*7a656419SBaptiste Daroussin     for (n = 0; table[n] != NULL; ++n) {
48*7a656419SBaptiste Daroussin 	entry_ptr = _nc_find_entry(table[n], hash_table);
49*7a656419SBaptiste Daroussin 	if (entry_ptr == 0) {
50*7a656419SBaptiste Daroussin 	    printf("  %s\n", table[n]);
51*7a656419SBaptiste Daroussin 	    errs++;
52*7a656419SBaptiste Daroussin 	}
53*7a656419SBaptiste Daroussin     }
54*7a656419SBaptiste Daroussin     if (errs)
55*7a656419SBaptiste Daroussin 	printf("%d errors\n", errs);
56*7a656419SBaptiste Daroussin }
57*7a656419SBaptiste Daroussin 
58*7a656419SBaptiste Daroussin int
main(void)59*7a656419SBaptiste Daroussin main(void)
60*7a656419SBaptiste Daroussin {
61*7a656419SBaptiste Daroussin #define CHECK_TI(name) check_names(#name, name, 0)
62*7a656419SBaptiste Daroussin #define CHECK_TC(name) check_names(#name, name, 1)
63*7a656419SBaptiste Daroussin 
64*7a656419SBaptiste Daroussin     CHECK_TI(boolnames);
65*7a656419SBaptiste Daroussin     CHECK_TI(numnames);
66*7a656419SBaptiste Daroussin     CHECK_TI(strnames);
67*7a656419SBaptiste Daroussin 
68*7a656419SBaptiste Daroussin     CHECK_TC(boolcodes);
69*7a656419SBaptiste Daroussin     CHECK_TC(numcodes);
70*7a656419SBaptiste Daroussin     CHECK_TC(strcodes);
71*7a656419SBaptiste Daroussin 
72*7a656419SBaptiste Daroussin     return EXIT_SUCCESS;
73*7a656419SBaptiste Daroussin }
74