X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_terminfo.c;h=8e6ae1ca63fdd07e89eb992b45f12f1970efef4c;hp=533a5f0a1960ac00e84b724d39a54a3155748d46;hb=02f02dcd4464143580e783ae32c822d8eb8cdcbf;hpb=0266ec751090f9523ae676f357095176e293fb16 diff --git a/test/demo_terminfo.c b/test/demo_terminfo.c index 533a5f0a..8e6ae1ca 100644 --- a/test/demo_terminfo.c +++ b/test/demo_terminfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2009-2013,2014 Free Software Foundation, Inc. * + * Copyright (c) 2009-2014,2015 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 * @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: demo_terminfo.c,v 1.34 2014/08/31 23:11:39 tom Exp $ + * $Id: demo_terminfo.c,v 1.39 2015/07/10 23:45:44 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -266,6 +266,10 @@ abcdefghijklmnopqrstuvwxyz_"; if (!q_opt) printf("Terminal type \"%s\"\n", name); setupterm((NCURSES_CONST char *) name, 1, (int *) 0); + if (!q_opt) { + if (strcmp(name, ttytype)) + printf("... actual \"%s\"\n", ttytype); + } for (length = 1; length <= MAX_FORCE; ++length) { /* set all digits to zeros */ @@ -306,6 +310,12 @@ abcdefghijklmnopqrstuvwxyz_"; del_curterm(cur_term); } +#if USE_CODE_LISTS +#define fullname(type,n) f_opt ? type##fnames[n] : my_##type##codes[n] +#else +#define fullname(type,n) my_##type##codes[n] +#endif + static void demo_terminfo(char *name) { @@ -321,7 +331,7 @@ demo_terminfo(char *name) if (b_opt) { for (n = 0;; ++n) { - cap = f_opt ? boolfnames[n] : my_boolcodes[n]; + cap = fullname(bool, n); if (cap == 0) break; dumpit(cap); @@ -330,7 +340,7 @@ demo_terminfo(char *name) if (n_opt) { for (n = 0;; ++n) { - cap = f_opt ? numfnames[n] : my_numcodes[n]; + cap = fullname(num, n); if (cap == 0) break; dumpit(cap); @@ -339,7 +349,7 @@ demo_terminfo(char *name) if (s_opt) { for (n = 0;; ++n) { - cap = f_opt ? strfnames[n] : my_strcodes[n]; + cap = fullname(str, n); if (cap == 0) break; dumpit(cap); @@ -411,6 +421,8 @@ typedef enum { static void parse_description(const char *input_name) { + static char empty[1]; + FILE *fp; struct stat sb; size_t count_bools = 0; @@ -445,6 +457,7 @@ parse_description(const char *input_name) if ((fp = fopen(input_name, "r")) == 0) failed("cannot open input-file"); len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp); + my_blob[sb.st_size] = '\0'; fclose(fp); /* @@ -628,10 +641,10 @@ parse_description(const char *input_name) * known order. */ if (count_strs) { - my_strvalues[count_strs] = ""; + my_strvalues[count_strs] = empty; my_strcodes[count_strs++] = &my_blob[j]; } else if (count_nums) { - my_numvalues[count_nums] = ""; + my_numvalues[count_nums] = empty; my_numcodes[count_nums++] = &my_blob[j]; } else { my_boolcodes[count_bools++] = &my_blob[j]; @@ -706,7 +719,7 @@ copy_code_list(NCURSES_CONST char *const *list) { int pass; size_t count; - size_t length = 0; + size_t length = 1; char **result = 0; char *blob = 0; char *unused = 0; @@ -825,7 +838,7 @@ main(int argc, char *argv[]) } } -#if NCURSES_XNAMES +#if HAVE_USE_EXTENDED_NAMES use_extended_names(x_opt); #endif