-/* $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. *
/* 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
-major=6
+major=7
minor=0
-/* $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 *
/* and: Eric S. Raymond <esr@snark.thyrsus.com> */
/****************************************************************************/
-/* $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
#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 */
-/* $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 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
+/* $From: term_entry.h,v 1.28 2000/03/12 00:44:04 tom Exp $ */
/*
* term_entry.h -- interface to entry-manipulation code
#include <term.h>
#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;
/* 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
.\"***************************************************************************
.\"
.\" $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
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
.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,
-/* $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 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* alloc_entry.c -- allocation functions for terminfo entries
*
#include <tic.h>
#include <term_entry.h>
-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;
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;
* 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;
-/* $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 *
#include <ctype.h>
#include <tic.h>
-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 */
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;
if (saw_n++ == 0) {
bufptr = save_string(bufptr, "%m");
}
- } else {
+ } else { /* cm-style format element */
str++;
switch (*str) {
case '%':
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':
break;
default:
- return (0);
-
+ bufptr = save_char(bufptr, *str);
+ syntax_error = TRUE;
+ break;
} /* endswitch (*str) */
} /* endelse (*str == '%') */
} /* endwhile (*str) */
- return (my_string);
+ return (syntax_error ? NULL : my_string);
}
#ifdef MAIN
-/* $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 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
-
/*
* comp_parse.c -- parser driver loop and use handling.
*
#include <tic.h>
#include <term_entry.h>
-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;
/****************************************************************************
*
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
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++] = '|';
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++] = '|';
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);
}
/****************************************************************************
*
****************************************************************************/
-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");
* 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;
_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"));
* 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;
/* 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;
+ }
}
/*
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);
}
/*
#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)
|| 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)
}
-/* $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. *
/* cursor_visible,cursor_normal,cursor_invisible */
#include <tic.h> /* 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()
-/* $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. *
#include <term.h>
-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)
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);
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;
}
-/* $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. *
*/
#include <curses.priv.h>
-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 <names.c>
-/* $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. *
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-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[] =
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 {
* 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);
-/* $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. *
#include <tic.h>
#include <term_entry.h>
-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... */
{
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++)
-/* $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. *
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
-/* $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. *
#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;
boolmax = 0;
for (i = 0; i < last_bool; i++) {
- if (tp->Booleans[i])
+ if (tp->Booleans[i] == TRUE)
boolmax = i + 1;
}
/* 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))
'\" 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 *
.\" 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
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
\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.
-/* $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 *
#include <term_entry.h>
#include <dump_entry.h>
-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";
***************************************************************************/
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;
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);
}
char *bp;
(void) strcpy(buf, ptr);
- if ((bp = strchr(buf, '|')) != (char *) NULL)
+ if ((bp = strchr(buf, '|')) != 0)
*bp = '\0';
return (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;
/*
* 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;
/*
* 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);
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;
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);
#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;
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;
+ }
+ }
}
/***************************************************************************
(void) strcat(buf2, ep);
(void) strcat(buf2, ";");
} while
- ((ep = strtok((char *) NULL, ";")));
+ ((ep = strtok((char *) 0, ";")));
buf2[strlen(buf2) - 1] = '\0';
expansion = buf2;
}
(void) strcat(buf2, ep);
(void) strcat(buf2, ";");
} while
- ((ep = strtok((char *) NULL, ";")));
+ ((ep = strtok((char *) 0, ";")));
buf2[strlen(buf2) - 1] = '\0';
expansion = buf2;
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]);
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);
}
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++;
}
}
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;
+ }
}
}
}
," -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)"
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 = '_';
/* dump C initializers for the terminal type */
static void
-dump_initializers(void)
+dump_initializers(TERMTYPE * term)
{
int n;
const char *str = 0;
(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";
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 {
/* 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");
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;
/* 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;
ignorepads = TRUE;
break;
+ case 'q':
+ quiet = TRUE;
+ s_absent = "-";
+ s_cancel = "@";
+ bool_sep = ", ";
+ break;
+
case 'r':
tversion = 0;
limited = FALSE;
argv[optind], tfile[termcount]);
status = _nc_read_file_entry(tfile[termcount],
- &term[termcount]);
+ &entries[termcount].tterm);
} else {
if (itrace)
(void) fprintf(stderr,
status = _nc_read_entry(tname[termcount],
tfile[termcount],
- &term[termcount]);
+ &entries[termcount].tterm);
directory = TERMINFO; /* for error message */
}
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);
}
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);
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:
(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:
(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));
-/* $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. *
#include <termsort.c> /* this C file is generated */
#include <parametrized.h> /* 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
}
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))
if (len & 1)
len++;
- repair_acsc(tterm);
for_each_string(j, tterm) {
i = StrIndirect(j);
name = ExtStrname(tterm, i, str_names);
}
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);
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);
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);
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)
* Convert an alternate-character-set string to canonical form: sorted and
* unique.
*/
-static void
+void
repair_acsc(TERMTYPE * tp)
{
if (VALID_STRING(acs_chars)) {
-/* $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. *
#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
#include <dump_entry.h>
#include <term_entry.h>
-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";
/* 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;
}
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);
#include <curses.h> /* for bool typedef */
#include <dump_entry.h>
-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;
else
termp = base = arg;
- for (;; ++arg) /* Optional conditionals. */
+ for (;; ++arg) { /* Optional conditionals. */
switch (*arg) {
case '<':
if (mapp->conditional & GT)
default:
goto next;
}
+ }
- next:if (*arg == ':') {
+ next:
+ if (*arg == ':') {
if (mapp->conditional)
goto badmopt;
++arg;
}
/* 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);
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. */