From a2d977cefdbe60d0c9bcede71e0721380b10984a Mon Sep 17 00:00:00 2001 From: millert Date: Mon, 13 Mar 2000 23:53:38 +0000 Subject: [PATCH] update to ncurses-5.0-20000311 --- lib/libcurses/curses.h | 4 +- lib/libcurses/shlib_version | 2 +- lib/libcurses/term.h | 9 +- lib/libcurses/term_entry.h | 19 +- lib/libcurses/terminfo.5tbl | 22 +- lib/libcurses/tinfo/alloc_entry.c | 218 ++++++------- lib/libcurses/tinfo/captoinfo.c | 23 +- lib/libcurses/tinfo/comp_parse.c | 421 ++++++++++++------------ lib/libcurses/tinfo/init_keytry.c | 4 +- lib/libcurses/tinfo/lib_options.c | 8 +- lib/libcurses/tinfo/make_keys.c | 4 +- lib/libcurses/tinfo/parse_entry.c | 8 +- lib/libcurses/tinfo/read_entry.c | 6 +- lib/libcurses/tinfo/read_termcap.c | 4 +- lib/libcurses/tinfo/write_entry.c | 17 +- usr.bin/infocmp/infocmp.1tbl | 22 +- usr.bin/infocmp/infocmp.c | 499 ++++++++++++++++++----------- usr.bin/tic/dump_entry.c | 26 +- usr.bin/tic/dump_entry.h | 11 +- usr.bin/tic/tic.c | 6 +- usr.bin/tset/tset.c | 13 +- 21 files changed, 756 insertions(+), 590 deletions(-) diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index 8bac7690346..b17f89d8f67 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.h,v 1.47 2000/03/10 01:35:01 millert Exp $ */ +/* $OpenBSD: curses.h,v 1.48 2000/03/13 23:53:38 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -50,7 +50,7 @@ /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 5 #define NCURSES_VERSION_MINOR 0 -#define NCURSES_VERSION_PATCH 20000304 +#define NCURSES_VERSION_PATCH 20000311 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION diff --git a/lib/libcurses/shlib_version b/lib/libcurses/shlib_version index 9c1551636c5..5b844bbf422 100644 --- a/lib/libcurses/shlib_version +++ b/lib/libcurses/shlib_version @@ -1,2 +1,2 @@ -major=6 +major=7 minor=0 diff --git a/lib/libcurses/term.h b/lib/libcurses/term.h index 1d44050ec54..4011b24e0c7 100644 --- a/lib/libcurses/term.h +++ b/lib/libcurses/term.h @@ -1,7 +1,7 @@ -/* $OpenBSD: term.h,v 1.8 2000/01/08 06:26:25 millert Exp $ */ +/* $OpenBSD: term.h,v 1.9 2000/03/13 23:53:39 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,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 * @@ -33,7 +33,7 @@ /* and: Eric S. Raymond */ /****************************************************************************/ -/* $From: MKterm.h.awk.in,v 1.36 1999/09/01 22:36:52 Peter.Wemm Exp $ */ +/* $From: MKterm.h.awk.in,v 1.37 2000/03/12 02:40:07 tom Exp $ */ /* ** term.h -- Definition of struct term @@ -691,6 +691,9 @@ extern "C" { #define NUMCOUNT 39 #define STRCOUNT 414 +/* used by code for comparing entries */ +#define acs_chars_index 146 + typedef struct termtype { /* in-core form of terminfo data */ char *term_names; /* str_table offset of term names */ char *str_table; /* pointer to string table */ diff --git a/lib/libcurses/term_entry.h b/lib/libcurses/term_entry.h index 76c23c9fc21..4d42cb32e56 100644 --- a/lib/libcurses/term_entry.h +++ b/lib/libcurses/term_entry.h @@ -1,7 +1,7 @@ -/* $OpenBSD: term_entry.h,v 1.8 1999/05/17 03:03:57 millert Exp $ */ +/* $OpenBSD: term_entry.h,v 1.9 2000/03/13 23:53:39 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998,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 * @@ -33,6 +33,7 @@ * and: Eric S. Raymond * ****************************************************************************/ +/* $From: term_entry.h,v 1.28 2000/03/12 00:44:04 tom Exp $ */ /* * term_entry.h -- interface to entry-manipulation code @@ -48,16 +49,20 @@ extern "C" { #include #define MAX_USES 32 +#define MAX_CROSSLINKS 16 typedef struct entry { TERMTYPE tterm; int nuses; struct { - void *parent; /* (char *) or (ENTRY *) */ + char *name; + struct entry *link; long line; } uses[MAX_USES]; + int ncrosslinks; + struct entry *crosslinks[MAX_CROSSLINKS]; long cstart, cend; long startline; struct entry *next; @@ -143,19 +148,13 @@ extern void _nc_write_entry(TERMTYPE *const); /* comp_parse.c: entry list handling */ extern void _nc_read_entry_source(FILE*, char*, int, bool, bool (*)(ENTRY*)); extern bool _nc_entry_match(char *, char *); -extern int _nc_resolve_uses(void); +extern int _nc_resolve_uses(bool); extern void _nc_free_entries(ENTRY *); extern void (*_nc_check_termtype)(TERMTYPE *); /* trace_xnames.c */ extern void _nc_trace_xnames(TERMTYPE *); -#ifdef __OpenBSD__ -/* read_bsd_terminfo.c: terminfo.db reading */ -extern int _nc_read_bsd_terminfo_entry(const char * const, char * const, TERMTYPE *const); -extern int _nc_read_bsd_terminfo_file(const char * const, TERMTYPE *const); -#endif /* __OpenBSD__ */ - #ifdef __cplusplus } #endif diff --git a/lib/libcurses/terminfo.5tbl b/lib/libcurses/terminfo.5tbl index 587bf6b767f..f12d171a732 100644 --- a/lib/libcurses/terminfo.5tbl +++ b/lib/libcurses/terminfo.5tbl @@ -33,7 +33,7 @@ .\"*************************************************************************** .\" .\" $From: terminfo.head,v 1.8 1998/03/11 21:12:53 juergen Exp $ -.\" $OpenBSD: terminfo.5tbl,v 1.6 2000/01/09 05:06:01 millert Exp $ +.\" $OpenBSD: terminfo.5tbl,v 1.7 2000/03/13 23:53:39 millert Exp $ .TH TERMINFO 5 "" "" "File Formats" .ds n 5 .ds d /usr/share/terminfo @@ -1623,7 +1623,7 @@ YI Set page length to #1 hundredth of an inch T} .TE .ad -.\" $From: terminfo.tail,v 1.30 2000/01/08 22:09:12 tom Exp $ +.\" $From: terminfo.tail,v 1.31 2000/03/12 00:36:41 tom Exp $ .\" Beginning of terminfo.tail file .ps +1 .PP @@ -2951,16 +2951,20 @@ capabilities of the form \fBx\fR\fIx\fR. .PP .SS Similar Terminals .PP -If there are two very similar terminals, -one can be defined as being just like the other with certain exceptions. -The string capability \fBuse\fR can be given -with the name of the similar terminal. -The capabilities given before +If there are two very similar terminals, one (the variant) can be defined as +being just like the other (the base) with certain exceptions. In the +definition of the variant, the string capability \fBuse\fR can be given with +the name of the base terminal. The capabilities given before .B use -override those in the terminal type invoked by +override those in the base type named by .BR use . +If there are multiple \fBuse\fR capabilities, they are merged in reverse order. +That is, the rightmost \fBuse\fR reference is processed first, then the one to +its left, and so forth. Capabilities given explicitly in the entry override +those brought in by \fBuse\fR references. +.PP A capability can be canceled by placing \fBxx@\fR to the left of the -capability definition, where xx is the capability. +use reference that imports it, where \fIxx\fP is the capability. For example, the entry .PP 2621-nl, smkx@, rmkx@, use=2621, diff --git a/lib/libcurses/tinfo/alloc_entry.c b/lib/libcurses/tinfo/alloc_entry.c index 3f94b109c31..b019f59ce6e 100644 --- a/lib/libcurses/tinfo/alloc_entry.c +++ b/lib/libcurses/tinfo/alloc_entry.c @@ -1,7 +1,7 @@ -/* $OpenBSD: alloc_entry.c,v 1.2 1999/03/02 06:23:28 millert Exp $ */ +/* $OpenBSD: alloc_entry.c,v 1.3 2000/03/13 23:53:39 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 * @@ -33,7 +33,6 @@ * and: Eric S. Raymond * ****************************************************************************/ - /* * alloc_entry.c -- allocation functions for terminfo entries * @@ -50,149 +49,152 @@ #include #include -MODULE_ID("$From: alloc_entry.c,v 1.30 1999/03/01 02:03:45 tom Exp $") +MODULE_ID("$From: alloc_entry.c,v 1.32 2000/03/12 00:16:31 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 #define MAX_STRTAB 4096 /* documented maximum entry size */ -static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */ -static size_t next_free; /* next free character in stringbuf */ +static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */ +static size_t next_free; /* next free character in stringbuf */ -void _nc_init_entry(TERMTYPE *const tp) +void +_nc_init_entry(TERMTYPE * const tp) /* initialize a terminal type data block */ { -int i; + int i; #if NCURSES_XNAMES - tp->num_Booleans = BOOLCOUNT; - tp->num_Numbers = NUMCOUNT; - tp->num_Strings = STRCOUNT; - tp->ext_Booleans = 0; - tp->ext_Numbers = 0; - tp->ext_Strings = 0; + tp->num_Booleans = BOOLCOUNT; + tp->num_Numbers = NUMCOUNT; + tp->num_Strings = STRCOUNT; + tp->ext_Booleans = 0; + tp->ext_Numbers = 0; + tp->ext_Strings = 0; #endif - if (tp->Booleans == 0) - tp->Booleans = typeMalloc(char,BOOLCOUNT); - if (tp->Numbers == 0) - tp->Numbers = typeMalloc(short,NUMCOUNT); - if (tp->Strings == 0) - tp->Strings = typeMalloc(char *,STRCOUNT); + if (tp->Booleans == 0) + tp->Booleans = typeMalloc(char, BOOLCOUNT); + if (tp->Numbers == 0) + tp->Numbers = typeMalloc(short, NUMCOUNT); + if (tp->Strings == 0) + tp->Strings = typeMalloc(char *, STRCOUNT); - for_each_boolean(i,tp) - tp->Booleans[i] = FALSE; + for_each_boolean(i, tp) + tp->Booleans[i] = FALSE; - for_each_number(i,tp) - tp->Numbers[i] = ABSENT_NUMERIC; + for_each_number(i, tp) + tp->Numbers[i] = ABSENT_NUMERIC; - for_each_string(i,tp) - tp->Strings[i] = ABSENT_STRING; + for_each_string(i, tp) + tp->Strings[i] = ABSENT_STRING; - next_free = 0; + next_free = 0; } -ENTRY *_nc_copy_entry(ENTRY *oldp) +ENTRY * +_nc_copy_entry(ENTRY * oldp) { - ENTRY *newp = typeCalloc(ENTRY,1); + ENTRY *newp = typeCalloc(ENTRY, 1); - if (newp != 0) { - *newp = *oldp; - _nc_copy_termtype(&(newp->tterm), &(oldp->tterm)); - } - return newp; + if (newp != 0) { + *newp = *oldp; + _nc_copy_termtype(&(newp->tterm), &(oldp->tterm)); + } + return newp; } -char *_nc_save_str(const char *const string) +char * +_nc_save_str(const char *const string) /* save a copy of string in the string buffer */ { -size_t old_next_free = next_free; -size_t len = strlen(string) + 1; - - if (next_free + len < MAX_STRTAB) - { - strcpy(&stringbuf[next_free], string); - DEBUG(7, ("Saved string %s", _nc_visbuf(string))); - DEBUG(7, ("at location %d", (int) next_free)); - next_free += len; - } - return(stringbuf + old_next_free); + size_t old_next_free = next_free; + size_t len = strlen(string) + 1; + + if (next_free + len < MAX_STRTAB) { + strcpy(&stringbuf[next_free], string); + DEBUG(7, ("Saved string %s", _nc_visbuf(string))); + DEBUG(7, ("at location %d", (int) next_free)); + next_free += len; + } + return (stringbuf + old_next_free); } -void _nc_wrap_entry(ENTRY *const ep) +void +_nc_wrap_entry(ENTRY * const ep) /* copy the string parts to allocated storage, preserving pointers to it */ { -int offsets[MAX_ENTRY_SIZE/2], useoffsets[MAX_USES]; -int i, n; -TERMTYPE *tp = &(ep->tterm); - - n = tp->term_names - stringbuf; - for_each_string(i, &(ep->tterm)) { - if (tp->Strings[i] == ABSENT_STRING) - offsets[i] = ABSENT_OFFSET; - else if (tp->Strings[i] == CANCELLED_STRING) - offsets[i] = CANCELLED_OFFSET; - else - offsets[i] = tp->Strings[i] - stringbuf; - } + int offsets[MAX_ENTRY_SIZE / 2], useoffsets[MAX_USES]; + int i, n; + TERMTYPE *tp = &(ep->tterm); + + n = tp->term_names - stringbuf; + for_each_string(i, &(ep->tterm)) { + if (tp->Strings[i] == ABSENT_STRING) + offsets[i] = ABSENT_OFFSET; + else if (tp->Strings[i] == CANCELLED_STRING) + offsets[i] = CANCELLED_OFFSET; + else + offsets[i] = tp->Strings[i] - stringbuf; + } - for (i=0; i < ep->nuses; i++) { - if (ep->uses[i].parent == (void *)0) - useoffsets[i] = ABSENT_OFFSET; - else - useoffsets[i] = (char *)(ep->uses[i].parent) - stringbuf; - } + for (i = 0; i < ep->nuses; i++) { + if (ep->uses[i].name == 0) + useoffsets[i] = ABSENT_OFFSET; + else + useoffsets[i] = ep->uses[i].name - stringbuf; + } - if ((tp->str_table = typeMalloc(char, next_free)) == (char *)0) - _nc_err_abort("Out of memory"); - (void) memcpy(tp->str_table, stringbuf, next_free); - - tp->term_names = tp->str_table + n; - for_each_string(i, &(ep->tterm)) { - if (offsets[i] == ABSENT_OFFSET) - tp->Strings[i] = ABSENT_STRING; - else if (offsets[i] == CANCELLED_OFFSET) - tp->Strings[i] = CANCELLED_STRING; - else - tp->Strings[i] = tp->str_table + offsets[i]; - } + if ((tp->str_table = typeMalloc(char, next_free)) == (char *) 0) + _nc_err_abort("Out of memory"); + (void) memcpy(tp->str_table, stringbuf, next_free); + + tp->term_names = tp->str_table + n; + for_each_string(i, &(ep->tterm)) { + if (offsets[i] == ABSENT_OFFSET) + tp->Strings[i] = ABSENT_STRING; + else if (offsets[i] == CANCELLED_OFFSET) + tp->Strings[i] = CANCELLED_STRING; + else + tp->Strings[i] = tp->str_table + offsets[i]; + } #if NCURSES_XNAMES - if ((n = NUM_EXT_NAMES(tp)) != 0) { - unsigned length = 0; - for (i = 0; i < n; i++) { - length += strlen(tp->ext_Names[i]) + 1; - offsets[i] = tp->ext_Names[i] - stringbuf; - } - if ((tp->ext_str_table = typeMalloc(char, length)) == 0) - _nc_err_abort("Out of memory"); - for (i = 0, length = 0; i < n; i++) { - tp->ext_Names[i] = tp->ext_str_table + length; - strcpy(tp->ext_Names[i], stringbuf + offsets[i]); - length += strlen(tp->ext_Names[i]) + 1; - } + if ((n = NUM_EXT_NAMES(tp)) != 0) { + unsigned length = 0; + for (i = 0; i < n; i++) { + length += strlen(tp->ext_Names[i]) + 1; + offsets[i] = tp->ext_Names[i] - stringbuf; + } + if ((tp->ext_str_table = typeMalloc(char, length)) == 0) + _nc_err_abort("Out of memory"); + for (i = 0, length = 0; i < n; i++) { + tp->ext_Names[i] = tp->ext_str_table + length; + strcpy(tp->ext_Names[i], stringbuf + offsets[i]); + length += strlen(tp->ext_Names[i]) + 1; } + } #endif - for (i=0; i < ep->nuses; i++) { - if (useoffsets[i] == ABSENT_OFFSET) - ep->uses[i].parent = (void *)0; - else - ep->uses[i].parent = (char *)(tp->str_table + useoffsets[i]); - } + for (i = 0; i < ep->nuses; i++) { + if (useoffsets[i] == ABSENT_OFFSET) + ep->uses[i].name = 0; + else + ep->uses[i].name = (tp->str_table + useoffsets[i]); + } } -void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from) +void +_nc_merge_entry(TERMTYPE * const to, TERMTYPE * const from) /* merge capabilities from `from' entry into `to' entry */ { - int i; + int i; #if NCURSES_XNAMES _nc_align_termtype(to, from); #endif - for_each_boolean(i, from) - { - int mergebool = from->Booleans[i]; + for_each_boolean(i, from) { + int mergebool = from->Booleans[i]; if (mergebool == CANCELLED_BOOLEAN) to->Booleans[i] = FALSE; @@ -200,9 +202,8 @@ void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from) to->Booleans[i] = mergebool; } - for_each_number(i, from) - { - int mergenum = from->Numbers[i]; + for_each_number(i, from) { + int mergenum = from->Numbers[i]; if (mergenum == CANCELLED_NUMERIC) to->Numbers[i] = ABSENT_NUMERIC; @@ -215,9 +216,8 @@ void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from) * storage. This is OK right now, but will be a problem if we * we ever want to deallocate entries. */ - for_each_string(i, from) - { - char *mergestring = from->Strings[i]; + for_each_string(i, from) { + char *mergestring = from->Strings[i]; if (mergestring == CANCELLED_STRING) to->Strings[i] = ABSENT_STRING; diff --git a/lib/libcurses/tinfo/captoinfo.c b/lib/libcurses/tinfo/captoinfo.c index 44008a41c80..d0e487f779f 100644 --- a/lib/libcurses/tinfo/captoinfo.c +++ b/lib/libcurses/tinfo/captoinfo.c @@ -1,7 +1,7 @@ -/* $OpenBSD: captoinfo.c,v 1.5 1999/12/12 04:49:19 millert Exp $ */ +/* $OpenBSD: captoinfo.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998,1999 Free Software Foundation, Inc. * + * Copyright (c) 1998,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 * @@ -94,7 +94,7 @@ #include #include -MODULE_ID("$From: captoinfo.c,v 1.33 1999/12/12 02:25:56 tom Exp $") +MODULE_ID("$From: captoinfo.c,v 1.35 2000/03/11 12:27:55 tom Exp $") #define MAX_PUSHED 16 /* max # args we can push onto the stack */ @@ -645,6 +645,7 @@ _nc_infotocap( char ch1 = 0, ch2 = 0; char *bufptr = init_string(); int len; + bool syntax_error = FALSE; /* we may have to move some trailing mandatory padding up front */ padding = str + strlen(str) - 1; @@ -715,7 +716,7 @@ _nc_infotocap( if (saw_n++ == 0) { bufptr = save_string(bufptr, "%m"); } - } else { + } else { /* cm-style format element */ str++; switch (*str) { case '%': @@ -735,8 +736,11 @@ _nc_infotocap( bufptr = save_char(bufptr, '%'); while (isdigit(*str)) bufptr = save_char(bufptr, *str++); - if (*str != 'd') /* termcap doesn't have octal, hex */ - return 0; + if (strchr("doxX", *str)) { + if (*str != 'd') /* termcap doesn't have octal, hex */ + return 0; + str++; + } break; case 'd': @@ -774,8 +778,9 @@ _nc_infotocap( break; default: - return (0); - + bufptr = save_char(bufptr, *str); + syntax_error = TRUE; + break; } /* endswitch (*str) */ } /* endelse (*str == '%') */ @@ -784,7 +789,7 @@ _nc_infotocap( } /* endwhile (*str) */ - return (my_string); + return (syntax_error ? NULL : my_string); } #ifdef MAIN diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c index 253febbafc2..e336f915316 100644 --- a/lib/libcurses/tinfo/comp_parse.c +++ b/lib/libcurses/tinfo/comp_parse.c @@ -1,7 +1,7 @@ -/* $OpenBSD: comp_parse.c,v 1.4 1999/11/28 17:49:53 millert Exp $ */ +/* $OpenBSD: comp_parse.c,v 1.5 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998,1999 Free Software Foundation, Inc. * + * Copyright (c) 1998,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 * @@ -33,8 +33,6 @@ * and: Eric S. Raymond * ****************************************************************************/ - - /* * comp_parse.c -- parser driver loop and use handling. * @@ -56,10 +54,10 @@ #include #include -MODULE_ID("$From: comp_parse.c,v 1.36 1999/10/31 00:56:12 tom Exp $") +MODULE_ID("$From: comp_parse.c,v 1.38 2000/03/12 00:14:46 tom Exp $") static void sanity_check(TERMTYPE *); -void (*_nc_check_termtype)(TERMTYPE *) = sanity_check; +void (*_nc_check_termtype) (TERMTYPE *) = sanity_check; /**************************************************************************** * @@ -84,29 +82,30 @@ void (*_nc_check_termtype)(TERMTYPE *) = sanity_check; ENTRY *_nc_head = 0, *_nc_tail = 0; -static void enqueue(ENTRY *ep) +static void +enqueue(ENTRY * ep) /* add an entry to the in-core list */ { - ENTRY *newp = _nc_copy_entry(ep); + ENTRY *newp = _nc_copy_entry(ep); - if (newp == NULL) - _nc_err_abort("Out of memory"); + if (newp == 0) + _nc_err_abort("Out of memory"); - newp->last = _nc_tail; - _nc_tail = newp; + newp->last = _nc_tail; + _nc_tail = newp; - newp->next = (ENTRY *)NULL; - if (newp->last) - newp->last->next = newp; + newp->next = 0; + if (newp->last) + newp->last->next = newp; } -void _nc_free_entries(ENTRY *headp) +void +_nc_free_entries(ENTRY * headp) /* free the allocated storage consumed by list entries */ { - ENTRY *ep, *next; + ENTRY *ep, *next; - for (ep = headp; ep; ep = next) - { + for (ep = headp; ep; ep = next) { /* * This conditional lets us disconnect storage from the list. * To do this, copy an entry out of the list, then null out @@ -118,20 +117,22 @@ void _nc_free_entries(ENTRY *headp) next = ep->next; free(ep); - if (ep == _nc_head) _nc_head = 0; - if (ep == _nc_tail) _nc_tail = 0; + if (ep == _nc_head) + _nc_head = 0; + if (ep == _nc_tail) + _nc_tail = 0; } } -bool _nc_entry_match(char *n1, char *n2) +bool +_nc_entry_match(char *n1, char *n2) /* do any of the aliases in a pair of terminal names match? */ { - char *pstart, *qstart, *pend, *qend; - char nc1[MAX_NAME_SIZE+1], nc2[MAX_NAME_SIZE+1]; - size_t n; + char *pstart, *qstart, *pend, *qend; + char nc1[MAX_NAME_SIZE + 1], nc2[MAX_NAME_SIZE + 1]; + size_t n; - if (strchr(n1, '|') == NULL) - { + if (strchr(n1, '|') == NULL) { if ((n = strlcpy(nc1, n1, sizeof(nc1))) > sizeof(nc1) - 2) n = sizeof(nc1) - 2; nc1[n++] = '|'; @@ -139,8 +140,7 @@ bool _nc_entry_match(char *n1, char *n2) n1 = nc1; } - if (strchr(n2, '|') == NULL) - { + if (strchr(n2, '|') == NULL) { if ((n = strlcpy(nc2, n2, sizeof(nc2))) > sizeof(nc2) - 2) n = sizeof(nc2) - 2; nc2[n++] = '|'; @@ -150,11 +150,11 @@ bool _nc_entry_match(char *n1, char *n2) for (pstart = n1; (pend = strchr(pstart, '|')); pstart = pend + 1) for (qstart = n2; (qend = strchr(qstart, '|')); qstart = qend + 1) - if ((pend-pstart == qend-qstart) - && memcmp(pstart, qstart, (size_t)(pend-pstart)) == 0) - return(TRUE); + if ((pend - pstart == qend - qstart) + && memcmp(pstart, qstart, (size_t) (pend - pstart)) == 0) + return (TRUE); - return(FALSE); + return (FALSE); } /**************************************************************************** @@ -163,21 +163,22 @@ bool _nc_entry_match(char *n1, char *n2) * ****************************************************************************/ -void _nc_read_entry_source(FILE *fp, char *buf, - int literal, bool silent, - bool (*hook)(ENTRY *)) +void +_nc_read_entry_source(FILE * fp, char *buf, + int literal, bool silent, + bool(*hook) (ENTRY *)) /* slurp all entries in the given file into core */ { - ENTRY thisentry; - bool oldsuppress = _nc_suppress_warnings; - int immediate = 0; + ENTRY thisentry; + bool oldsuppress = _nc_suppress_warnings; + int immediate = 0; 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; ) - { + for (_nc_reset_input(fp, buf); _nc_parse_entry(&thisentry, literal, + silent) != ERR;) { if (!isalnum(thisentry.tterm.term_names[0])) _nc_err_abort("terminal names must start with letter or digit"); @@ -186,14 +187,13 @@ void _nc_read_entry_source(FILE *fp, char *buf, * use references to disk, so as to avoid chewing up a lot of * core when the resolution code could fetch entries off disk. */ - if (hook != NULLHOOK && (*hook)(&thisentry)) + if (hook != NULLHOOK && (*hook) (&thisentry)) immediate++; else enqueue(&thisentry); } - if (_nc_tail) - { + if (_nc_tail) { /* set up the head pointer */ for (_nc_head = _nc_tail; _nc_head->last; _nc_head = _nc_head->last) continue; @@ -209,12 +209,13 @@ void _nc_read_entry_source(FILE *fp, char *buf, _nc_suppress_warnings = oldsuppress; } -int _nc_resolve_uses(void) +int +_nc_resolve_uses(bool fullresolve) /* try to resolve all use capabilities */ { - ENTRY *qp, *rp, *lastread = NULL; - bool keepgoing; - int i, j, unresolved, total_unresolved, multiples; + ENTRY *qp, *rp, *lastread = 0; + bool keepgoing; + int i, j, unresolved, total_unresolved, multiples; DEBUG(2, ("RESOLUTION BEGINNING")); @@ -222,48 +223,41 @@ int _nc_resolve_uses(void) * Check for multiple occurrences of the same name. */ multiples = 0; - for_entry_list(qp) - { + for_entry_list(qp) { int matchcount = 0; for_entry_list(rp) if (qp > rp - && _nc_entry_match(qp->tterm.term_names, rp->tterm.term_names)) - { - matchcount++; - if (matchcount == 1) - { - (void) fprintf(stderr, "Name collision between %s", - _nc_first_name(qp->tterm.term_names)); - multiples++; - } - if (matchcount >= 1) - (void) fprintf(stderr, " %s", _nc_first_name(rp->tterm.term_names)); + && _nc_entry_match(qp->tterm.term_names, rp->tterm.term_names)) { + matchcount++; + if (matchcount == 1) { + (void) fprintf(stderr, "Name collision between %s", + _nc_first_name(qp->tterm.term_names)); + multiples++; } + if (matchcount >= 1) + (void) fprintf(stderr, " %s", _nc_first_name(rp->tterm.term_names)); + } if (matchcount >= 1) (void) putc('\n', stderr); } if (multiples > 0) - return(FALSE); + return (FALSE); DEBUG(2, ("NO MULTIPLE NAME OCCURRENCES")); /* - * First resolution stage: replace names in use arrays with entry - * pointers. By doing this, we avoid having to do the same name - * match once for each time a use entry is itself unresolved. + * First resolution stage: compute link pointers corresponding to names. */ total_unresolved = 0; _nc_curr_col = -1; - for_entry_list(qp) - { + for_entry_list(qp) { unresolved = 0; - for (i = 0; i < qp->nuses; i++) - { - bool foundit; - char *child = _nc_first_name(qp->tterm.term_names); - char *lookfor = (char *)(qp->uses[i].parent); - long lookline = qp->uses[i].line; + for (i = 0; i < qp->nuses; i++) { + bool foundit; + char *child = _nc_first_name(qp->tterm.term_names); + char *lookfor = qp->uses[i].name; + long lookline = qp->uses[i].line; foundit = FALSE; @@ -272,146 +266,142 @@ int _nc_resolve_uses(void) /* first, try to resolve from in-core records */ for_entry_list(rp) if (rp != qp - && _nc_name_match(rp->tterm.term_names, lookfor, "|")) - { - DEBUG(2, ("%s: resolving use=%s (in core)", - child, lookfor)); + && _nc_name_match(rp->tterm.term_names, lookfor, "|")) { + DEBUG(2, ("%s: resolving use=%s (in core)", + child, lookfor)); - qp->uses[i].parent = rp; - foundit = TRUE; - } + qp->uses[i].link = rp; + foundit = TRUE; + } /* if that didn't work, try to merge in a compiled entry */ - if (!foundit) - { - TERMTYPE thisterm; - char filename[PATH_MAX]; + if (!foundit) { + TERMTYPE thisterm; + char filename[PATH_MAX]; memset(&thisterm, 0, sizeof(thisterm)); - if (_nc_read_entry(lookfor, filename, &thisterm) == 1) - { + if (_nc_read_entry(lookfor, filename, &thisterm) == 1) { DEBUG(2, ("%s: resolving use=%s (compiled)", - child, lookfor)); + child, lookfor)); - rp = typeMalloc(ENTRY,1); - if (rp == NULL) + rp = typeMalloc(ENTRY, 1); + if (rp == 0) _nc_err_abort("Out of memory"); rp->tterm = thisterm; rp->nuses = 0; rp->next = lastread; lastread = rp; - qp->uses[i].parent = rp; + qp->uses[i].link = rp; foundit = TRUE; } } /* no good, mark this one unresolvable and complain */ - if (!foundit) - { + if (!foundit) { unresolved++; total_unresolved++; _nc_curr_line = lookline; _nc_warning("resolution of use=%s failed", lookfor); - qp->uses[i].parent = (ENTRY *)NULL; + qp->uses[i].link = 0; } } } - if (total_unresolved) - { + if (total_unresolved) { /* free entries read in off disk */ _nc_free_entries(lastread); - return(FALSE); + return (FALSE); } DEBUG(2, ("NAME RESOLUTION COMPLETED OK")); /* - * OK, at this point all (char *) references have been successfully - * replaced by (ENTRY *) pointers. Time to do the actual merges. + * OK, at this point all (char *) references in `name' mwmbers + * have been successfully converred to (ENTRY *) pointers in + * `link' members. Time to do the actual merges. */ - do { - TERMTYPE merged; - - keepgoing = FALSE; - - for_entry_list(qp) - { - if (qp->nuses > 0) - { - DEBUG(2, ("%s: attempting merge", _nc_first_name(qp->tterm.term_names))); - /* - * If any of the use entries we're looking for is - * incomplete, punt. We'll catch this entry on a - * subsequent pass. - */ - for (i = 0; i < qp->nuses; i++) - if (((ENTRY *)qp->uses[i].parent)->nuses) - { - DEBUG(2, ("%s: use entry %d unresolved", - _nc_first_name(qp->tterm.term_names), i)); - goto incomplete; - } - - /* - * First, make sure there's no garbage in the merge block. - * as a side effect, copy into the merged entry the name - * field and string table pointer. - */ - _nc_copy_termtype(&merged, &(qp->tterm)); - - /* - * Now merge in each use entry in the proper - * (reverse) order. - */ - for (; qp->nuses; qp->nuses--) - _nc_merge_entry(&merged, - &((ENTRY *)qp->uses[qp->nuses-1].parent)->tterm); - - /* - * Now merge in the original entry. - */ - _nc_merge_entry(&merged, &qp->tterm); - - /* - * Replace the original entry with the merged one. - */ - FreeIfNeeded(qp->tterm.Booleans); - FreeIfNeeded(qp->tterm.Numbers); - FreeIfNeeded(qp->tterm.Strings); - qp->tterm = merged; - - /* - * We know every entry is resolvable because name resolution - * didn't bomb. So go back for another pass. - */ - /* FALLTHRU */ - incomplete: - keepgoing = TRUE; + if (fullresolve) { + do { + TERMTYPE merged; + + keepgoing = FALSE; + + for_entry_list(qp) { + if (qp->nuses > 0) { + DEBUG(2, ("%s: attempting merge", + _nc_first_name(qp->tterm.term_names))); + /* + * If any of the use entries we're looking for is + * incomplete, punt. We'll catch this entry on a + * subsequent pass. + */ + for (i = 0; i < qp->nuses; i++) + if (qp->uses[i].link->nuses) { + DEBUG(2, ("%s: use entry %d unresolved", + _nc_first_name(qp->tterm.term_names), i)); + goto incomplete; + } + + /* + * First, make sure there's no garbage in the + * merge block. as a side effect, copy into + * the merged entry the name field and string + * table pointer. + */ + _nc_copy_termtype(&merged, &(qp->tterm)); + + /* + * Now merge in each use entry in the proper + * (reverse) order. + */ + for (; qp->nuses; qp->nuses--) + _nc_merge_entry(&merged, + &qp->uses[qp->nuses - 1].link->tterm); + + /* + * Now merge in the original entry. + */ + _nc_merge_entry(&merged, &qp->tterm); + + /* + * Replace the original entry with the merged one. + */ + FreeIfNeeded(qp->tterm.Booleans); + FreeIfNeeded(qp->tterm.Numbers); + FreeIfNeeded(qp->tterm.Strings); + qp->tterm = merged; + + /* + * We know every entry is resolvable because name resolution + * didn't bomb. So go back for another pass. + */ + /* FALLTHRU */ + incomplete: + keepgoing = TRUE; + } } - } - } while - (keepgoing); + } while + (keepgoing); - DEBUG(2, ("MERGES COMPLETED OK")); + DEBUG(2, ("MERGES COMPLETED OK")); - /* - * The exit condition of the loop above is such that all entries - * must now be resolved. Now handle cancellations. In a resolved - * entry there should be no cancellation markers. - */ - for_entry_list(qp) - { - for_each_boolean(j, &(qp->tterm)) - if (qp->tterm.Booleans[j] == CANCELLED_BOOLEAN) - qp->tterm.Booleans[j] = FALSE; - for_each_number(j, &(qp->tterm)) - if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC) + /* + * The exit condition of the loop above is such that all entries + * must now be resolved. Now handle cancellations. In a resolved + * entry there should be no cancellation markers. + */ + for_entry_list(qp) { + for_each_boolean(j, &(qp->tterm)) + if (qp->tterm.Booleans[j] == CANCELLED_BOOLEAN) + qp->tterm.Booleans[j] = ABSENT_BOOLEAN; + for_each_number(j, &(qp->tterm)) + if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC) qp->tterm.Numbers[j] = ABSENT_NUMERIC; - for_each_string(j, &(qp->tterm)) - if (qp->tterm.Strings[j] == CANCELLED_STRING) + for_each_string(j, &(qp->tterm)) + if (qp->tterm.Strings[j] == CANCELLED_STRING) qp->tterm.Strings[j] = ABSENT_STRING; + } } /* @@ -423,19 +413,18 @@ int _nc_resolve_uses(void) DEBUG(2, ("RESOLUTION FINISHED")); - if (_nc_check_termtype != 0) - { - _nc_curr_col = -1; - for_entry_list(qp) - { - _nc_curr_line = qp->startline; - _nc_set_type(_nc_first_name(qp->tterm.term_names)); - _nc_check_termtype(&qp->tterm); + if (fullresolve) + if (_nc_check_termtype != 0) { + _nc_curr_col = -1; + for_entry_list(qp) { + _nc_curr_line = qp->startline; + _nc_set_type(_nc_first_name(qp->tterm.term_names)); + _nc_check_termtype(&qp->tterm); + } + DEBUG(2, ("SANITY CHECK FINISHED")); } - DEBUG(2, ("SANITY CHECK FINISHED")); - } - return(TRUE); + return (TRUE); } /* @@ -447,14 +436,14 @@ int _nc_resolve_uses(void) #undef CUR #define CUR tp-> -static void sanity_check(TERMTYPE *tp) +static void +sanity_check(TERMTYPE * tp) { - if (!PRESENT(exit_attribute_mode)) - { -#ifdef __UNUSED__ /* this casts too wide a net */ - bool terminal_entry = !strchr(tp->term_names, '+'); + if (!PRESENT(exit_attribute_mode)) { +#ifdef __UNUSED__ /* this casts too wide a net */ + bool terminal_entry = !strchr(tp->term_names, '+'); if (terminal_entry && - (PRESENT(set_attributes) + (PRESENT(set_attributes) || PRESENT(enter_standout_mode) || PRESENT(enter_underline_mode) || PRESENT(enter_blink_mode) @@ -465,31 +454,31 @@ static void sanity_check(TERMTYPE *tp) || PRESENT(enter_reverse_mode))) _nc_warning("no exit_attribute_mode"); #endif /* __UNUSED__ */ - PAIRED(enter_standout_mode, exit_standout_mode) - PAIRED(enter_underline_mode, exit_underline_mode) + PAIRED(enter_standout_mode, exit_standout_mode) + PAIRED(enter_underline_mode, exit_underline_mode) } - /* listed in structure-member order of first argument */ - PAIRED(enter_alt_charset_mode, exit_alt_charset_mode) - ANDMISSING(enter_alt_charset_mode, acs_chars) - ANDMISSING(exit_alt_charset_mode, acs_chars) - ANDMISSING(enter_blink_mode, exit_attribute_mode) - ANDMISSING(enter_bold_mode, exit_attribute_mode) - PAIRED(exit_ca_mode, enter_ca_mode) - PAIRED(enter_delete_mode, exit_delete_mode) - ANDMISSING(enter_dim_mode, exit_attribute_mode) - PAIRED(enter_insert_mode, exit_insert_mode) - ANDMISSING(enter_secure_mode, exit_attribute_mode) - ANDMISSING(enter_protected_mode, exit_attribute_mode) - ANDMISSING(enter_reverse_mode, exit_attribute_mode) - PAIRED(from_status_line, to_status_line) - PAIRED(meta_off, meta_on) - - PAIRED(prtr_on, prtr_off) - PAIRED(save_cursor, restore_cursor) - PAIRED(enter_xon_mode, exit_xon_mode) - PAIRED(enter_am_mode, exit_am_mode) - ANDMISSING(label_off, label_on) - PAIRED(display_clock, remove_clock) - ANDMISSING(set_color_pair, initialize_pair) + /* listed in structure-member order of first argument */ + PAIRED(enter_alt_charset_mode, exit_alt_charset_mode) + ANDMISSING(enter_alt_charset_mode, acs_chars) + ANDMISSING(exit_alt_charset_mode, acs_chars) + ANDMISSING(enter_blink_mode, exit_attribute_mode) + ANDMISSING(enter_bold_mode, exit_attribute_mode) + PAIRED(exit_ca_mode, enter_ca_mode) + PAIRED(enter_delete_mode, exit_delete_mode) + ANDMISSING(enter_dim_mode, exit_attribute_mode) + PAIRED(enter_insert_mode, exit_insert_mode) + ANDMISSING(enter_secure_mode, exit_attribute_mode) + ANDMISSING(enter_protected_mode, exit_attribute_mode) + ANDMISSING(enter_reverse_mode, exit_attribute_mode) + PAIRED(from_status_line, to_status_line) + PAIRED(meta_off, meta_on) + + PAIRED(prtr_on, prtr_off) + PAIRED(save_cursor, restore_cursor) + PAIRED(enter_xon_mode, exit_xon_mode) + PAIRED(enter_am_mode, exit_am_mode) + ANDMISSING(label_off, label_on) + PAIRED(display_clock, remove_clock) + ANDMISSING(set_color_pair, initialize_pair) } diff --git a/lib/libcurses/tinfo/init_keytry.c b/lib/libcurses/tinfo/init_keytry.c index e19d49dbe43..d4c96517309 100644 --- a/lib/libcurses/tinfo/init_keytry.c +++ b/lib/libcurses/tinfo/init_keytry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_keytry.c,v 1.3 1999/11/28 18:05:38 millert Exp $ */ +/* $OpenBSD: init_keytry.c,v 1.4 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1999 Free Software Foundation, Inc. * @@ -34,7 +34,7 @@ /* cursor_visible,cursor_normal,cursor_invisible */ #include /* struct tinfo_fkeys */ -MODULE_ID("$From: init_keytry.c,v 1.2 1999/09/11 17:32:57 Jeffrey.Honig Exp $") +MODULE_ID("$From: init_keytry.c,v 1.3 2000/03/12 02:55:50 Todd.C.Miller Exp $") /* ** _nc_init_keytry() diff --git a/lib/libcurses/tinfo/lib_options.c b/lib/libcurses/tinfo/lib_options.c index 8641792431a..7a16334c5a2 100644 --- a/lib/libcurses/tinfo/lib_options.c +++ b/lib/libcurses/tinfo/lib_options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_options.c,v 1.6 2000/03/10 01:35:04 millert Exp $ */ +/* $OpenBSD: lib_options.c,v 1.7 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include -MODULE_ID("$From: lib_options.c,v 1.38 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: lib_options.c,v 1.39 2000/03/12 00:19:11 tom Exp $") int idlok(WINDOW *win, bool flag) @@ -52,7 +52,7 @@ idlok(WINDOW *win, bool flag) T((T_CALLED("idlok(%p,%d)"), win, flag)); if (win) { - _nc_idlok = win->_idlok = flag && (has_il() || change_scroll_region); + _nc_idlok = win->_idlok = (flag && (has_il() || change_scroll_region)); returnCode(OK); } else returnCode(ERR); @@ -64,7 +64,7 @@ idcok(WINDOW *win, bool flag) T((T_CALLED("idcok(%p,%d)"), win, flag)); if (win) - _nc_idcok = win->_idcok = flag && has_ic(); + _nc_idcok = win->_idcok = (flag && has_ic()); returnVoid; } diff --git a/lib/libcurses/tinfo/make_keys.c b/lib/libcurses/tinfo/make_keys.c index d85eef5e41a..1f36655815a 100644 --- a/lib/libcurses/tinfo/make_keys.c +++ b/lib/libcurses/tinfo/make_keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: make_keys.c,v 1.5 1999/11/28 18:05:38 millert Exp $ */ +/* $OpenBSD: make_keys.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -39,7 +39,7 @@ */ #include -MODULE_ID("$From: make_keys.c,v 1.7 1999/09/11 17:32:57 Jeffrey.Honig Exp $") +MODULE_ID("$From: make_keys.c,v 1.8 2000/03/12 02:55:50 Todd.C.Miller Exp $") #include diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c index 2293a69d821..3f03844dc48 100644 --- a/lib/libcurses/tinfo/parse_entry.c +++ b/lib/libcurses/tinfo/parse_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_entry.c,v 1.5 2000/03/10 01:35:04 millert Exp $ */ +/* $OpenBSD: parse_entry.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -49,7 +49,7 @@ #define __INTERNAL_CAPS_VISIBLE #include -MODULE_ID("$From: parse_entry.c,v 1.42 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: parse_entry.c,v 1.43 2000/03/12 00:09:06 tom Exp $") #ifdef LINT static short const parametrized[] = @@ -257,7 +257,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) token_type = _nc_get_token()) { if (strcmp(_nc_curr_token.tk_name, "use") == 0 || strcmp(_nc_curr_token.tk_name, "tc") == 0) { - entryp->uses[entryp->nuses].parent = (void *) _nc_save_str(_nc_curr_token.tk_valstring); + entryp->uses[entryp->nuses].name = _nc_save_str(_nc_curr_token.tk_valstring); entryp->uses[entryp->nuses].line = _nc_curr_line; entryp->nuses++; } else { @@ -458,7 +458,7 @@ _nc_parse_entry(struct entry *entryp, int literal, bool silent) * have picked up defaults via translation. */ for (i = 0; i < entryp->nuses; i++) - if (!strchr((char *) entryp->uses[i].parent, '+')) + if (!strchr((char *) entryp->uses[i].name, '+')) has_base_entry = TRUE; postprocess_termcap(&entryp->tterm, has_base_entry); diff --git a/lib/libcurses/tinfo/read_entry.c b/lib/libcurses/tinfo/read_entry.c index d5de19e42b6..f4d07feaf50 100644 --- a/lib/libcurses/tinfo/read_entry.c +++ b/lib/libcurses/tinfo/read_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read_entry.c,v 1.8 2000/03/10 01:35:04 millert Exp $ */ +/* $OpenBSD: read_entry.c,v 1.9 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -43,7 +43,7 @@ #include #include -MODULE_ID("$From: read_entry.c,v 1.66 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: read_entry.c,v 1.67 2000/03/11 12:35:45 tom Exp $") #if !HAVE_TELL #define tell(fd) 0 /* lseek() is POSIX, but not tell() - odd... */ @@ -359,7 +359,9 @@ read_termtype(int fd, TERMTYPE * ptr) { T(("...done reading terminfo bool %d num %d str %d", bool_count, num_count, str_count)); +#if NCURSES_XNAMES TR(TRACE_DATABASE, ("normal: num_Booleans:%d", ptr->num_Booleans)); +#endif } for (i = bool_count; i < BOOLCOUNT; i++) diff --git a/lib/libcurses/tinfo/read_termcap.c b/lib/libcurses/tinfo/read_termcap.c index 07dd5af175e..d127ef7a0fa 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.5 2000/03/10 01:35:04 millert Exp $ */ +/* $OpenBSD: read_termcap.c,v 1.6 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -1044,7 +1044,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp) return (ERR); /* resolve all use references */ - _nc_resolve_uses(); + _nc_resolve_uses(TRUE); /* find a terminal matching tn, if we can */ #if USE_GETCAP_CACHE diff --git a/lib/libcurses/tinfo/write_entry.c b/lib/libcurses/tinfo/write_entry.c index f73548f95bd..fb9599ddb43 100644 --- a/lib/libcurses/tinfo/write_entry.c +++ b/lib/libcurses/tinfo/write_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: write_entry.c,v 1.7 2000/03/10 01:35:04 millert Exp $ */ +/* $OpenBSD: write_entry.c,v 1.8 2000/03/13 23:53:40 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * @@ -54,7 +54,7 @@ #define TRACE_OUT(p) /*nothing */ #endif -MODULE_ID("$From: write_entry.c,v 1.51 2000/02/13 01:01:26 tom Exp $") +MODULE_ID("$From: write_entry.c,v 1.52 2000/03/11 12:23:42 tom Exp $") static int total_written; @@ -427,7 +427,7 @@ write_object(FILE * fp, TERMTYPE * tp) boolmax = 0; for (i = 0; i < last_bool; i++) { - if (tp->Booleans[i]) + if (tp->Booleans[i] == TRUE) boolmax = i + 1; } @@ -456,8 +456,15 @@ write_object(FILE * fp, TERMTYPE * tp) /* write out the header */ TRACE_OUT(("Header of %s @%ld", namelist, ftell(fp))); if (fwrite(buf, 12, 1, fp) != 1 - || fwrite(namelist, sizeof(char), namelen, fp) != namelen - || fwrite(tp->Booleans, sizeof(char), boolmax, fp) != boolmax) + || fwrite(namelist, sizeof(char), namelen, fp) != namelen) + return (ERR); + + for (i = 0; i < boolmax; i++) + if (tp->Booleans[i] == TRUE) + buf[i] = TRUE; + else + buf[i] = FALSE; + if (fwrite(buf, sizeof(char), boolmax, fp) != boolmax) return (ERR); if (even_boundary(namelen + boolmax)) diff --git a/usr.bin/infocmp/infocmp.1tbl b/usr.bin/infocmp/infocmp.1tbl index a63627556be..227a9174c01 100644 --- a/usr.bin/infocmp/infocmp.1tbl +++ b/usr.bin/infocmp/infocmp.1tbl @@ -1,8 +1,8 @@ '\" t -.\" $OpenBSD: infocmp.1tbl,v 1.6 2000/01/08 06:26:24 millert Exp $ +.\" $OpenBSD: infocmp.1tbl,v 1.7 2000/03/13 23:53:41 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 * @@ -29,14 +29,14 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $From: infocmp.1m,v 1.21 1999/06/15 23:12:25 tom Exp $ +.\" $From: infocmp.1m,v 1.23 2000/03/12 02:52:56 tom Exp $ .TH infocmp 1 "" .ds n 5 .ds d /usr/share/terminfo .SH NAME \fBinfocmp\fR - compare or print out \fIterminfo\fR descriptions .SH SYNOPSIS -\fBinfocmp\fR [\fB-dceEGgnpILCuV1\fR] [\fB-v\fR \fIn\fR] [\fB-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] +\fBinfocmp\fR [\fB-dceEGgnpqrILCuV1\fR] [\fB-v\fR \fIn\fR] [\fB-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] .br [\fB-w\fR\ \fIwidth\fR] [\fB-A\fR\ \fIdirectory\fR] [\fB-B\fR\ \fIdirectory\fR] .br @@ -215,12 +215,19 @@ filenames. The files are searched for pairwise matches between entries, with two entries considered to match if any of their names do. The report printed to standard output lists entries with no matches in the other file, and entries with more than one match. For entries -with exactly one match it includes a difference report. +with exactly one match it includes a difference report. Normally, +to reduce the volume of the report, use references are +not resolved before looking for differences, but resolution can be forced +by also specifying \fB-r\fR. .TP \fB-G\fR Display constant literals in decimal form rather than their character equivalents. .TP 5 +\fB-q\fR +Make the comparison listing shorter by omitting subheadings, and using +"-" for absent capabilities, "@" for cancelled rather than "NULL". +.TP 5 \fB-R\fR\fIsubset\fR Restrict output to a given subset. This option is for use with archaic versions of terminfo like those on SVr1, Ultrix, or HP/UX that don't support @@ -341,8 +348,9 @@ The \fB-e\fR, \fB-f\fR, \fB-g\fR, -\fB-i\fR, and -\fB-p\fR +\fB-i\fR, +\fB-p\fR, and +\fB-q\fR options are not supported in SVr4 curses. The \fB-r\fR option's notion of `termcap' capabilities is System V Release 4's. diff --git a/usr.bin/infocmp/infocmp.c b/usr.bin/infocmp/infocmp.c index 76a1ebe94cb..f684a048bd9 100644 --- a/usr.bin/infocmp/infocmp.c +++ b/usr.bin/infocmp/infocmp.c @@ -1,7 +1,7 @@ -/* $OpenBSD: infocmp.c,v 1.8 2000/01/16 01:35:19 millert Exp $ */ +/* $OpenBSD: infocmp.c,v 1.9 2000/03/13 23:53:41 millert Exp $ */ /**************************************************************************** - * Copyright (c) 1998-2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,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 * @@ -43,12 +43,13 @@ #include #include -MODULE_ID("$From: infocmp.c,v 1.48 2000/01/15 22:46:12 tom Exp $") +MODULE_ID("$From: infocmp.c,v 1.52 2000/03/12 02:34:09 tom Exp $") #define L_CURL "{" #define R_CURL "}" #define MAXTERMS 32 /* max # terminal arguments we can handle */ +#define MAX_STRING 1024 /* maximum formatted string */ const char *_nc_progname = "infocmp"; @@ -62,15 +63,20 @@ typedef char path[PATH_MAX]; ***************************************************************************/ static char *tname[MAXTERMS]; /* terminal type names */ -static TERMTYPE term[MAXTERMS]; /* terminfo entries */ +static ENTRY entries[MAXTERMS]; /* terminfo entries */ static int termcount; /* count of terminal entries */ +static bool limited = TRUE; /* "-r" option is not set */ +static bool quiet = FALSE; +static char *bool_sep = ":"; +static char *s_absent = "NULL"; +static char *s_cancel = "NULL"; static const char *tversion; /* terminfo version selected */ -static int numbers = 0; /* format "%'char'" to/from "%{number}" */ -static int outform = F_TERMINFO; /* output format */ -static int sortmode; /* sort_mode */ static int itrace; /* trace flag for debugging */ static int mwidth = 60; +static int numbers = 0; /* format "%'char'" to/from "%{number}" */ +static int outform = F_TERMINFO;/* output format */ +static int sortmode; /* sort_mode */ /* main comparison mode */ static int compare; @@ -90,7 +96,7 @@ static void ExitProgram(int code) { while (termcount-- > 0) - _nc_free_termtype(&term[termcount]); + _nc_free_termtype(&entries[termcount].tterm); _nc_leaks_dump_entry(); _nc_free_and_exit(code); } @@ -103,7 +109,7 @@ canonical_name(char *ptr, char *buf) char *bp; (void) strcpy(buf, ptr); - if ((bp = strchr(buf, '|')) != (char *) NULL) + if ((bp = strchr(buf, '|')) != 0) *bp = '\0'; return (buf); @@ -116,28 +122,29 @@ canonical_name(char *ptr, char *buf) ***************************************************************************/ static int -capcmp(const char *s, const char *t) +capcmp(int idx, const char *s, const char *t) /* capability comparison function */ { if (!VALID_STRING(s) && !VALID_STRING(t)) - return (0); + return (s != t); else if (!VALID_STRING(s) || !VALID_STRING(t)) return (1); - if (ignorepads) - return (_nc_capcmp(s, t)); - else + if ((idx == acs_chars_index) || !ignorepads) return (strcmp(s, t)); + else + return (_nc_capcmp(s, t)); } static int use_predicate(int type, int idx) /* predicate function to use for use decompilation */ { - TERMTYPE *tp; + ENTRY *ep; switch (type) { - case BOOLEAN:{ + case BOOLEAN: + { int is_set = FALSE; /* @@ -146,19 +153,24 @@ use_predicate(int type, int idx) * This is true if we take the semantics of multiple uses to * be 'each capability gets the first non-default value found * in the sequence of use entries'. + * + * Note that cancelled or absent booleans are stored as FALSE, + * unlike numbers and strings, whose cancelled/absent state is + * recorded in the terminfo database. */ - for (tp = &term[1]; tp < term + termcount; tp++) - if (tp->Booleans[idx]) { - is_set = TRUE; + for (ep = &entries[1]; ep < entries + termcount; ep++) + if (ep->tterm.Booleans[idx] == TRUE) { + is_set = entries[0].tterm.Booleans[idx]; break; } - if (is_set != term->Booleans[idx]) + if (is_set != entries[0].tterm.Booleans[idx]) return (!is_set); else return (FAIL); } - case NUMBER:{ + case NUMBER: + { int value = ABSENT_NUMERIC; /* @@ -166,37 +178,38 @@ use_predicate(int type, int idx) * capability gets the first non-default value found * in the sequence of use entries'. */ - for (tp = &term[1]; tp < term + termcount; tp++) - if (tp->Numbers[idx] >= 0) { - value = tp->Numbers[idx]; + for (ep = &entries[1]; ep < entries + termcount; ep++) + if (VALID_NUMERIC(ep->tterm.Numbers[idx])) { + value = ep->tterm.Numbers[idx]; break; } - if (value != term->Numbers[idx]) + if (value != entries[0].tterm.Numbers[idx]) return (value != ABSENT_NUMERIC); else return (FAIL); } - case STRING:{ + case STRING: + { char *termstr, *usestr = ABSENT_STRING; - termstr = term->Strings[idx]; + termstr = entries[0].tterm.Strings[idx]; /* * We take the semantics of multiple uses to be 'each * capability gets the first non-default value found * in the sequence of use entries'. */ - for (tp = &term[1]; tp < term + termcount; tp++) - if (tp->Strings[idx]) { - usestr = tp->Strings[idx]; + for (ep = &entries[1]; ep < entries + termcount; ep++) + if (ep->tterm.Strings[idx]) { + usestr = ep->tterm.Strings[idx]; break; } if (usestr == ABSENT_STRING && termstr == ABSENT_STRING) return (FAIL); - else if (!usestr || !termstr || capcmp(usestr, termstr)) + else if (!usestr || !termstr || capcmp(idx, usestr, termstr)) return (TRUE); else return (FAIL); @@ -206,9 +219,36 @@ use_predicate(int type, int idx) return (FALSE); /* pacify compiler */ } +static bool +useeq(ENTRY * e1, ENTRY * e2) +/* are the use references in two entries equivalent? */ +{ + int i, j; + + if (e1->nuses != e2->nuses) + return (FALSE); + + /* Ugh...this is quadratic again */ + for (i = 0; i < e1->nuses; i++) { + bool foundmatch = FALSE; + + /* search second entry for given use reference */ + for (j = 0; j < e2->nuses; j++) + if (!strcmp(e1->uses[i].name, e2->uses[j].name)) { + foundmatch = TRUE; + break; + } + + if (!foundmatch) + return (FALSE); + } + + return (TRUE); +} + static bool entryeq(TERMTYPE * t1, TERMTYPE * t2) -/* are two terminal types equal */ +/* are two entries equivalent? */ { int i; @@ -221,7 +261,7 @@ entryeq(TERMTYPE * t1, TERMTYPE * t2) return (FALSE); for (i = 0; i < NUM_STRINGS(t1); i++) - if (capcmp(t1->Strings[i], t2->Strings[i])) + if (capcmp(i, t1->Strings[i], t2->Strings[i])) return (FALSE); return (TRUE); @@ -229,90 +269,145 @@ entryeq(TERMTYPE * t1, TERMTYPE * t2) #define TIC_EXPAND(result) _nc_tic_expand(result, outform==F_TERMINFO, numbers) +static void +print_uses(ENTRY * ep, FILE * fp) +/* print an entry's use references */ +{ + int i; + + if (!ep->nuses) + fputs("NULL", fp); + else + for (i = 0; i < ep->nuses; i++) { + fputs(ep->uses[i].name, fp); + if (i < ep->nuses - 1) + fputs(" ", fp); + } +} + +static char * +dump_boolean(int val) +/* display the value of a boolean capability */ +{ + switch (val) { + case ABSENT_BOOLEAN: + return (s_absent); + case CANCELLED_BOOLEAN: + return (s_cancel); + case FALSE: + return ("F"); + case TRUE: + return ("T"); + default: + return ("?"); + } +} + +static void +dump_numeric(int val, char *buf) +/* display the value of a boolean capability */ +{ + switch (val) { + case ABSENT_NUMERIC: + strcpy(buf, s_absent); + break; + case CANCELLED_NUMERIC: + strcpy(buf, s_cancel); + break; + default: + sprintf(buf, "%d", val); + break; + } +} + +static void +dump_string(char *val, char *buf) +/* display the value of a string capability */ +{ + if (val == ABSENT_STRING) + strcpy(buf, s_absent); + else if (val == CANCELLED_STRING) + strcpy(buf, s_cancel); + else { + sprintf(buf, "'%.*s'", MAX_STRING - 3, TIC_EXPAND(val)); + } +} + static void compare_predicate(int type, int idx, const char *name) /* predicate function to use for entry difference reports */ { - register TERMTYPE *t1 = &term[0]; - register TERMTYPE *t2 = &term[1]; + register ENTRY *e1 = &entries[0]; + register ENTRY *e2 = &entries[1]; + char buf1[MAX_STRING], buf2[MAX_STRING]; + int b1, b2; + int n1, n2; char *s1, *s2; switch (type) { - case BOOLEAN: + case CMP_BOOLEAN: + b1 = e1->tterm.Booleans[idx]; + b2 = e2->tterm.Booleans[idx]; switch (compare) { case C_DIFFERENCE: - if (t1->Booleans[idx] != t2->Booleans[idx]) - (void) printf("\t%s: %c:%c.\n", + if (!(b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) && b1 != b2) + (void) printf("\t%s: %s%s%s.\n", name, - t1->Booleans[idx] ? 'T' : 'F', - t2->Booleans[idx] ? 'T' : 'F'); + dump_boolean(b1), + bool_sep, + dump_boolean(b2)); break; case C_COMMON: - if (t1->Booleans[idx] && t2->Booleans[idx]) - (void) printf("\t%s= T.\n", name); + if (b1 == b2 && b1 != ABSENT_BOOLEAN) + (void) printf("\t%s= %s.\n", name, dump_boolean(b1)); break; case C_NAND: - if (!t1->Booleans[idx] && !t2->Booleans[idx]) + if (b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) (void) printf("\t!%s.\n", name); break; } break; - case NUMBER: + case CMP_NUMBER: + n1 = e1->tterm.Numbers[idx]; + n2 = e2->tterm.Numbers[idx]; + dump_numeric(n1, buf1); + dump_numeric(n2, buf2); switch (compare) { case C_DIFFERENCE: - if (t1->Numbers[idx] != t2->Numbers[idx]) - (void) printf("\t%s: %d:%d.\n", - name, t1->Numbers[idx], t2->Numbers[idx]); + if (!((n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)) && n1 != n2) + (void) printf("\t%s: %s, %s.\n", name, buf1, buf2); break; case C_COMMON: - if (t1->Numbers[idx] != -1 && t2->Numbers[idx] != -1 - && t1->Numbers[idx] == t2->Numbers[idx]) - (void) printf("\t%s= %d.\n", name, t1->Numbers[idx]); + if (n1 != ABSENT_NUMERIC && n2 != ABSENT_NUMERIC && n1 == n2) + (void) printf("\t%s= %s.\n", name, buf1); break; case C_NAND: - if (t1->Numbers[idx] == -1 && t2->Numbers[idx] == -1) + if (n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC) (void) printf("\t!%s.\n", name); break; } break; - case STRING: - s1 = t1->Strings[idx]; - s2 = t2->Strings[idx]; + case CMP_STRING: + s1 = e1->tterm.Strings[idx]; + s2 = e2->tterm.Strings[idx]; switch (compare) { case C_DIFFERENCE: - if (capcmp(s1, s2)) { - char buf1[BUFSIZ], buf2[BUFSIZ]; - - if (s1 == (char *) NULL) - (void) strcpy(buf1, "NULL"); - else { - (void) strcpy(buf1, "'"); - (void) strcat(buf1, TIC_EXPAND(s1)); - (void) strcat(buf1, "'"); - } - - if (s2 == (char *) NULL) - (void) strcpy(buf2, "NULL"); - else { - (void) strcpy(buf2, "'"); - (void) strcat(buf2, TIC_EXPAND(s2)); - (void) strcat(buf2, "'"); - } - + if (capcmp(idx, s1, s2)) { + dump_string(s1, buf1); + dump_string(s2, buf2); if (strcmp(buf1, buf2)) - (void) printf("\t%s: %s, %s.\n", - name, buf1, buf2); + (void) printf("\t%s: %s, %s.\n", name, buf1, buf2); } break; case C_COMMON: - if (s1 && s2 && !capcmp(s1, s2)) + if (s1 && s2 && !capcmp(idx, s1, s2)) (void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1)); break; @@ -322,8 +417,34 @@ compare_predicate(int type, int idx, const char *name) break; } break; - } + case CMP_USE: + /* unlike the other modes, this compares *all* use entries */ + switch (compare) { + case C_DIFFERENCE: + if (!useeq(e1, e2)) { + (void) fputs("\tuse: ", stdout); + print_uses(e1, stdout); + fputs(", ", stdout); + print_uses(e2, stdout); + fputs(".\n", stdout); + } + break; + + case C_COMMON: + if (e1->nuses && e2->nuses && useeq(e1, e2)) { + (void) fputs("\tuse: ", stdout); + print_uses(e1, stdout); + fputs(".\n", stdout); + } + break; + + case C_NAND: + if (!e1->nuses && !e2->nuses) + (void) printf("\t!use.\n"); + break; + } + } } /*************************************************************************** @@ -507,7 +628,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE * tp) (void) strcat(buf2, ep); (void) strcat(buf2, ";"); } while - ((ep = strtok((char *) NULL, ";"))); + ((ep = strtok((char *) 0, ";"))); buf2[strlen(buf2) - 1] = '\0'; expansion = buf2; } @@ -542,7 +663,7 @@ analyze_string(const char *name, const char *cap, TERMTYPE * tp) (void) strcat(buf2, ep); (void) strcat(buf2, ";"); } while - ((ep = strtok((char *) NULL, ";"))); + ((ep = strtok((char *) 0, ";"))); buf2[strlen(buf2) - 1] = '\0'; expansion = buf2; @@ -595,13 +716,13 @@ file_comparison(int argc, char *argv[]) ENTRY *qp, *rp; int i, n; - dump_init((char *) NULL, F_LITERAL, S_TERMINFO, 0, itrace, FALSE); + dump_init((char *) 0, F_LITERAL, S_TERMINFO, 0, itrace, FALSE); for (n = 0; n < argc && n < MAXCOMPARE; n++) { - if (freopen(argv[n], "r", stdin) == NULL) + if (freopen(argv[n], "r", stdin) == 0) _nc_err_abort("Can't open %s", argv[n]); - _nc_head = _nc_tail = (ENTRY *) NULL; + _nc_head = _nc_tail = 0; /* parse entries out of the source file */ _nc_set_source(argv[n]); @@ -610,15 +731,16 @@ file_comparison(int argc, char *argv[]) if (itrace) (void) fprintf(stderr, "Resolving file %d...\n", n - 0); - /* do use resolution */ - if (!_nc_resolve_uses()) { + /* maybe do use resolution */ + if (!_nc_resolve_uses(!limited)) { (void) fprintf(stderr, "There are unresolved use entries in %s:\n", argv[n]); - for_entry_list(qp) + for_entry_list(qp) { if (qp->nuses) { - (void) fputs(qp->tterm.term_names, stderr); - (void) fputc('\n', stderr); + (void) fputs(qp->tterm.term_names, stderr); + (void) fputc('\n', stderr); + } } exit(EXIT_FAILURE); } @@ -632,28 +754,17 @@ file_comparison(int argc, char *argv[]) if (itrace) (void) fprintf(stderr, "Entries are now in core...\n"); - /* - * The entry-matching loop. We're not using the use[] - * slots any more (they got zeroed out by resolve_uses) so - * we stash each entry's matches in the other file there. - * Sigh, this is intrinsically quadratic. - */ + /* The entry-matching loop. Sigh, this is intrinsically quadratic. */ for (qp = heads[0]; qp; qp = qp->next) { for (rp = heads[1]; rp; rp = rp->next) if (_nc_entry_match(qp->tterm.term_names, rp->tterm.term_names)) { - /* - * This is why the uses structure parent element is - * (void *) -- so we can have either (char *) for - * names or entry structure pointers in them and still - * be type-safe. - */ - if (qp->nuses < MAX_USES) - qp->uses[qp->nuses].parent = (void *) rp; - qp->nuses++; + if (qp->ncrosslinks < MAX_CROSSLINKS) + qp->crosslinks[qp->ncrosslinks] = rp; + qp->ncrosslinks++; - if (rp->nuses < MAX_USES) - rp->uses[rp->nuses].parent = (void *) qp; - rp->nuses++; + if (rp->ncrosslinks < MAX_CROSSLINKS) + rp->crosslinks[rp->ncrosslinks] = qp; + rp->ncrosslinks++; } } @@ -661,101 +772,116 @@ file_comparison(int argc, char *argv[]) if (itrace) (void) fprintf(stderr, "Name matches are done...\n"); - for (qp = heads[0]; qp; qp = qp->next) - if (qp->nuses > 1) { + for (qp = heads[0]; qp; qp = qp->next) { + if (qp->ncrosslinks > 1) { (void) fprintf(stderr, "%s in file 1 (%s) has %d matches in file 2 (%s):\n", _nc_first_name(qp->tterm.term_names), argv[0], - qp->nuses, + qp->ncrosslinks, argv[1]); - for (i = 0; i < qp->nuses; i++) + for (i = 0; i < qp->ncrosslinks; i++) (void) fprintf(stderr, "\t%s\n", - _nc_first_name(((ENTRY *) qp->uses[i].parent)->tterm.term_names)); + _nc_first_name((qp->crosslinks[i])->tterm.term_names)); } - for (rp = heads[1]; rp; rp = rp->next) - if (rp->nuses > 1) { + } + + for (rp = heads[1]; rp; rp = rp->next) { + if (rp->ncrosslinks > 1) { (void) fprintf(stderr, "%s in file 2 (%s) has %d matches in file 1 (%s):\n", _nc_first_name(rp->tterm.term_names), argv[1], - rp->nuses, + rp->ncrosslinks, argv[0]); - for (i = 0; i < rp->nuses; i++) + for (i = 0; i < rp->ncrosslinks; i++) (void) fprintf(stderr, "\t%s\n", - _nc_first_name(((ENTRY *) rp->uses[i].parent)->tterm.term_names)); + _nc_first_name((rp->crosslinks[i])->tterm.term_names)); } + } (void) printf("In file 1 (%s) only:\n", argv[0]); for (qp = heads[0]; qp; qp = qp->next) - if (qp->nuses == 0) + if (qp->ncrosslinks == 0) (void) printf("\t%s\n", _nc_first_name(qp->tterm.term_names)); (void) printf("In file 2 (%s) only:\n", argv[1]); for (rp = heads[1]; rp; rp = rp->next) - if (rp->nuses == 0) + if (rp->ncrosslinks == 0) (void) printf("\t%s\n", _nc_first_name(rp->tterm.term_names)); (void) printf("The following entries are equivalent:\n"); for (qp = heads[0]; qp; qp = qp->next) { - rp = (ENTRY *) qp->uses[0].parent; + rp = qp->crosslinks[0]; + + if (qp->ncrosslinks == 1) { + rp = qp->crosslinks[0]; - if (qp->nuses == 1 && entryeq(&qp->tterm, &rp->tterm)) { - char name1[NAMESIZE], name2[NAMESIZE]; + repair_acsc(&qp->tterm); + repair_acsc(&rp->tterm); +#if NCURSES_XNAMES + _nc_align_termtype(&qp->tterm, &rp->tterm); +#endif + if (entryeq(&qp->tterm, &rp->tterm) && useeq(qp, rp)) { + char name1[NAMESIZE], name2[NAMESIZE]; - (void) canonical_name(qp->tterm.term_names, name1); - (void) canonical_name(rp->tterm.term_names, name2); + (void) canonical_name(qp->tterm.term_names, name1); + (void) canonical_name(rp->tterm.term_names, name2); - (void) printf("%s = %s\n", name1, name2); + (void) printf("%s = %s\n", name1, name2); + } } } (void) printf("Differing entries:\n"); termcount = 2; for (qp = heads[0]; qp; qp = qp->next) { - rp = (ENTRY *) qp->uses[0].parent; + if (qp->ncrosslinks == 1) { + rp = qp->crosslinks[0]; #if NCURSES_XNAMES - if (termcount > 1) + /* sorry - we have to do this on each pass */ _nc_align_termtype(&qp->tterm, &rp->tterm); #endif - if (qp->nuses == 1 && !entryeq(&qp->tterm, &rp->tterm)) { - char name1[NAMESIZE], name2[NAMESIZE]; + if (!(entryeq(&qp->tterm, &rp->tterm) && useeq(qp, rp))) { + char name1[NAMESIZE], name2[NAMESIZE]; - term[0] = qp->tterm; - term[1] = rp->tterm; + entries[0] = *qp; + entries[1] = *rp; - (void) canonical_name(qp->tterm.term_names, name1); - (void) canonical_name(rp->tterm.term_names, name2); + (void) canonical_name(qp->tterm.term_names, name1); + (void) canonical_name(rp->tterm.term_names, name2); - switch (compare) { - case C_DIFFERENCE: - if (itrace) - (void) fprintf(stderr, "infocmp: dumping differences\n"); - (void) printf("comparing %s to %s.\n", name1, name2); - compare_entry(compare_predicate, term); - break; + switch (compare) { + case C_DIFFERENCE: + if (itrace) + (void) fprintf(stderr, + "infocmp: dumping differences\n"); + (void) printf("comparing %s to %s.\n", name1, name2); + compare_entry(compare_predicate, &entries->tterm, quiet); + break; - case C_COMMON: - if (itrace) - (void) fprintf(stderr, - "infocmp: dumping common capabilities\n"); - (void) printf("comparing %s to %s.\n", name1, name2); - compare_entry(compare_predicate, term); - break; + case C_COMMON: + if (itrace) + (void) fprintf(stderr, + "infocmp: dumping common capabilities\n"); + (void) printf("comparing %s to %s.\n", name1, name2); + compare_entry(compare_predicate, &entries->tterm, quiet); + break; - case C_NAND: - if (itrace) - (void) fprintf(stderr, - "infocmp: dumping differences\n"); - (void) printf("comparing %s to %s.\n", name1, name2); - compare_entry(compare_predicate, term); - break; + case C_NAND: + if (itrace) + (void) fprintf(stderr, + "infocmp: dumping differences\n"); + (void) printf("comparing %s to %s.\n", name1, name2); + compare_entry(compare_predicate, &entries->tterm, quiet); + break; + } } } } @@ -788,7 +914,9 @@ usage(void) ," -l output terminfo names" ," -n list capabilities in neither" ," -p ignore padding specifiers" + ," -q brief listing, removes headers" ," -r with -C, output in termcap form" + ," -r with -F, resolve use-references" ," -s [d|i|l|c] sort fields" ," -u produce source with 'use='" ," -v number (verbose)" @@ -816,9 +944,9 @@ name_initializer(const char *type) char *s; if (initializer == 0) - initializer = malloc(strlen(term->term_names) + 20); + initializer = (char *) malloc(strlen(entries->tterm.term_names) + 20); - (void) sprintf(initializer, "%s_data_%s", type, term->term_names); + (void) sprintf(initializer, "%s_data_%s", type, entries->tterm.term_names); for (s = initializer; *s != 0 && *s != '|'; s++) { if (!isalnum(*s)) *s = '_'; @@ -829,7 +957,7 @@ name_initializer(const char *type) /* dump C initializers for the terminal type */ static void -dump_initializers(void) +dump_initializers(TERMTYPE * term) { int n; const char *str = 0; @@ -888,7 +1016,7 @@ dump_initializers(void) (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL); for_each_string(n, term) { - char buf[BUFSIZ], *sp, *tp; + char buf[MAX_STRING], *sp, *tp; if (term->Strings[n] == ABSENT_STRING) str = "ABSENT_STRING"; @@ -897,7 +1025,9 @@ dump_initializers(void) else { tp = buf; *tp++ = '"'; - for (sp = term->Strings[n]; *sp; sp++) { + for (sp = term->Strings[n]; + *sp != 0 && (tp - buf) < MAX_STRING - 6; + sp++) { if (isascii(*sp) && isprint(*sp) && *sp != '\\' && *sp != '"') *tp++ = *sp; else { @@ -926,7 +1056,7 @@ dump_initializers(void) /* dump C initializers for the terminal type */ static void -dump_termtype(void) +dump_termtype(TERMTYPE * term) { (void) printf("\t%s\n\t\t\"%s\",\n", L_CURL, term->term_names); (void) printf("\t\t(char *)0,\t/* pointer to string table */\n"); @@ -972,15 +1102,14 @@ main(int argc, char *argv[]) char *terminal, *firstdir, *restdir; /* Avoid "local data >32k" error with mwcc */ /* Also avoid overflowing smaller stacks on systems like AmigaOS */ - path *tfile = malloc(sizeof(path) * MAXTERMS); + path *tfile = (path *) malloc(sizeof(path) * MAXTERMS); int c, i, len; bool formatted = FALSE; bool filecompare = FALSE; int initdump = 0; bool init_analyze = FALSE; - bool limited = TRUE; - if ((terminal = getenv("TERM")) == NULL) { + if ((terminal = getenv("TERM")) == 0) { (void) fprintf(stderr, "infocmp: environment variable TERM not set\n"); return EXIT_FAILURE; @@ -989,7 +1118,7 @@ main(int argc, char *argv[]) /* where is the terminfo database location going to default to? */ restdir = firstdir = 0; - while ((c = getopt(argc, argv, "deEcCfFGgIinlLprR:s:uv:Vw:A:B:1T")) != EOF) + while ((c = getopt(argc, argv, "deEcCfFGgIinlLpqrR:s:uv:Vw:A:B:1T")) != EOF) switch (c) { case 'd': compare = C_DIFFERENCE; @@ -1059,6 +1188,13 @@ main(int argc, char *argv[]) ignorepads = TRUE; break; + case 'q': + quiet = TRUE; + s_absent = "-"; + s_cancel = "@"; + bool_sep = ", "; + break; + case 'r': tversion = 0; limited = FALSE; @@ -1164,7 +1300,7 @@ main(int argc, char *argv[]) argv[optind], tfile[termcount]); status = _nc_read_file_entry(tfile[termcount], - &term[termcount]); + &entries[termcount].tterm); } else { if (itrace) (void) fprintf(stderr, @@ -1173,7 +1309,7 @@ main(int argc, char *argv[]) status = _nc_read_entry(tname[termcount], tfile[termcount], - &term[termcount]); + &entries[termcount].tterm); directory = TERMINFO; /* for error message */ } @@ -1183,36 +1319,37 @@ main(int argc, char *argv[]) tfile[termcount]); return EXIT_FAILURE; } + repair_acsc(&entries[termcount].tterm); termcount++; } } #if NCURSES_XNAMES if (termcount > 1) - _nc_align_termtype(&term[0], &term[1]); + _nc_align_termtype(&entries[0].tterm, &entries[1].tterm); #endif /* dump as C initializer for the terminal type */ if (initdump) { if (initdump & 1) - dump_termtype(); + dump_termtype(&entries[0].tterm); if (initdump & 2) - dump_initializers(); + dump_initializers(&entries[0].tterm); ExitProgram(EXIT_SUCCESS); } /* analyze the init strings */ if (init_analyze) { #undef CUR -#define CUR term[0]. - analyze_string("is1", init_1string, &term[0]); - analyze_string("is2", init_2string, &term[0]); - analyze_string("is3", init_3string, &term[0]); - analyze_string("rs1", reset_1string, &term[0]); - analyze_string("rs2", reset_2string, &term[0]); - analyze_string("rs3", reset_3string, &term[0]); - analyze_string("smcup", enter_ca_mode, &term[0]); - analyze_string("rmcup", exit_ca_mode, &term[0]); +#define CUR entries[0].tterm. + analyze_string("is1", init_1string, &entries[0].tterm); + analyze_string("is2", init_2string, &entries[0].tterm); + analyze_string("is3", init_3string, &entries[0].tterm); + analyze_string("rs1", reset_1string, &entries[0].tterm); + analyze_string("rs2", reset_2string, &entries[0].tterm); + analyze_string("rs3", reset_3string, &entries[0].tterm); + analyze_string("smcup", enter_ca_mode, &entries[0].tterm); + analyze_string("rmcup", exit_ca_mode, &entries[0].tterm); #undef CUR ExitProgram(EXIT_SUCCESS); } @@ -1228,7 +1365,7 @@ main(int argc, char *argv[]) tname[0]); (void) printf("#\tReconstructed via infocmp from file: %s\n", tfile[0]); - len = dump_entry(&term[0], limited, numbers, NULL); + len = dump_entry(&entries[0].tterm, limited, numbers, NULL); putchar('\n'); if (itrace) (void) fprintf(stderr, "infocmp: length %d\n", len); @@ -1238,7 +1375,7 @@ main(int argc, char *argv[]) if (itrace) (void) fprintf(stderr, "infocmp: dumping differences\n"); (void) printf("comparing %s to %s.\n", tname[0], tname[1]); - compare_entry(compare_predicate, term); + compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_COMMON: @@ -1246,7 +1383,7 @@ main(int argc, char *argv[]) (void) fprintf(stderr, "infocmp: dumping common capabilities\n"); (void) printf("comparing %s to %s.\n", tname[0], tname[1]); - compare_entry(compare_predicate, term); + compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_NAND: @@ -1254,13 +1391,13 @@ main(int argc, char *argv[]) (void) fprintf(stderr, "infocmp: dumping differences\n"); (void) printf("comparing %s to %s.\n", tname[0], tname[1]); - compare_entry(compare_predicate, term); + compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_USEALL: if (itrace) (void) fprintf(stderr, "infocmp: dumping use entry\n"); - len = dump_entry(&term[0], limited, numbers, use_predicate); + len = dump_entry(&entries[0].tterm, limited, numbers, use_predicate); for (i = 1; i < termcount; i++) len += dump_uses(tname[i], !(outform == F_TERMCAP || outform == F_TCONVERR)); diff --git a/usr.bin/tic/dump_entry.c b/usr.bin/tic/dump_entry.c index 248fc9c9646..6282378922f 100644 --- a/usr.bin/tic/dump_entry.c +++ b/usr.bin/tic/dump_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump_entry.c,v 1.13 2000/01/09 05:06:02 millert Exp $ */ +/* $OpenBSD: dump_entry.c,v 1.14 2000/03/13 23:53:41 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998-2000 Free Software Foundation, Inc. * @@ -40,7 +40,7 @@ #include /* this C file is generated */ #include /* so is this */ -MODULE_ID("$From: dump_entry.c,v 1.45 2000/01/08 22:19:05 Todd.Miller Exp $") +MODULE_ID("$From: dump_entry.c,v 1.48 2000/03/12 02:33:01 tom Exp $") #define INDENT 8 #define DISCARD(string) string = ABSENT_STRING @@ -249,7 +249,6 @@ dump_predicate(int type, int idx) } static void set_obsolete_termcaps(TERMTYPE * tp); -static void repair_acsc(TERMTYPE * tp); /* is this the index of a function key string? */ #define FNKEY(i) (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268)) @@ -566,7 +565,6 @@ fmt_entry(TERMTYPE * tterm, if (len & 1) len++; - repair_acsc(tterm); for_each_string(j, tterm) { i = StrIndirect(j); name = ExtStrname(tterm, i, str_names); @@ -824,13 +822,13 @@ dump_uses(const char *name, bool infodump) } void -compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_UNUSED) +compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_UNUSED, bool quiet) /* compare two entries */ { int i, j; NCURSES_CONST char *name; - (void) fputs(" comparing booleans.\n", stdout); + if (!quiet) fputs(" comparing booleans.\n", stdout); for_each_boolean(j, tp) { i = BoolIndirect(j); name = ExtBoolname(tp, i, bool_names); @@ -838,10 +836,10 @@ compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_U if (isObsolete(outform, name)) continue; - (*hook) (BOOLEAN, i, name); + (*hook) (CMP_BOOLEAN, i, name); } - (void) fputs(" comparing numbers.\n", stdout); + if (!quiet) fputs(" comparing numbers.\n", stdout); for_each_number(j, tp) { i = NumIndirect(j); name = ExtNumname(tp, i, num_names); @@ -849,10 +847,10 @@ compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_U if (isObsolete(outform, name)) continue; - (*hook) (NUMBER, i, name); + (*hook) (CMP_NUMBER, i, name); } - (void) fputs(" comparing strings.\n", stdout); + if (!quiet) fputs(" comparing strings.\n", stdout); for_each_string(j, tp) { i = StrIndirect(j); name = ExtStrname(tp, i, str_names); @@ -860,8 +858,12 @@ compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_U if (isObsolete(outform, name)) continue; - (*hook) (STRING, i, name); + (*hook) (CMP_STRING, i, name); } + + /* (void) fputs(" comparing use entries.\n", stdout); */ + (*hook) (CMP_USE, 0, "use"); + } #define NOTSET(s) ((s) == 0) @@ -884,7 +886,7 @@ set_obsolete_termcaps(TERMTYPE * tp) * Convert an alternate-character-set string to canonical form: sorted and * unique. */ -static void +void repair_acsc(TERMTYPE * tp) { if (VALID_STRING(acs_chars)) { diff --git a/usr.bin/tic/dump_entry.h b/usr.bin/tic/dump_entry.h index b49634d248f..c088c550ef5 100644 --- a/usr.bin/tic/dump_entry.h +++ b/usr.bin/tic/dump_entry.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dump_entry.h,v 1.4 1999/03/11 21:08:09 millert Exp $ */ +/* $OpenBSD: dump_entry.h,v 1.5 2000/03/13 23:53:41 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -52,11 +52,18 @@ #define S_VARIABLE 3 /* sort by C variable names */ #define S_TERMCAP 4 /* sort by termcap names */ +/* capability types for the comparison hook */ +#define CMP_BOOLEAN 0 /* comparison on booleans */ +#define CMP_NUMBER 1 /* comparison on numerics */ +#define CMP_STRING 2 /* comparison on strings */ +#define CMP_USE 3 /* comparison on use capabilities */ + extern NCURSES_CONST char *nametrans(const char *); extern void dump_init(const char *, int, int, int, int, bool); extern int fmt_entry(TERMTYPE *, int (*)(int, int), bool, bool, int); extern int dump_entry(TERMTYPE *, bool, int, int (*)(int, int)); extern int dump_uses(const char *, bool); -extern void compare_entry(void (*)(int, int, const char *), TERMTYPE *); +extern void compare_entry(void (*)(int, int, const char *), TERMTYPE *, bool); +extern void repair_acsc(TERMTYPE * tp); #define FAIL -1 diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c index acc0fde7bd3..a637a663a53 100644 --- a/usr.bin/tic/tic.c +++ b/usr.bin/tic/tic.c @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$From: tic.c,v 1.63 2000/03/05 04:33:15 tom Exp $") +MODULE_ID("$From: tic.c,v 1.64 2000/03/11 21:45:07 tom Exp $") const char *_nc_progname = "tic"; @@ -627,7 +627,7 @@ main(int argc, char *argv[]) /* do use resolution */ if (check_only || (!infodump && !capdump) || forceresolve) { - if (!_nc_resolve_uses() && !check_only) { + if (!_nc_resolve_uses(TRUE) && !check_only) { cleanup(); return EXIT_FAILURE; } @@ -677,7 +677,7 @@ main(int argc, char *argv[]) len = dump_entry(&qp->tterm, limited, numbers, NULL); for (j = 0; j < qp->nuses; j++) - len += dump_uses((char *) (qp->uses[j].parent), !capdump); + len += dump_uses(qp->uses[j].name, !capdump); (void) putchar('\n'); if (debug_level != 0 && !limited) printf("# length=%d\n", len); diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c index dcbde200dcb..06b4357f1d1 100644 --- a/usr.bin/tset/tset.c +++ b/usr.bin/tset/tset.c @@ -102,7 +102,7 @@ char *ttyname(int fd); #include /* for bool typedef */ #include -MODULE_ID("$From: tset.c,v 0.40 2000/03/05 04:37:53 tom Exp $") +MODULE_ID("$From: tset.c,v 0.41 2000/03/12 00:03:00 tom Exp $") extern char **environ; @@ -355,7 +355,7 @@ add_mapping(const char *port, char *arg) else termp = base = arg; - for (;; ++arg) /* Optional conditionals. */ + for (;; ++arg) { /* Optional conditionals. */ switch (*arg) { case '<': if (mapp->conditional & GT) @@ -377,8 +377,10 @@ add_mapping(const char *port, char *arg) default: goto next; } + } - next:if (*arg == ':') { + next: + if (*arg == ':') { if (mapp->conditional) goto badmopt; ++arg; @@ -580,7 +582,7 @@ get_termcap_entry(char *userarg) } /* Find the terminfo entry. If it doesn't exist, ask the user. */ while ((rval = setupterm((NCURSES_CONST char *) ttype, STDOUT_FILENO, - &errret)) != OK) { + &errret)) != OK) { if (errret == 0) { (void) fprintf(stderr, "tset: unknown terminal type %s\n", ttype); @@ -1156,12 +1158,13 @@ main(int argc, char **argv) set_init(); /* Set the modes if they've changed. */ - if (memcmp(&mode, &oldmode, sizeof(mode))) + if (memcmp(&mode, &oldmode, sizeof(mode))) { #ifdef TERMIOS tcsetattr(STDERR_FILENO, TCSADRAIN, &mode); #else stty(STDERR_FILENO, &mode); #endif + } } /* Get the terminal name from the entry. */ -- 2.20.1