diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-03-26 16:45:05 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-03-26 16:45:05 +0000 |
commit | bba3d511e6e50417b63a435c26721c994c19d610 (patch) | |
tree | c478ba94ed20a8be221c80bbd4badb6f7d2b405f /lib/libcurses/tinfo | |
parent | a764b29e491a525c695ea312bcaeb0a4e1558300 (diff) |
Update to ncurses-5.0-20000325
Diffstat (limited to 'lib/libcurses/tinfo')
-rw-r--r-- | lib/libcurses/tinfo/add_tries.c | 133 | ||||
-rw-r--r-- | lib/libcurses/tinfo/alloc_ttype.c | 190 | ||||
-rw-r--r-- | lib/libcurses/tinfo/captoinfo.c | 7 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_parse.c | 12 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_scan.c | 26 | ||||
-rw-r--r-- | lib/libcurses/tinfo/free_ttype.c | 5 | ||||
-rw-r--r-- | lib/libcurses/tinfo/read_termcap.c | 4 |
7 files changed, 206 insertions, 171 deletions
diff --git a/lib/libcurses/tinfo/add_tries.c b/lib/libcurses/tinfo/add_tries.c index 31a6e6906ec..fddee879548 100644 --- a/lib/libcurses/tinfo/add_tries.c +++ b/lib/libcurses/tinfo/add_tries.c @@ -1,7 +1,7 @@ -/* $OpenBSD: add_tries.c,v 1.1 1999/01/18 19:10:12 millert Exp $ */ +/* $OpenBSD: add_tries.c,v 1.2 2000/03/26 16:45:03 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000 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 * @@ -41,86 +41,87 @@ #include <curses.priv.h> -MODULE_ID("$From: add_tries.c,v 1.1 1998/11/08 00:04:18 tom Exp $") +MODULE_ID("$From: add_tries.c,v 1.2 2000/03/18 22:23:56 tom Exp $") #define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0' #define CMP_TRY(a,b) ((a)? (a == b) : (b == 128)) -void _nc_add_to_try(struct tries **tree, char *str, unsigned short code) +void +_nc_add_to_try(struct tries **tree, const char *str, unsigned short code) { - static bool out_of_memory = FALSE; - struct tries *ptr, *savedptr; - unsigned char *txt = (unsigned char *)str; - - if (txt == 0 || *txt == '\0' || out_of_memory || code == 0) - return; - - if ((*tree) != 0) { - ptr = savedptr = (*tree); - - for (;;) { - unsigned char cmp = *txt; - - while (!CMP_TRY(ptr->ch, cmp) - && ptr->sibling != 0) - ptr = ptr->sibling; - - if (CMP_TRY(ptr->ch, cmp)) { - if (*(++txt) == '\0') { - ptr->value = code; - return; - } - if (ptr->child != 0) - ptr = ptr->child; - else - break; - } else { - if ((ptr->sibling = typeCalloc(struct tries,1)) == 0) { - out_of_memory = TRUE; - return; - } - - savedptr = ptr = ptr->sibling; - SET_TRY(ptr,txt); - ptr->value = 0; - - break; - } - } /* end for (;;) */ - } else { /* (*tree) == 0 :: First sequence to be added */ - savedptr = ptr = (*tree) = typeCalloc(struct tries,1); - - if (ptr == 0) { - out_of_memory = TRUE; - return; + static bool out_of_memory = FALSE; + struct tries *ptr, *savedptr; + unsigned const char *txt = (unsigned const char *) str; + + if (txt == 0 || *txt == '\0' || out_of_memory || code == 0) + return; + + if ((*tree) != 0) { + ptr = savedptr = (*tree); + + for (;;) { + unsigned char cmp = *txt; + + while (!CMP_TRY(ptr->ch, cmp) + && ptr->sibling != 0) + ptr = ptr->sibling; + + if (CMP_TRY(ptr->ch, cmp)) { + if (*(++txt) == '\0') { + ptr->value = code; + return; + } + if (ptr->child != 0) + ptr = ptr->child; + else + break; + } else { + if ((ptr->sibling = typeCalloc(struct tries, 1)) == 0) { + out_of_memory = TRUE; + return; } - SET_TRY(ptr,txt); + savedptr = ptr = ptr->sibling; + SET_TRY(ptr, txt); ptr->value = 0; + + break; + } + } /* end for (;;) */ + } else { /* (*tree) == 0 :: First sequence to be added */ + savedptr = ptr = (*tree) = typeCalloc(struct tries, 1); + + if (ptr == 0) { + out_of_memory = TRUE; + return; } - /* at this point, we are adding to the try. ptr->child == 0 */ + SET_TRY(ptr, txt); + ptr->value = 0; + } - while (*txt) { - ptr->child = typeCalloc(struct tries,1); + /* at this point, we are adding to the try. ptr->child == 0 */ - ptr = ptr->child; + while (*txt) { + ptr->child = typeCalloc(struct tries, 1); - if (ptr == 0) { - out_of_memory = TRUE; + ptr = ptr->child; - while ((ptr = savedptr) != 0) { - savedptr = ptr->child; - free(ptr); - } + if (ptr == 0) { + out_of_memory = TRUE; - return; - } + while ((ptr = savedptr) != 0) { + savedptr = ptr->child; + free(ptr); + } - SET_TRY(ptr,txt); - ptr->value = 0; + return; } - ptr->value = code; - return; + SET_TRY(ptr, txt); + ptr->value = 0; + } + + ptr->value = code; + return; } diff --git a/lib/libcurses/tinfo/alloc_ttype.c b/lib/libcurses/tinfo/alloc_ttype.c index 85b88790c88..c2ec35fc070 100644 --- a/lib/libcurses/tinfo/alloc_ttype.c +++ b/lib/libcurses/tinfo/alloc_ttype.c @@ -1,7 +1,7 @@ -/* $OpenBSD: alloc_ttype.c,v 1.2 1999/05/08 20:29:00 millert Exp $ */ +/* $OpenBSD: alloc_ttype.c,v 1.3 2000/03/26 16:45:03 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1999 Free Software Foundation, Inc. * + * Copyright (c) 1999,2000 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 * @@ -32,7 +32,6 @@ * Author: Thomas E. Dickey <dickey@clark.net> 1999 * ****************************************************************************/ - /* * align_ttype.c -- functions for TERMTYPE * @@ -46,14 +45,15 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: alloc_ttype.c,v 1.6 1999/03/01 22:10:44 tom Exp $") +MODULE_ID("$From: alloc_ttype.c,v 1.8 2000/03/25 17:03:11 tom Exp $") #if NCURSES_XNAMES /* * Merge the a/b lists into dst. Both a/b are sorted (see _nc_extend_names()), * so we do not have to worry about order dependencies. */ -static int merge_names(char **dst, char **a, int na, char **b, int nb) +static int +merge_names(char **dst, char **a, int na, char **b, int nb) { int n = 0; while (na && nb) { @@ -80,7 +80,8 @@ static int merge_names(char **dst, char **a, int na, char **b, int nb) return n; } -static bool find_name(char **table, int length, char *name) +static bool +find_name(char **table, int length, char *name) { while (length-- > 0) { if (!strcmp(*table++, name)) { @@ -92,7 +93,9 @@ static bool find_name(char **table, int length, char *name) return FALSE; } -static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int ext_Numbers, int ext_Strings) +static void +realign_data(TERMTYPE * to, char **ext_Names, int ext_Booleans, int + ext_Numbers, int ext_Strings) { int n, m, base; int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings); @@ -100,9 +103,9 @@ static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int e if (to->ext_Booleans != ext_Booleans) { to->num_Booleans += (ext_Booleans - to->ext_Booleans); to->Booleans = typeRealloc(char, to->num_Booleans, to->Booleans); - for (n = to->ext_Booleans-1, - m = ext_Booleans-1, - base = to->num_Booleans - (m+1); m >= 0; m--) { + for (n = to->ext_Booleans - 1, + m = ext_Booleans - 1, + base = to->num_Booleans - (m + 1); m >= 0; m--) { if (find_name(to->ext_Names, limit, ext_Names[m])) { to->Booleans[base + m] = to->Booleans[base + n--]; } else { @@ -114,24 +117,24 @@ static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int e if (to->ext_Numbers != ext_Numbers) { to->num_Numbers += (ext_Numbers - to->ext_Numbers); to->Numbers = typeRealloc(short, to->num_Numbers, to->Numbers); - for (n = to->ext_Numbers-1, - m = ext_Numbers-1, - base = to->num_Numbers - (m+1); m >= 0; m--) { - if (find_name(to->ext_Names, limit, ext_Names[m+ext_Booleans])) { + for (n = to->ext_Numbers - 1, + m = ext_Numbers - 1, + base = to->num_Numbers - (m + 1); m >= 0; m--) { + if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans])) { to->Numbers[base + m] = to->Numbers[base + n--]; } else { to->Numbers[base + m] = ABSENT_NUMERIC; } } - to->ext_Numbers = ext_Numbers; + to->ext_Numbers = ext_Numbers; } if (to->ext_Strings != ext_Strings) { to->num_Strings += (ext_Strings - to->ext_Strings); - to->Strings = typeRealloc(char*, to->num_Strings, to->Strings); - for (n = to->ext_Strings-1, - m = ext_Strings-1, - base = to->num_Strings - (m+1); m >= 0; m--) { - if (find_name(to->ext_Names, limit, ext_Names[m+ext_Booleans+ext_Numbers])) { + to->Strings = typeRealloc(char *, to->num_Strings, to->Strings); + for (n = to->ext_Strings - 1, + m = ext_Strings - 1, + base = to->num_Strings - (m + 1); m >= 0; m--) { + if (find_name(to->ext_Names, limit, ext_Names[m + ext_Booleans + ext_Numbers])) { to->Strings[base + m] = to->Strings[base + n--]; } else { to->Strings[base + m] = ABSENT_STRING; @@ -144,7 +147,8 @@ static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int e /* * Returns the first index in ext_Names[] for the given token-type */ -static int _nc_first_ext_name(TERMTYPE *tp, int token_type) +static int +_nc_first_ext_name(TERMTYPE * tp, int token_type) { int first; @@ -168,20 +172,21 @@ static int _nc_first_ext_name(TERMTYPE *tp, int token_type) /* * Returns the last index in ext_Names[] for the given token-type */ -static int _nc_last_ext_name(TERMTYPE *tp, int token_type) +static int +_nc_last_ext_name(TERMTYPE * tp, int token_type) { int last; switch (token_type) { case BOOLEAN: - last = tp->ext_Booleans; + last = tp->ext_Booleans; break; case NUMBER: - last = tp->ext_Booleans + tp->ext_Numbers; + last = tp->ext_Booleans + tp->ext_Numbers; break; default: case STRING: - last = NUM_EXT_NAMES(tp); + last = NUM_EXT_NAMES(tp); break; } return last; @@ -190,11 +195,12 @@ static int _nc_last_ext_name(TERMTYPE *tp, int token_type) /* * Lookup an entry from extended-names, returning -1 if not found */ -static int _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type) +static int +_nc_find_ext_name(TERMTYPE * tp, char *name, int token_type) { unsigned j; unsigned first = _nc_first_ext_name(tp, token_type); - unsigned last = _nc_last_ext_name(tp, token_type); + unsigned last = _nc_last_ext_name(tp, token_type); for (j = first; j < last; j++) { if (!strcmp(name, tp->ext_Names[j])) { @@ -208,7 +214,8 @@ static int _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type) * Translate an index into ext_Names[] into the corresponding index into data * (e.g., Booleans[]). */ -static int _nc_ext_data_index(TERMTYPE *tp, int n, int token_type) +static int +_nc_ext_data_index(TERMTYPE * tp, int n, int token_type) { switch (token_type) { case BOOLEAN: @@ -216,12 +223,12 @@ static int _nc_ext_data_index(TERMTYPE *tp, int n, int token_type) break; case NUMBER: n += (tp->num_Numbers - tp->ext_Numbers) - - (tp->ext_Booleans); + - (tp->ext_Booleans); break; default: case STRING: n += (tp->num_Strings - tp->ext_Strings) - - (tp->ext_Booleans + tp->ext_Numbers); + - (tp->ext_Booleans + tp->ext_Numbers); } return n; } @@ -230,7 +237,8 @@ static int _nc_ext_data_index(TERMTYPE *tp, int n, int token_type) * Adjust tables to remove (not free) an extended name and its corresponding * data. */ -static void _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type) +static void +_nc_del_ext_name(TERMTYPE * tp, char *name, int token_type) { int j; int first, last; @@ -238,28 +246,28 @@ static void _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type) if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) { last = NUM_EXT_NAMES(tp) - 1; for (j = first; j < last; j++) { - tp->ext_Names[j] = tp->ext_Names[j+1]; + tp->ext_Names[j] = tp->ext_Names[j + 1]; } first = _nc_ext_data_index(tp, first, token_type); switch (token_type) { case BOOLEAN: last = tp->num_Booleans - 1; for (j = first; j < last; j++) - tp->Booleans[j] = tp->Booleans[j+1]; + tp->Booleans[j] = tp->Booleans[j + 1]; tp->ext_Booleans -= 1; tp->num_Booleans -= 1; break; case NUMBER: last = tp->num_Numbers - 1; for (j = first; j < last; j++) - tp->Numbers[j] = tp->Numbers[j+1]; + tp->Numbers[j] = tp->Numbers[j + 1]; tp->ext_Numbers -= 1; tp->num_Numbers -= 1; break; case STRING: last = tp->num_Strings - 1; for (j = first; j < last; j++) - tp->Strings[j] = tp->Strings[j+1]; + tp->Strings[j] = tp->Strings[j + 1]; tp->ext_Strings -= 1; tp->num_Strings -= 1; break; @@ -271,10 +279,11 @@ static void _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type) * Adjust tables to insert an extended name, making room for new data. The * index into the corresponding data array is returned. */ -static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type) +static int +_nc_ins_ext_name(TERMTYPE * tp, char *name, int token_type) { unsigned first = _nc_first_ext_name(tp, token_type); - unsigned last = _nc_last_ext_name(tp, token_type); + unsigned last = _nc_last_ext_name(tp, token_type); unsigned total = NUM_EXT_NAMES(tp) + 1; unsigned j, k; @@ -289,8 +298,8 @@ static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type) } tp->ext_Names = typeRealloc(char *, total, tp->ext_Names); - for (k = total-1; k > j; k--) - tp->ext_Names[k] = tp->ext_Names[k-1]; + for (k = total - 1; k > j; k--) + tp->ext_Names[k] = tp->ext_Names[k - 1]; tp->ext_Names[j] = name; j = _nc_ext_data_index(tp, j, token_type); @@ -299,22 +308,22 @@ static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type) tp->ext_Booleans += 1; tp->num_Booleans += 1; tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans); - for (k = tp->num_Booleans-1; k > j; k--) - tp->Booleans[k] = tp->Booleans[k-1]; + for (k = tp->num_Booleans - 1; k > j; k--) + tp->Booleans[k] = tp->Booleans[k - 1]; break; case NUMBER: tp->ext_Numbers += 1; tp->num_Numbers += 1; tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers); - for (k = tp->num_Numbers-1; k > j; k--) - tp->Numbers[k] = tp->Numbers[k-1]; + for (k = tp->num_Numbers - 1; k > j; k--) + tp->Numbers[k] = tp->Numbers[k - 1]; break; case STRING: tp->ext_Strings += 1; tp->num_Strings += 1; tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings); - for (k = tp->num_Strings-1; k > j; k--) - tp->Strings[k] = tp->Strings[k-1]; + for (k = tp->num_Strings - 1; k > j; k--) + tp->Strings[k] = tp->Strings[k - 1]; break; } return j; @@ -325,13 +334,14 @@ static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type) * as a boolean or number. We'll get this as a special case when we get a * cancellation of a name that is inherited from another entry. */ -static void adjust_cancels(TERMTYPE *to, TERMTYPE *from) +static void +adjust_cancels(TERMTYPE * to, TERMTYPE * from) { int first = to->ext_Booleans + to->ext_Numbers; - int last = first + to->ext_Strings; + int last = first + to->ext_Strings; int j, k; - for (j = first; j < last; ) { + for (j = first; j < last;) { char *name = to->ext_Names[j]; unsigned j_str = to->num_Strings - first - to->ext_Strings; @@ -340,7 +350,8 @@ static void adjust_cancels(TERMTYPE *to, TERMTYPE *from) _nc_del_ext_name(to, name, STRING); k = _nc_ins_ext_name(to, name, BOOLEAN); to->Booleans[k] = FALSE; - } else if ((k = _nc_find_ext_name(from, to->ext_Names[j], NUMBER)) >= 0) { + } else if ((k = _nc_find_ext_name(from, to->ext_Names[j], + NUMBER)) >= 0) { _nc_del_ext_name(to, name, STRING); k = _nc_ins_ext_name(to, name, NUMBER); to->Numbers[k] = CANCELLED_NUMERIC; @@ -351,7 +362,8 @@ static void adjust_cancels(TERMTYPE *to, TERMTYPE *from) } } -void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from) +void +_nc_align_termtype(TERMTYPE * to, TERMTYPE * from) { int na = NUM_EXT_NAMES(to); int nb = NUM_EXT_NAMES(from); @@ -360,13 +372,14 @@ void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from) char **ext_Names; int ext_Booleans, ext_Numbers, ext_Strings; - DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names, nb, from->term_names)); + DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names, + nb, from->term_names)); if (na != 0 || nb != 0) { if ((na == nb) /* check if the arrays are equivalent */ - && (to->ext_Booleans == from->ext_Booleans) - && (to->ext_Numbers == from->ext_Numbers) - && (to->ext_Strings == from->ext_Strings)) { + &&(to->ext_Booleans == from->ext_Booleans) + && (to->ext_Numbers == from->ext_Numbers) + && (to->ext_Strings == from->ext_Strings)) { for (n = 0, same = TRUE; n < na; n++) { if (strcmp(to->ext_Names[n], from->ext_Names[n])) { same = FALSE; @@ -382,7 +395,7 @@ void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from) * into it, updating to's counts for booleans, etc. Fortunately we do * this only for the terminfo compiler (tic) and comparer (infocmp). */ - ext_Names = typeMalloc(char *, na+nb); + ext_Names = typeMalloc(char *, na + nb); if (to->ext_Strings && (from->ext_Booleans + from->ext_Numbers)) adjust_cancels(to, from); @@ -391,62 +404,65 @@ void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from) adjust_cancels(from, to); ext_Booleans = merge_names(ext_Names, - to->ext_Names, - to->ext_Booleans, - from->ext_Names, - from->ext_Booleans); - ext_Numbers = merge_names(ext_Names + ext_Booleans, - to->ext_Names - + to->ext_Booleans, - to->ext_Numbers, - from->ext_Names - + from->ext_Booleans, - from->ext_Numbers); - ext_Strings = merge_names(ext_Names + ext_Numbers + ext_Booleans, - to->ext_Names - + to->ext_Booleans - + to->ext_Numbers, - to->ext_Strings, - from->ext_Names - + from->ext_Booleans - + from->ext_Numbers, - from->ext_Strings); + to->ext_Names, + to->ext_Booleans, + from->ext_Names, + from->ext_Booleans); + ext_Numbers = merge_names(ext_Names + ext_Booleans, + to->ext_Names + + to->ext_Booleans, + to->ext_Numbers, + from->ext_Names + + from->ext_Booleans, + from->ext_Numbers); + ext_Strings = merge_names(ext_Names + ext_Numbers + ext_Booleans, + to->ext_Names + + to->ext_Booleans + + to->ext_Numbers, + to->ext_Strings, + from->ext_Names + + from->ext_Booleans + + from->ext_Numbers, + from->ext_Strings); /* * Now we must reallocate the Booleans, etc., to allow the data to be * overlaid. */ if (na != (ext_Booleans + ext_Numbers + ext_Strings)) { realign_data(to, ext_Names, ext_Booleans, ext_Numbers, ext_Strings); - free(to->ext_Names); + FreeIfNeeded(to->ext_Names); to->ext_Names = ext_Names; - DEBUG(2, ("realigned %d extended names for '%s' (to)", NUM_EXT_NAMES(to), to->term_names)); + DEBUG(2, ("realigned %d extended names for '%s' (to)", + NUM_EXT_NAMES(to), to->term_names)); } if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) { nb = (ext_Booleans + ext_Numbers + ext_Strings); realign_data(from, ext_Names, ext_Booleans, ext_Numbers, ext_Strings); from->ext_Names = typeRealloc(char *, nb, from->ext_Names); memcpy(from->ext_Names, ext_Names, sizeof(char *) * nb); - DEBUG(2, ("realigned %d extended names for '%s' (from)", NUM_EXT_NAMES(from), from->term_names)); + DEBUG(2, ("realigned %d extended names for '%s' (from)", + NUM_EXT_NAMES(from), from->term_names)); } } } #endif -void _nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src) +void +_nc_copy_termtype(TERMTYPE * dst, TERMTYPE * src) { int i; - *dst = *src; /* ...to copy the sizes and string-tables */ - dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst)); - dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst)); - dst->Strings = typeMalloc(char *, NUM_STRINGS(dst)); + *dst = *src; /* ...to copy the sizes and string-tables */ + dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst)); + dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst)); + dst->Strings = typeMalloc(char *, NUM_STRINGS(dst)); /* FIXME: use memcpy for these and similar loops */ - for_each_boolean(i,dst) + for_each_boolean(i, dst) dst->Booleans[i] = src->Booleans[i]; - for_each_number(i,dst) + for_each_number(i, dst) dst->Numbers[i] = src->Numbers[i]; - for_each_string(i,dst) + for_each_string(i, dst) dst->Strings[i] = src->Strings[i]; /* FIXME: we probably should also copy str_table and ext_str_table, @@ -457,6 +473,8 @@ void _nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src) if ((i = NUM_EXT_NAMES(src)) != 0) { dst->ext_Names = typeMalloc(char *, i); memcpy(dst->ext_Names, src->ext_Names, i * sizeof(char *)); + } else { + dst->ext_Names = 0; } #endif diff --git a/lib/libcurses/tinfo/captoinfo.c b/lib/libcurses/tinfo/captoinfo.c index d0e487f779f..8d29df29720 100644 --- a/lib/libcurses/tinfo/captoinfo.c +++ b/lib/libcurses/tinfo/captoinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: captoinfo.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ +/* $OpenBSD: captoinfo.c,v 1.7 2000/03/26 16:45:03 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -94,7 +94,7 @@ #include <ctype.h> #include <tic.h> -MODULE_ID("$From: captoinfo.c,v 1.35 2000/03/11 12:27:55 tom Exp $") +MODULE_ID("$From: captoinfo.c,v 1.36 2000/03/19 23:04:26 tom Exp $") #define MAX_PUSHED 16 /* max # args we can push onto the stack */ @@ -736,10 +736,9 @@ _nc_infotocap( bufptr = save_char(bufptr, '%'); while (isdigit(*str)) bufptr = save_char(bufptr, *str++); - if (strchr("doxX", *str)) { + if (strchr("doxX.", *str)) { if (*str != 'd') /* termcap doesn't have octal, hex */ return 0; - str++; } break; diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c index e336f915316..9f0afdef140 100644 --- a/lib/libcurses/tinfo/comp_parse.c +++ b/lib/libcurses/tinfo/comp_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_parse.c,v 1.5 2000/03/13 23:53:40 millert Exp $ */ +/* $OpenBSD: comp_parse.c,v 1.6 2000/03/26 16:45:03 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -54,7 +54,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: comp_parse.c,v 1.38 2000/03/12 00:14:46 tom Exp $") +MODULE_ID("$From: comp_parse.c,v 1.39 2000/03/25 17:07:30 tom Exp $") static void sanity_check(TERMTYPE *); void (*_nc_check_termtype) (TERMTYPE *) = sanity_check; @@ -176,9 +176,11 @@ _nc_read_entry_source(FILE * fp, char *buf, if (silent) _nc_suppress_warnings = TRUE; /* shut the lexer up, too */ - memset(&thisentry, 0, sizeof(thisentry)); - for (_nc_reset_input(fp, buf); _nc_parse_entry(&thisentry, literal, - silent) != ERR;) { + _nc_reset_input(fp, buf); + for (;;) { + memset(&thisentry, 0, sizeof(thisentry)); + if (_nc_parse_entry(&thisentry, literal, silent) == ERR) + break; if (!isalnum(thisentry.tterm.term_names[0])) _nc_err_abort("terminal names must start with letter or digit"); diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c index dea4b5cc350..0b23157bc8b 100644 --- a/lib/libcurses/tinfo/comp_scan.c +++ b/lib/libcurses/tinfo/comp_scan.c @@ -47,9 +47,10 @@ #include <curses.priv.h> #include <ctype.h> +#include <term_entry.h> #include <tic.h> -MODULE_ID("$From: comp_scan.c,v 1.38 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: comp_scan.c,v 1.41 2000/03/25 17:25:33 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -171,7 +172,11 @@ _nc_get_token(void) if (separator == ':' && ch == ':') ch = next_char(); - if (ch == '.') { + if (ch == '.' +#ifdef NCURSES_EXT_FUNCS + && !_nc_disable_period +#endif + ) { dot_flag = TRUE; DEBUG(8, ("dot-flag set")); @@ -185,7 +190,11 @@ _nc_get_token(void) } /* have to make some punctuation chars legal for terminfo */ - if (!isalnum(ch) && !strchr(terminfo_punct, (char) ch)) { + if (!isalnum(ch) +#ifdef NCURSES_EXT_FUNCS + && !(ch == '.' && _nc_disable_period) +#endif + && !strchr(terminfo_punct, (char) ch)) { _nc_warning("Illegal character (expected alphanumeric or %s) - %s", terminfo_punct, _tracechar((chtype) ch)); _nc_panic_mode(separator); @@ -346,7 +355,7 @@ _nc_get_token(void) break; case '=': - ch = _nc_trans_string(ptr); + ch = _nc_trans_string(ptr, buffer + sizeof(buffer)); if (ch != separator) _nc_warning("Missing separator"); _nc_curr_token.tk_name = buffer; @@ -440,15 +449,18 @@ _nc_get_token(void) */ char -_nc_trans_string(char *ptr) +_nc_trans_string(char *ptr, char *last) { int count = 0; int number; int i, c; chtype ch, last_ch = '\0'; bool ignored = FALSE; + bool long_warning = FALSE; while ((ch = c = next_char()) != (chtype) separator && c != EOF) { + if (ptr == (last - 1)) + break; if ((_nc_syntax == SYN_TERMCAP) && c == '\n') break; if (ch == '^' && last_ch != '%') { @@ -571,8 +583,10 @@ _nc_trans_string(char *ptr) } ignored = FALSE; - if (count > MAXCAPLEN) + if (count > MAXCAPLEN && !long_warning) { _nc_warning("Very long string found. Missing separator?"); + long_warning = TRUE; + } } /* end while */ *ptr = '\0'; diff --git a/lib/libcurses/tinfo/free_ttype.c b/lib/libcurses/tinfo/free_ttype.c index 2b6a053d13c..f21d4ea2282 100644 --- a/lib/libcurses/tinfo/free_ttype.c +++ b/lib/libcurses/tinfo/free_ttype.c @@ -1,4 +1,4 @@ -/* $OpenBSD: free_ttype.c,v 1.2 1999/05/08 20:29:01 millert Exp $ */ +/* $OpenBSD: free_ttype.c,v 1.3 2000/03/26 16:45:04 millert Exp $ */ /**************************************************************************** * Copyright (c) 1999 Free Software Foundation, Inc. * @@ -46,7 +46,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: free_ttype.c,v 1.2 1999/03/01 00:30:35 tom Exp $") +MODULE_ID("$From: free_ttype.c,v 1.3 2000/03/19 02:03:07 tom Exp $") void _nc_free_termtype(TERMTYPE *ptr) { @@ -64,6 +64,7 @@ void _nc_free_termtype(TERMTYPE *ptr) #if NCURSES_XNAMES bool _nc_user_definable = TRUE; +bool _nc_disable_period = FALSE; /* used by tic -a option */ int use_extended_names(bool flag) { diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c index d127ef7a0fa..45d9bb000cb 100644 --- a/lib/libcurses/tinfo/read_termcap.c +++ b/lib/libcurses/tinfo/read_termcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read_termcap.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ +/* $OpenBSD: read_termcap.c,v 1.7 2000/03/26 16:45:04 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -57,7 +57,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$From: read_termcap.c,v 1.45 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: read_termcap.c,v 1.46 2000/03/18 21:53:26 tom Exp $") #ifndef PURE_TERMINFO |