From cdaf29481becd3e1c21baa574ac1ab88ea5f3d38 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 10 Mar 2019 02:12:50 +0000 Subject: [PATCH] ncurses 6.1 - patch 20190309 + in-progress changes to add parameter-checking for common user-defined capabilities in tic. + update MKcodes.awk and MKnames.awk to ignore the new "userdef" data in Caps-ncurses (cf: 20190302). --- MANIFEST | 1 + NEWS | 8 +- VERSION | 2 +- dist.mk | 4 +- include/tic.h | 25 +++- ncurses/Makefile.in | 9 +- ncurses/curses.priv.h | 13 +- ncurses/modules | 5 +- ncurses/tinfo/MKcodes.awk | 6 +- ncurses/tinfo/MKnames.awk | 6 +- ncurses/tinfo/MKuserdefs.sh | 142 +++++++++++++++++++ ncurses/tinfo/comp_hash.c | 33 ++++- ncurses/tinfo/entries.c | 5 +- ncurses/tinfo/make_hash.c | 226 ++++++++++++++++++++++--------- package/debian-mingw/changelog | 4 +- package/debian-mingw64/changelog | 4 +- package/debian/changelog | 4 +- package/mingw-ncurses.nsi | 4 +- package/mingw-ncurses.spec | 2 +- package/ncurses.spec | 2 +- package/ncursest.spec | 2 +- 21 files changed, 414 insertions(+), 93 deletions(-) create mode 100644 ncurses/tinfo/MKuserdefs.sh diff --git a/MANIFEST b/MANIFEST index 1f03f57f..88d631a7 100644 --- a/MANIFEST +++ b/MANIFEST @@ -901,6 +901,7 @@ ./ncurses/tinfo/MKfallback.sh ./ncurses/tinfo/MKkeys_list.sh ./ncurses/tinfo/MKnames.awk +./ncurses/tinfo/MKuserdefs.sh ./ncurses/tinfo/README ./ncurses/tinfo/access.c ./ncurses/tinfo/add_tries.c diff --git a/NEWS b/NEWS index 5e0ff370..9768cbfb 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.3283 2019/03/03 01:12:40 tom Exp $ +-- $Id: NEWS,v 1.3286 2019/03/09 21:35:49 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,12 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20190309 + + in-progress changes to add parameter-checking for common user-defined + capabilities in tic. + + update MKcodes.awk and MKnames.awk to ignore the new "userdef" + data in Caps-ncurses (cf: 20190302). + 20190302 + corrected some of the undocumented terminfo names in Caps.hpux11 + add "Caps-ncurses" file to help with checking inconsistencies in some diff --git a/VERSION b/VERSION index ebda0ff5..b1c30873 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5:0:10 6.1 20190302 +5:0:10 6.1 20190309 diff --git a/dist.mk b/dist.mk index 718d3d52..df60f23b 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.1270 2019/02/28 00:12:30 tom Exp $ +# $Id: dist.mk,v 1.1271 2019/03/09 16:50:35 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 6 NCURSES_MINOR = 1 -NCURSES_PATCH = 20190302 +NCURSES_PATCH = 20190309 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/include/tic.h b/include/tic.h index fe7c2969..5a0bfbea 100644 --- a/include/tic.h +++ b/include/tic.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 1998-2018,2019 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 * @@ -33,7 +33,7 @@ ****************************************************************************/ /* - * $Id: tic.h,v 1.76 2018/05/06 00:19:34 tom Exp $ + * $Id: tic.h,v 1.78 2019/03/10 00:06:02 tom Exp $ * tic.h - Global variables and structures for the terminfo compiler. */ @@ -214,6 +214,21 @@ struct alias #define NOTFOUND ((struct name_table_entry *) 0) +/* + * The file comp_userdefs.c contains an array of these structures, one per + * possible capability. These are indexed by a hash table array of pointers to + * the same structures for use by the parser. + */ +struct user_table_entry +{ + const char *ute_name; /* name to hash on */ + int ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ + unsigned ute_argc; /* number of parameters */ + unsigned ute_args; /* bit-mask for string parameters */ + HashValue ute_index; /* index of associated variable in its array */ + HashValue ute_link; /* index in table of next hash, or -1 */ +}; + /* * The casts are required for correct sign-propagation with systems such as * AIX, IRIX64, Solaris which default to unsigned characters. The C standard @@ -266,6 +281,8 @@ extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool); /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry (const char *, int, bool); +extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry + (const char *); /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(int) _nc_get_token (bool); @@ -295,6 +312,10 @@ extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings; /* comp_scan.c */ extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token; +/* comp_userdefs.c */ +NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void); +NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void); + /* captoinfo.c: capability conversion */ extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const); extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const); diff --git a/ncurses/Makefile.in b/ncurses/Makefile.in index 0740f257..5e528243 100644 --- a/ncurses/Makefile.in +++ b/ncurses/Makefile.in @@ -1,4 +1,4 @@ -# $Id: Makefile.in,v 1.157 2019/03/02 22:18:27 tom Exp $ +# $Id: Makefile.in,v 1.160 2019/03/09 23:39:14 tom Exp $ ############################################################################## # Copyright (c) 1998-2018,2019 Free Software Foundation, Inc. # # # @@ -164,6 +164,7 @@ TIC_PATH = @TIC_PATH@ AUTO_SRC = \ ./codes.c \ ./comp_captab.c \ + ./comp_userdefs.c \ ./expanded.c \ ./fallback.c \ ./lib_gen.c \ @@ -257,6 +258,12 @@ report_offsets$(BUILD_EXEEXT) : \ $(tinfo)/MKcaptab.awk $(SHELL) -e $(tinfo)/MKcaptab.sh $(AWK) $(USE_BIG_STRINGS) $(tinfo)/MKcaptab.awk $(CAPLIST) > $@ +./comp_userdefs.c: \ + make_hash$(BUILD_EXEEXT) \ + ../include/hashsize.h \ + $(tinfo)/MKuserdefs.sh + $(SHELL) -e $(tinfo)/MKuserdefs.sh $(AWK) $(USE_BIG_STRINGS) $(CAPLIST) > $@ + ./lib_keyname.c: keys.list $(base)/MKkeyname.awk $(AWK) -f $(base)/MKkeyname.awk bigstrings=$(USE_BIG_STRINGS) keys.list > $@ diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 4807761c..b35f8215 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.616 2019/02/23 17:54:39 tom Exp $ + * $Id: curses.priv.h,v 1.618 2019/03/09 23:43:24 tom Exp $ * * curses.priv.h * @@ -2048,6 +2048,16 @@ typedef struct short source; } alias_table_data; +/* comp_userdefs.c */ +typedef struct { + short ute_name; /* offset of name to hash on */ + unsigned ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ + unsigned ute_argc; /* number of parameters */ + unsigned ute_args; /* bit-mask for string parameters */ + short ute_index; /* index of associated variable in its array */ + short ute_link; /* index in table of next hash, or -1 */ +} user_table_data; + /* doupdate.c */ #if USE_XMC_SUPPORT extern NCURSES_EXPORT(void) _nc_do_xmc_glitch (attr_t); @@ -2262,6 +2272,7 @@ extern NCURSES_EXPORT(void) _nc_codes_leaks(void); extern NCURSES_EXPORT(void) _nc_comp_captab_leaks(void); extern NCURSES_EXPORT(void) _nc_comp_error_leaks(void); extern NCURSES_EXPORT(void) _nc_comp_scan_leaks(void); +extern NCURSES_EXPORT(void) _nc_comp_userdefs_leaks(void); extern NCURSES_EXPORT(void) _nc_db_iterator_leaks(void); extern NCURSES_EXPORT(void) _nc_keyname_leaks(void); extern NCURSES_EXPORT(void) _nc_names_leaks(void); diff --git a/ncurses/modules b/ncurses/modules index 2efa2996..2772225e 100644 --- a/ncurses/modules +++ b/ncurses/modules @@ -1,6 +1,6 @@ -# $Id: modules,v 1.122 2017/04/29 20:23:50 tom Exp $ +# $Id: modules,v 1.123 2019/03/09 21:36:58 tom Exp $ ############################################################################## -# Copyright (c) 1998-2013,2017 Free Software Foundation, Inc. # +# Copyright (c) 1998-2017,2019 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 "Software"), # @@ -165,6 +165,7 @@ codes lib . $(HEADER_DEPS) comp_captab lib . $(HEADER_DEPS) $(INCDIR)/tic.h ../include/hashsize.h comp_error lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h comp_hash lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h ../include/hashsize.h +comp_userdefs lib . $(HEADER_DEPS) $(INCDIR)/tic.h ../include/hashsize.h db_iterator lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h doalloc lib $(tinfo) $(HEADER_DEPS) entries lib $(tinfo) $(HEADER_DEPS) $(INCDIR)/tic.h diff --git a/ncurses/tinfo/MKcodes.awk b/ncurses/tinfo/MKcodes.awk index 97e5131b..f0dc7b30 100644 --- a/ncurses/tinfo/MKcodes.awk +++ b/ncurses/tinfo/MKcodes.awk @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. # +# Copyright (c) 1998-2010,2019 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 "Software"), # @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: MKcodes.awk,v 1.9 2010/01/23 17:57:43 tom Exp $ +# $Id: MKcodes.awk,v 1.10 2019/03/09 16:43:37 tom Exp $ function large_item(value) { result = sprintf("%d,", offset); offset = offset + length(value) + 1; @@ -79,7 +79,9 @@ BEGIN { } $1 ~ /^#/ {next;} +$1 ~ /^(cap|info)alias/ {next;} +$1 == "userdef" {next;} $1 == "SKIPWARN" {next;} $3 == "bool" { diff --git a/ncurses/tinfo/MKnames.awk b/ncurses/tinfo/MKnames.awk index 7685d183..b8dd4b93 100644 --- a/ncurses/tinfo/MKnames.awk +++ b/ncurses/tinfo/MKnames.awk @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2007-2008,2009 Free Software Foundation, Inc. # +# Copyright (c) 2007-2009,2019 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 "Software"), # @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: MKnames.awk,v 1.22 2009/03/21 21:03:39 tom Exp $ +# $Id: MKnames.awk,v 1.23 2019/03/09 16:49:06 tom Exp $ function large_item(value) { result = sprintf("%d,", offset); offset = offset + length(value) + 1; @@ -79,7 +79,9 @@ BEGIN { } $1 ~ /^#/ {next;} +$1 ~ /^(cap|info)alias/ {next;} +$1 == "userdef" {next;} $1 == "SKIPWARN" {next;} $3 == "bool" { diff --git a/ncurses/tinfo/MKuserdefs.sh b/ncurses/tinfo/MKuserdefs.sh new file mode 100644 index 00000000..05b3afbb --- /dev/null +++ b/ncurses/tinfo/MKuserdefs.sh @@ -0,0 +1,142 @@ +#!/bin/sh +############################################################################## +# Copyright (c) 2019 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 "Software"), # +# to deal in the Software without restriction, including without limitation # +# the rights to use, copy, modify, merge, publish, distribute, distribute # +# with modifications, sublicense, and/or sell copies of the Software, and to # +# permit persons to whom the Software is furnished to do so, subject to the # +# following conditions: # +# # +# The above copyright notice and this permission notice shall be included in # +# all copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # +# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # +# DEALINGS IN THE SOFTWARE. # +# # +# Except as contained in this notice, the name(s) of the above copyright # +# holders shall not be used in advertising or otherwise to promote the sale, # +# use or other dealings in this Software without prior written # +# authorization. # +############################################################################## +# $Id: MKuserdefs.sh,v 1.6 2019/03/10 01:08:14 tom Exp $ +AWK=${1-awk}; shift 1 +OPT1=${1-0}; shift 1 + +cat < +#include +#include + +#if NCURSES_XNAMES +EOF + +cat "$@" | ./make_hash 1 user $OPT1 + +cat < #include -MODULE_ID("$Id: comp_hash.c,v 1.48 2009/08/08 17:36:21 tom Exp $") +MODULE_ID("$Id: comp_hash.c,v 1.49 2019/03/10 00:06:48 tom Exp $") /* * Finds the entry for the given string in the hash table if present. @@ -112,3 +112,32 @@ _nc_find_type_entry(const char *string, return ptr; } + +#if NCURSES_XNAMES +NCURSES_EXPORT(struct user_table_entry const *) +_nc_find_user_entry(const char *string) +{ + const HashData *data = _nc_get_hash_user(); + int hashvalue; + struct user_table_entry const *ptr = 0; + struct user_table_entry const *real_table; + + hashvalue = data->hash_of(string); + + if (data->table_data[hashvalue] >= 0) { + + real_table = _nc_get_userdefs_table(); + ptr = real_table + data->table_data[hashvalue]; + while (!data->compare_names(ptr->ute_name, string)) { + if (ptr->ute_link < 0) { + ptr = 0; + break; + } + ptr = real_table + (ptr->ute_link + + data->table_data[data->table_size]); + } + } + + return (ptr); +} +#endif /* NCURSES_XNAMES */ diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c index 998205d0..0f86cab3 100644 --- a/ncurses/tinfo/entries.c +++ b/ncurses/tinfo/entries.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2006-2012,2017 Free Software Foundation, Inc. * + * Copyright (c) 2006-2017,2019 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 * @@ -37,7 +37,7 @@ #include -MODULE_ID("$Id: entries.c,v 1.26 2017/08/04 09:01:39 tom Exp $") +MODULE_ID("$Id: entries.c,v 1.27 2019/03/09 23:41:08 tom Exp $") /**************************************************************************** * @@ -130,6 +130,7 @@ _nc_leaks_tinfo(void) _nc_forget_prescr(); _nc_comp_captab_leaks(); + _nc_comp_userdefs_leaks(); _nc_free_entries(_nc_head); _nc_get_type(0); _nc_first_name(0); diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c index c8bf911f..9274b877 100644 --- a/ncurses/tinfo/make_hash.c +++ b/ncurses/tinfo/make_hash.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 1998-2018,2019 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 * @@ -43,14 +43,14 @@ #include -MODULE_ID("$Id: make_hash.c,v 1.17 2018/05/12 15:58:31 tom Exp $") +MODULE_ID("$Id: make_hash.c,v 1.26 2019/03/10 01:10:15 tom Exp $") /* * _nc_make_hash_table() * * Takes the entries in table[] and hashes them into hash_table[] - * by name. There are CAPTABSIZE entries in table[] and HASHTABSIZE - * slots in hash_table[]. + * by name. There are CAPTABSIZE entries in the predefined table[] + * and HASHTABSIZE slots in hash_table[]. * */ @@ -58,6 +58,14 @@ MODULE_ID("$Id: make_hash.c,v 1.17 2018/05/12 15:58:31 tom Exp $") #define MODULE_ID(id) /*nothing */ #include +#define L_PAREN "(" +#define R_PAREN ")" +#define L_BRACE "{" +#define R_BRACE "}" + +static const char *typenames[] = +{"BOOLEAN", "NUMBER", "STRING"}; + static void failed(const char *s) { @@ -100,28 +108,29 @@ hash_function(const char *string) } static void -_nc_make_hash_table(struct name_table_entry *table, - HashValue * hash_table) +_nc_make_hash_table(struct user_table_entry *table, + HashValue * hash_table, + unsigned tablesize) { - short i; + unsigned i; int hashvalue; int collisions = 0; for (i = 0; i < HASHTABSIZE; i++) { hash_table[i] = -1; } - for (i = 0; i < CAPTABSIZE; i++) { - hashvalue = hash_function(table[i].nte_name); + for (i = 0; i < tablesize; i++) { + hashvalue = hash_function(table[i].ute_name); if (hash_table[hashvalue] >= 0) collisions++; if (hash_table[hashvalue] != 0) - table[i].nte_link = hash_table[hashvalue]; - hash_table[hashvalue] = i; + table[i].ute_link = hash_table[hashvalue]; + hash_table[hashvalue] = (HashValue) i; } - printf("/* %d collisions out of %d entries */\n", collisions, CAPTABSIZE); + printf("/* %d collisions out of %d entries */\n", collisions, tablesize); } /* @@ -155,6 +164,14 @@ parse_columns(char *buffer) int col = 0; +#if NO_LEAKS + if (buffer == 0) { + free(list); + list = 0; + return 0; + } +#endif + if (*buffer != '#') { if (list == 0) { list = typeCalloc(char *, (MAX_COLUMNS + 1)); @@ -189,21 +206,52 @@ parse_columns(char *buffer) return col ? list : 0; } +#define SetType(n,t) \ + if (is_user) \ + name_table[n].ute_type |= (int)(1 << (t)); \ + else \ + name_table[n].ute_type = (t) + +#define GetType(n) \ + (is_user \ + ? get_type(name_table[n].ute_type) \ + : typenames[name_table[n].ute_type]) + +static char * +get_type(int type_mask) +{ + static char result[40]; + unsigned n; + strcpy(result, L_PAREN); + for (n = 0; n < 3; ++n) { + if ((1 << n) & type_mask) { + if (result[1]) + strcat(result, "|"); + strcat(result, "1<<"); + strcat(result, typenames[n]); + } + } + strcat(result, R_PAREN); + return result; +} + int main(int argc, char **argv) { - struct name_table_entry *name_table = typeCalloc(struct - name_table_entry, CAPTABSIZE); + unsigned tablesize = CAPTABSIZE; + struct user_table_entry *name_table = typeCalloc(struct + user_table_entry, tablesize); HashValue *hash_table = typeCalloc(HashValue, HASHTABSIZE); const char *root_name = ""; int column = 0; int bigstring = 0; - int n; + unsigned n; + unsigned nn; + unsigned tableused = 0; + bool is_user; + const char *table_name; char buffer[BUFSIZ]; - static const char *typenames[] = - {"BOOLEAN", "NUMBER", "STRING"}; - short BoolCount = 0; short NumCount = 0; short StrCount = 0; @@ -221,11 +269,13 @@ main(int argc, char **argv) fprintf(stderr, "usage: make_hash column root_name bigstring\n"); exit(EXIT_FAILURE); } + is_user = (*root_name == 'u'); + table_name = (is_user ? "user" : "name"); /* * Read the table into our arrays. */ - for (n = 0; (n < CAPTABSIZE) && fgets(buffer, BUFSIZ, stdin);) { + for (n = 0; (n < tablesize) && fgets(buffer, BUFSIZ, stdin);) { char **list; char *nlp = strchr(buffer, '\n'); if (nlp) @@ -235,6 +285,12 @@ main(int argc, char **argv) list = parse_columns(buffer); if (list == 0) /* blank or comment */ continue; + if (is_user) { + if (strcmp(list[0], "userdef")) + continue; + } else if (!strcmp(list[0], "userdef")) { + continue; + } if (column < 0 || column > count_columns(list)) { fprintf(stderr, "expected %d columns, have %d:\n%s\n", column, @@ -242,24 +298,51 @@ main(int argc, char **argv) buffer); exit(EXIT_FAILURE); } - name_table[n].nte_link = -1; /* end-of-hash */ - name_table[n].nte_name = strmalloc(list[column]); + nn = tableused; + if (is_user) { + unsigned j; + for (j = 0; j < tableused; ++j) { + if (!strcmp(list[column], name_table[j].ute_name)) { + nn = j; + break; + } + } + } + if (nn == tableused) { + name_table[nn].ute_link = -1; /* end-of-hash */ + name_table[nn].ute_name = strmalloc(list[column]); + ++tableused; + } + if (!strcmp(list[2], "bool")) { - name_table[n].nte_type = BOOLEAN; - name_table[n].nte_index = BoolCount++; + SetType(nn, BOOLEAN); + name_table[nn].ute_index = BoolCount++; } else if (!strcmp(list[2], "num")) { - name_table[n].nte_type = NUMBER; - name_table[n].nte_index = NumCount++; + SetType(nn, NUMBER); + name_table[nn].ute_index = NumCount++; } else if (!strcmp(list[2], "str")) { - name_table[n].nte_type = STRING; - name_table[n].nte_index = StrCount++; + SetType(nn, STRING); + name_table[nn].ute_index = StrCount++; + if (is_user) { + if (*list[3] != '-') { + unsigned j; + name_table[nn].ute_argc = (unsigned) strlen(list[3]); + for (j = 0; j < name_table[nn].ute_argc; ++j) { + if (list[3][j] == 's') { + name_table[nn].ute_args |= (1U << j); + } + } + } + } } else { fprintf(stderr, "Unknown type: %s\n", list[2]); exit(EXIT_FAILURE); } n++; } - _nc_make_hash_table(name_table, hash_table); + if (tablesize > tableused) + tablesize = tableused; + _nc_make_hash_table(name_table, hash_table, tablesize); /* * Write the compiled tables to standard output @@ -269,72 +352,87 @@ main(int argc, char **argv) int nxt; printf("static const char %s_names_text[] = \\\n", root_name); - for (n = 0; n < CAPTABSIZE; n++) { - nxt = (int) strlen(name_table[n].nte_name) + 5; + for (n = 0; n < tablesize; n++) { + nxt = (int) strlen(name_table[n].ute_name) + 5; if (nxt + len > 72) { printf("\\\n"); len = 0; } - printf("\"%s\\0\" ", name_table[n].nte_name); + printf("\"%s\\0\" ", name_table[n].ute_name); len += nxt; } printf(";\n\n"); len = 0; - printf("static name_table_data const %s_names_data[] =\n", + printf("static %s_table_data const %s_names_data[] =\n", + table_name, root_name); - printf("{\n"); - for (n = 0; n < CAPTABSIZE; n++) { - printf("\t{ %15d,\t%10s,\t%3d, %3d }%c\n", - len, - typenames[name_table[n].nte_type], - name_table[n].nte_index, - name_table[n].nte_link, - n < CAPTABSIZE - 1 ? ',' : ' '); - len += (int) strlen(name_table[n].nte_name) + 1; + printf("%s\n", L_BRACE); + for (n = 0; n < tablesize; n++) { + printf("\t%s %15d,\t%10s,", L_BRACE, len, GetType(n)); + if (is_user) + printf("\t%d,%d,", + name_table[n].ute_argc, + name_table[n].ute_args); + printf("\t%3d, %3d %s%c\n", + name_table[n].ute_index, + name_table[n].ute_link, + R_BRACE, + n < tablesize - 1 ? ',' : ' '); + len += (int) strlen(name_table[n].ute_name) + 1; } - printf("};\n\n"); - printf("static struct name_table_entry *_nc_%s_table = 0;\n\n", root_name); + printf("%s;\n\n", R_BRACE); + printf("static struct %s_table_entry *_nc_%s_table = 0;\n\n", + table_name, + root_name); } else { - printf("static struct name_table_entry const _nc_%s_table[] =\n", + printf("static struct %s_table_entry const _nc_%s_table[] =\n", + table_name, root_name); - printf("{\n"); - for (n = 0; n < CAPTABSIZE; n++) { + printf("%s\n", L_BRACE); + for (n = 0; n < tablesize; n++) { _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "\"%s\"", - name_table[n].nte_name); - printf("\t{ %15s,\t%10s,\t%3d, %3d }%c\n", - buffer, - typenames[name_table[n].nte_type], - name_table[n].nte_index, - name_table[n].nte_link, - n < CAPTABSIZE - 1 ? ',' : ' '); + name_table[n].ute_name); + printf("\t%s %15s,\t%10s,", L_BRACE, buffer, GetType(n)); + if (is_user) + printf("\t%d,%d,", + name_table[n].ute_argc, + name_table[n].ute_args); + printf("\t%3d, %3d %s%c\n", + name_table[n].ute_index, + name_table[n].ute_link, + R_BRACE, + n < tablesize - 1 ? ',' : ' '); } - printf("};\n\n"); + printf("%s;\n\n", R_BRACE); } printf("static const HashValue _nc_%s_hash_table[%d] =\n", root_name, HASHTABSIZE + 1); - printf("{\n"); + printf("%s\n", L_BRACE); for (n = 0; n < HASHTABSIZE; n++) { printf("\t%3d,\n", hash_table[n]); } printf("\t0\t/* base-of-table */\n"); - printf("};\n\n"); - - printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n", - BoolCount, NumCount, StrCount); - printf("#error\t--> term.h and comp_captab.c disagree about the <--\n"); - printf("#error\t--> numbers of booleans, numbers and/or strings <--\n"); - printf("#endif\n\n"); + printf("%s;\n\n", R_BRACE); + + if (!is_user) { + printf("#if (BOOLCOUNT!=%d)||(NUMCOUNT!=%d)||(STRCOUNT!=%d)\n", + BoolCount, NumCount, StrCount); + printf("#error\t--> term.h and comp_captab.c disagree about the <--\n"); + printf("#error\t--> numbers of booleans, numbers and/or strings <--\n"); + printf("#endif\n\n"); + } free(hash_table); #if NO_LEAKS - for (n = 0; (n < CAPTABSIZE); ++n) { - free((void *) name_table[n].nte_name); + for (n = 0; (n < tablesize); ++n) { + free((void *) name_table[n].ute_name); } free(name_table); + parse_columns(0); #endif return EXIT_SUCCESS; } diff --git a/package/debian-mingw/changelog b/package/debian-mingw/changelog index 2c8fc1b7..b3723b3c 100644 --- a/package/debian-mingw/changelog +++ b/package/debian-mingw/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.1+20190302) unstable; urgency=low +ncurses6 (6.1+20190309) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Wed, 27 Feb 2019 19:12:30 -0500 + -- Thomas E. Dickey Sat, 09 Mar 2019 11:50:35 -0500 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian-mingw64/changelog b/package/debian-mingw64/changelog index 2c8fc1b7..b3723b3c 100644 --- a/package/debian-mingw64/changelog +++ b/package/debian-mingw64/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.1+20190302) unstable; urgency=low +ncurses6 (6.1+20190309) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Wed, 27 Feb 2019 19:12:30 -0500 + -- Thomas E. Dickey Sat, 09 Mar 2019 11:50:35 -0500 ncurses6 (5.9-20131005) unstable; urgency=low diff --git a/package/debian/changelog b/package/debian/changelog index d2f817ef..f1c951cd 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,8 +1,8 @@ -ncurses6 (6.1+20190302) unstable; urgency=low +ncurses6 (6.1+20190309) unstable; urgency=low * latest weekly patch - -- Thomas E. Dickey Wed, 27 Feb 2019 19:12:30 -0500 + -- Thomas E. Dickey Sat, 09 Mar 2019 11:50:35 -0500 ncurses6 (5.9-20120608) unstable; urgency=low diff --git a/package/mingw-ncurses.nsi b/package/mingw-ncurses.nsi index a3a06e7c..cef11c74 100644 --- a/package/mingw-ncurses.nsi +++ b/package/mingw-ncurses.nsi @@ -1,4 +1,4 @@ -; $Id: mingw-ncurses.nsi,v 1.317 2019/02/28 00:12:30 tom Exp $ +; $Id: mingw-ncurses.nsi,v 1.318 2019/03/09 16:50:35 tom Exp $ ; TODO add examples ; TODO bump ABI to 6 @@ -10,7 +10,7 @@ !define VERSION_MAJOR "6" !define VERSION_MINOR "1" !define VERSION_YYYY "2019" -!define VERSION_MMDD "0302" +!define VERSION_MMDD "0309" !define VERSION_PATCH ${VERSION_YYYY}${VERSION_MMDD} !define MY_ABI "5" diff --git a/package/mingw-ncurses.spec b/package/mingw-ncurses.spec index 0643e365..e93a6d83 100644 --- a/package/mingw-ncurses.spec +++ b/package/mingw-ncurses.spec @@ -3,7 +3,7 @@ Summary: shared libraries for terminal handling Name: mingw32-ncurses6 Version: 6.1 -Release: 20190302 +Release: 20190309 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncurses.spec b/package/ncurses.spec index 954b823c..02e7791e 100644 --- a/package/ncurses.spec +++ b/package/ncurses.spec @@ -1,7 +1,7 @@ Summary: shared libraries for terminal handling Name: ncurses6 Version: 6.1 -Release: 20190302 +Release: 20190309 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz diff --git a/package/ncursest.spec b/package/ncursest.spec index 27fbd956..fd876ad9 100644 --- a/package/ncursest.spec +++ b/package/ncursest.spec @@ -1,7 +1,7 @@ Summary: Curses library with POSIX thread support. Name: ncursest6 Version: 6.1 -Release: 20190302 +Release: 20190309 License: X11 Group: Development/Libraries Source: ncurses-%{version}-%{release}.tgz -- 2.44.0