From ceaf3464e98d7984ed377f023abf63d69b7b8045 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 26 May 2012 23:58:56 +0000 Subject: [PATCH] ncurses 5.9 - patch 20120526 + extend -c and -n options of infocmp to allow comparing more than two entries. + correct check in infocmp for number of terminal names when more than two are given. + correct typo in curs_threads.3x (report by Yanhui Shen on freebsd-hackers mailing list). --- NEWS | 10 +- dist.mk | 4 +- man/curs_threads.3x | 8 +- man/infocmp.1m | 128 ++++++++++++++-------- progs/infocmp.c | 255 +++++++++++++++++++++++++++++++++----------- 5 files changed, 289 insertions(+), 116 deletions(-) diff --git a/NEWS b/NEWS index 17574be7..f7acd3f4 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------- --- $Id: NEWS,v 1.1904 2012/05/12 23:39:01 tom Exp $ +-- $Id: NEWS,v 1.1907 2012/05/26 21:15:19 tom Exp $ ------------------------------------------------------------------------------- This is a log of changes that ncurses has gone through since Zeyd started @@ -45,6 +45,14 @@ See the AUTHORS file for the corresponding full names. Changes through 1.9.9e did not credit all contributions; it is not possible to add this information. +20120526 + + extend -c and -n options of infocmp to allow comparing more than two + entries. + + correct check in infocmp for number of terminal names when more than + two are given. + + correct typo in curs_threads.3x (report by Yanhui Shen on + freebsd-hackers mailing list). + 20120512 + corrected 'op' for bterm (report by Samuel Thibault) -TD + modify test/background.c to demonstrate a background character diff --git a/dist.mk b/dist.mk index eda3aad3..dbb87a6f 100644 --- a/dist.mk +++ b/dist.mk @@ -25,7 +25,7 @@ # use or other dealings in this Software without prior written # # authorization. # ############################################################################## -# $Id: dist.mk,v 1.873 2012/05/12 16:32:15 tom Exp $ +# $Id: dist.mk,v 1.874 2012/05/26 16:49:35 tom Exp $ # Makefile for creating ncurses distributions. # # This only needs to be used directly as a makefile by developers, but @@ -37,7 +37,7 @@ SHELL = /bin/sh # These define the major/minor/patch versions of ncurses. NCURSES_MAJOR = 5 NCURSES_MINOR = 9 -NCURSES_PATCH = 20120512 +NCURSES_PATCH = 20120526 # We don't append the patch to the version, since this only applies to releases VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR) diff --git a/man/curs_threads.3x b/man/curs_threads.3x index 4baa2a1f..5732e924 100644 --- a/man/curs_threads.3x +++ b/man/curs_threads.3x @@ -1,5 +1,5 @@ .\"*************************************************************************** -.\" Copyright (c) 2008,2010 Free Software Foundation, Inc. * +.\" Copyright (c) 2008-2010,2012 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 * @@ -26,7 +26,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: curs_threads.3x,v 1.18 2010/12/04 18:38:55 tom Exp $ +.\" $Id: curs_threads.3x,v 1.19 2012/05/26 17:03:26 tom Exp $ .TH curs_threads 3X "" .de bP .IP \(bu 4 @@ -51,9 +51,9 @@ .br \fBint set_tabsize(int size);\fR .br -\fBint use_screen(SCREEN *scr, NCURSES_WINDOW_CB func, void *data);\fR +\fBint use_screen(SCREEN *scr, NCURSES_SCREEN_CB func, void *data);\fR .br -\fBint use_window(WINDOW *win, NCURSES_SCREEN_CB func, void *data);\fR +\fBint use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data);\fR .br .SH DESCRIPTION This implementation can be configured to provide rudimentary support diff --git a/man/infocmp.1m b/man/infocmp.1m index e598a8a8..601ba3be 100644 --- a/man/infocmp.1m +++ b/man/infocmp.1m @@ -1,6 +1,6 @@ '\" t .\"*************************************************************************** -.\" Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * +.\" Copyright (c) 1998-2011,2012 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 * @@ -27,7 +27,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: infocmp.1m,v 1.50 2011/12/17 23:15:19 tom Exp $ +.\" $Id: infocmp.1m,v 1.51 2012/05/26 21:32:01 tom Exp $ .TH @INFOCMP@ 1M "" .ds n 5 .ds d @TERMINFO@ @@ -71,32 +71,40 @@ x\ \fB@INFOCMP@\fR can be used to compare a binary \fBterminfo\fR entry with other terminfo entries, rewrite a \fBterminfo\fR description to take advantage of the \fBuse=\fR terminfo field, or print out a \fBterminfo\fR description from the -binary file (\fBterm\fR) in a variety of formats. In all cases, the boolean +binary file (\fBterm\fR) in a variety of formats. +In all cases, the boolean fields will be printed first, followed by the numeric fields, followed by the string fields. .SS Default Options If no options are specified and zero or one \fItermnames\fR are specified, the -\fB\-I\fR option will be assumed. If more than one \fItermname\fR is specified, +\fB\-I\fR option will be assumed. +If more than one \fItermname\fR is specified, the \fB\-d\fR option will be assumed. .SS Comparison Options [\-d] [\-c] [\-n] \fB@INFOCMP@\fR compares the \fBterminfo\fR description of the first terminal \fItermname\fR with each of the descriptions given by the entries for the other -terminal's \fItermnames\fR. If a capability is defined for only one of the +terminal's \fItermnames\fR. +If a capability is defined for only one of the terminals, the value returned will depend on the type of the capability: \fBF\fR for boolean variables, \fB\-1\fR for integer variables, and \fBNULL\fR for string variables. .PP The \fB\-d\fR option produces a list of each capability that is different -between two entries. This option is useful to show the difference between two +between two entries. +This option is useful to show the difference between two entries, created by different people, for the same or similar terminals. .PP The \fB\-c\fR option produces a list of each capability that is common between -two entries. Capabilities that are not set are ignored. This option can be +two or more entries. +Capabilities that are not set are ignored. +This option can be used as a quick check to see if the \fB\-u\fR option is worth using. .PP -The \fB\-n\fR option produces a list of each capability that is in neither -entry. If no \fItermnames\fR are given, the environment variable \fBTERM\fR -will be used for both of the \fItermnames\fR. This can be used as a quick +The \fB\-n\fR option produces a list of each capability that is in none of +the given entries. +If no \fItermnames\fR are given, the environment variable \fBTERM\fR +will be used for both of the \fItermnames\fR. +This can be used as a quick check to see if anything was left out of a description. .SS Source Listing Options [\-I] [\-L] [\-C] [\-r] The \fB\-I\fR, \fB\-L\fR, and \fB\-C\fR options will produce a source listing for @@ -117,18 +125,23 @@ used for the terminal name. .PP The source produced by the \fB\-C\fR option may be used directly as a \fBtermcap\fR entry, but not all parameterized strings can be changed to -the \fBtermcap\fR format. \fB@INFOCMP@\fR will attempt to convert most of the +the \fBtermcap\fR format. +\fB@INFOCMP@\fR will attempt to convert most of the parameterized information, and anything not converted will be plainly marked in -the output and commented out. These should be edited by hand. +the output and commented out. +These should be edited by hand. .PP All padding information for strings will be collected together and placed -at the beginning of the string where \fBtermcap\fR expects it. Mandatory +at the beginning of the string where \fBtermcap\fR expects it. +Mandatory padding (padding information with a trailing '/') will become optional. .PP All \fBtermcap\fR variables no longer supported by \fBterminfo\fR, but which -are derivable from other \fBterminfo\fR variables, will be output. Not all +are derivable from other \fBterminfo\fR variables, will be output. +Not all \fBterminfo\fR capabilities will be translated; only those variables which were -part of \fBtermcap\fR will normally be output. Specifying the \fB\-r\fR option +part of \fBtermcap\fR will normally be output. +Specifying the \fB\-r\fR option will take off this restriction, allowing all capabilities to be output in \fItermcap\fR form. Normally you would use both the \fB\-C\fP and \fB\-r\fP options. @@ -138,10 +151,12 @@ For a stricter BSD-compatible translation, use the \fB\-K\fR option rather than \fB\-C\fP. .PP Note that because padding is collected to the beginning of the capability, not -all capabilities are output. Mandatory padding is not supported. Because +all capabilities are output. +Mandatory padding is not supported. +Because \fBtermcap\fR strings are not as flexible, it is not always possible to convert -a \fBterminfo\fR string capability into an equivalent \fBtermcap\fR format. A -subsequent conversion of the \fBtermcap\fR file back into \fBterminfo\fR format +a \fBterminfo\fR string capability into an equivalent \fBtermcap\fR format. +A subsequent conversion of the \fBtermcap\fR file back into \fBterminfo\fR format will not necessarily reproduce the original \fBterminfo\fR source. .PP @@ -164,27 +179,33 @@ l l l. .SS Use= Option [\-u] The \fB\-u\fR option produces a \fBterminfo\fR source description of the first terminal \fItermname\fR which is relative to the sum of the descriptions given -by the entries for the other terminals \fItermnames\fR. It does this by +by the entries for the other terminals \fItermnames\fR. +It does this by analyzing the differences between the first \fItermname\fR and the other \fItermnames\fR and producing a description with \fBuse=\fR fields for the -other terminals. In this manner, it is possible to retrofit generic terminfo -entries into a terminal's description. Or, if two similar terminals exist, but +other terminals. +In this manner, it is possible to retrofit generic terminfo +entries into a terminal's description. +Or, if two similar terminals exist, but were coded at different times or by different people so that each description is a full description, using \fB@INFOCMP@\fR will show what can be done to change one description to be relative to the other. .PP A capability will get printed with an at-sign (@) if it no longer exists in the first \fItermname\fR, but one of the other \fItermname\fR entries contains a -value for it. A capability's value gets printed if the value in the first +value for it. +A capability's value gets printed if the value in the first \fItermname\fR is not found in any of the other \fItermname\fR entries, or if the first of the other \fItermname\fR entries that has this capability gives a different value for the capability than that in the first \fItermname\fR. .PP -The order of the other \fItermname\fR entries is significant. Since the +The order of the other \fItermname\fR entries is significant. +Since the terminfo compiler \fB@TIC@\fR does a left-to-right scan of the capabilities, specifying two \fBuse=\fR entries that contain differing entries for the same capabilities will produce different results depending on the order that the -entries are given in. \fB@INFOCMP@\fR will flag any such inconsistencies between +entries are given in. +\fB@INFOCMP@\fR will flag any such inconsistencies between the other \fItermname\fR entries as they are found. .PP Alternatively, specifying a capability \fIafter\fR a \fBuse=\fR entry that @@ -195,18 +216,24 @@ description. .PP Another error that does not cause incorrect compiled files, but will slow down the compilation time, is specifying extra \fBuse=\fR fields that are -superfluous. \fB@INFOCMP@\fR will flag any other \fItermname use=\fR fields that +superfluous. +\fB@INFOCMP@\fR will flag any other \fItermname use=\fR fields that were not needed. .SS Changing Databases [\-A \fIdirectory\fR] [\-B \fIdirectory\fR] The location of the compiled \fBterminfo\fR database is taken from the -environment variable \fBTERMINFO\fR . If the variable is not defined, or the +environment variable \fBTERMINFO\fR\ . +If the variable is not defined, or the terminal is not found in that location, the system \fBterminfo\fR database, -in \fB@TERMINFO@\fR, will be used. The options \fB\-A\fR -and \fB\-B\fR may be used to override this location. The \fB\-A\fR option will +in \fB@TERMINFO@\fR, will be used. +The options \fB\-A\fR +and \fB\-B\fR may be used to override this location. +The \fB\-A\fR option will set \fBTERMINFO\fR for the first \fItermname\fR and the \fB\-B\fR option will -set \fBTERMINFO\fR for the other \fItermnames\fR. With this, it is possible to +set \fBTERMINFO\fR for the other \fItermnames\fR. +With this, it is possible to compare descriptions for a terminal with the same name located in two different -databases. This is useful for comparing descriptions for the same terminal +databases. +This is useful for comparing descriptions for the same terminal created by different people. .SS Other Options .TP 5 @@ -214,13 +241,15 @@ created by different people. causes the fields to be printed on one line, without wrapping. .TP 5 \fB\-1\fR -causes the fields to be printed out one to a line. Otherwise, +causes the fields to be printed out one to a line. +Otherwise, the fields will be printed several to a line to a maximum width of 60 characters. .TP \fB\-a\fR tells \fB@INFOCMP@\fP to retain commented-out capabilities rather than discarding -them. Capabilities are commented by prefixing them with a period. +them. +Capabilities are commented by prefixing them with a period. .TP \fB\-D\fR tells \fB@INFOCMP@\fP to print the database locations that it knows about, and exit. @@ -245,12 +274,15 @@ This option is useful for preparing versions of the curses library hardwired for a given terminal type. .TP 5 \fB\-F\fR -compare terminfo files. This assumes that two following arguments are -filenames. The files are searched for pairwise matches between +compare terminfo files. +This assumes that two following arguments are 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. Normally, +the other file, and entries with more than one match. +For entries +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. @@ -269,14 +301,17 @@ rather than their decimal equivalents. .TP 5 \fB\-i\fR Analyze the initialization (\fBis1\fR, \fBis2\fR, \fBis3\fR), and reset -(\fBrs1\fR, \fBrs2\fR, \fBrs3\fR), strings in the entry. For each string, the +(\fBrs1\fR, \fBrs2\fR, \fBrs3\fR), strings in the entry. +For each string, the code tries to analyze it into actions in terms of the other capabilities in the entry, certain X3.64/ISO 6429/ECMA\-48 capabilities, and certain DEC VT-series private modes (the set of recognized special sequences has been selected for -completeness over the existing terminfo database). Each report line consists +completeness over the existing terminfo database). +Each report line consists of the capability name, followed by a colon and space, followed by a printable expansion of the capability string with sections matching recognized actions -translated into {}-bracketed descriptions. Here is a list of the DEC/ANSI +translated into {}-bracketed descriptions. +Here is a list of the DEC/ANSI special sequences recognized: i. .TS @@ -322,7 +357,8 @@ DEC[+\-]ARM/auto-repeat mode .sp It also recognizes a SGR action corresponding to ANSI/ISO 6429/ECMA Set Graphics Rendition, with the values NORMAL, BOLD, UNDERLINE, BLINK, and -REVERSE. All but NORMAL may be prefixed with `+' (turn on) or `\-' (turn off). +REVERSE. +All but NORMAL may be prefixed with `+' (turn on) or `\-' (turn off). .PP An SGR0 designates an empty highlight sequence (equivalent to {SGR:NORMAL}). .TP 5 @@ -337,12 +373,15 @@ Make the comparison listing shorter by omitting subheadings, and using "\-" for absent capabilities, "@" for canceled rather than "NULL". .TP 5 \fB\-R\fR\fIsubset\fR -Restrict output to a given subset. This option is for use with archaic +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 do not support the full set of SVR4/XSI Curses terminfo; and variants such as AIX -that have their own extensions incompatible with SVr4/XSI. Available terminfo +that have their own extensions incompatible with SVr4/XSI. +Available terminfo subsets are "SVr1", "Ultrix", "HP", and "AIX"; see \fBterminfo\fR(\*n) for -details. You can also choose the subset "BSD" which selects only capabilities +details. +You can also choose the subset "BSD" which selects only capabilities with termcap equivalents recognized by 4.4BSD. .TP \fB\-s \fR\fI[d|i|l|c]\fR @@ -426,7 +465,8 @@ The options are not supported in SVr4 curses. .PP The \fB\-r\fR option's notion of `termcap' capabilities is System V Release 4's. -Actual BSD curses versions will have a more restricted set. To see only the +Actual BSD curses versions will have a more restricted set. +To see only the 4.4BSD set, use \fB\-r\fR \fB\-RBSD\fR. .SH BUGS The \fB\-F\fR option of \fB@INFOCMP@\fR(1M) should be a \fB@TOE@\fR(1M) mode. diff --git a/progs/infocmp.c b/progs/infocmp.c index 2e6f67a8..d57fa857 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.115 2012/04/07 19:12:01 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.118 2012/05/26 21:11:32 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -333,6 +333,39 @@ dump_string(char *val, char *buf) } } +/* + * Show "comparing..." message for the given terminal names. + */ +static void +show_comparing(char **names) +{ + if (itrace) { + switch (compare) { + case C_DIFFERENCE: + (void) fprintf(stderr, "%s: dumping differences\n", _nc_progname); + break; + + case C_COMMON: + (void) fprintf(stderr, "%s: dumping common capabilities\n", _nc_progname); + break; + + case C_NAND: + (void) fprintf(stderr, "%s: dumping differences\n", _nc_progname); + break; + } + } + if (*names) { + printf("comparing %s", *names++); + if (*names) { + printf(" to %s", *names++); + while (*names) { + printf(", %s", *names++); + } + } + printf(".\n"); + } +} + /* * ncurses stores two types of non-standard capabilities: * a) capabilities listed past the "STOP-HERE" comment in the Caps file. @@ -348,24 +381,33 @@ dump_string(char *val, char *buf) */ #define check_user_definable(n,limit) if (!_nc_user_definable && (n) > (limit)) break +/* + * Use these macros to simplify loops on C_COMMON and C_NAND: + */ +#define for_each_entry() while (entries[extra].tterm.term_names) +#define next_entry (&(entries[extra++].tterm)) + static void compare_predicate(PredType type, PredIdx idx, const char *name) /* predicate function to use for entry difference reports */ { - register ENTRY *e1 = &entries[0]; - register ENTRY *e2 = &entries[1]; - char buf1[MAX_STRING], buf2[MAX_STRING]; + ENTRY *e1 = &entries[0]; + ENTRY *e2 = &entries[1]; + char buf1[MAX_STRING]; + char buf2[MAX_STRING]; int b1, b2; int n1, n2; char *s1, *s2; + bool found; + int extra = 1; switch (type) { case CMP_BOOLEAN: check_user_definable(idx, BOOLWRITE); b1 = e1->tterm.Booleans[idx]; - b2 = e2->tterm.Booleans[idx]; switch (compare) { case C_DIFFERENCE: + b2 = next_entry->Booleans[idx]; if (!(b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) && b1 != b2) (void) printf("\t%s: %s%s%s.\n", name, @@ -375,13 +417,35 @@ compare_predicate(PredType type, PredIdx idx, const char *name) break; case C_COMMON: - if (b1 == b2 && b1 != ABSENT_BOOLEAN) - (void) printf("\t%s= %s.\n", name, dump_boolean(b1)); + if (b1 != ABSENT_BOOLEAN) { + found = TRUE; + for_each_entry() { + b2 = next_entry->Booleans[idx]; + if (b1 != b2) { + found = FALSE; + break; + } + } + if (found) { + (void) printf("\t%s= %s.\n", name, dump_boolean(b1)); + } + } break; case C_NAND: - if (b1 == ABSENT_BOOLEAN && b2 == ABSENT_BOOLEAN) - (void) printf("\t!%s.\n", name); + if (b1 == ABSENT_BOOLEAN) { + found = TRUE; + for_each_entry() { + b2 = next_entry->Booleans[idx]; + if (b1 != b2) { + found = FALSE; + break; + } + } + if (found) { + (void) printf("\t!%s.\n", name); + } + } break; } break; @@ -389,23 +453,47 @@ compare_predicate(PredType type, PredIdx idx, const char *name) case CMP_NUMBER: check_user_definable(idx, NUMWRITE); n1 = e1->tterm.Numbers[idx]; - n2 = e2->tterm.Numbers[idx]; - dump_numeric(n1, buf1); - dump_numeric(n2, buf2); switch (compare) { case C_DIFFERENCE: - if (!((n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)) && n1 != n2) + n2 = next_entry->Numbers[idx]; + if (!((n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC)) && n1 != n2) { + dump_numeric(n1, buf1); + dump_numeric(n2, buf2); (void) printf("\t%s: %s, %s.\n", name, buf1, buf2); + } break; case C_COMMON: - if (n1 != ABSENT_NUMERIC && n2 != ABSENT_NUMERIC && n1 == n2) - (void) printf("\t%s= %s.\n", name, buf1); + if (n1 != ABSENT_NUMERIC) { + found = TRUE; + for_each_entry() { + n2 = next_entry->Numbers[idx]; + if (n1 != n2) { + found = FALSE; + break; + } + } + if (found) { + dump_numeric(n1, buf1); + (void) printf("\t%s= %s.\n", name, buf1); + } + } break; case C_NAND: - if (n1 == ABSENT_NUMERIC && n2 == ABSENT_NUMERIC) - (void) printf("\t!%s.\n", name); + if (n1 == ABSENT_NUMERIC) { + found = TRUE; + for_each_entry() { + n2 = next_entry->Numbers[idx]; + if (n1 != n2) { + found = FALSE; + break; + } + } + if (found) { + (void) printf("\t!%s.\n", name); + } + } break; } break; @@ -413,9 +501,9 @@ compare_predicate(PredType type, PredIdx idx, const char *name) case CMP_STRING: check_user_definable(idx, STRWRITE); s1 = e1->tterm.Strings[idx]; - s2 = e2->tterm.Strings[idx]; switch (compare) { case C_DIFFERENCE: + s2 = next_entry->Strings[idx]; if (capcmp(idx, s1, s2)) { dump_string(s1, buf1); dump_string(s2, buf2); @@ -425,13 +513,35 @@ compare_predicate(PredType type, PredIdx idx, const char *name) break; case C_COMMON: - if (s1 && s2 && !capcmp(idx, s1, s2)) - (void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1)); + if (s1 != ABSENT_STRING) { + found = TRUE; + for_each_entry() { + s2 = next_entry->Strings[idx]; + if (capcmp(idx, s1, s2) != 0) { + found = FALSE; + break; + } + } + if (found) { + (void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1)); + } + } break; case C_NAND: - if (!s1 && !s2) - (void) printf("\t!%s.\n", name); + if (s1 == ABSENT_STRING) { + found = TRUE; + for_each_entry() { + s2 = next_entry->Strings[idx]; + if (s2 != s1) { + found = FALSE; + break; + } + } + if (found) { + (void) printf("\t!%s.\n", name); + } + } break; } break; @@ -450,16 +560,36 @@ compare_predicate(PredType type, PredIdx idx, const char *name) break; case C_COMMON: - if (e1->nuses && e2->nuses && useeq(e1, e2)) { - (void) fputs("\tuse: ", stdout); - print_uses(e1, stdout); - fputs(".\n", stdout); + if (e1->nuses) { + found = TRUE; + for_each_entry() { + e2 = &entries[extra++]; + if (e2->nuses != e1->nuses || !useeq(e1, e2)) { + found = FALSE; + break; + } + } + if (found) { + (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"); + if (!e1->nuses) { + for_each_entry() { + e2 = &entries[extra++]; + if (e2->nuses != e1->nuses) { + found = FALSE; + break; + } + } + if (found) { + (void) printf("\t!use.\n"); + } + } break; } } @@ -953,6 +1083,11 @@ file_comparison(int argc, char *argv[]) #endif if (!(entryeq(&qp->tterm, &rp->tterm) && useeq(qp, rp))) { char name1[NAMESIZE], name2[NAMESIZE]; + char *names[3]; + + names[0] = name1; + names[1] = name2; + names[2] = 0; entries[0] = *qp; entries[1] = *rp; @@ -962,29 +1097,17 @@ file_comparison(int argc, char *argv[]) switch (compare) { case C_DIFFERENCE: - if (itrace) - (void) fprintf(stderr, - "%s: dumping differences\n", - _nc_progname); - (void) printf("comparing %s to %s.\n", name1, name2); + show_comparing(names); compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_COMMON: - if (itrace) - (void) fprintf(stderr, - "%s: dumping common capabilities\n", - _nc_progname); - (void) printf("comparing %s to %s.\n", name1, name2); + show_comparing(names); compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_NAND: - if (itrace) - (void) fprintf(stderr, - "%s: dumping differences\n", - _nc_progname); - (void) printf("comparing %s to %s.\n", name1, name2); + show_comparing(names); compare_entry(compare_predicate, &entries->tterm, quiet); break; @@ -1543,9 +1666,6 @@ main(int argc, char *argv[]) if (sortmode == S_DEFAULT) sortmode = S_TERMINFO; - /* set up for display */ - dump_init(tversion, outform, sortmode, mwidth, mheight, itrace, formatted); - /* make sure we have at least one terminal name to work with */ if (optind >= argc) argv[argc++] = terminal_env(); @@ -1554,9 +1674,23 @@ main(int argc, char *argv[]) if (compare != C_DEFAULT && optind >= argc - 1) argv[argc++] = terminal_env(); + /* exactly one terminal name with no options means display it */ /* exactly two terminal names with no options means do -d */ - if (argc - optind == 2 && compare == C_DEFAULT) - compare = C_DIFFERENCE; + if (compare == C_DEFAULT) { + switch (argc - optind) { + default: + fprintf(stderr, "%s: too many names to compare\n", _nc_progname); + ExitProgram(EXIT_FAILURE); + case 1: + break; + case 2: + compare = C_DIFFERENCE; + break; + } + } + + /* set up for display */ + dump_init(tversion, outform, sortmode, mwidth, mheight, itrace, formatted); if (!filecompare) { /* grab the entries */ @@ -1668,27 +1802,17 @@ main(int argc, char *argv[]) break; case C_DIFFERENCE: - if (itrace) - (void) fprintf(stderr, "%s: dumping differences\n", _nc_progname); - (void) printf("comparing %s to %s.\n", tname[0], tname[1]); + show_comparing(tname); compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_COMMON: - if (itrace) - (void) fprintf(stderr, - "%s: dumping common capabilities\n", - _nc_progname); - (void) printf("comparing %s to %s.\n", tname[0], tname[1]); + show_comparing(tname); compare_entry(compare_predicate, &entries->tterm, quiet); break; case C_NAND: - if (itrace) - (void) fprintf(stderr, - "%s: dumping differences\n", - _nc_progname); - (void) printf("comparing %s to %s.\n", tname[0], tname[1]); + show_comparing(tname); compare_entry(compare_predicate, &entries->tterm, quiet); break; @@ -1709,15 +1833,16 @@ main(int argc, char *argv[]) break; } } - } else if (compare == C_USEALL) + } else if (compare == C_USEALL) { (void) fprintf(stderr, "Sorry, -u doesn't work with -F\n"); - else if (compare == C_DEFAULT) + } else if (compare == C_DEFAULT) { (void) fprintf(stderr, "Use `tic -[CI] ' for this.\n"); - else if (argc - optind != 2) + } else if (argc - optind != 2) { (void) fprintf(stderr, "File comparison needs exactly two file arguments.\n"); - else + } else { file_comparison(argc - optind, argv + optind); + } MAIN_LEAKS(); ExitProgram(EXIT_SUCCESS); -- 2.44.0