summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2000-01-16 01:35:17 +0000
committermillert <millert@openbsd.org>2000-01-16 01:35:17 +0000
commit6ac042424beda7bda585fd10ccc8aa68c90a995c (patch)
treea654cb60802b1628f11f37fe51881e71f2690dd0
parentETHERTYPE_ATALK -> ETHERTYPE_AT (op21@squish.org) (diff)
downloadwireguard-openbsd-6ac042424beda7bda585fd10ccc8aa68c90a995c.tar.xz
wireguard-openbsd-6ac042424beda7bda585fd10ccc8aa68c90a995c.zip
Update to ncurses-5.0-20000115:
+ additional fixes for non-bce terminals (handling of delete_character) to work when assume_default_colors() is not specified. + modify warning message from _nc_parse_entry() regarding extended capability names to print only if tic/infocmp/toe have the -v flag set, and not at all in ordinary user applications. Otherwise, this warning would be shown for screen's extended capabilities in programs that use the termcap interface. + modify use of _nc_tracing from programs such as tic so their debug level is not in the same range as values set by trace() function. + small panel header cleanup (patch by Juergen Pfeifer).
-rw-r--r--lib/libcurses/curses.h4
-rw-r--r--lib/libcurses/tic.h19
-rw-r--r--lib/libcurses/tinfo/comp_scan.c885
-rw-r--r--lib/libcurses/tinfo/lib_termcap.c11
-rw-r--r--lib/libcurses/tinfo/lib_ti.c6
-rw-r--r--lib/libcurses/tinfo/lib_tputs.c324
-rw-r--r--lib/libcurses/tinfo/parse_entry.c480
-rw-r--r--lib/libcurses/tty/tty_update.c30
-rw-r--r--lib/libpanel/panel.priv.h9
-rw-r--r--usr.bin/infocmp/infocmp.c1428
-rw-r--r--usr.bin/tic/tic.c6
11 files changed, 1578 insertions, 1624 deletions
diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h
index 0689baa1e28..6c751a4f665 100644
--- a/lib/libcurses/curses.h
+++ b/lib/libcurses/curses.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: curses.h,v 1.43 2000/01/09 05:06:01 millert Exp $ */
+/* $OpenBSD: curses.h,v 1.44 2000/01/16 01:35:17 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -50,7 +50,7 @@
/* These are defined only in curses.h, and are used for conditional compiles */
#define NCURSES_VERSION_MAJOR 5
#define NCURSES_VERSION_MINOR 0
-#define NCURSES_VERSION_PATCH 20000108
+#define NCURSES_VERSION_PATCH 20000115
/* This is defined in more than one ncurses header, for identification */
#undef NCURSES_VERSION
diff --git a/lib/libcurses/tic.h b/lib/libcurses/tic.h
index f3b6aa4684a..b7652978ff1 100644
--- a/lib/libcurses/tic.h
+++ b/lib/libcurses/tic.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: tic.h,v 1.7 1999/11/28 17:59:28 millert Exp $ */
+/* $OpenBSD: tic.h,v 1.8 2000/01/16 01:35:17 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 *
@@ -99,8 +99,21 @@ extern "C" {
/* location of user's personal info directory */
#define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */
+/*
+ * Some traces are designed to be used via tic's verbose option (and similar in
+ * infocmp and toe) rather than the 'trace()' function. So we use the bits
+ * above the normal trace() parameter as a debug-level.
+ */
+
+#define MAX_DEBUG_LEVEL 15
+#define DEBUG_LEVEL(n) ((n) << 12) /* see TRACE_MAXIMUM */
+
+#define set_trace_level(n) \
+ _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
+ _nc_tracing |= DEBUG_LEVEL(n)
+
#ifdef TRACE
-#define DEBUG(n, a) if (_nc_tracing & (1 << (n - 1))) _tracef a
+#define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a
#else
#define DEBUG(n, a) /*nothing*/
#endif
diff --git a/lib/libcurses/tinfo/comp_scan.c b/lib/libcurses/tinfo/comp_scan.c
index fa5f1e327d1..c8784f0aedc 100644
--- a/lib/libcurses/tinfo/comp_scan.c
+++ b/lib/libcurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999 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 *
@@ -49,7 +49,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$From: comp_scan.c,v 1.35 1999/10/30 23:00:16 tom Exp $")
+MODULE_ID("$From: comp_scan.c,v 1.37 2000/01/15 21:52:23 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -59,11 +59,11 @@ MODULE_ID("$From: comp_scan.c,v 1.35 1999/10/30 23:00:16 tom Exp $")
#define iswhite(ch) (ch == ' ' || ch == '\t')
-int _nc_syntax = 0; /* termcap or terminfo? */
-long _nc_curr_file_pos = 0; /* file offset of current line */
-long _nc_comment_start = 0; /* start of comment range before name */
-long _nc_comment_end = 0; /* end of comment range before name */
-long _nc_start_line = 0; /* start line of current entry */
+int _nc_syntax = 0; /* termcap or terminfo? */
+long _nc_curr_file_pos = 0; /* file offset of current line */
+long _nc_comment_start = 0; /* start of comment range before name */
+long _nc_comment_end = 0; /* end of comment range before name */
+long _nc_start_line = 0; /* start line of current entry */
/*****************************************************************************
*
@@ -74,21 +74,22 @@ long _nc_start_line = 0; /* start line of current entry */
static bool first_column; /* See 'next_char()' below */
static char separator; /* capability separator */
static int pushtype; /* type of pushback token */
-static char pushname[MAX_NAME_SIZE+1];
+static char pushname[MAX_NAME_SIZE + 1];
-static int last_char(void);
-static int next_char(void);
+static int last_char(void);
+static int next_char(void);
static long stream_pos(void);
static bool end_of_stream(void);
static void push_back(char c);
/* Assume we may be looking at a termcap-style continuation */
-static inline int eat_escaped_newline(int ch)
+static inline int
+eat_escaped_newline(int ch)
{
- if (ch == '\\')
- while ((ch = next_char()) == '\n' || iswhite(ch))
- continue;
- return ch;
+ if (ch == '\\')
+ while ((ch = next_char()) == '\n' || iswhite(ch))
+ continue;
+ return ch;
}
/*
@@ -124,316 +125,299 @@ static inline int eat_escaped_newline(int ch)
*
*/
-int _nc_get_token(void)
+int
+_nc_get_token(void)
{
-static const char terminfo_punct[] = "@%&*!#";
-long number;
-int type;
-int ch;
-char * numchk;
-char numbuf[80];
-unsigned found;
-static char buffer[MAX_ENTRY_SIZE];
-char *ptr;
-int dot_flag = FALSE;
-long token_start;
-
- if (pushtype != NO_PUSHBACK)
- {
- int retval = pushtype;
-
- _nc_set_type(pushname);
- DEBUG(3, ("pushed-back token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
-
- pushtype = NO_PUSHBACK;
- pushname[0] = '\0';
-
- /* currtok wasn't altered by _nc_push_token() */
- return(retval);
- }
+ static const char terminfo_punct[] = "@%&*!#";
+ long number;
+ int type;
+ int ch;
+ char *numchk;
+ char numbuf[80];
+ unsigned found;
+ static char buffer[MAX_ENTRY_SIZE];
+ char *ptr;
+ int dot_flag = FALSE;
+ long token_start;
+
+ if (pushtype != NO_PUSHBACK) {
+ int retval = pushtype;
+
+ _nc_set_type(pushname);
+ DEBUG(3, ("pushed-back token: `%s', class %d",
+ _nc_curr_token.tk_name, pushtype));
- if (end_of_stream())
- return(EOF);
+ pushtype = NO_PUSHBACK;
+ pushname[0] = '\0';
-start_token:
- token_start = stream_pos();
- while ((ch = next_char()) == '\n' || iswhite(ch))
- continue;
+ /* currtok wasn't altered by _nc_push_token() */
+ return (retval);
+ }
- ch = eat_escaped_newline(ch);
+ if (end_of_stream())
+ return (EOF);
- if (ch == EOF)
- type = EOF;
- else {
- /* if this is a termcap entry, skip a leading separator */
- if (separator == ':' && ch == ':')
- ch = next_char();
+ start_token:
+ token_start = stream_pos();
+ while ((ch = next_char()) == '\n' || iswhite(ch))
+ continue;
- if (ch == '.') {
- dot_flag = TRUE;
- DEBUG(8, ("dot-flag set"));
+ ch = eat_escaped_newline(ch);
- while ((ch = next_char())=='.' || iswhite(ch))
- continue;
- }
+ if (ch == EOF)
+ type = EOF;
+ else {
+ /* if this is a termcap entry, skip a leading separator */
+ if (separator == ':' && ch == ':')
+ ch = next_char();
- if (ch == EOF) {
- type = EOF;
- goto end_of_token;
- }
+ if (ch == '.') {
+ dot_flag = TRUE;
+ DEBUG(8, ("dot-flag set"));
- /* have to make some punctuation chars legal for terminfo */
- if (!isalnum(ch) && !strchr(terminfo_punct, (char)ch)) {
- _nc_warning("Illegal character (expected alphanumeric or %s) - %s",
- terminfo_punct, _tracechar((chtype)ch));
- _nc_panic_mode(separator);
- goto start_token;
- }
+ while ((ch = next_char()) == '.' || iswhite(ch))
+ continue;
+ }
- ptr = buffer;
- *(ptr++) = ch;
-
- if (first_column) {
- char *desc;
-
- _nc_comment_start = token_start;
- _nc_comment_end = _nc_curr_file_pos;
- _nc_start_line = _nc_curr_line;
-
- _nc_syntax = ERR;
- while ((ch = next_char()) != '\n')
- {
- if (ch == EOF)
- _nc_err_abort("premature EOF");
- else if (ch == ':' && last_char() != ',')
- {
- _nc_syntax = SYN_TERMCAP;
- separator = ':';
- break;
- }
- else if (ch == ',')
- {
- _nc_syntax = SYN_TERMINFO;
- separator = ',';
- /*
- * Fall-through here is not an accident.
- * The idea is that if we see a comma, we
- * figure this is terminfo unless we
- * subsequently run into a colon -- but
- * we don't stop looking for that colon until
- * hitting a newline. This allows commas to
- * be embedded in description fields of
- * either syntax.
- */
- /* FALLTHRU */
- }
- else
- ch = eat_escaped_newline(ch);
-
- *ptr++ = ch;
- }
- ptr[0] = '\0';
- if (_nc_syntax == ERR)
- {
- /*
- * Grrr...what we ought to do here is barf,
- * complaining that the entry is malformed.
- * But because a couple of name fields in the
- * 8.2 termcap file end with |\, we just have
- * to assume it's termcap syntax.
- */
- _nc_syntax = SYN_TERMCAP;
- separator = ':';
- }
- else if (_nc_syntax == SYN_TERMINFO)
- {
- /* throw away trailing /, *$/ */
- for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
- continue;
- ptr[1] = '\0';
- }
+ if (ch == EOF) {
+ type = EOF;
+ goto end_of_token;
+ }
- /*
- * This is the soonest we have the terminal name
- * fetched. Set up for following warning messages.
- */
- ptr = strchr(buffer, '|');
- if (ptr == (char *)NULL)
- ptr = buffer + strlen(buffer);
- ch = *ptr;
- *ptr = '\0';
- _nc_set_type(buffer);
- *ptr = ch;
-
- /*
- * Compute the boundary between the aliases and the
- * description field for syntax-checking purposes.
- */
- desc = strrchr(buffer, '|');
- if (desc) {
- if (*desc == '\0')
- _nc_warning("empty longname field");
- else if (strchr(desc, ' ') == (char *)NULL)
- _nc_warning("older tic versions may treat the description field as an alias");
- }
- if (!desc)
- desc = buffer + strlen(buffer);
-
- /*
- * Whitespace in a name field other than the long name
- * can confuse rdist and some termcap tools. Slashes
- * are a no-no. Other special characters can be
- * dangerous due to shell expansion.
- */
- for (ptr = buffer; ptr < desc; ptr++)
- {
- if (isspace(*ptr))
- {
- _nc_warning("whitespace in name or alias field");
- break;
- }
- else if (*ptr == '/')
- {
- _nc_warning("slashes aren't allowed in names or aliases");
- break;
- }
- else if (strchr("$[]!*?", *ptr))
- {
- _nc_warning("dubious character `%c' in name or alias field", *ptr);
- break;
- }
- }
+ /* have to make some punctuation chars legal for terminfo */
+ if (!isalnum(ch) && !strchr(terminfo_punct, (char) ch)) {
+ _nc_warning("Illegal character (expected alphanumeric or %s) - %s",
+ terminfo_punct, _tracechar((chtype) ch));
+ _nc_panic_mode(separator);
+ goto start_token;
+ }
- ptr = buffer;
+ ptr = buffer;
+ *(ptr++) = ch;
- _nc_curr_token.tk_name = buffer;
- type = NAMES;
- } else {
- while ((ch = next_char()) != EOF) {
- if (!isalnum(ch)) {
- if (_nc_syntax == SYN_TERMINFO) {
- if (ch != '_')
- break;
- } else { /* allow ';' for "k;" */
- if (ch != ';')
- break;
- }
- }
- *(ptr++) = ch;
- }
+ if (first_column) {
+ char *desc;
- *ptr++ = '\0';
- switch (ch) {
- case ',':
- case ':':
- if (ch != separator)
- _nc_err_abort("Separator inconsistent with syntax");
- _nc_curr_token.tk_name = buffer;
- type = BOOLEAN;
- break;
- case '@':
- if ((ch = next_char()) != separator)
- _nc_warning("Missing separator after `%s', have %s",
- buffer, _tracechar((chtype)ch));
- _nc_curr_token.tk_name = buffer;
- type = CANCEL;
- break;
-
- case '#':
- found = 0;
- while (isalnum(ch = next_char())) {
- numbuf[found++] = ch;
- if (found >= sizeof(numbuf)-1)
- break;
- }
- numbuf[found] = '\0';
- number = strtol(numbuf, &numchk, 0);
- if (numchk == numbuf)
- _nc_warning("no value given for `%s'", buffer);
- if ((*numchk != '\0') || (ch != separator))
- _nc_warning("Missing separator");
- _nc_curr_token.tk_name = buffer;
- _nc_curr_token.tk_valnumber = number;
- type = NUMBER;
- break;
-
- case '=':
- ch = _nc_trans_string(ptr);
- if (ch != separator)
- _nc_warning("Missing separator");
- _nc_curr_token.tk_name = buffer;
- _nc_curr_token.tk_valstring = ptr;
- type = STRING;
- break;
-
- case EOF:
- type = EOF;
- break;
- default:
- /* just to get rid of the compiler warning */
- type = UNDEF;
- _nc_warning("Illegal character - %s",
- _tracechar((chtype)ch));
- }
- } /* end else (first_column == FALSE) */
- } /* end else (ch != EOF) */
-
-end_of_token:
+ _nc_comment_start = token_start;
+ _nc_comment_end = _nc_curr_file_pos;
+ _nc_start_line = _nc_curr_line;
-#ifdef TRACE
- if (dot_flag == TRUE)
- DEBUG(8, ("Commented out "));
-
- if (_nc_tracing & TRACE_IEVENT)
- {
- fprintf(stderr, "Token: ");
- switch (type)
- {
- case BOOLEAN:
- fprintf(stderr, "Boolean; name='%s'\n",
- _nc_curr_token.tk_name);
+ _nc_syntax = ERR;
+ while ((ch = next_char()) != '\n') {
+ if (ch == EOF)
+ _nc_err_abort("premature EOF");
+ else if (ch == ':' && last_char() != ',') {
+ _nc_syntax = SYN_TERMCAP;
+ separator = ':';
break;
+ } else if (ch == ',') {
+ _nc_syntax = SYN_TERMINFO;
+ separator = ',';
+ /*
+ * Fall-through here is not an accident.
+ * The idea is that if we see a comma, we
+ * figure this is terminfo unless we
+ * subsequently run into a colon -- but
+ * we don't stop looking for that colon until
+ * hitting a newline. This allows commas to
+ * be embedded in description fields of
+ * either syntax.
+ */
+ /* FALLTHRU */
+ } else
+ ch = eat_escaped_newline(ch);
+
+ *ptr++ = ch;
+ }
+ ptr[0] = '\0';
+ if (_nc_syntax == ERR) {
+ /*
+ * Grrr...what we ought to do here is barf,
+ * complaining that the entry is malformed.
+ * But because a couple of name fields in the
+ * 8.2 termcap file end with |\, we just have
+ * to assume it's termcap syntax.
+ */
+ _nc_syntax = SYN_TERMCAP;
+ separator = ':';
+ } else if (_nc_syntax == SYN_TERMINFO) {
+ /* throw away trailing /, *$/ */
+ for (--ptr; iswhite(*ptr) || *ptr == ','; ptr--)
+ continue;
+ ptr[1] = '\0';
+ }
- case NUMBER:
- fprintf(stderr, "Number; name='%s', value=%d\n",
- _nc_curr_token.tk_name,
- _nc_curr_token.tk_valnumber);
+ /*
+ * This is the soonest we have the terminal name
+ * fetched. Set up for following warning messages.
+ */
+ ptr = strchr(buffer, '|');
+ if (ptr == (char *) NULL)
+ ptr = buffer + strlen(buffer);
+ ch = *ptr;
+ *ptr = '\0';
+ _nc_set_type(buffer);
+ *ptr = ch;
+
+ /*
+ * Compute the boundary between the aliases and the
+ * description field for syntax-checking purposes.
+ */
+ desc = strrchr(buffer, '|');
+ if (desc) {
+ if (*desc == '\0')
+ _nc_warning("empty longname field");
+ else if (strchr(desc, ' ') == (char *) NULL)
+ _nc_warning("older tic versions may treat the description field as an alias");
+ }
+ if (!desc)
+ desc = buffer + strlen(buffer);
+
+ /*
+ * Whitespace in a name field other than the long name
+ * can confuse rdist and some termcap tools. Slashes
+ * are a no-no. Other special characters can be
+ * dangerous due to shell expansion.
+ */
+ for (ptr = buffer; ptr < desc; ptr++) {
+ if (isspace(*ptr)) {
+ _nc_warning("whitespace in name or alias field");
break;
-
- case STRING:
- fprintf(stderr, "String; name='%s', value=%s\n",
- _nc_curr_token.tk_name,
- _nc_visbuf(_nc_curr_token.tk_valstring));
+ } else if (*ptr == '/') {
+ _nc_warning("slashes aren't allowed in names or aliases");
break;
-
- case CANCEL:
- fprintf(stderr, "Cancel; name='%s'\n",
- _nc_curr_token.tk_name);
+ } else if (strchr("$[]!*?", *ptr)) {
+ _nc_warning("dubious character `%c' in name or alias field", *ptr);
break;
+ }
+ }
+
+ ptr = buffer;
- case NAMES:
+ _nc_curr_token.tk_name = buffer;
+ type = NAMES;
+ } else {
+ while ((ch = next_char()) != EOF) {
+ if (!isalnum(ch)) {
+ if (_nc_syntax == SYN_TERMINFO) {
+ if (ch != '_')
+ break;
+ } else { /* allow ';' for "k;" */
+ if (ch != ';')
+ break;
+ }
+ }
+ *(ptr++) = ch;
+ }
- fprintf(stderr, "Names; value='%s'\n",
- _nc_curr_token.tk_name);
- break;
+ *ptr++ = '\0';
+ switch (ch) {
+ case ',':
+ case ':':
+ if (ch != separator)
+ _nc_err_abort("Separator inconsistent with syntax");
+ _nc_curr_token.tk_name = buffer;
+ type = BOOLEAN;
+ break;
+ case '@':
+ if ((ch = next_char()) != separator)
+ _nc_warning("Missing separator after `%s', have %s",
+ buffer, _tracechar((chtype) ch));
+ _nc_curr_token.tk_name = buffer;
+ type = CANCEL;
+ break;
- case EOF:
- fprintf(stderr, "End of file\n");
- break;
+ case '#':
+ found = 0;
+ while (isalnum(ch = next_char())) {
+ numbuf[found++] = ch;
+ if (found >= sizeof(numbuf) - 1)
+ break;
+ }
+ numbuf[found] = '\0';
+ number = strtol(numbuf, &numchk, 0);
+ if (numchk == numbuf)
+ _nc_warning("no value given for `%s'", buffer);
+ if ((*numchk != '\0') || (ch != separator))
+ _nc_warning("Missing separator");
+ _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_valnumber = number;
+ type = NUMBER;
+ break;
- default:
- _nc_warning("Bad token type");
+ case '=':
+ ch = _nc_trans_string(ptr);
+ if (ch != separator)
+ _nc_warning("Missing separator");
+ _nc_curr_token.tk_name = buffer;
+ _nc_curr_token.tk_valstring = ptr;
+ type = STRING;
+ break;
+
+ case EOF:
+ type = EOF;
+ break;
+ default:
+ /* just to get rid of the compiler warning */
+ type = UNDEF;
+ _nc_warning("Illegal character - %s",
+ _tracechar((chtype) ch));
}
+ } /* end else (first_column == FALSE) */
+ } /* end else (ch != EOF) */
+
+ end_of_token:
+
+#ifdef TRACE
+ if (dot_flag == TRUE)
+ DEBUG(8, ("Commented out "));
+
+ if (_nc_tracing >= DEBUG_LEVEL(7)) {
+ switch (type) {
+ case BOOLEAN:
+ _tracef("Token: Boolean; name='%s'",
+ _nc_curr_token.tk_name);
+ break;
+
+ case NUMBER:
+ _tracef("Token: Number; name='%s', value=%d",
+ _nc_curr_token.tk_name,
+ _nc_curr_token.tk_valnumber);
+ break;
+
+ case STRING:
+ _tracef("Token: String; name='%s', value=%s",
+ _nc_curr_token.tk_name,
+ _nc_visbuf(_nc_curr_token.tk_valstring));
+ break;
+
+ case CANCEL:
+ _tracef("Token: Cancel; name='%s'",
+ _nc_curr_token.tk_name);
+ break;
+
+ case NAMES:
+
+ _tracef("Token: Names; value='%s'",
+ _nc_curr_token.tk_name);
+ break;
+
+ case EOF:
+ _tracef("Token: End of file");
+ break;
+
+ default:
+ _nc_warning("Bad token type");
}
+ }
#endif
- if (dot_flag == TRUE) /* if commented out, use the next one */
- type = _nc_get_token();
+ if (dot_flag == TRUE) /* if commented out, use the next one */
+ type = _nc_get_token();
- DEBUG(3, ("token: `%s', class %d", _nc_curr_token.tk_name, type));
+ DEBUG(3, ("token: `%s', class %d", _nc_curr_token.tk_name, type));
- return(type);
+ return (type);
}
/*
@@ -458,118 +442,142 @@ end_of_token:
char
_nc_trans_string(char *ptr)
{
-int count = 0;
-int number;
-int i, c;
-chtype ch, last_ch = '\0';
-bool ignored = FALSE;
-
- while ((ch = c = next_char()) != (chtype)separator && c != EOF) {
- if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
- break;
- if (ch == '^' && last_ch != '%') {
- ch = c = next_char();
- if (c == EOF)
- _nc_err_abort("Premature EOF");
-
- if (! (is7bits(ch) && isprint(ch))) {
- _nc_warning("Illegal ^ character - %s",
- _tracechar((unsigned char)ch));
- }
- if (ch == '?') {
- *(ptr++) = '\177';
- } else {
- if ((ch &= 037) == 0)
- ch = 128;
- *(ptr++) = (char)(ch);
- }
+ int count = 0;
+ int number;
+ int i, c;
+ chtype ch, last_ch = '\0';
+ bool ignored = FALSE;
+
+ while ((ch = c = next_char()) != (chtype) separator && c != EOF) {
+ if ((_nc_syntax == SYN_TERMCAP) && c == '\n')
+ break;
+ if (ch == '^' && last_ch != '%') {
+ ch = c = next_char();
+ if (c == EOF)
+ _nc_err_abort("Premature EOF");
+
+ if (!(is7bits(ch) && isprint(ch))) {
+ _nc_warning("Illegal ^ character - %s",
+ _tracechar((unsigned char) ch));
}
- else if (ch == '\\') {
- ch = c = next_char();
- if (c == EOF)
- _nc_err_abort("Premature EOF");
-
- if (ch >= '0' && ch <= '7') {
- number = ch - '0';
- for (i=0; i < 2; i++) {
- ch = c = next_char();
- if (c == EOF)
- _nc_err_abort("Premature EOF");
-
- if (c < '0' || c > '7') {
- if (isdigit(c)) {
- _nc_warning("Non-octal digit `%c' in \\ sequence", c);
- /* allow the digit; it'll do less harm */
- } else {
- push_back((char)c);
- break;
- }
+ if (ch == '?') {
+ *(ptr++) = '\177';
+ } else {
+ if ((ch &= 037) == 0)
+ ch = 128;
+ *(ptr++) = (char) (ch);
+ }
+ } else if (ch == '\\') {
+ ch = c = next_char();
+ if (c == EOF)
+ _nc_err_abort("Premature EOF");
+
+ if (ch >= '0' && ch <= '7') {
+ number = ch - '0';
+ for (i = 0; i < 2; i++) {
+ ch = c = next_char();
+ if (c == EOF)
+ _nc_err_abort("Premature EOF");
+
+ if (c < '0' || c > '7') {
+ if (isdigit(c)) {
+ _nc_warning("Non-octal digit `%c' in \\ sequence", c);
+ /* allow the digit; it'll do less harm */
+ } else {
+ push_back((char) c);
+ break;
}
-
- number = number * 8 + c - '0';
}
- if (number == 0)
- number = 0200;
- *(ptr++) = (char) number;
- } else {
- switch (c) {
- case 'E':
- case 'e': *(ptr++) = '\033'; break;
+ number = number * 8 + c - '0';
+ }
- case 'a': *(ptr++) = '\007'; break;
+ if (number == 0)
+ number = 0200;
+ *(ptr++) = (char) number;
+ } else {
+ switch (c) {
+ case 'E':
+ case 'e':
+ *(ptr++) = '\033';
+ break;
- case 'l':
- case 'n': *(ptr++) = '\n'; break;
+ case 'a':
+ *(ptr++) = '\007';
+ break;
- case 'r': *(ptr++) = '\r'; break;
+ case 'l':
+ case 'n':
+ *(ptr++) = '\n';
+ break;
- case 'b': *(ptr++) = '\010'; break;
+ case 'r':
+ *(ptr++) = '\r';
+ break;
- case 's': *(ptr++) = ' '; break;
+ case 'b':
+ *(ptr++) = '\010';
+ break;
- case 'f': *(ptr++) = '\014'; break;
+ case 's':
+ *(ptr++) = ' ';
+ break;
- case 't': *(ptr++) = '\t'; break;
+ case 'f':
+ *(ptr++) = '\014';
+ break;
- case '\\': *(ptr++) = '\\'; break;
+ case 't':
+ *(ptr++) = '\t';
+ break;
- case '^': *(ptr++) = '^'; break;
+ case '\\':
+ *(ptr++) = '\\';
+ break;
- case ',': *(ptr++) = ','; break;
+ case '^':
+ *(ptr++) = '^';
+ break;
- case ':': *(ptr++) = ':'; break;
+ case ',':
+ *(ptr++) = ',';
+ break;
- case '\n':
- continue;
+ case ':':
+ *(ptr++) = ':';
+ break;
- default:
- _nc_warning("Illegal character %s in \\ sequence",
- _tracechar((unsigned char)ch));
- *(ptr++) = (char)ch;
- } /* endswitch (ch) */
- } /* endelse (ch < '0' || ch > '7') */
- } /* end else if (ch == '\\') */
- else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
- /* newlines embedded in a terminfo string are ignored */
- ignored = TRUE;
- } else {
- *(ptr++) = (char)ch;
- }
+ case '\n':
+ continue;
- if (!ignored) {
- last_ch = ch;
- count ++;
- }
- ignored = FALSE;
+ default:
+ _nc_warning("Illegal character %s in \\ sequence",
+ _tracechar((unsigned char) ch));
+ *(ptr++) = (char) ch;
+ } /* endswitch (ch) */
+ } /* endelse (ch < '0' || ch > '7') */
+ }
+ /* end else if (ch == '\\') */
+ else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
+ /* newlines embedded in a terminfo string are ignored */
+ ignored = TRUE;
+ } else {
+ *(ptr++) = (char) ch;
+ }
- if (count > MAXCAPLEN)
- _nc_warning("Very long string found. Missing separator?");
- } /* end while */
+ if (!ignored) {
+ last_ch = ch;
+ count++;
+ }
+ ignored = FALSE;
+
+ if (count > MAXCAPLEN)
+ _nc_warning("Very long string found. Missing separator?");
+ } /* end while */
- *ptr = '\0';
+ *ptr = '\0';
- return(ch);
+ return (ch);
}
/*
@@ -579,7 +587,8 @@ bool ignored = FALSE;
* get_token() call.
*/
-void _nc_push_token(int tokclass)
+void
+_nc_push_token(int tokclass)
{
/*
* This implementation is kind of bogus, it will fail if we ever do
@@ -591,23 +600,24 @@ void _nc_push_token(int tokclass)
_nc_get_type(pushname);
DEBUG(3, ("pushing token: `%s', class %d",
- _nc_curr_token.tk_name, pushtype));
+ _nc_curr_token.tk_name, pushtype));
}
/*
* Panic mode error recovery - skip everything until a "ch" is found.
*/
-void _nc_panic_mode(char ch)
+void
+_nc_panic_mode(char ch)
{
- int c;
-
- for (;;) {
- c = next_char();
- if (c == ch)
- return;
- if (c == EOF)
- return;
- }
+ int c;
+
+ for (;;) {
+ c = next_char();
+ if (c == ch)
+ return;
+ if (c == EOF)
+ return;
+ }
}
/*****************************************************************************
@@ -630,16 +640,17 @@ static FILE *yyin; /* scanner's input file descriptor */
* non-null.
*/
-void _nc_reset_input(FILE *fp, char *buf)
+void
+_nc_reset_input(FILE * fp, char *buf)
{
- pushtype = NO_PUSHBACK;
- pushname[0] = '\0';
- yyin = fp;
- bufstart = bufptr = buf;
- _nc_curr_file_pos = 0L;
- if (fp != 0)
- _nc_curr_line = 0;
- _nc_curr_col = 0;
+ pushtype = NO_PUSHBACK;
+ pushname[0] = '\0';
+ yyin = fp;
+ bufstart = bufptr = buf;
+ _nc_curr_file_pos = 0L;
+ if (fp != 0)
+ _nc_curr_line = 0;
+ _nc_curr_col = 0;
}
/*
@@ -650,12 +661,12 @@ void _nc_reset_input(FILE *fp, char *buf)
static int
last_char(void)
{
- size_t len = strlen(bufptr);
- while (len--) {
- if (!isspace(bufptr[len]))
- return bufptr[len];
- }
- return 0;
+ size_t len = strlen(bufptr);
+ while (len--) {
+ if (!isspace(bufptr[len]))
+ return bufptr[len];
+ }
+ return 0;
}
/*
@@ -675,17 +686,14 @@ last_char(void)
static int
next_char(void)
{
- if (!yyin)
- {
+ if (!yyin) {
if (*bufptr == '\0')
- return(EOF);
+ return (EOF);
if (*bufptr == '\n') {
_nc_curr_line++;
_nc_curr_col = 0;
}
- }
- else if (!bufptr || !*bufptr)
- {
+ } else if (!bufptr || !*bufptr) {
/*
* In theory this could be recoded to do its I/O one
* character at a time, saving the buffer space. In
@@ -697,15 +705,15 @@ next_char(void)
size_t len;
do {
- _nc_curr_file_pos = ftell(yyin);
+ _nc_curr_file_pos = ftell(yyin);
- if ((bufstart = fgets(line, LEXBUFSIZ, yyin)) != NULL) {
- _nc_curr_line++;
- _nc_curr_col = 0;
- }
- bufptr = bufstart;
- } while
- (bufstart != NULL && line[0] == '#');
+ if ((bufstart = fgets(line, LEXBUFSIZ, yyin)) != NULL) {
+ _nc_curr_line++;
+ _nc_curr_col = 0;
+ }
+ bufptr = bufstart;
+ } while
+ (bufstart != NULL && line[0] == '#');
if (bufstart == NULL)
return (EOF);
@@ -718,10 +726,10 @@ next_char(void)
* files on OS/2, etc.
*/
if ((len = strlen(bufptr)) > 1) {
- if (bufptr[len-1] == '\n'
- && bufptr[len-2] == '\r') {
- bufptr[len-2] = '\n';
- bufptr[len-1] = '\0';
+ if (bufptr[len - 1] == '\n'
+ && bufptr[len - 2] == '\r') {
+ bufptr[len - 2] = '\n';
+ bufptr[len - 1] = '\0';
}
}
}
@@ -729,28 +737,31 @@ next_char(void)
first_column = (bufptr == bufstart);
_nc_curr_col++;
- return(*bufptr++);
+ return (*bufptr++);
}
-static void push_back(char c)
+static void
+push_back(char c)
/* push a character back onto the input stream */
{
if (bufptr == bufstart)
- _nc_syserr_abort("Can't backspace off beginning of line");
+ _nc_syserr_abort("Can't backspace off beginning of line");
*--bufptr = c;
}
-static long stream_pos(void)
+static long
+stream_pos(void)
/* return our current character position in the input stream */
{
return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
}
-static bool end_of_stream(void)
+static bool
+end_of_stream(void)
/* are we at end of input? */
{
return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
- ? TRUE : FALSE);
+ ? TRUE : FALSE);
}
/* comp_scan.c ends here */
diff --git a/lib/libcurses/tinfo/lib_termcap.c b/lib/libcurses/tinfo/lib_termcap.c
index d99749636e0..e28706ed02a 100644
--- a/lib/libcurses/tinfo/lib_termcap.c
+++ b/lib/libcurses/tinfo/lib_termcap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_termcap.c,v 1.4 2000/01/02 22:06:51 millert Exp $ */
+/* $OpenBSD: lib_termcap.c,v 1.5 2000/01/16 01:35:18 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998-2000 Free Software Foundation, Inc. *
@@ -41,7 +41,7 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$From: lib_termcap.c,v 1.32 2000/01/01 16:49:54 tom Exp $")
+MODULE_ID("$From: lib_termcap.c,v 1.35 2000/01/15 20:47:21 tom Exp $")
/*
some of the code in here was contributed by:
@@ -150,7 +150,7 @@ tgetnum(NCURSES_CONST char *id)
const char *capname = ExtNumname(tp, i, numcodes);
if (!strncmp(id, capname, 2)) {
if (!VALID_NUMERIC(tp->Numbers[i]))
- return ABSENT_NUMERIC;
+ returnCode(ABSENT_NUMERIC);
returnCode(tp->Numbers[i]);
}
}
@@ -177,10 +177,9 @@ tgetstr(NCURSES_CONST char *id, char **area)
TERMTYPE *tp = &(cur_term->type);
for_each_string(i, tp) {
const char *capname = ExtStrname(tp, i, strcodes);
- T(("trying %s", capname));
if (!strncmp(id, capname, 2)) {
- T(("found match : %s", _nc_visbuf(tp->Strings[i])));
- /* setupterm forces cancelled strings to null */
+ TR(TRACE_DATABASE,("found match : %s", _nc_visbuf(tp->Strings[i])));
+ /* setupterm forces canceled strings to null */
if (area != 0
&& *area != 0
&& VALID_STRING(tp->Strings[i])) {
diff --git a/lib/libcurses/tinfo/lib_ti.c b/lib/libcurses/tinfo/lib_ti.c
index 91164f528fb..98fa68f72b8 100644
--- a/lib/libcurses/tinfo/lib_ti.c
+++ b/lib/libcurses/tinfo/lib_ti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_ti.c,v 1.3 2000/01/02 22:06:51 millert Exp $ */
+/* $OpenBSD: lib_ti.c,v 1.4 2000/01/16 01:35:18 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998-2000 Free Software Foundation, Inc. *
@@ -38,7 +38,7 @@
#include <term_entry.h>
#include <tic.h>
-MODULE_ID("$From: lib_ti.c,v 1.18 2000/01/01 16:58:30 tom Exp $")
+MODULE_ID("$From: lib_ti.c,v 1.19 2000/01/15 20:47:37 tom Exp $")
int
tigetflag(NCURSES_CONST char *str)
@@ -74,7 +74,7 @@ tigetnum(NCURSES_CONST char *str)
const char *capname = ExtNumname(tp, i, numnames);
if (!strcmp(str, capname)) {
if (!VALID_NUMERIC(tp->Numbers[i]))
- return ABSENT_NUMERIC;
+ returnCode(ABSENT_NUMERIC);
returnCode(tp->Numbers[i]);
}
}
diff --git a/lib/libcurses/tinfo/lib_tputs.c b/lib/libcurses/tinfo/lib_tputs.c
index e6955723c0b..b6a879fd3ef 100644
--- a/lib/libcurses/tinfo/lib_tputs.c
+++ b/lib/libcurses/tinfo/lib_tputs.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: lib_tputs.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */
+/* $OpenBSD: lib_tputs.c,v 1.4 2000/01/16 01:35:18 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,7 +33,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* tputs.c
* delay_output()
@@ -44,210 +43,211 @@
#include <curses.priv.h>
#include <ctype.h>
-#include <term.h> /* padding_baud_rate, xon_xoff */
-#include <termcap.h> /* ospeed */
+#include <term.h> /* padding_baud_rate, xon_xoff */
+#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$From: lib_tputs.c,v 1.42 1999/10/30 23:00:16 tom Exp $")
+MODULE_ID("$From: lib_tputs.c,v 1.43 2000/01/15 20:13:04 tom Exp $")
-char PC = 0; /* used by termcap library */
-speed_t ospeed = 0; /* used by termcap library */
+char PC = 0; /* used by termcap library */
+speed_t ospeed = 0; /* used by termcap library */
-int _nc_nulls_sent = 0; /* used by 'tack' program */
+int _nc_nulls_sent = 0; /* used by 'tack' program */
-static int (*my_outch)(int c) = _nc_outch;
+static int (*my_outch) (int c) = _nc_outch;
-int delay_output(int ms)
+int
+delay_output(int ms)
{
- T((T_CALLED("delay_output(%d)"), ms));
+ T((T_CALLED("delay_output(%d)"), ms));
- if (no_pad_char)
- napms(ms);
- else {
- register int nullcount;
+ if (no_pad_char)
+ napms(ms);
+ else {
+ register int nullcount;
- nullcount = (ms * _nc_baudrate(ospeed)) / 10000;
- for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
- my_outch(PC);
- if (my_outch == _nc_outch)
- _nc_flush();
- }
+ nullcount = (ms * _nc_baudrate(ospeed)) / 10000;
+ for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
+ my_outch(PC);
+ if (my_outch == _nc_outch)
+ _nc_flush();
+ }
- returnCode(OK);
+ returnCode(OK);
}
-int _nc_outch(int ch)
+int
+_nc_outch(int ch)
{
#ifdef TRACE
- _nc_outchars++;
+ _nc_outchars++;
#endif /* TRACE */
- if (SP != 0
- && SP->_cleanup) {
- char tmp = ch;
- /*
- * POSIX says write() is safe in a signal handler, but the
- * buffered I/O is not.
- */
- write(fileno(NC_OUTPUT), &tmp, 1);
- } else {
- putc(ch, NC_OUTPUT);
- }
- return OK;
+ if (SP != 0
+ && SP->_cleanup) {
+ char tmp = ch;
+ /*
+ * POSIX says write() is safe in a signal handler, but the
+ * buffered I/O is not.
+ */
+ write(fileno(NC_OUTPUT), &tmp, 1);
+ } else {
+ putc(ch, NC_OUTPUT);
+ }
+ return OK;
}
-int putp(const char *string)
+int
+putp(const char *string)
{
- return tputs(string, 1, _nc_outch);
+ return tputs(string, 1, _nc_outch);
}
-int tputs(const char *string, int affcnt, int (*outc)(int))
+int
+tputs(const char *string, int affcnt, int (*outc) (int))
{
-bool always_delay;
-bool normal_delay;
-int number;
+ bool always_delay;
+ bool normal_delay;
+ int number;
#ifdef BSD_TPUTS
-int trailpad;
+ int trailpad;
#endif /* BSD_TPUTS */
#ifdef TRACE
-char addrbuf[32];
-
- if (_nc_tracing & TRACE_TPUTS)
- {
- if (outc == _nc_outch)
- (void) strcpy(addrbuf, "_nc_outch");
- else
- (void) sprintf(addrbuf, "%p", outc);
- if (_nc_tputs_trace) {
- TR(TRACE_MAXIMUM, ("tputs(%s = %s, %d, %s) called", _nc_tputs_trace, _nc_visbuf(string), affcnt, addrbuf));
- }
- else {
- TR(TRACE_MAXIMUM, ("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf));
- }
- _nc_tputs_trace = (char *)NULL;
+ char addrbuf[32];
+
+ if (_nc_tracing & TRACE_TPUTS) {
+ if (outc == _nc_outch)
+ (void) strcpy(addrbuf, "_nc_outch");
+ else
+ (void) sprintf(addrbuf, "%p", outc);
+ if (_nc_tputs_trace) {
+ _tracef("tputs(%s = %s, %d, %s) called", _nc_tputs_trace,
+ _nc_visbuf(string), affcnt, addrbuf);
+ } else {
+ _tracef("tputs(%s, %d, %s) called", _nc_visbuf(string), affcnt, addrbuf);
}
+ _nc_tputs_trace = (char *) NULL;
+ }
#endif /* TRACE */
-
- if (!VALID_STRING(string))
- return ERR;
- if (cur_term == 0) {
- always_delay = FALSE;
- normal_delay = TRUE;
- } else {
- always_delay = (string == bell) || (string == flash_screen);
- normal_delay =
- !xon_xoff
- && padding_baud_rate
+ if (!VALID_STRING(string))
+ return ERR;
+
+ if (cur_term == 0) {
+ always_delay = FALSE;
+ normal_delay = TRUE;
+ } else {
+ always_delay = (string == bell) || (string == flash_screen);
+ normal_delay =
+ !xon_xoff
+ && padding_baud_rate
#ifdef NCURSES_NO_PADDING
- && (SP == 0 || !(SP->_no_padding))
+ && (SP == 0 || !(SP->_no_padding))
#endif
- && (_nc_baudrate(ospeed) >= padding_baud_rate);
- }
+ && (_nc_baudrate(ospeed) >= padding_baud_rate);
+ }
#ifdef BSD_TPUTS
- /*
- * This ugly kluge deals with the fact that some ancient BSD programs
- * (like nethack) actually do the likes of tputs("50") to get delays.
- */
- trailpad = 0;
- if (isdigit(*string)) {
+ /*
+ * This ugly kluge deals with the fact that some ancient BSD programs
+ * (like nethack) actually do the likes of tputs("50") to get delays.
+ */
+ trailpad = 0;
+ if (isdigit(*string)) {
+ while (isdigit(*string)) {
+ trailpad = trailpad * 10 + (*string - '0');
+ string++;
+ }
+ trailpad *= 10;
+ if (*string == '.') {
+ string++;
+ if (isdigit(*string)) {
+ trailpad += (*string - '0');
+ string++;
+ }
+ while (isdigit(*string))
+ string++;
+ }
+
+ if (*string == '*') {
+ trailpad *= affcnt;
+ string++;
+ }
+ }
+#endif /* BSD_TPUTS */
+
+ my_outch = outc; /* redirect delay_output() */
+ while (*string) {
+ if (*string != '$')
+ (*outc) (*string);
+ else {
+ string++;
+ if (*string != '<') {
+ (*outc) ('$');
+ if (*string)
+ (*outc) (*string);
+ } else {
+ bool mandatory;
+
+ string++;
+ if ((!isdigit(*string) && *string != '.') || !strchr(string, '>')) {
+ (*outc) ('$');
+ (*outc) ('<');
+ continue;
+ }
+
+ number = 0;
while (isdigit(*string)) {
- trailpad = trailpad * 10 + (*string - '0');
- string++;
+ number = number * 10 + (*string - '0');
+ string++;
}
- trailpad *= 10;
+ number *= 10;
if (*string == '.') {
+ string++;
+ if (isdigit(*string)) {
+ number += (*string - '0');
+ string++;
+ }
+ while (isdigit(*string))
string++;
- if (isdigit(*string)) {
- trailpad += (*string - '0');
- string++;
- }
- while (isdigit(*string))
- string++;
}
- if (*string == '*') {
- trailpad *= affcnt;
+ mandatory = FALSE;
+ while (*string == '*' || *string == '/') {
+ if (*string == '*') {
+ number *= affcnt;
+ string++;
+ } else { /* if (*string == '/') */
+ mandatory = TRUE;
string++;
+ }
}
- }
-#endif /* BSD_TPUTS */
- my_outch = outc; /* redirect delay_output() */
- while (*string) {
- if (*string != '$')
- (*outc)(*string);
- else {
- string++;
- if (*string != '<') {
- (*outc)('$');
- if (*string)
- (*outc)(*string);
- } else {
- bool mandatory;
-
- string++;
- if ((!isdigit(*string) && *string != '.') || !strchr(string, '>')) {
- (*outc)('$');
- (*outc)('<');
- continue;
- }
-
- number = 0;
- while (isdigit(*string)) {
- number = number * 10 + (*string - '0');
- string++;
- }
- number *= 10;
- if (*string == '.') {
- string++;
- if (isdigit(*string)) {
- number += (*string - '0');
- string++;
- }
- while (isdigit(*string))
- string++;
- }
-
- mandatory = FALSE;
- while (*string == '*' || *string == '/')
- {
- if (*string == '*') {
- number *= affcnt;
- string++;
- }
- else /* if (*string == '/') */ {
- mandatory = TRUE;
- string++;
- }
- }
-
- if (number > 0
- && (always_delay
- || normal_delay
- || mandatory))
- delay_output(number/10);
-
- } /* endelse (*string == '<') */
- } /* endelse (*string == '$') */
-
- if (*string == '\0')
- break;
+ if (number > 0
+ && (always_delay
+ || normal_delay
+ || mandatory))
+ delay_output(number / 10);
- string++;
- }
+ } /* endelse (*string == '<') */
+ } /* endelse (*string == '$') */
+
+ if (*string == '\0')
+ break;
+
+ string++;
+ }
#ifdef BSD_TPUTS
- /*
- * Emit any BSD-style prefix padding that we've accumulated now.
- */
- if (trailpad > 0
- && (always_delay || normal_delay))
- delay_output(trailpad/10);
+ /*
+ * Emit any BSD-style prefix padding that we've accumulated now.
+ */
+ if (trailpad > 0
+ && (always_delay || normal_delay))
+ delay_output(trailpad / 10);
#endif /* BSD_TPUTS */
- my_outch = _nc_outch;
- return OK;
+ my_outch = _nc_outch;
+ return OK;
}
diff --git a/lib/libcurses/tinfo/parse_entry.c b/lib/libcurses/tinfo/parse_entry.c
index 08a2a859fba..cfc70ee2ffc 100644
--- a/lib/libcurses/tinfo/parse_entry.c
+++ b/lib/libcurses/tinfo/parse_entry.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: parse_entry.c,v 1.3 1999/11/28 17:49:54 millert Exp $ */
+/* $OpenBSD: parse_entry.c,v 1.4 2000/01/16 01:35:18 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1999,1999 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,7 +33,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* parse_entry.c -- compile one terminfo or termcap entry
*
@@ -50,24 +49,26 @@
#define __INTERNAL_CAPS_VISIBLE
#include <term_entry.h>
-MODULE_ID("$From: parse_entry.c,v 1.40 1999/10/30 23:00:16 tom Exp $")
+MODULE_ID("$From: parse_entry.c,v 1.41 2000/01/15 22:30:27 tom Exp $")
#ifdef LINT
-static short const parametrized[] = { 0 };
+static short const parametrized[] =
+{0};
#else
#include <parametrized.h>
#endif
-struct token _nc_curr_token = { 0, 0, 0 };
+struct token _nc_curr_token =
+{0, 0, 0};
-static void postprocess_termcap(TERMTYPE *, bool);
-static void postprocess_terminfo(TERMTYPE *);
-static struct name_table_entry const * lookup_fullname(const char *name);
+static void postprocess_termcap(TERMTYPE *, bool);
+static void postprocess_terminfo(TERMTYPE *);
+static struct name_table_entry const *lookup_fullname(const char *name);
#if NCURSES_XNAMES
-static struct name_table_entry const *
-_nc_extend_names(ENTRY *entryp, char *name, int token_type)
+static struct name_table_entry const *
+_nc_extend_names(ENTRY * entryp, char *name, int token_type)
{
static struct name_table_entry temp;
TERMTYPE *tp = &(entryp->tterm);
@@ -79,20 +80,20 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
switch (token_type) {
case BOOLEAN:
- first = 0;
- last = tp->ext_Booleans;
+ first = 0;
+ last = tp->ext_Booleans;
offset = tp->ext_Booleans;
tindex = tp->num_Booleans;
break;
case NUMBER:
- first = tp->ext_Booleans;
- last = tp->ext_Numbers + first;
+ first = tp->ext_Booleans;
+ last = tp->ext_Numbers + first;
offset = tp->ext_Booleans + tp->ext_Numbers;
tindex = tp->num_Numbers;
break;
case STRING:
- first = tp->ext_Booleans + tp->ext_Numbers;
- last = tp->ext_Strings + first;
+ first = tp->ext_Booleans + tp->ext_Numbers;
+ last = tp->ext_Strings + first;
offset = tp->ext_Booleans + tp->ext_Numbers + tp->ext_Strings;
tindex = tp->num_Strings;
break;
@@ -100,7 +101,7 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
actual = NUM_EXT_NAMES(tp);
for (n = 0; n < actual; n++) {
if (!strcmp(name, tp->ext_Names[n])) {
- if (n > (unsigned)(tp->ext_Booleans + tp->ext_Numbers)) {
+ if (n > (unsigned) (tp->ext_Booleans + tp->ext_Numbers)) {
token_type = STRING;
} else if (n > tp->ext_Booleans) {
token_type = NUMBER;
@@ -127,9 +128,15 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
offset = n;
tindex = n - first;
switch (token_type) {
- case BOOLEAN: tindex += BOOLCOUNT; break;
- case NUMBER: tindex += NUMCOUNT; break;
- case STRING: tindex += STRCOUNT; break;
+ case BOOLEAN:
+ tindex += BOOLCOUNT;
+ break;
+ case NUMBER:
+ tindex += NUMCOUNT;
+ break;
+ case STRING:
+ tindex += STRCOUNT;
+ break;
}
break;
}
@@ -140,35 +147,35 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
tp->ext_Booleans += 1;
tp->num_Booleans += 1;
tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
- for (last = tp->num_Booleans-1; last > tindex; last--)
- tp->Booleans[last] = tp->Booleans[last-1];
+ for (last = tp->num_Booleans - 1; last > tindex; last--)
+ tp->Booleans[last] = tp->Booleans[last - 1];
break;
case NUMBER:
tp->ext_Numbers += 1;
tp->num_Numbers += 1;
tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
- for (last = tp->num_Numbers-1; last > tindex; last--)
- tp->Numbers[last] = tp->Numbers[last-1];
+ for (last = tp->num_Numbers - 1; last > tindex; last--)
+ tp->Numbers[last] = tp->Numbers[last - 1];
break;
case STRING:
tp->ext_Strings += 1;
tp->num_Strings += 1;
tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
- for (last = tp->num_Strings-1; last > tindex; last--)
- tp->Strings[last] = tp->Strings[last-1];
+ for (last = tp->num_Strings - 1; last > tindex; last--)
+ tp->Strings[last] = tp->Strings[last - 1];
break;
}
actual = NUM_EXT_NAMES(tp);
- tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
+ tp->ext_Names = typeRealloc(char *, actual, tp->ext_Names);
while (--actual > offset)
- tp->ext_Names[actual] = tp->ext_Names[actual-1];
+ tp->ext_Names[actual] = tp->ext_Names[actual - 1];
tp->ext_Names[offset] = _nc_save_str(name);
}
- temp.nte_name = tp->ext_Names[offset];
- temp.nte_type = token_type;
+ temp.nte_name = tp->ext_Names[offset];
+ temp.nte_type = token_type;
temp.nte_index = tindex;
- temp.nte_link = -1;
+ temp.nte_link = -1;
return &temp;
}
@@ -193,16 +200,17 @@ _nc_extend_names(ENTRY *entryp, char *name, int token_type)
* push back token
*/
-int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
+int
+_nc_parse_entry(struct entry *entryp, int literal, bool silent)
{
- int token_type;
- struct name_table_entry const *entry_ptr;
- char *ptr, namecpy[MAX_NAME_SIZE+1];
+ int token_type;
+ struct name_table_entry const *entry_ptr;
+ char *ptr, namecpy[MAX_NAME_SIZE + 1];
token_type = _nc_get_token();
if (token_type == EOF)
- return(EOF);
+ return (EOF);
if (token_type != NAMES)
_nc_err_abort("Entry does not start with terminal names in column one");
@@ -215,8 +223,7 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* junk the 2-character termcap name, if present */
ptr = _nc_curr_token.tk_name;
- if (ptr[2] == '|')
- {
+ if (ptr[2] == '|') {
ptr = _nc_curr_token.tk_name + 3;
_nc_curr_token.tk_name[2] = '\0';
}
@@ -234,30 +241,29 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* check for overly-long names and aliases */
(void) strlcpy(namecpy, entryp->tterm.term_names, sizeof(namecpy));
- if ((ptr = strrchr(namecpy, '|')) != (char *)0)
+ if ((ptr = strrchr(namecpy, '|')) != (char *) 0)
*ptr = '\0';
ptr = strtok(namecpy, "|");
if (strlen(ptr) > MAX_ALIAS)
_nc_warning("primary name may be too long");
- while ((ptr = strtok((char *)0, "|")) != (char *)0)
+ while ((ptr = strtok((char *) 0, "|")) != (char *) 0)
if (strlen(ptr) > MAX_ALIAS)
_nc_warning("alias `%s' may be too long", ptr);
entryp->nuses = 0;
for (token_type = _nc_get_token();
- token_type != EOF && token_type != NAMES;
- token_type = _nc_get_token())
- {
+ token_type != EOF && token_type != NAMES;
+ 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].parent = (void *) _nc_save_str(_nc_curr_token.tk_valstring);
entryp->uses[entryp->nuses].line = _nc_curr_line;
entryp->nuses++;
} else {
/* normal token lookup */
entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
- _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
+ _nc_syntax ? _nc_cap_hash_table : _nc_info_hash_table);
/*
* Our kluge to handle aliasing. The reason it's done
@@ -267,43 +273,37 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* making this case fast, aliased caps aren't common now
* and will get rarer.
*/
- if (entry_ptr == NOTFOUND)
- {
- const struct alias *ap;
+ if (entry_ptr == NOTFOUND) {
+ const struct alias *ap;
- if (_nc_syntax == SYN_TERMCAP)
- {
+ if (_nc_syntax == SYN_TERMCAP) {
for (ap = _nc_capalias_table; ap->from; ap++)
- if (strcmp(ap->from, _nc_curr_token.tk_name) == 0)
- {
- if (ap->to == (char *)0)
- {
+ if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
+ if (ap->to == (char *) 0) {
_nc_warning("%s (%s termcap extension) ignored",
- ap->from, ap->source);
+ ap->from, ap->source);
goto nexttok;
}
entry_ptr = _nc_find_entry(ap->to, _nc_cap_hash_table);
if (entry_ptr && !silent)
- _nc_warning("%s (%s termcap extension) aliased to %s", ap->from, ap->source, ap->to);
+ _nc_warning("%s (%s termcap extension) aliased to %s",
+ ap->from, ap->source, ap->to);
break;
}
- }
- else /* if (_nc_syntax == SYN_TERMINFO) */
- {
+ } else { /* if (_nc_syntax == SYN_TERMINFO) */
for (ap = _nc_infoalias_table; ap->from; ap++)
- if (strcmp(ap->from, _nc_curr_token.tk_name) == 0)
- {
- if (ap->to == (char *)0)
- {
+ if (strcmp(ap->from, _nc_curr_token.tk_name) == 0) {
+ if (ap->to == (char *) 0) {
_nc_warning("%s (%s terminfo extension) ignored",
- ap->from, ap->source);
+ ap->from, ap->source);
goto nexttok;
}
entry_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
if (entry_ptr && !silent)
- _nc_warning("%s (%s terminfo extension) aliased to %s", ap->from, ap->source, ap->to);
+ _nc_warning("%s (%s terminfo extension) aliased to %s",
+ ap->from, ap->source, ap->to);
break;
}
@@ -312,16 +312,17 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
}
}
}
-
#if NCURSES_XNAMES
/*
* If we have extended-names active, we will automatically
* define a name based on its context.
*/
if (entry_ptr == NOTFOUND
- && _nc_user_definable
- && (entry_ptr = _nc_extend_names(entryp, _nc_curr_token.tk_name, token_type)) != 0) {
- _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
+ && _nc_user_definable
+ && (entry_ptr = _nc_extend_names(entryp,
+ _nc_curr_token.tk_name, token_type)) != 0) {
+ if (_nc_tracing >= DEBUG_LEVEL(1))
+ _nc_warning("extended capability '%s'", _nc_curr_token.tk_name);
}
#endif /* NCURSES_XNAMES */
@@ -329,13 +330,12 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
if (entry_ptr == NOTFOUND) {
if (!silent)
_nc_warning("unknown capability '%s'",
- _nc_curr_token.tk_name);
+ _nc_curr_token.tk_name);
continue;
}
/* deal with bad type/value combinations. */
- if (token_type != CANCEL && entry_ptr->nte_type != token_type)
- {
+ if (token_type != CANCEL && entry_ptr->nte_type != token_type) {
/*
* Nasty special cases here handle situations in which type
* information can resolve name clashes. Normal lookup
@@ -349,39 +349,36 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
/* tell max_attributes from arrow_key_map */
if (token_type == NUMBER && !strcmp("ma", _nc_curr_token.tk_name))
entry_ptr = _nc_find_type_entry("ma", NUMBER,
- _nc_get_table(_nc_syntax != 0));
+ _nc_get_table(_nc_syntax != 0));
/* map terminfo's string MT to MT */
- else if (token_type==STRING &&!strcmp("MT",_nc_curr_token.tk_name))
+ else if (token_type == STRING && !strcmp("MT", _nc_curr_token.tk_name))
entry_ptr = _nc_find_type_entry("MT", STRING,
- _nc_get_table(_nc_syntax != 0));
+ _nc_get_table(_nc_syntax != 0));
/* treat strings without following "=" as empty strings */
- else if (token_type==BOOLEAN && entry_ptr->nte_type==STRING)
+ else if (token_type == BOOLEAN && entry_ptr->nte_type == STRING)
token_type = STRING;
/* we couldn't recover; skip this token */
- else
- {
- if (!silent)
- {
+ else {
+ if (!silent) {
const char *type_name;
- switch (entry_ptr->nte_type)
- {
+ switch (entry_ptr->nte_type) {
case BOOLEAN:
- type_name = "boolean";
- break;
+ type_name = "boolean";
+ break;
case STRING:
- type_name = "string";
- break;
+ type_name = "string";
+ break;
case NUMBER:
- type_name = "numeric";
- break;
+ type_name = "numeric";
+ break;
default:
- type_name = "unknown";
- break;
+ type_name = "unknown";
+ break;
}
_nc_warning("wrong type used for %s capability '%s'",
- type_name, _nc_curr_token.tk_name);
+ type_name, _nc_curr_token.tk_name);
}
continue;
}
@@ -416,23 +413,23 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
case STRING:
ptr = _nc_curr_token.tk_valstring;
- if (_nc_syntax==SYN_TERMCAP)
+ if (_nc_syntax == SYN_TERMCAP)
ptr = _nc_captoinfo(_nc_curr_token.tk_name,
- ptr,
- parametrized[entry_ptr->nte_index]);
+ ptr,
+ parametrized[entry_ptr->nte_index]);
entryp->tterm.Strings[entry_ptr->nte_index] = _nc_save_str(ptr);
break;
default:
if (!silent)
_nc_warning("unknown token type");
- _nc_panic_mode((_nc_syntax==SYN_TERMCAP) ? ':' : ',');
+ _nc_panic_mode((_nc_syntax == SYN_TERMCAP) ? ':' : ',');
continue;
}
- } /* end else cur_token.name != "use" */
- nexttok:
- continue; /* cannot have a label w/o statement */
- } /* endwhile (not EOF and not NAMES) */
+ } /* end else cur_token.name != "use" */
+ nexttok:
+ continue; /* cannot have a label w/o statement */
+ } /* endwhile (not EOF and not NAMES) */
_nc_push_token(token_type);
_nc_set_type(_nc_first_name(entryp->tterm.term_names));
@@ -444,10 +441,9 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* to be done before entry allocation is wrapped up.
*/
if (!literal) {
- if (_nc_syntax == SYN_TERMCAP)
- {
- bool has_base_entry = FALSE;
- int i;
+ if (_nc_syntax == SYN_TERMCAP) {
+ bool has_base_entry = FALSE;
+ int i;
/*
* Don't insert defaults if this is a `+' entry meant only
@@ -462,50 +458,49 @@ int _nc_parse_entry(struct entry *entryp, int literal, bool silent)
* have picked up defaults via translation.
*/
for (i = 0; i < entryp->nuses; i++)
- if (!strchr((char *)entryp->uses[i].parent, '+'))
+ if (!strchr((char *) entryp->uses[i].parent, '+'))
has_base_entry = TRUE;
postprocess_termcap(&entryp->tterm, has_base_entry);
- }
- else
+ } else
postprocess_terminfo(&entryp->tterm);
}
_nc_wrap_entry(entryp);
- return(OK);
+ return (OK);
}
-int _nc_capcmp(const char *s, const char *t)
+int
+_nc_capcmp(const char *s, const char *t)
/* compare two string capabilities, stripping out padding */
{
if (!s && !t)
- return(0);
+ return (0);
else if (!s || !t)
- return(1);
-
- for (;;)
- {
- if (s[0] == '$' && s[1] == '<')
- {
- for (s += 2; ; s++)
- if (!(isdigit(*s) || *s=='.' || *s=='*' || *s=='/' || *s=='>'))
+ return (1);
+
+ for (;;) {
+ if (s[0] == '$' && s[1] == '<') {
+ for (s += 2;; s++)
+ if (!(isdigit(*s) || *s == '.' || *s == '*' || *s == '/' ||
+ *s == '>'))
break;
}
- if (t[0] == '$' && t[1] == '<')
- {
- for (t += 2; ; t++)
- if (!(isdigit(*t) || *t=='.' || *t=='*' || *t=='/' || *t=='>'))
+ if (t[0] == '$' && t[1] == '<') {
+ for (t += 2;; t++)
+ if (!(isdigit(*t) || *t == '.' || *t == '*' || *t == '/' ||
+ *t == '>'))
break;
}
/* we've now pushed s and t past any padding they were pointing at */
if (*s == '\0' && *t == '\0')
- return(0);
+ return (0);
if (*s != *t)
- return(*t - *s);
+ return (*t - *s);
/* else *s == *t but one is not NUL, so continue */
s++, t++;
@@ -517,29 +512,32 @@ int _nc_capcmp(const char *s, const char *t)
* list. For each capability, we may assume there is a keycap that sends the
* string which is the value of that capability.
*/
-typedef struct {const char *from; const char *to;} assoc;
+typedef struct {
+ const char *from;
+ const char *to;
+} assoc;
static assoc const ko_xlate[] =
{
- {"al", "kil1"}, /* insert line key -> KEY_IL */
- {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
- {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
- {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
- {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
- {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
- {"dc", "kdch1"}, /* delete char -> KEY_DC */
- {"dl", "kdl1"}, /* delete line -> KEY_DL */
- {"do", "kcud1"}, /* down key -> KEY_DOWN */
- {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
- {"ho", "khome"}, /* home key -> KEY_HOME */
- {"ic", "kich1"}, /* insert char key -> KEY_IC */
- {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
- {"le", "kcub1"}, /* le key -> KEY_LEFT */
- {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
- {"nl", "kent"}, /* new line key -> KEY_ENTER */
- {"st", "khts"}, /* set-tab key -> KEY_STAB */
- {"ta", CANCELLED_STRING},
- {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
- {(char *)0, (char *)0},
+ {"al", "kil1"}, /* insert line key -> KEY_IL */
+ {"bt", "kcbt"}, /* back tab -> KEY_BTAB */
+ {"cd", "ked"}, /* clear-to-eos key -> KEY_EOL */
+ {"ce", "kel"}, /* clear-to-eol key -> KEY_EOS */
+ {"cl", "kclr"}, /* clear key -> KEY_CLEAR */
+ {"ct", "tbc"}, /* clear all tabs -> KEY_CATAB */
+ {"dc", "kdch1"}, /* delete char -> KEY_DC */
+ {"dl", "kdl1"}, /* delete line -> KEY_DL */
+ {"do", "kcud1"}, /* down key -> KEY_DOWN */
+ {"ei", "krmir"}, /* exit insert key -> KEY_EIC */
+ {"ho", "khome"}, /* home key -> KEY_HOME */
+ {"ic", "kich1"}, /* insert char key -> KEY_IC */
+ {"im", "kIC"}, /* insert-mode key -> KEY_SIC */
+ {"le", "kcub1"}, /* le key -> KEY_LEFT */
+ {"nd", "kcuf1"}, /* nd key -> KEY_RIGHT */
+ {"nl", "kent"}, /* new line key -> KEY_ENTER */
+ {"st", "khts"}, /* set-tab key -> KEY_STAB */
+ {"ta", CANCELLED_STRING},
+ {"up", "kcuu1"}, /* up-arrow key -> KEY_UP */
+ {(char *) 0, (char *) 0},
};
/*
@@ -570,7 +568,8 @@ static const char C_HT[] = "\t";
#define CUR tp->
static
-void postprocess_termcap(TERMTYPE *tp, bool has_base)
+void
+postprocess_termcap(TERMTYPE * tp, bool has_base)
{
char buf[MAX_LINE * 2 + 2];
@@ -583,8 +582,7 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
*/
/* if there was a tc entry, assume we picked up defaults via that */
- if (!has_base)
- {
+ if (!has_base) {
if (WANTED(init_3string) && termcap_init2)
init_3string = _nc_save_str(termcap_init2);
@@ -638,12 +636,12 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
} else
newline = _nc_save_str(C_LF);
} else if (PRESENT(carriage_return) && PRESENT(scroll_forward)) {
- strlcpy(buf, carriage_return, MAX_LINE+1);
- strlcat(buf, scroll_forward, MAX_LINE+1);
+ strlcpy(buf, carriage_return, MAX_LINE + 1);
+ strlcat(buf, scroll_forward, MAX_LINE + 1);
newline = _nc_save_str(buf);
} else if (PRESENT(carriage_return) && PRESENT(cursor_down)) {
- strlcpy(buf, carriage_return, MAX_LINE+1);
- strlcat(buf, cursor_down, MAX_LINE+1);
+ strlcpy(buf, carriage_return, MAX_LINE + 1);
+ strlcat(buf, cursor_down, MAX_LINE + 1);
newline = _nc_save_str(buf);
}
}
@@ -658,8 +656,7 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* These translations will *not* be inverted by tgetent().
*/
- if (!has_base)
- {
+ if (!has_base) {
/*
* We wait until now to decide if we've got a working cr because even
* one that doesn't work can be used for newline. Unfortunately the
@@ -695,13 +692,11 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
if (has_hardware_tabs == TRUE) {
if (init_tabs != 8 && init_tabs != ABSENT_NUMERIC)
_nc_warning("hardware tabs with a width other than 8: %d", init_tabs);
- else
- {
+ else {
if (tab && _nc_capcmp(tab, C_HT))
_nc_warning("hardware tabs with a non-^I tab string %s",
- _nc_visbuf(tab));
- else
- {
+ _nc_visbuf(tab));
+ else {
if (WANTED(tab))
tab = _nc_save_str(C_HT);
init_tabs = 8;
@@ -712,14 +707,13 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* Now translate the ko capability, if there is one. This
* isn't from mytinfo...
*/
- if (PRESENT(other_non_function_keys))
- {
- char *dp, *cp = strtok(other_non_function_keys, ",");
- struct name_table_entry const *from_ptr;
- struct name_table_entry const *to_ptr;
- assoc const *ap;
- char buf2[MAX_TERMINFO_LENGTH];
- bool foundim;
+ if (PRESENT(other_non_function_keys)) {
+ char *dp, *cp = strtok(other_non_function_keys, ",");
+ struct name_table_entry const *from_ptr;
+ struct name_table_entry const *to_ptr;
+ assoc const *ap;
+ char buf2[MAX_TERMINFO_LENGTH];
+ bool foundim;
/* we're going to use this for a special case later */
dp = strchr(other_non_function_keys, 'i');
@@ -730,30 +724,26 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
for (ap = ko_xlate; ap->from; ap++)
if (strcmp(ap->from, cp) == 0)
break;
- if (!ap->to)
- {
+ if (!ap->to) {
_nc_warning("unknown capability `%s' in ko string", cp);
continue;
- }
- else if (ap->to == CANCELLED_STRING) /* ignore it */
+ } else if (ap->to == CANCELLED_STRING) /* ignore it */
continue;
/* now we know we found a match in ko_table, so... */
from_ptr = _nc_find_entry(ap->from, _nc_cap_hash_table);
- to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
+ to_ptr = _nc_find_entry(ap->to, _nc_info_hash_table);
if (!from_ptr || !to_ptr) /* should never happen! */
_nc_err_abort("ko translation table is invalid, I give up");
- if (WANTED(tp->Strings[from_ptr->nte_index]))
- {
+ if (WANTED(tp->Strings[from_ptr->nte_index])) {
_nc_warning("no value for ko capability %s", ap->from);
continue;
}
- if (tp->Strings[to_ptr->nte_index])
- {
+ if (tp->Strings[to_ptr->nte_index]) {
/* There's no point in warning about it if it's the same
* string; that's just an inefficiency.
*/
@@ -761,8 +751,8 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
tp->Strings[from_ptr->nte_index],
tp->Strings[to_ptr->nte_index]) != 0)
_nc_warning("%s (%s) already has an explicit value %s, ignoring ko",
- ap->to, ap->from,
- _nc_visbuf(tp->Strings[to_ptr->nte_index]) );
+ ap->to, ap->from,
+ _nc_visbuf(tp->Strings[to_ptr->nte_index]));
continue;
}
@@ -771,24 +761,21 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* stripping out padding.
*/
dp = buf2;
- for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++)
- {
- if (cp[0] == '$' && cp[1] == '<')
- {
+ for (cp = tp->Strings[from_ptr->nte_index]; *cp; cp++) {
+ if (cp[0] == '$' && cp[1] == '<') {
while (*cp && *cp != '>')
if (!*cp)
break;
- else
+ else
++cp;
- }
- else
+ } else
*dp++ = *cp;
}
*dp++ = '\0';
tp->Strings[to_ptr->nte_index] = _nc_save_str(buf2);
} while
- ((cp = strtok((char *)0, ",")) != 0);
+ ((cp = strtok((char *) 0, ",")) != 0);
/*
* Note: ko=im and ko=ic both want to grab the `Insert'
@@ -796,15 +783,13 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
* got mapped to kich1 and im to kIC to avoid a collision.
* If the description has im but not ic, hack kIC back to kich1.
*/
- if (foundim && WANTED(key_ic) && key_sic)
- {
+ if (foundim && WANTED(key_ic) && key_sic) {
key_ic = key_sic;
key_sic = ABSENT_STRING;
}
}
- if (!hard_copy)
- {
+ if (!hard_copy) {
if (WANTED(key_backspace))
key_backspace = _nc_save_str(C_BS);
if (WANTED(key_left))
@@ -826,90 +811,76 @@ void postprocess_termcap(TERMTYPE *tp, bool has_base)
PRESENT(acs_ttee) ||
PRESENT(acs_hline) ||
PRESENT(acs_vline) ||
- PRESENT(acs_plus))
- {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
+ PRESENT(acs_plus)) {
+ char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
- if (acs_chars)
- {
- (void)strcpy(bp, acs_chars);
+ if (acs_chars) {
+ (void) strcpy(bp, acs_chars);
bp += strlen(bp);
}
- if (acs_ulcorner && acs_ulcorner[1] == '\0')
- {
+ if (acs_ulcorner && acs_ulcorner[1] == '\0') {
*bp++ = 'l';
*bp++ = *acs_ulcorner;
}
- if (acs_llcorner && acs_llcorner[1] == '\0')
- {
+ if (acs_llcorner && acs_llcorner[1] == '\0') {
*bp++ = 'm';
*bp++ = *acs_llcorner;
}
- if (acs_urcorner && acs_urcorner[1] == '\0')
- {
+ if (acs_urcorner && acs_urcorner[1] == '\0') {
*bp++ = 'k';
*bp++ = *acs_urcorner;
}
- if (acs_lrcorner && acs_lrcorner[1] == '\0')
- {
+ if (acs_lrcorner && acs_lrcorner[1] == '\0') {
*bp++ = 'j';
*bp++ = *acs_lrcorner;
}
- if (acs_ltee && acs_ltee[1] == '\0')
- {
+ if (acs_ltee && acs_ltee[1] == '\0') {
*bp++ = 't';
*bp++ = *acs_ltee;
}
- if (acs_rtee && acs_rtee[1] == '\0')
- {
+ if (acs_rtee && acs_rtee[1] == '\0') {
*bp++ = 'u';
*bp++ = *acs_rtee;
}
- if (acs_btee && acs_btee[1] == '\0')
- {
+ if (acs_btee && acs_btee[1] == '\0') {
*bp++ = 'v';
*bp++ = *acs_btee;
}
- if (acs_ttee && acs_ttee[1] == '\0')
- {
+ if (acs_ttee && acs_ttee[1] == '\0') {
*bp++ = 'w';
*bp++ = *acs_ttee;
}
- if (acs_hline && acs_hline[1] == '\0')
- {
+ if (acs_hline && acs_hline[1] == '\0') {
*bp++ = 'q';
*bp++ = *acs_hline;
}
- if (acs_vline && acs_vline[1] == '\0')
- {
+ if (acs_vline && acs_vline[1] == '\0') {
*bp++ = 'x';
*bp++ = *acs_vline;
}
- if (acs_plus)
- {
+ if (acs_plus) {
*bp++ = 'n';
strcpy(bp, acs_plus);
bp = buf2 + strlen(buf2);
}
- if (bp != buf2)
- {
+ if (bp != buf2) {
*bp++ = '\0';
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from XENIX capabilities");
}
- }
- else if (acs_chars == 0
- && enter_alt_charset_mode != 0
- && exit_alt_charset_mode != 0)
- {
- acs_chars = _nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
+ } else if (acs_chars == 0
+ && enter_alt_charset_mode != 0
+ && exit_alt_charset_mode != 0) {
+ acs_chars =
+ _nc_save_str("``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~");
}
}
static
-void postprocess_terminfo(TERMTYPE *tp)
+void
+postprocess_terminfo(TERMTYPE * tp)
{
/*
* TERMINFO-TO-TERMINFO MAPPINGS FOR SOURCE TRANSLATION
@@ -919,74 +890,60 @@ void postprocess_terminfo(TERMTYPE *tp)
/*
* Translate AIX forms characters.
*/
- if (PRESENT(box_chars_1))
- {
- char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
+ if (PRESENT(box_chars_1)) {
+ char buf2[MAX_TERMCAP_LENGTH], *bp = buf2;
- if (acs_chars)
- {
- (void)strcpy(bp, acs_chars);
+ if (acs_chars) {
+ (void) strcpy(bp, acs_chars);
bp += strlen(bp);
}
- if (box_chars_1[0]) /* ACS_ULCORNER */
- {
+ if (box_chars_1[0]) { /* ACS_ULCORNER */
*bp++ = 'l';
*bp++ = box_chars_1[0];
}
- if (box_chars_1[1]) /* ACS_HLINE */
- {
+ if (box_chars_1[1]) { /* ACS_HLINE */
*bp++ = 'q';
*bp++ = box_chars_1[1];
}
- if (box_chars_1[2]) /* ACS_URCORNER */
- {
+ if (box_chars_1[2]) { /* ACS_URCORNER */
*bp++ = 'k';
*bp++ = box_chars_1[2];
}
- if (box_chars_1[3]) /* ACS_VLINE */
- {
+ if (box_chars_1[3]) { /* ACS_VLINE */
*bp++ = 'x';
*bp++ = box_chars_1[3];
}
- if (box_chars_1[4]) /* ACS_LRCORNER */
- {
+ if (box_chars_1[4]) { /* ACS_LRCORNER */
*bp++ = 'j';
*bp++ = box_chars_1[4];
}
- if (box_chars_1[5]) /* ACS_LLCORNER */
- {
+ if (box_chars_1[5]) { /* ACS_LLCORNER */
*bp++ = 'm';
*bp++ = box_chars_1[5];
}
- if (box_chars_1[6]) /* ACS_TTEE */
- {
+ if (box_chars_1[6]) { /* ACS_TTEE */
*bp++ = 'w';
*bp++ = box_chars_1[6];
}
- if (box_chars_1[7]) /* ACS_RTEE */
- {
+ if (box_chars_1[7]) { /* ACS_RTEE */
*bp++ = 'u';
*bp++ = box_chars_1[7];
}
- if (box_chars_1[8]) /* ACS_BTEE */
- {
+ if (box_chars_1[8]) { /* ACS_BTEE */
*bp++ = 'v';
*bp++ = box_chars_1[8];
}
- if (box_chars_1[9]) /* ACS_LTEE */
- {
+ if (box_chars_1[9]) { /* ACS_LTEE */
*bp++ = 't';
*bp++ = box_chars_1[9];
}
- if (box_chars_1[10]) /* ACS_PLUS */
- {
+ if (box_chars_1[10]) { /* ACS_PLUS */
*bp++ = 'n';
*bp++ = box_chars_1[10];
}
- if (bp != buf2)
- {
+ if (bp != buf2) {
*bp++ = '\0';
acs_chars = _nc_save_str(buf2);
_nc_warning("acsc string synthesized from AIX capabilities");
@@ -1007,7 +964,8 @@ void postprocess_terminfo(TERMTYPE *tp)
* sorted, but the nte_type fields are not necessarily grouped together.
*/
static
-struct name_table_entry const * lookup_fullname(const char *find)
+struct name_table_entry const *
+lookup_fullname(const char *find)
{
int state = -1;
@@ -1031,10 +989,10 @@ struct name_table_entry const * lookup_fullname(const char *find)
for (count = 0; names[count] != 0; count++) {
if (!strcmp(names[count], find)) {
- struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
- while (entry_ptr->nte_type != state
+ struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
+ while (entry_ptr->nte_type != state
|| entry_ptr->nte_index != count)
- entry_ptr++;
+ entry_ptr++;
return entry_ptr;
}
}
diff --git a/lib/libcurses/tty/tty_update.c b/lib/libcurses/tty/tty_update.c
index 2df0aa2f81d..07102426eeb 100644
--- a/lib/libcurses/tty/tty_update.c
+++ b/lib/libcurses/tty/tty_update.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tty_update.c,v 1.4 1999/11/28 17:49:55 millert Exp $ */
+/* $OpenBSD: tty_update.c,v 1.5 2000/01/16 01:35:18 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 *
@@ -75,7 +75,7 @@
#include <term.h>
-MODULE_ID("$From: tty_update.c,v 1.122 1999/11/28 03:07:38 tom Exp $")
+MODULE_ID("$From: tty_update.c,v 1.123 2000/01/15 23:49:36 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -88,6 +88,7 @@ MODULE_ID("$From: tty_update.c,v 1.122 1999/11/28 03:07:38 tom Exp $")
*/
#define CHECK_INTERVAL 5
+#define FILL_BCE() (SP->_coloron && !SP->_default_color && !back_color_erase)
/*
* Enable checking to see if doupdate and friends are tracking the true
* cursor position correctly. NOTE: this is a debugging hack which will
@@ -874,7 +875,7 @@ bool needclear = FALSE;
TPUTS_TRACE("clr_eol");
if (SP->_el_cost > (screen_columns - SP->_curscol)
#ifdef NCURSES_EXT_FUNCS
- || (SP->_coloron && !SP->_default_color && !back_color_erase)
+ || FILL_BCE()
#endif
)
{
@@ -901,7 +902,7 @@ int row, col;
col = SP->_curscol;
#ifdef NCURSES_EXT_FUNCS
- if (SP->_coloron && !SP->_default_color && !back_color_erase) {
+ if (FILL_BCE()) {
int i, j, k = col;
for (i = row; i < screen_lines; i++) {
GoTo(i, k);
@@ -1377,18 +1378,29 @@ static void InsStr(chtype *line, int count)
static void DelChar(int count)
{
+ int n;
+
T(("DelChar(%d) called, position = (%d,%d)", count, newscr->_cury, newscr->_curx));
if (parm_dch) {
TPUTS_TRACE("parm_dch");
tputs(tparm(parm_dch, count), count, _nc_outch);
} else {
- while (count--)
- {
+ for (n = 0; n < count; n++) {
TPUTS_TRACE("delete_character");
putp(delete_character);
}
}
+#ifdef NCURSES_EXT_FUNCS
+ if (FILL_BCE()) {
+ chtype blank = ClrBlank(stdscr);
+ GoTo(SP->_cursrow, screen_columns - count);
+ UpdateAttrs(blank);
+ for (n = 0; n < count; n++) {
+ PutChar(blank);
+ }
+ }
+#endif
}
/*
@@ -1492,7 +1504,7 @@ static int scroll_csr_forward(int n, int top, int bot, int miny, int maxy, chtyp
return ERR;
#ifdef NCURSES_EXT_FUNCS
- if (SP->_coloron && !SP->_default_color && !back_color_erase) {
+ if (FILL_BCE()) {
for (i = 0; i < n; i++) {
GoTo(bot-i, 0);
for (j = 0; j < screen_columns; j++)
@@ -1561,7 +1573,7 @@ static int scroll_csr_backward(int n, int top, int bot, int miny, int maxy, chty
return ERR;
#ifdef NCURSES_EXT_FUNCS
- if (SP->_coloron && !SP->_default_color && !back_color_erase) {
+ if (FILL_BCE()) {
for (i = 0; i < n; i++) {
GoTo(top+i, 0);
for (j = 0; j < screen_columns; j++)
diff --git a/lib/libpanel/panel.priv.h b/lib/libpanel/panel.priv.h
index 3e1f3f45cca..e6d2a7878b9 100644
--- a/lib/libpanel/panel.priv.h
+++ b/lib/libpanel/panel.priv.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: panel.priv.h,v 1.4 1999/11/28 17:49:19 millert Exp $ */
-/* $From: panel.priv.h,v 1.12 1999/11/25 13:49:26 juergen Exp $ */
+/* $OpenBSD: panel.priv.h,v 1.5 2000/01/16 01:35:18 millert Exp $ */
+/* $From: panel.priv.h,v 1.13 2000/01/15 20:39:53 juergen Exp $ */
#ifndef _PANEL_PRIV_H
#define _PANEL_PRIV_H
@@ -124,13 +124,12 @@
updated.
---------------------------------------------------------------------------*/
#define PANEL_UPDATE(pan,panstart,touch)\
-{ int y;\
- PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\
+{ PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\
if (touch)\
Touchpan(pan);\
while(pan2) {\
if ((pan2 != pan) && PANELS_OVERLAPPED(pan,pan2)) {\
- int ix1,ix2,iy1,iy2;\
+ int y,ix1,ix2,iy1,iy2;\
COMPUTE_INTERSECTION(pan,pan2,ix1,ix2,iy1,iy2);\
for(y = iy1; y <= iy2; y++) {\
if (is_linetouched(pan->win,y - PSTARTY(pan))) {\
diff --git a/usr.bin/infocmp/infocmp.c b/usr.bin/infocmp/infocmp.c
index da55421aa44..76a1ebe94cb 100644
--- a/usr.bin/infocmp/infocmp.c
+++ b/usr.bin/infocmp/infocmp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: infocmp.c,v 1.7 1999/12/06 02:14:34 millert Exp $ */
+/* $OpenBSD: infocmp.c,v 1.8 2000/01/16 01:35:19 millert Exp $ */
/****************************************************************************
- * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,7 +33,6 @@
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
****************************************************************************/
-
/*
* infocmp.c -- decompile an entry, or compare two entries
* written by Eric S. Raymond
@@ -44,7 +43,7 @@
#include <term_entry.h>
#include <dump_entry.h>
-MODULE_ID("$From: infocmp.c,v 1.47 1999/12/05 01:13:01 tom Exp $")
+MODULE_ID("$From: infocmp.c,v 1.48 2000/01/15 22:46:12 tom Exp $")
#define L_CURL "{"
#define R_CURL "}"
@@ -53,7 +52,7 @@ MODULE_ID("$From: infocmp.c,v 1.47 1999/12/05 01:13:01 tom Exp $")
const char *_nc_progname = "infocmp";
-typedef char path[PATH_MAX];
+typedef char path[PATH_MAX];
/***************************************************************************
*
@@ -68,7 +67,7 @@ static int termcount; /* count of terminal entries */
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 outform = F_TERMINFO; /* output format */
static int sortmode; /* sort_mode */
static int itrace; /* trace flag for debugging */
static int mwidth = 60;
@@ -84,26 +83,30 @@ static bool ignorepads; /* ignore pad prefixes when diffing */
#if NO_LEAKS
#undef ExitProgram
-static void ExitProgram(int code) GCC_NORETURN;
-static void ExitProgram(int code)
+static void
+ExitProgram(int code) GCC_NORETURN;
+/* prototype is to get gcc to accept the noreturn attribute */
+static void
+ExitProgram(int code)
{
- while (termcount-- > 0)
- _nc_free_termtype(&term[termcount]);
- _nc_leaks_dump_entry();
- _nc_free_and_exit(code);
+ while (termcount-- > 0)
+ _nc_free_termtype(&term[termcount]);
+ _nc_leaks_dump_entry();
+ _nc_free_and_exit(code);
}
#endif
-static char *canonical_name(char *ptr, char *buf)
+static char *
+canonical_name(char *ptr, char *buf)
/* extract the terminal type's primary name */
{
- char *bp;
+ char *bp;
(void) strcpy(buf, ptr);
- if ((bp = strchr(buf, '|')) != (char *)NULL)
+ if ((bp = strchr(buf, '|')) != (char *) NULL)
*bp = '\0';
- return(buf);
+ return (buf);
}
/***************************************************************************
@@ -112,219 +115,214 @@ static char *canonical_name(char *ptr, char *buf)
*
***************************************************************************/
-static int capcmp(const char *s, const char *t)
+static int
+capcmp(const char *s, const char *t)
/* capability comparison function */
{
if (!VALID_STRING(s) && !VALID_STRING(t))
- return(0);
+ return (0);
else if (!VALID_STRING(s) || !VALID_STRING(t))
- return(1);
+ return (1);
if (ignorepads)
- return(_nc_capcmp(s, t));
+ return (_nc_capcmp(s, t));
else
- return(strcmp(s, t));
+ return (strcmp(s, t));
}
-static int use_predicate(int type, int idx)
+static int
+use_predicate(int type, int idx)
/* predicate function to use for use decompilation */
{
- TERMTYPE *tp;
+ TERMTYPE *tp;
- switch(type)
- {
- case BOOLEAN: {
- int is_set = FALSE;
+ switch (type) {
+ case BOOLEAN:{
+ int is_set = FALSE;
- /*
- * This assumes that multiple use entries are supposed
- * to contribute the logical or of their boolean capabilities.
- * 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'.
- */
- for (tp = &term[1]; tp < term + termcount; tp++)
- if (tp->Booleans[idx]) {
- is_set = TRUE;
- break;
- }
- if (is_set != term->Booleans[idx])
- return(!is_set);
- else
- return(FAIL);
+ /*
+ * This assumes that multiple use entries are supposed
+ * to contribute the logical or of their boolean capabilities.
+ * 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'.
+ */
+ for (tp = &term[1]; tp < term + termcount; tp++)
+ if (tp->Booleans[idx]) {
+ is_set = TRUE;
+ break;
}
+ if (is_set != term->Booleans[idx])
+ return (!is_set);
+ else
+ return (FAIL);
+ }
- case NUMBER: {
- int value = ABSENT_NUMERIC;
+ case NUMBER:{
+ int value = ABSENT_NUMERIC;
- /*
- * 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->Numbers[idx] >= 0) {
- value = tp->Numbers[idx];
- break;
- }
-
- if (value != term->Numbers[idx])
- return(value != ABSENT_NUMERIC);
- else
- return(FAIL);
+ /*
+ * 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->Numbers[idx] >= 0) {
+ value = tp->Numbers[idx];
+ break;
}
- case STRING: {
- char *termstr, *usestr = ABSENT_STRING;
+ if (value != term->Numbers[idx])
+ return (value != ABSENT_NUMERIC);
+ else
+ return (FAIL);
+ }
- termstr = term->Strings[idx];
+ case STRING:{
+ char *termstr, *usestr = ABSENT_STRING;
- /*
- * 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];
- break;
- }
-
- if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
- return(FAIL);
- else if (!usestr || !termstr || capcmp(usestr, termstr))
- return(TRUE);
- else
- return(FAIL);
- }
+ termstr = term->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];
+ break;
+ }
+
+ if (usestr == ABSENT_STRING && termstr == ABSENT_STRING)
+ return (FAIL);
+ else if (!usestr || !termstr || capcmp(usestr, termstr))
+ return (TRUE);
+ else
+ return (FAIL);
}
+ }
- return(FALSE); /* pacify compiler */
+ return (FALSE); /* pacify compiler */
}
-static bool entryeq(TERMTYPE *t1, TERMTYPE *t2)
+static bool
+entryeq(TERMTYPE * t1, TERMTYPE * t2)
/* are two terminal types equal */
{
- int i;
+ int i;
for (i = 0; i < NUM_BOOLEANS(t1); i++)
if (t1->Booleans[i] != t2->Booleans[i])
- return(FALSE);
+ return (FALSE);
for (i = 0; i < NUM_NUMBERS(t1); i++)
if (t1->Numbers[i] != t2->Numbers[i])
- return(FALSE);
+ return (FALSE);
for (i = 0; i < NUM_STRINGS(t1); i++)
if (capcmp(t1->Strings[i], t2->Strings[i]))
- return(FALSE);
+ return (FALSE);
- return(TRUE);
+ return (TRUE);
}
#define TIC_EXPAND(result) _nc_tic_expand(result, outform==F_TERMINFO, numbers)
-static void compare_predicate(int type, int idx, const char *name)
+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];
- char *s1, *s2;
-
- switch(type)
- {
- case BOOLEAN:
- switch(compare)
- {
- case C_DIFFERENCE:
- if (t1->Booleans[idx] != t2->Booleans[idx])
- (void) printf("\t%s: %c:%c.\n",
- name,
- t1->Booleans[idx] ? 'T' : 'F',
- t2->Booleans[idx] ? 'T' : 'F');
- break;
+ register TERMTYPE *t1 = &term[0];
+ register TERMTYPE *t2 = &term[1];
+ char *s1, *s2;
+
+ switch (type) {
+ case BOOLEAN:
+ switch (compare) {
+ case C_DIFFERENCE:
+ if (t1->Booleans[idx] != t2->Booleans[idx])
+ (void) printf("\t%s: %c:%c.\n",
+ name,
+ t1->Booleans[idx] ? 'T' : 'F',
+ t2->Booleans[idx] ? 'T' : 'F');
+ break;
- case C_COMMON:
- if (t1->Booleans[idx] && t2->Booleans[idx])
- (void) printf("\t%s= T.\n", name);
- break;
+ case C_COMMON:
+ if (t1->Booleans[idx] && t2->Booleans[idx])
+ (void) printf("\t%s= T.\n", name);
+ break;
- case C_NAND:
- if (!t1->Booleans[idx] && !t2->Booleans[idx])
- (void) printf("\t!%s.\n", name);
- break;
- }
- break;
+ case C_NAND:
+ if (!t1->Booleans[idx] && !t2->Booleans[idx])
+ (void) printf("\t!%s.\n", name);
+ break;
+ }
+ break;
- case NUMBER:
- 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]);
- break;
+ case NUMBER:
+ 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]);
+ 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]);
- 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]);
+ break;
- case C_NAND:
- if (t1->Numbers[idx]==-1 && t2->Numbers[idx] == -1)
- (void) printf("\t!%s.\n", name);
- break;
- }
+ case C_NAND:
+ if (t1->Numbers[idx] == -1 && t2->Numbers[idx] == -1)
+ (void) printf("\t!%s.\n", name);
+ break;
+ }
break;
- case STRING:
- s1 = t1->Strings[idx];
- s2 = t2->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 (strcmp(buf1, buf2))
- (void) printf("\t%s: %s, %s.\n",
- name, buf1, buf2);
- }
- break;
-
- case C_COMMON:
- if (s1 && s2 && !capcmp(s1, s2))
- (void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1));
- break;
+ case STRING:
+ s1 = t1->Strings[idx];
+ s2 = t2->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, "'");
+ }
- case C_NAND:
- if (!s1 && !s2)
- (void) printf("\t!%s.\n", name);
- break;
+ if (s2 == (char *) NULL)
+ (void) strcpy(buf2, "NULL");
+ else {
+ (void) strcpy(buf2, "'");
+ (void) strcat(buf2, TIC_EXPAND(s2));
+ (void) strcat(buf2, "'");
}
- break;
+
+ if (strcmp(buf1, buf2))
+ (void) printf("\t%s: %s, %s.\n",
+ name, buf1, buf2);
+ }
+ break;
+
+ case C_COMMON:
+ if (s1 && s2 && !capcmp(s1, s2))
+ (void) printf("\t%s= '%s'.\n", name, TIC_EXPAND(s1));
+ break;
+
+ case C_NAND:
+ if (!s1 && !s2)
+ (void) printf("\t!%s.\n", name);
+ break;
}
+ break;
+ }
}
@@ -334,114 +332,115 @@ static void compare_predicate(int type, int idx, const char *name)
*
***************************************************************************/
-typedef struct {const char *from; const char *to;} assoc;
+typedef struct {
+ const char *from;
+ const char *to;
+} assoc;
static const assoc std_caps[] =
{
/* these are specified by X.364 and iBCS2 */
- {"\033c", "RIS"}, /* full reset */
- {"\0337", "SC"}, /* save cursor */
- {"\0338", "RC"}, /* restore cursor */
- {"\033[r", "RSR"}, /* not an X.364 mnemonic */
- {"\033[m", "SGR0"}, /* not an X.364 mnemonic */
- {"\033[2J", "ED2"}, /* clear page */
+ {"\033c", "RIS"}, /* full reset */
+ {"\0337", "SC"}, /* save cursor */
+ {"\0338", "RC"}, /* restore cursor */
+ {"\033[r", "RSR"}, /* not an X.364 mnemonic */
+ {"\033[m", "SGR0"}, /* not an X.364 mnemonic */
+ {"\033[2J", "ED2"}, /* clear page */
/* this group is specified by ISO 2022 */
- {"\033(0", "ISO DEC G0"}, /* enable DEC graphics for G0 */
- {"\033(A", "ISO UK G0"}, /* enable UK chars for G0 */
- {"\033(B", "ISO US G0"}, /* enable US chars for G0 */
- {"\033)0", "ISO DEC G1"}, /* enable DEC graphics for G1 */
- {"\033)A", "ISO UK G1"}, /* enable UK chars for G1 */
- {"\033)B", "ISO US G1"}, /* enable US chars for G1 */
+ {"\033(0", "ISO DEC G0"}, /* enable DEC graphics for G0 */
+ {"\033(A", "ISO UK G0"}, /* enable UK chars for G0 */
+ {"\033(B", "ISO US G0"}, /* enable US chars for G0 */
+ {"\033)0", "ISO DEC G1"}, /* enable DEC graphics for G1 */
+ {"\033)A", "ISO UK G1"}, /* enable UK chars for G1 */
+ {"\033)B", "ISO US G1"}, /* enable US chars for G1 */
/* these are DEC private modes widely supported by emulators */
- {"\033=", "DECPAM"}, /* application keypad mode */
- {"\033>", "DECPNM"}, /* normal keypad mode */
- {"\033<", "DECANSI"}, /* enter ANSI mode */
+ {"\033=", "DECPAM"}, /* application keypad mode */
+ {"\033>", "DECPNM"}, /* normal keypad mode */
+ {"\033<", "DECANSI"}, /* enter ANSI mode */
- { (char *)0, (char *)0}
+ {(char *) 0, (char *) 0}
};
static const assoc private_modes[] =
/* DEC \E[ ... [hl] modes recognized by many emulators */
{
- {"1", "CKM"}, /* application cursor keys */
- {"2", "ANM"}, /* set VT52 mode */
- {"3", "COLM"}, /* 132-column mode */
- {"4", "SCLM"}, /* smooth scroll */
- {"5", "SCNM"}, /* reverse video mode */
- {"6", "OM"}, /* origin mode */
- {"7", "AWM"}, /* wraparound mode */
- {"8", "ARM"}, /* auto-repeat mode */
- {(char *)0, (char *)0}
+ {"1", "CKM"}, /* application cursor keys */
+ {"2", "ANM"}, /* set VT52 mode */
+ {"3", "COLM"}, /* 132-column mode */
+ {"4", "SCLM"}, /* smooth scroll */
+ {"5", "SCNM"}, /* reverse video mode */
+ {"6", "OM"}, /* origin mode */
+ {"7", "AWM"}, /* wraparound mode */
+ {"8", "ARM"}, /* auto-repeat mode */
+ {(char *) 0, (char *) 0}
};
static const assoc ecma_highlights[] =
/* recognize ECMA attribute sequences */
{
- {"0", "NORMAL"}, /* normal */
- {"1", "+BOLD"}, /* bold on */
- {"2", "+DIM"}, /* dim on */
- {"3", "+ITALIC"}, /* italic on */
- {"4", "+UNDERLINE"}, /* underline on */
- {"5", "+BLINK"}, /* blink on */
- {"6", "+FASTBLINK"}, /* fastblink on */
- {"7", "+REVERSE"}, /* reverse on */
- {"8", "+INVISIBLE"}, /* invisible on */
- {"9", "+DELETED"}, /* deleted on */
- {"10", "MAIN-FONT"}, /* select primary font */
- {"11", "ALT-FONT-1"}, /* select alternate font 1 */
- {"12", "ALT-FONT-2"}, /* select alternate font 2 */
- {"13", "ALT-FONT-3"}, /* select alternate font 3 */
- {"14", "ALT-FONT-4"}, /* select alternate font 4 */
- {"15", "ALT-FONT-5"}, /* select alternate font 5 */
- {"16", "ALT-FONT-6"}, /* select alternate font 6 */
- {"17", "ALT-FONT-7"}, /* select alternate font 7 */
- {"18", "ALT-FONT-1"}, /* select alternate font 1 */
- {"19", "ALT-FONT-1"}, /* select alternate font 1 */
- {"20", "FRAKTUR"}, /* Fraktur font */
- {"21", "DOUBLEUNDER"}, /* double underline */
- {"22", "-DIM"}, /* dim off */
- {"23", "-ITALIC"}, /* italic off */
- {"24", "-UNDERLINE"}, /* underline off */
- {"25", "-BLINK"}, /* blink off */
- {"26", "-FASTBLINK"}, /* fastblink off */
- {"27", "-REVERSE"}, /* reverse off */
- {"28", "-INVISIBLE"}, /* invisible off */
- {"29", "-DELETED"}, /* deleted off */
- {(char *)0, (char *)0}
+ {"0", "NORMAL"}, /* normal */
+ {"1", "+BOLD"}, /* bold on */
+ {"2", "+DIM"}, /* dim on */
+ {"3", "+ITALIC"}, /* italic on */
+ {"4", "+UNDERLINE"}, /* underline on */
+ {"5", "+BLINK"}, /* blink on */
+ {"6", "+FASTBLINK"}, /* fastblink on */
+ {"7", "+REVERSE"}, /* reverse on */
+ {"8", "+INVISIBLE"}, /* invisible on */
+ {"9", "+DELETED"}, /* deleted on */
+ {"10", "MAIN-FONT"}, /* select primary font */
+ {"11", "ALT-FONT-1"}, /* select alternate font 1 */
+ {"12", "ALT-FONT-2"}, /* select alternate font 2 */
+ {"13", "ALT-FONT-3"}, /* select alternate font 3 */
+ {"14", "ALT-FONT-4"}, /* select alternate font 4 */
+ {"15", "ALT-FONT-5"}, /* select alternate font 5 */
+ {"16", "ALT-FONT-6"}, /* select alternate font 6 */
+ {"17", "ALT-FONT-7"}, /* select alternate font 7 */
+ {"18", "ALT-FONT-1"}, /* select alternate font 1 */
+ {"19", "ALT-FONT-1"}, /* select alternate font 1 */
+ {"20", "FRAKTUR"}, /* Fraktur font */
+ {"21", "DOUBLEUNDER"}, /* double underline */
+ {"22", "-DIM"}, /* dim off */
+ {"23", "-ITALIC"}, /* italic off */
+ {"24", "-UNDERLINE"}, /* underline off */
+ {"25", "-BLINK"}, /* blink off */
+ {"26", "-FASTBLINK"}, /* fastblink off */
+ {"27", "-REVERSE"}, /* reverse off */
+ {"28", "-INVISIBLE"}, /* invisible off */
+ {"29", "-DELETED"}, /* deleted off */
+ {(char *) 0, (char *) 0}
};
-static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
+static void
+analyze_string(const char *name, const char *cap, TERMTYPE * tp)
{
- char buf[MAX_TERMINFO_LENGTH];
- char buf2[MAX_TERMINFO_LENGTH];
- const char *sp, *ep;
- const assoc *ap;
+ char buf[MAX_TERMINFO_LENGTH];
+ char buf2[MAX_TERMINFO_LENGTH];
+ const char *sp, *ep;
+ const assoc *ap;
if (cap == ABSENT_STRING || cap == CANCELLED_STRING)
return;
(void) printf("%s: ", name);
buf[0] = '\0';
- for (sp = cap; *sp; sp++)
- {
- int i;
- size_t len = 0;
+ for (sp = cap; *sp; sp++) {
+ int i;
+ size_t len = 0;
const char *expansion = 0;
/* first, check other capabilities in this entry */
- for (i = 0; i < STRCOUNT; i++)
- {
- char *cp = tp->Strings[i];
+ for (i = 0; i < STRCOUNT; i++) {
+ char *cp = tp->Strings[i];
/* don't use soft-key capabilities */
if (strnames[i][0] == 'k' && strnames[i][0] == 'f')
continue;
-
- if (cp != ABSENT_STRING && cp != CANCELLED_STRING && cp[0] && cp != cap)
- {
+ if (cp != ABSENT_STRING && cp != CANCELLED_STRING && cp[0] && cp
+ != cap) {
len = strlen(cp);
(void) strncpy(buf2, sp, len);
buf2[len] = '\0';
@@ -469,12 +468,10 @@ static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
/* now check the standard capabilities */
if (!expansion)
- for (ap = std_caps; ap->from; ap++)
- {
+ for (ap = std_caps; ap->from; ap++) {
len = strlen(ap->from);
- if (strncmp(ap->from, sp, len) == 0)
- {
+ if (strncmp(ap->from, sp, len) == 0) {
expansion = ap->to;
break;
}
@@ -482,11 +479,10 @@ static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
/* now check for private-mode sequences */
if (!expansion
- && sp[0] == '\033' && sp[1] == '[' && sp[2] == '?'
- && (len = strspn(sp + 3, "0123456789;"))
- && ((sp[3 + len] == 'h') || (sp[3 + len] == 'l')))
- {
- char buf3[MAX_TERMINFO_LENGTH];
+ && sp[0] == '\033' && sp[1] == '[' && sp[2] == '?'
+ && (len = strspn(sp + 3, "0123456789;"))
+ && ((sp[3 + len] == 'h') || (sp[3 + len] == 'l'))) {
+ char buf3[MAX_TERMINFO_LENGTH];
(void) strcpy(buf2, (sp[3 + len] == 'h') ? "DEC+" : "DEC-");
(void) strncpy(buf3, sp + 3, len);
@@ -495,36 +491,33 @@ static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
ep = strtok(buf3, ";");
do {
- bool found = FALSE;
-
- for (ap = private_modes; ap->from; ap++)
- {
- size_t tlen = strlen(ap->from);
-
- if (strncmp(ap->from, ep, tlen) == 0)
- {
- (void) strcat(buf2, ap->to);
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- (void) strcat(buf2, ep);
- (void) strcat(buf2, ";");
- } while
- ((ep = strtok((char *)NULL, ";")));
+ bool found = FALSE;
+
+ for (ap = private_modes; ap->from; ap++) {
+ size_t tlen = strlen(ap->from);
+
+ if (strncmp(ap->from, ep, tlen) == 0) {
+ (void) strcat(buf2, ap->to);
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+ (void) strcat(buf2, ep);
+ (void) strcat(buf2, ";");
+ } while
+ ((ep = strtok((char *) NULL, ";")));
buf2[strlen(buf2) - 1] = '\0';
expansion = buf2;
}
/* now check for ECMA highlight sequences */
if (!expansion
- && sp[0] == '\033' && sp[1] == '['
- && (len = strspn(sp + 2, "0123456789;"))
- && sp[2 + len] == 'm')
- {
- char buf3[MAX_TERMINFO_LENGTH];
+ && sp[0] == '\033' && sp[1] == '['
+ && (len = strspn(sp + 2, "0123456789;"))
+ && sp[2 + len] == 'm') {
+ char buf3[MAX_TERMINFO_LENGTH];
(void) strcpy(buf2, "SGR:");
(void) strncpy(buf3, sp + 2, len);
@@ -533,32 +526,29 @@ static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
ep = strtok(buf3, ";");
do {
- bool found = FALSE;
-
- for (ap = ecma_highlights; ap->from; ap++)
- {
- size_t tlen = strlen(ap->from);
-
- if (strncmp(ap->from, ep, tlen) == 0)
- {
- (void) strcat(buf2, ap->to);
- found = TRUE;
- break;
- }
- }
-
- if (!found)
- (void) strcat(buf2, ep);
- (void) strcat(buf2, ";");
- } while
- ((ep = strtok((char *)NULL, ";")));
+ bool found = FALSE;
+
+ for (ap = ecma_highlights; ap->from; ap++) {
+ size_t tlen = strlen(ap->from);
+
+ if (strncmp(ap->from, ep, tlen) == 0) {
+ (void) strcat(buf2, ap->to);
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+ (void) strcat(buf2, ep);
+ (void) strcat(buf2, ";");
+ } while
+ ((ep = strtok((char *) NULL, ";")));
buf2[strlen(buf2) - 1] = '\0';
expansion = buf2;
}
/* now check for scroll region reset */
- if (!expansion)
- {
+ if (!expansion) {
(void) sprintf(buf2, "\033[1;%dr", tp->Numbers[2]);
len = strlen(buf2);
if (strncmp(buf2, sp, len) == 0)
@@ -566,23 +556,19 @@ static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
}
/* now check for home-down */
- if (!expansion)
- {
+ if (!expansion) {
(void) sprintf(buf2, "\033[%d;1H", tp->Numbers[2]);
len = strlen(buf2);
if (strncmp(buf2, sp, len) == 0)
- expansion = "LL";
+ expansion = "LL";
}
/* now look at the expansion we got, if any */
- if (expansion)
- {
+ if (expansion) {
(void) sprintf(buf + strlen(buf), "{%s}", expansion);
sp += len - 1;
continue;
- }
- else
- {
+ } else {
/* couldn't match anything */
buf2[0] = *sp;
buf2[1] = '\0';
@@ -598,44 +584,42 @@ static void analyze_string(const char *name, const char *cap, TERMTYPE *tp)
*
***************************************************************************/
-static void file_comparison(int argc, char *argv[])
+static void
+file_comparison(int argc, char *argv[])
{
#define MAXCOMPARE 2
/* someday we may allow comparisons on more files */
- int filecount = 0;
- ENTRY *heads[MAXCOMPARE];
- ENTRY *tails[MAXCOMPARE];
- ENTRY *qp, *rp;
- int i, n;
+ int filecount = 0;
+ ENTRY *heads[MAXCOMPARE];
+ ENTRY *tails[MAXCOMPARE];
+ ENTRY *qp, *rp;
+ int i, n;
- dump_init((char *)NULL, F_LITERAL, S_TERMINFO, 0, itrace, FALSE);
+ dump_init((char *) NULL, F_LITERAL, S_TERMINFO, 0, itrace, FALSE);
- for (n = 0; n < argc && n < MAXCOMPARE; n++)
- {
+ for (n = 0; n < argc && n < MAXCOMPARE; n++) {
if (freopen(argv[n], "r", stdin) == NULL)
_nc_err_abort("Can't open %s", argv[n]);
- _nc_head = _nc_tail = (ENTRY *)NULL;
+ _nc_head = _nc_tail = (ENTRY *) NULL;
/* parse entries out of the source file */
_nc_set_source(argv[n]);
_nc_read_entry_source(stdin, NULL, TRUE, FALSE, NULLHOOK);
if (itrace)
- (void) fprintf(stderr, "Resolving file %d...\n", n-0);
+ (void) fprintf(stderr, "Resolving file %d...\n", n - 0);
/* do use resolution */
- if (!_nc_resolve_uses())
- {
+ if (!_nc_resolve_uses()) {
(void) fprintf(stderr,
- "There are unresolved use entries in %s:\n",
- argv[n]);
+ "There are unresolved use entries in %s:\n",
+ argv[n]);
for_entry_list(qp)
- if (qp->nuses)
- {
- (void) fputs(qp->tterm.term_names, stderr);
- (void) fputc('\n', stderr);
- }
+ if (qp->nuses) {
+ (void) fputs(qp->tterm.term_names, stderr);
+ (void) fputc('\n', stderr);
+ }
exit(EXIT_FAILURE);
}
@@ -654,11 +638,9 @@ static void file_comparison(int argc, char *argv[])
* we stash each entry's matches in the other file there.
* Sigh, this is intrinsically quadratic.
*/
- for (qp = heads[0]; qp; qp = qp->next)
- {
+ 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))
- {
+ 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
@@ -666,11 +648,11 @@ static void file_comparison(int argc, char *argv[])
* be type-safe.
*/
if (qp->nuses < MAX_USES)
- qp->uses[qp->nuses].parent = (void *)rp;
+ qp->uses[qp->nuses].parent = (void *) rp;
qp->nuses++;
if (rp->nuses < MAX_USES)
- rp->uses[rp->nuses].parent = (void *)qp;
+ rp->uses[rp->nuses].parent = (void *) qp;
rp->nuses++;
}
}
@@ -680,53 +662,49 @@ static void file_comparison(int argc, char *argv[])
(void) fprintf(stderr, "Name matches are done...\n");
for (qp = heads[0]; qp; qp = qp->next)
- if (qp->nuses > 1)
- {
+ if (qp->nuses > 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,
- argv[1]);
+ "%s in file 1 (%s) has %d matches in file 2 (%s):\n",
+ _nc_first_name(qp->tterm.term_names),
+ argv[0],
+ qp->nuses,
+ argv[1]);
for (i = 0; i < qp->nuses; i++)
(void) fprintf(stderr,
- "\t%s\n",
- _nc_first_name(((ENTRY *)qp->uses[i].parent)->tterm.term_names));
+ "\t%s\n",
+ _nc_first_name(((ENTRY *) qp->uses[i].parent)->tterm.term_names));
}
for (rp = heads[1]; rp; rp = rp->next)
- if (rp->nuses > 1)
- {
+ if (rp->nuses > 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,
- argv[0]);
+ "%s in file 2 (%s) has %d matches in file 1 (%s):\n",
+ _nc_first_name(rp->tterm.term_names),
+ argv[1],
+ rp->nuses,
+ argv[0]);
for (i = 0; i < rp->nuses; i++)
(void) fprintf(stderr,
- "\t%s\n",
- _nc_first_name(((ENTRY *)rp->uses[i].parent)->tterm.term_names));
+ "\t%s\n",
+ _nc_first_name(((ENTRY *) rp->uses[i].parent)->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)
(void) printf("\t%s\n",
- _nc_first_name(qp->tterm.term_names));
+ _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)
(void) printf("\t%s\n",
- _nc_first_name(rp->tterm.term_names));
+ _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;
+ for (qp = heads[0]; qp; qp = qp->next) {
+ rp = (ENTRY *) qp->uses[0].parent;
- if (qp->nuses == 1 && entryeq(&qp->tterm, &rp->tterm))
- {
+ if (qp->nuses == 1 && entryeq(&qp->tterm, &rp->tterm)) {
char name1[NAMESIZE], name2[NAMESIZE];
(void) canonical_name(qp->tterm.term_names, name1);
@@ -738,16 +716,14 @@ static void file_comparison(int argc, char *argv[])
(void) printf("Differing entries:\n");
termcount = 2;
- for (qp = heads[0]; qp; qp = qp->next)
- {
- rp = (ENTRY *)qp->uses[0].parent;
+ for (qp = heads[0]; qp; qp = qp->next) {
+ rp = (ENTRY *) qp->uses[0].parent;
#if NCURSES_XNAMES
if (termcount > 1)
_nc_align_termtype(&qp->tterm, &rp->tterm);
#endif
- if (qp->nuses == 1 && !entryeq(&qp->tterm, &rp->tterm))
- {
+ if (qp->nuses == 1 && !entryeq(&qp->tterm, &rp->tterm)) {
char name1[NAMESIZE], name2[NAMESIZE];
term[0] = qp->tterm;
@@ -756,11 +732,10 @@ static void file_comparison(int argc, char *argv[])
(void) canonical_name(qp->tterm.term_names, name1);
(void) canonical_name(rp->tterm.term_names, name2);
- switch (compare)
- {
+ switch (compare) {
case C_DIFFERENCE:
if (itrace)
- (void)fprintf(stderr, "infocmp: dumping differences\n");
+ (void) fprintf(stderr, "infocmp: dumping differences\n");
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, term);
break;
@@ -768,7 +743,7 @@ static void file_comparison(int argc, char *argv[])
case C_COMMON:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping common capabilities\n");
+ "infocmp: dumping common capabilities\n");
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, term);
break;
@@ -776,7 +751,7 @@ static void file_comparison(int argc, char *argv[])
case C_NAND:
if (itrace)
(void) fprintf(stderr,
- "infocmp: dumping differences\n");
+ "infocmp: dumping differences\n");
(void) printf("comparing %s to %s.\n", name1, name2);
compare_entry(compare_predicate, term);
break;
@@ -786,53 +761,56 @@ static void file_comparison(int argc, char *argv[])
}
}
-static void usage(void)
+static void
+usage(void)
{
- static const char *tbl[] = {
- "Usage: infocmp [options] [-A directory] [-B directory] [termname...]"
- ,""
- ,"Options:"
- ," -1 print single-column"
- ," -C use termcap-names"
- ," -F compare terminfo-files"
- ," -I use terminfo-names"
- ," -L use long names"
- ," -R subset (see manpage)"
- ," -T eliminate size limits (test)"
- ," -V print version"
- ," -c list common capabilities"
- ," -d list different capabilities"
- ," -e format output for C initializer"
- ," -E format output as C tables"
- ," -f with -1, format complex strings"
- ," -G format %{number} to %'char'"
- ," -g format %'char' to %{number}"
- ," -i analyze initialization/reset"
- ," -l output terminfo names"
- ," -n list capabilities in neither"
- ," -p ignore padding specifiers"
- ," -r with -C, output in termcap form"
- ," -s [d|i|l|c] sort fields"
- ," -u produce source with 'use='"
- ," -v number (verbose)"
- ," -w number (width)"
- };
- const size_t first = 3;
- const size_t last = sizeof(tbl)/sizeof(tbl[0]);
- const size_t left = (last - first + 1) / 2 + first;
- size_t n;
-
- for (n = 0; n < left; n++) {
- size_t m = (n < first) ? last : n + left - first;
- if (m < last)
- fprintf(stderr, "%-40.40s%s\n", tbl[n], tbl[m]);
- else
- fprintf(stderr, "%s\n", tbl[n]);
- }
- exit(EXIT_FAILURE);
+ static const char *tbl[] =
+ {
+ "Usage: infocmp [options] [-A directory] [-B directory] [termname...]"
+ ,""
+ ,"Options:"
+ ," -1 print single-column"
+ ," -C use termcap-names"
+ ," -F compare terminfo-files"
+ ," -I use terminfo-names"
+ ," -L use long names"
+ ," -R subset (see manpage)"
+ ," -T eliminate size limits (test)"
+ ," -V print version"
+ ," -c list common capabilities"
+ ," -d list different capabilities"
+ ," -e format output for C initializer"
+ ," -E format output as C tables"
+ ," -f with -1, format complex strings"
+ ," -G format %{number} to %'char'"
+ ," -g format %'char' to %{number}"
+ ," -i analyze initialization/reset"
+ ," -l output terminfo names"
+ ," -n list capabilities in neither"
+ ," -p ignore padding specifiers"
+ ," -r with -C, output in termcap form"
+ ," -s [d|i|l|c] sort fields"
+ ," -u produce source with 'use='"
+ ," -v number (verbose)"
+ ," -w number (width)"
+ };
+ const size_t first = 3;
+ const size_t last = sizeof(tbl) / sizeof(tbl[0]);
+ const size_t left = (last - first + 1) / 2 + first;
+ size_t n;
+
+ for (n = 0; n < left; n++) {
+ size_t m = (n < first) ? last : n + left - first;
+ if (m < last)
+ fprintf(stderr, "%-40.40s%s\n", tbl[n], tbl[m]);
+ else
+ fprintf(stderr, "%s\n", tbl[n]);
+ }
+ exit(EXIT_FAILURE);
}
-static char * name_initializer(const char *type)
+static char *
+name_initializer(const char *type)
{
static char *initializer;
char *s;
@@ -841,8 +819,7 @@ static char * name_initializer(const char *type)
initializer = malloc(strlen(term->term_names) + 20);
(void) sprintf(initializer, "%s_data_%s", type, term->term_names);
- for (s = initializer; *s != 0 && *s != '|'; s++)
- {
+ for (s = initializer; *s != 0 && *s != '|'; s++) {
if (!isalnum(*s))
*s = '_';
}
@@ -851,18 +828,17 @@ static char * name_initializer(const char *type)
}
/* dump C initializers for the terminal type */
-static void dump_initializers(void)
+static void
+dump_initializers(void)
{
- int n;
+ int n;
const char *str = 0;
- int size;
+ int size;
(void) printf("static char %s[] = %s\n", name_initializer("bool"), L_CURL);
- for_each_boolean(n,term)
- {
- switch((int)(term->Booleans[n]))
- {
+ for_each_boolean(n, term) {
+ switch ((int) (term->Booleans[n])) {
case TRUE:
str = "TRUE";
break;
@@ -880,17 +856,15 @@ static void dump_initializers(void)
break;
}
(void) printf("\t/* %3d: %-8s */\t%s,\n",
- n, ExtBoolname(term,n,boolnames), str);
+ n, ExtBoolname(term, n, boolnames), str);
}
(void) printf("%s;\n", R_CURL);
(void) printf("static short %s[] = %s\n", name_initializer("number"), L_CURL);
- for_each_number(n,term)
- {
- char buf[BUFSIZ];
- switch (term->Numbers[n])
- {
+ for_each_number(n, term) {
+ char buf[BUFSIZ];
+ switch (term->Numbers[n]) {
case ABSENT_NUMERIC:
str = "ABSENT_NUMERIC";
break;
@@ -902,7 +876,8 @@ static void dump_initializers(void)
str = buf;
break;
}
- (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtNumname(term,n,numnames), str);
+ (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtNumname(term, n,
+ numnames), str);
}
(void) printf("%s;\n", R_CURL);
@@ -912,24 +887,20 @@ static void dump_initializers(void)
(void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL);
- for_each_string(n,term)
- {
- char buf[BUFSIZ], *sp, *tp;
+ for_each_string(n, term) {
+ char buf[BUFSIZ], *sp, *tp;
if (term->Strings[n] == ABSENT_STRING)
str = "ABSENT_STRING";
else if (term->Strings[n] == CANCELLED_STRING)
str = "CANCELLED_STRING";
- else
- {
+ else {
tp = buf;
*tp++ = '"';
- for (sp = term->Strings[n]; *sp; sp++)
- {
- if (isascii(*sp) && isprint(*sp) && *sp !='\\' && *sp != '"')
+ for (sp = term->Strings[n]; *sp; sp++) {
+ if (isascii(*sp) && isprint(*sp) && *sp != '\\' && *sp != '"')
*tp++ = *sp;
- else
- {
+ else {
(void) sprintf(tp, "\\%03o", *sp & 0xff);
tp += 4;
}
@@ -940,20 +911,22 @@ static void dump_initializers(void)
str = buf;
}
#if NCURSES_XNAMES
- if (n == STRCOUNT)
- {
+ if (n == STRCOUNT) {
(void) printf("%s;\n", R_CURL);
- (void) printf("static char * %s[] = %s\n", name_initializer("string_ext"), L_CURL);
+ (void) printf("static char * %s[] = %s\n",
+ name_initializer("string_ext"), L_CURL);
}
#endif
- (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtStrname(term,n,strnames), str);
+ (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtStrname(term, n,
+ strnames), str);
}
(void) printf("%s;\n", R_CURL);
}
/* dump C initializers for the terminal type */
-static void dump_termtype(void)
+static void
+dump_termtype(void)
{
(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");
@@ -968,16 +941,19 @@ static void dump_termtype(void)
(void) printf("\t\t(char *)0,\t/* pointer to extended string table */\n");
(void) printf("\t\t%s,\t/* ...corresponding names */\n",
(NUM_STRINGS(term) != STRCOUNT)
- ? name_initializer("string_ext")
- : "(char **)0");
+ ? name_initializer("string_ext")
+ : "(char **)0");
(void) printf("\t\t%d,\t\t/* count total Booleans */\n", NUM_BOOLEANS(term));
- (void) printf("\t\t%d,\t\t/* count total Numbers */\n", NUM_NUMBERS(term));
- (void) printf("\t\t%d,\t\t/* count total Strings */\n", NUM_STRINGS(term));
+ (void) printf("\t\t%d,\t\t/* count total Numbers */\n", NUM_NUMBERS(term));
+ (void) printf("\t\t%d,\t\t/* count total Strings */\n", NUM_STRINGS(term));
- (void) printf("\t\t%d,\t\t/* count extensions to Booleans */\n", NUM_BOOLEANS(term) - BOOLCOUNT);
- (void) printf("\t\t%d,\t\t/* count extensions to Numbers */\n", NUM_NUMBERS(term) - NUMCOUNT);
- (void) printf("\t\t%d,\t\t/* count extensions to Strings */\n", NUM_STRINGS(term) - STRCOUNT);
+ (void) printf("\t\t%d,\t\t/* count extensions to Booleans */\n",
+ NUM_BOOLEANS(term) - BOOLCOUNT);
+ (void) printf("\t\t%d,\t\t/* count extensions to Numbers */\n",
+ NUM_NUMBERS(term) - NUMCOUNT);
+ (void) printf("\t\t%d,\t\t/* count extensions to Strings */\n",
+ NUM_STRINGS(term) - STRCOUNT);
(void) printf("#endif /* NCURSES_XNAMES */\n");
#endif /* NCURSES_XNAMES */
@@ -990,334 +966,320 @@ static void dump_termtype(void)
*
***************************************************************************/
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
- char *terminal, *firstdir, *restdir;
- /* Avoid "local data >32k" error with mwcc */
- /* Also avoid overflowing smaller stacks on systems like AmigaOS */
- path *tfile = malloc(sizeof(path)*MAXTERMS);
- 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)
- {
- (void) fprintf(stderr,
- "infocmp: environment variable TERM not set\n");
- return EXIT_FAILURE;
- }
+ 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);
+ 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) {
+ (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;
+ /* 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)
- switch (c)
- {
- case 'd':
- compare = C_DIFFERENCE;
- break;
+ while ((c = getopt(argc, argv, "deEcCfFGgIinlLprR:s:uv:Vw:A:B:1T")) != EOF)
+ switch (c) {
+ case 'd':
+ compare = C_DIFFERENCE;
+ break;
- case 'e':
- initdump |= 1;
- break;
+ case 'e':
+ initdump |= 1;
+ break;
- case 'E':
- initdump |= 2;
- break;
+ case 'E':
+ initdump |= 2;
+ break;
- case 'c':
- compare = C_COMMON;
- break;
+ case 'c':
+ compare = C_COMMON;
+ break;
- case 'C':
- outform = F_TERMCAP;
- tversion = "BSD";
- if (sortmode == S_DEFAULT)
- sortmode = S_TERMCAP;
- break;
+ case 'C':
+ outform = F_TERMCAP;
+ tversion = "BSD";
+ if (sortmode == S_DEFAULT)
+ sortmode = S_TERMCAP;
+ break;
- case 'f':
- formatted = TRUE;
- break;
+ case 'f':
+ formatted = TRUE;
+ break;
- case 'G':
- numbers = 1;
- break;
+ case 'G':
+ numbers = 1;
+ break;
- case 'g':
- numbers = -1;
- break;
+ case 'g':
+ numbers = -1;
+ break;
- case 'F':
- filecompare = TRUE;
- break;
+ case 'F':
+ filecompare = TRUE;
+ break;
- case 'I':
- outform = F_TERMINFO;
- if (sortmode == S_DEFAULT)
- sortmode = S_VARIABLE;
- tversion = 0;
- break;
+ case 'I':
+ outform = F_TERMINFO;
+ if (sortmode == S_DEFAULT)
+ sortmode = S_VARIABLE;
+ tversion = 0;
+ break;
- case 'i':
- init_analyze = TRUE;
- break;
+ case 'i':
+ init_analyze = TRUE;
+ break;
- case 'l':
- outform = F_TERMINFO;
- break;
+ case 'l':
+ outform = F_TERMINFO;
+ break;
- case 'L':
- outform = F_VARIABLE;
- if (sortmode == S_DEFAULT)
- sortmode = S_VARIABLE;
- break;
+ case 'L':
+ outform = F_VARIABLE;
+ if (sortmode == S_DEFAULT)
+ sortmode = S_VARIABLE;
+ break;
- case 'n':
- compare = C_NAND;
- break;
+ case 'n':
+ compare = C_NAND;
+ break;
- case 'p':
- ignorepads = TRUE;
- break;
+ case 'p':
+ ignorepads = TRUE;
+ break;
- case 'r':
- tversion = 0;
- limited = FALSE;
- break;
+ case 'r':
+ tversion = 0;
+ limited = FALSE;
+ break;
- case 'R':
- tversion = optarg;
- break;
+ case 'R':
+ tversion = optarg;
+ break;
- case 's':
- if (*optarg == 'd')
- sortmode = S_NOSORT;
- else if (*optarg == 'i')
- sortmode = S_TERMINFO;
- else if (*optarg == 'l')
- sortmode = S_VARIABLE;
- else if (*optarg == 'c')
- sortmode = S_TERMCAP;
- else
- {
- (void) fprintf(stderr,
- "infocmp: unknown sort mode\n");
- return EXIT_FAILURE;
- }
- break;
+ case 's':
+ if (*optarg == 'd')
+ sortmode = S_NOSORT;
+ else if (*optarg == 'i')
+ sortmode = S_TERMINFO;
+ else if (*optarg == 'l')
+ sortmode = S_VARIABLE;
+ else if (*optarg == 'c')
+ sortmode = S_TERMCAP;
+ else {
+ (void) fprintf(stderr,
+ "infocmp: unknown sort mode\n");
+ return EXIT_FAILURE;
+ }
+ break;
- case 'u':
- compare = C_USEALL;
- break;
+ case 'u':
+ compare = C_USEALL;
+ break;
- case 'v':
- itrace = atoi(optarg);
- _nc_tracing = (1 << itrace) - 1;
- break;
+ case 'v':
+ itrace = atoi(optarg);
+ set_trace_level(itrace);
+ break;
- case 'V':
- (void) fputs(NCURSES_VERSION, stdout);
- putchar('\n');
- ExitProgram(EXIT_SUCCESS);
+ case 'V':
+ (void) fputs(NCURSES_VERSION, stdout);
+ putchar('\n');
+ ExitProgram(EXIT_SUCCESS);
- case 'w':
- mwidth = atoi(optarg);
- break;
+ case 'w':
+ mwidth = atoi(optarg);
+ break;
- case 'A':
- firstdir = optarg;
- break;
+ case 'A':
+ firstdir = optarg;
+ break;
- case 'B':
- restdir = optarg;
- break;
+ case 'B':
+ restdir = optarg;
+ break;
- case '1':
- mwidth = 0;
- break;
+ case '1':
+ mwidth = 0;
+ break;
- case 'T':
- limited = FALSE;
- break;
- default:
- usage();
- }
+ case 'T':
+ limited = FALSE;
+ break;
+ default:
+ usage();
+ }
- /* by default, sort by terminfo name */
- if (sortmode == S_DEFAULT)
- sortmode = S_TERMINFO;
+ /* by default, sort by terminfo name */
+ if (sortmode == S_DEFAULT)
+ sortmode = S_TERMINFO;
- /* set up for display */
- dump_init(tversion, outform, sortmode, mwidth, itrace, formatted);
-
- /* make sure we have at least one terminal name to work with */
- if (optind >= argc)
- argv[argc++] = terminal;
-
- /* if user is after a comparison, make sure we have two entries */
- if (compare != C_DEFAULT && optind >= argc - 1)
- argv[argc++] = terminal;
-
- /* exactly two terminal names with no options means do -d */
- if (argc - optind == 2 && compare == C_DEFAULT)
- compare = C_DIFFERENCE;
-
- if (!filecompare)
- {
- /* grab the entries */
- termcount = 0;
- for (; optind < argc; optind++)
- {
- if (termcount >= MAXTERMS)
- {
- (void) fprintf(stderr,
- "infocmp: too many terminal type arguments\n");
- return EXIT_FAILURE;
- }
- else
- {
- const char *directory = termcount ? restdir : firstdir;
- int status;
-
- tname[termcount] = argv[optind];
-
- if (directory)
- {
- (void) sprintf(tfile[termcount], "%s/%c/%s",
- directory,
- *argv[optind], argv[optind]);
- if (itrace)
- (void) fprintf(stderr,
- "infocmp: reading entry %s from file %s\n",
- argv[optind], tfile[termcount]);
-
- status = _nc_read_file_entry(tfile[termcount],
- &term[termcount]);
- }
- else
- {
- if (itrace)
- (void) fprintf(stderr,
- "infocmp: reading entry %s from system directories %s\n",
- argv[optind], tname[termcount]);
-
- status = _nc_read_entry(tname[termcount],
- tfile[termcount],
- &term[termcount]);
- directory = TERMINFO; /* for error message */
- }
+ /* set up for display */
+ dump_init(tversion, outform, sortmode, mwidth, itrace, formatted);
+
+ /* make sure we have at least one terminal name to work with */
+ if (optind >= argc)
+ argv[argc++] = terminal;
+
+ /* if user is after a comparison, make sure we have two entries */
+ if (compare != C_DEFAULT && optind >= argc - 1)
+ argv[argc++] = terminal;
+
+ /* exactly two terminal names with no options means do -d */
+ if (argc - optind == 2 && compare == C_DEFAULT)
+ compare = C_DIFFERENCE;
- if (status <= 0)
- {
+ if (!filecompare) {
+ /* grab the entries */
+ termcount = 0;
+ for (; optind < argc; optind++) {
+ if (termcount >= MAXTERMS) {
+ (void) fprintf(stderr,
+ "infocmp: too many terminal type arguments\n");
+ return EXIT_FAILURE;
+ } else {
+ const char *directory = termcount ? restdir : firstdir;
+ int status;
+
+ tname[termcount] = argv[optind];
+
+ if (directory) {
+ (void) sprintf(tfile[termcount], "%s/%c/%s",
+ directory,
+ *argv[optind], argv[optind]);
+ if (itrace)
(void) fprintf(stderr,
- "infocmp: couldn't open terminfo file %s.\n",
- tfile[termcount]);
- return EXIT_FAILURE;
- }
- termcount++;
+ "infocmp: reading entry %s from file %s\n",
+ argv[optind], tfile[termcount]);
+
+ status = _nc_read_file_entry(tfile[termcount],
+ &term[termcount]);
+ } else {
+ if (itrace)
+ (void) fprintf(stderr,
+ "infocmp: reading entry %s from system directories %s\n",
+ argv[optind], tname[termcount]);
+
+ status = _nc_read_entry(tname[termcount],
+ tfile[termcount],
+ &term[termcount]);
+ directory = TERMINFO; /* for error message */
}
+
+ if (status <= 0) {
+ (void) fprintf(stderr,
+ "infocmp: couldn't open terminfo file %s.\n",
+ tfile[termcount]);
+ return EXIT_FAILURE;
+ }
+ termcount++;
}
+ }
#if NCURSES_XNAMES
- if (termcount > 1)
- _nc_align_termtype(&term[0], &term[1]);
+ if (termcount > 1)
+ _nc_align_termtype(&term[0], &term[1]);
#endif
- /* dump as C initializer for the terminal type */
- if (initdump)
- {
- if (initdump & 1)
- dump_termtype();
- if (initdump & 2)
- dump_initializers();
- ExitProgram(EXIT_SUCCESS);
- }
+ /* dump as C initializer for the terminal type */
+ if (initdump) {
+ if (initdump & 1)
+ dump_termtype();
+ if (initdump & 2)
+ dump_initializers();
+ ExitProgram(EXIT_SUCCESS);
+ }
- /* analyze the init strings */
- if (init_analyze)
- {
+ /* 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]);
+ 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]);
#undef CUR
- ExitProgram(EXIT_SUCCESS);
- }
+ ExitProgram(EXIT_SUCCESS);
+ }
- /*
- * Here's where the real work gets done
- */
- switch (compare)
- {
- case C_DEFAULT:
- if (itrace)
- (void) fprintf(stderr,
- "infocmp: about to dump %s\n",
- tname[0]);
- (void) printf("#\tReconstructed via infocmp from file: %s\n",
- tfile[0]);
- len = dump_entry(&term[0], limited, numbers, NULL);
- putchar('\n');
- if (itrace)
- (void)fprintf(stderr, "infocmp: length %d\n", len);
- break;
+ /*
+ * Here's where the real work gets done
+ */
+ switch (compare) {
+ case C_DEFAULT:
+ if (itrace)
+ (void) fprintf(stderr,
+ "infocmp: about to dump %s\n",
+ tname[0]);
+ (void) printf("#\tReconstructed via infocmp from file: %s\n",
+ tfile[0]);
+ len = dump_entry(&term[0], limited, numbers, NULL);
+ putchar('\n');
+ if (itrace)
+ (void) fprintf(stderr, "infocmp: length %d\n", len);
+ break;
- case C_DIFFERENCE:
- 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);
- break;
+ case C_DIFFERENCE:
+ 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);
+ break;
- case C_COMMON:
- if (itrace)
- (void) fprintf(stderr,
- "infocmp: dumping common capabilities\n");
- (void) printf("comparing %s to %s.\n", tname[0], tname[1]);
- 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", tname[0], tname[1]);
+ 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", tname[0], tname[1]);
- 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", tname[0], tname[1]);
+ compare_entry(compare_predicate, term);
+ break;
- case C_USEALL:
- if (itrace)
- (void) fprintf(stderr, "infocmp: dumping use entry\n");
- len = dump_entry(&term[0], limited, numbers, use_predicate);
- for (i = 1; i < termcount; i++)
- len += dump_uses(tname[i], !(outform==F_TERMCAP || outform==F_TCONVERR));
- putchar('\n');
- if (itrace)
- (void)fprintf(stderr, "infocmp: length %d\n", len);
- break;
- }
+ case C_USEALL:
+ if (itrace)
+ (void) fprintf(stderr, "infocmp: dumping use entry\n");
+ len = dump_entry(&term[0], limited, numbers, use_predicate);
+ for (i = 1; i < termcount; i++)
+ len += dump_uses(tname[i], !(outform == F_TERMCAP || outform
+ == F_TCONVERR));
+ putchar('\n');
+ if (itrace)
+ (void) fprintf(stderr, "infocmp: length %d\n", len);
+ break;
}
- else if (compare == C_USEALL)
- (void) fprintf(stderr, "Sorry, -u doesn't work with -F\n");
- else if (compare == C_DEFAULT)
- (void) fprintf(stderr, "Use `tic -[CI] <file>' for this.\n");
- else if (argc - optind != 2)
- (void) fprintf(stderr,
- "File comparison needs exactly two file arguments.\n");
- else
- file_comparison(argc-optind, argv+optind);
+ } else if (compare == C_USEALL)
+ (void) fprintf(stderr, "Sorry, -u doesn't work with -F\n");
+ else if (compare == C_DEFAULT)
+ (void) fprintf(stderr, "Use `tic -[CI] <file>' for this.\n");
+ else if (argc - optind != 2)
+ (void) fprintf(stderr,
+ "File comparison needs exactly two file arguments.\n");
+ else
+ file_comparison(argc - optind, argv + optind);
- ExitProgram(EXIT_SUCCESS);
+ ExitProgram(EXIT_SUCCESS);
}
/* infocmp.c ends here */
diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c
index 428f77ca01d..2fb3b3ab033 100644
--- a/usr.bin/tic/tic.c
+++ b/usr.bin/tic/tic.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,1999 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 *
@@ -42,7 +42,7 @@
#include <dump_entry.h>
#include <term_entry.h>
-MODULE_ID("$From: tic.c,v 1.55 1999/12/11 20:20:54 tom Exp $")
+MODULE_ID("$From: tic.c,v 1.57 2000/01/15 21:44:28 tom Exp $")
const char *_nc_progname = "tic";
@@ -518,7 +518,7 @@ main(int argc, char *argv[])
}
debug_level = (v_opt > 0) ? v_opt : (v_opt == 0);
- _nc_tracing = (1 << debug_level) - 1;
+ set_trace_level(debug_level);
if (_nc_tracing) {
save_check_termtype = _nc_check_termtype;