diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-12-12 04:49:20 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-12-12 04:49:20 +0000 |
commit | 0b755b897d08e998e345bce55e1bd47e5f507d99 (patch) | |
tree | b7acd2e68f3facb3817d3cc778d008fe5eb03a8a /usr.bin/tic | |
parent | 7ce53302fb39b617a8b44bea4abf417d703e80ef (diff) |
Update to ncurses-19991211:
o treat as untranslatable to termcap those terminfo strings which
contain non-decimal formatting, e.g., hexadecimal or octal.
o correct commented-out capabilities that cannot be translated to
termcap, which did not check if a colon must be escaped.
o correct termcap translation for "%>" and "%+", which did not check
if a colon must be escaped, for instance.
o use save_string/save_char for _nc_captoinfo() to eliminate fixed
buffer (originally for _nc_infotocap() in 960301 -TD).
o correct expression used for terminfo equivalent of termcap %B,
adjust regent100 entry which uses this.
o some cleanup and commenting of ad hoc cases in _nc_infotocap().
o eliminate a fixed-buffer in tic, used for translating comments.
o add manpage for infotocap.
Diffstat (limited to 'usr.bin/tic')
-rw-r--r-- | usr.bin/tic/dump_entry.c | 716 | ||||
-rw-r--r-- | usr.bin/tic/infotocap.1 | 74 | ||||
-rw-r--r-- | usr.bin/tic/tic.1 | 4 | ||||
-rw-r--r-- | usr.bin/tic/tic.c | 1183 |
4 files changed, 1019 insertions, 958 deletions
diff --git a/usr.bin/tic/dump_entry.c b/usr.bin/tic/dump_entry.c index 1616f99fe18..83a6f5b93ec 100644 --- a/usr.bin/tic/dump_entry.c +++ b/usr.bin/tic/dump_entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dump_entry.c,v 1.9 1999/12/06 02:14:34 millert Exp $ */ +/* $OpenBSD: dump_entry.c,v 1.10 1999/12/12 04:49:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -40,32 +40,31 @@ #include <termsort.c> /* this C file is generated */ #include <parametrized.h> /* so is this */ -MODULE_ID("$From: dump_entry.c,v 1.41 1999/12/05 02:03:59 tom Exp $") - +MODULE_ID("$From: dump_entry.c,v 1.43 1999/12/12 02:29:54 tom Exp $") #define INDENT 8 #define DISCARD(string) string = ABSENT_STRING -static int tversion; /* terminfo version */ -static int outform; /* output format to use */ -static int sortmode; /* sort mode to use */ -static int width = 60; /* max line width for listings */ -static int column; /* current column, limited by 'width' */ -static int oldcol; /* last value of column before wrap */ -static int tracelevel; /* level of debug output */ -static bool pretty; /* true if we format if-then-else strings */ + static int tversion; /* terminfo version */ + static int outform; /* output format to use */ + static int sortmode; /* sort mode to use */ + static int width = 60; /* max line width for listings */ + static int column; /* current column, limited by 'width' */ + static int oldcol; /* last value of column before wrap */ + static int tracelevel; /* level of debug output */ + static bool pretty; /* true if we format if-then-else strings */ -static char *outbuf; /* the output-buffer */ -static size_t out_used; /* ...its current length */ -static size_t out_size; /* ...and its allocated length */ + static char *outbuf; /* the output-buffer */ + static size_t out_used; /* ...its current length */ + static size_t out_size; /* ...and its allocated length */ /* indirection pointers for implementing sort and display modes */ -static const int *bool_indirect, *num_indirect, *str_indirect; -static NCURSES_CONST char * const *bool_names; -static NCURSES_CONST char * const *num_names; -static NCURSES_CONST char * const *str_names; + static const int *bool_indirect, *num_indirect, *str_indirect; + static NCURSES_CONST char *const *bool_names; + static NCURSES_CONST char *const *num_names; + static NCURSES_CONST char *const *str_names; -static const char *separator, *trailer; + static const char *separator, *trailer; /* cover various ports and variants of terminfo */ #define V_ALLCAPS 0 /* all capabilities (SVr4, XSI, ncurses) */ @@ -93,43 +92,46 @@ static const char *separator, *trailer; #endif #if NO_LEAKS -void _nc_leaks_dump_entry(void) + void + _nc_leaks_dump_entry(void) { - if (outbuf != 0) { - free(outbuf); - outbuf = 0; - } + if (outbuf != 0) { + free(outbuf); + outbuf = 0; + } } #endif -NCURSES_CONST char *nametrans(const char *name) +NCURSES_CONST char * +nametrans(const char *name) /* translate a capability name from termcap to terminfo */ { - const struct name_table_entry *np; + const struct name_table_entry *np; if ((np = _nc_find_entry(name, _nc_get_hash_table(0))) != 0) - switch(np->nte_type) - { + switch (np->nte_type) { case BOOLEAN: if (bool_from_termcap[np->nte_index]) - return(boolcodes[np->nte_index]); + return (boolcodes[np->nte_index]); break; case NUMBER: if (num_from_termcap[np->nte_index]) - return(numcodes[np->nte_index]); + return (numcodes[np->nte_index]); break; case STRING: if (str_from_termcap[np->nte_index]) - return(strcodes[np->nte_index]); + return (strcodes[np->nte_index]); break; } - return(0); + return (0); } -void dump_init(const char *version, int mode, int sort, int twidth, int traceval, bool formatted) +void +dump_init(const char *version, int mode, int sort, int twidth, int traceval, + bool formatted) /* set up for entry display */ { width = twidth; @@ -140,7 +142,7 @@ void dump_init(const char *version, int mode, int sort, int twidth, int traceval if (version == 0) tversion = V_ALLCAPS; else if (!strcmp(version, "SVr1") || !strcmp(version, "SVR1") - || !strcmp(version, "Ultrix")) + || !strcmp(version, "Ultrix")) tversion = V_SVR1; else if (!strcmp(version, "HP")) tversion = V_HPUX; @@ -152,8 +154,7 @@ void dump_init(const char *version, int mode, int sort, int twidth, int traceval tversion = V_ALLCAPS; /* implement display modes */ - switch (outform = mode) - { + switch (outform = mode) { case F_LITERAL: case F_TERMINFO: bool_names = boolnames; @@ -182,18 +183,17 @@ void dump_init(const char *version, int mode, int sort, int twidth, int traceval } /* implement sort modes */ - switch(sortmode = sort) - { + switch (sortmode = sort) { case S_NOSORT: if (traceval) (void) fprintf(stderr, - "%s: sorting by term structure order\n", _nc_progname); + "%s: sorting by term structure order\n", _nc_progname); break; case S_TERMINFO: if (traceval) (void) fprintf(stderr, - "%s: sorting by terminfo name order\n", _nc_progname); + "%s: sorting by terminfo name order\n", _nc_progname); bool_indirect = bool_terminfo_sort; num_indirect = num_terminfo_sort; str_indirect = str_terminfo_sort; @@ -202,7 +202,7 @@ void dump_init(const char *version, int mode, int sort, int twidth, int traceval case S_VARIABLE: if (traceval) (void) fprintf(stderr, - "%s: sorting by C variable order\n", _nc_progname); + "%s: sorting by C variable order\n", _nc_progname); bool_indirect = bool_variable_sort; num_indirect = num_variable_sort; str_indirect = str_variable_sort; @@ -211,7 +211,7 @@ void dump_init(const char *version, int mode, int sort, int twidth, int traceval case S_TERMCAP: if (traceval) (void) fprintf(stderr, - "%s: sorting by termcap name order\n", _nc_progname); + "%s: sorting by termcap name order\n", _nc_progname); bool_indirect = bool_termcap_sort; num_indirect = num_termcap_sort; str_indirect = str_termcap_sort; @@ -220,49 +220,49 @@ void dump_init(const char *version, int mode, int sort, int twidth, int traceval if (traceval) (void) fprintf(stderr, - "%s: width = %d, tversion = %d, outform = %d\n", - _nc_progname, width, tversion, outform); + "%s: width = %d, tversion = %d, outform = %d\n", + _nc_progname, width, tversion, outform); } -static TERMTYPE *cur_type; +static TERMTYPE *cur_type; -static int dump_predicate(int type, int idx) +static int +dump_predicate(int type, int idx) /* predicate function to use for ordinary decompilation */ { - switch(type) { - case BOOLEAN: - return (cur_type->Booleans[idx] == FALSE) - ? FAIL : cur_type->Booleans[idx]; - - case NUMBER: - return (cur_type->Numbers[idx] == ABSENT_NUMERIC) - ? FAIL : cur_type->Numbers[idx]; - - case STRING: - return (cur_type->Strings[idx] != ABSENT_STRING) - ? (int)TRUE : FAIL; - } + switch (type) { + case BOOLEAN: + return (cur_type->Booleans[idx] == FALSE) + ? FAIL : cur_type->Booleans[idx]; + + case NUMBER: + return (cur_type->Numbers[idx] == ABSENT_NUMERIC) + ? FAIL : cur_type->Numbers[idx]; + + case STRING: + return (cur_type->Strings[idx] != ABSENT_STRING) + ? (int) TRUE : FAIL; + } - return(FALSE); /* pacify compiler */ + return (FALSE); /* pacify compiler */ } -static void set_obsolete_termcaps(TERMTYPE *tp); -static void repair_acsc(TERMTYPE *tp); +static void set_obsolete_termcaps(TERMTYPE * tp); +static void repair_acsc(TERMTYPE * tp); /* is this the index of a function key string? */ #define FNKEY(i) (((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268)) -static bool version_filter(int type, int idx) +static bool +version_filter(int type, int idx) /* filter out capabilities we may want to suppress */ { - switch (tversion) - { - case V_ALLCAPS: /* SVr4, XSI Curses */ - return(TRUE); - - case V_SVR1: /* System V Release 1, Ultrix */ - switch (type) - { + switch (tversion) { + case V_ALLCAPS: /* SVr4, XSI Curses */ + return (TRUE); + + case V_SVR1: /* System V Release 1, Ultrix */ + switch (type) { case BOOLEAN: /* below and including xon_xoff */ return ((idx <= 20) ? TRUE : FALSE); @@ -276,8 +276,7 @@ static bool version_filter(int type, int idx) break; case V_HPUX: /* Hewlett-Packard */ - switch (type) - { + switch (type) { case BOOLEAN: /* below and including xon_xoff */ return ((idx <= 20) ? TRUE : FALSE); @@ -286,19 +285,18 @@ static bool version_filter(int type, int idx) return ((idx <= 10) ? TRUE : FALSE); case STRING: if (idx <= 144) /* below and including prtr_non */ - return(TRUE); + return (TRUE); else if (FNKEY(idx)) /* function keys */ - return(TRUE); - else if (idx==147||idx==156||idx==157) /* plab_norm,label_on,label_off */ - return(TRUE); + return (TRUE); + else if (idx == 147 || idx == 156 || idx == 157) /* plab_norm,label_on,label_off */ + return (TRUE); else - return(FALSE); + return (FALSE); } break; case V_AIX: /* AIX */ - switch (type) - { + switch (type) { case BOOLEAN: /* below and including xon_xoff */ return ((idx <= 20) ? TRUE : FALSE); @@ -307,17 +305,16 @@ static bool version_filter(int type, int idx) return ((idx <= 7) ? TRUE : FALSE); case STRING: if (idx <= 144) /* below and including prtr_non */ - return(TRUE); + return (TRUE); else if (FNKEY(idx)) /* function keys */ - return(TRUE); + return (TRUE); else - return(FALSE); + return (FALSE); } break; case V_BSD: /* BSD */ - switch (type) - { + switch (type) { case BOOLEAN: return bool_from_termcap[idx]; case NUMBER: @@ -328,51 +325,54 @@ static bool version_filter(int type, int idx) break; } - return(FALSE); /* pacify the compiler */ + return (FALSE); /* pacify the compiler */ } static -void append_output (const char *src) +void +append_output(const char *src) { - if (src == 0) { - out_used = 0; - append_output(""); - } else { - size_t need = strlen(src); - size_t want = need + out_used + 1; - if (want > out_size) { - out_size += want; /* be generous */ - if (outbuf == 0) - outbuf = malloc(out_size); - else - outbuf = realloc(outbuf, out_size); - } - (void)strcpy(outbuf + out_used, src); - out_used += need; + if (src == 0) { + out_used = 0; + append_output(""); + } else { + size_t need = strlen(src); + size_t want = need + out_used + 1; + if (want > out_size) { + out_size += want; /* be generous */ + if (outbuf == 0) + outbuf = malloc(out_size); + else + outbuf = realloc(outbuf, out_size); } + (void) strcpy(outbuf + out_used, src); + out_used += need; + } } static -void force_wrap(void) +void +force_wrap(void) { - oldcol = column; - append_output(trailer); - column = INDENT; + oldcol = column; + append_output(trailer); + column = INDENT; } static -void wrap_concat(const char *src) +void +wrap_concat(const char *src) { - int need = strlen(src); - int want = strlen(separator) + need; + int need = strlen(src); + int want = strlen(separator) + need; - if (column > INDENT - && column + want > width) { - force_wrap(); - } - append_output(src); - append_output(separator); - column += need; + if (column > INDENT + && column + want > width) { + force_wrap(); + } + append_output(src); + append_output(separator); + column += need; } #define IGNORE_SEP_TRAIL(first,last,sep_trail) \ @@ -390,109 +390,112 @@ void wrap_concat(const char *src) * of the best fixed-buffer implementation; the worst case may be much worse. */ #ifdef TEST_TERMCAP_LENGTH -static int termcap_length(const char *src) +static int +termcap_length(const char *src) { - static const char pattern[] = ":\\\n\t:"; + static const char pattern[] = ":\\\n\t:"; - int len = 0; - const char *const t = src + strlen(src); + int len = 0; + const char *const t = src + strlen(src); - while (*src != '\0') { - IGNORE_SEP_TRAIL(src, t, pattern); - src++; - len++; - } - return len; + while (*src != '\0') { + IGNORE_SEP_TRAIL(src, t, pattern); + src++; + len++; + } + return len; } #else #define termcap_length(src) strlen(src) #endif -static char * fmt_complex(char *dst, char *src, int level) +static char * +fmt_complex(char *dst, char *src, int level) { - int percent = 0; - int n; - bool if_then = strstr(src, "%?") != 0; - bool params = !if_then && (strlen(src) > 50) && (strstr(src, "%p") != 0); - - dst += strlen(dst); - while (*src != '\0') { - switch (*src) { - case '\\': - percent = 0; - *dst++ = *src++; - break; - case '%': - percent = 1; - break; - case '?': /* "if" */ - case 't': /* "then" */ - case 'e': /* "else" */ - if (percent) { - percent = 0; - dst[-1] = '\n'; - for (n = 0; n <= level; n++) - *dst++ = '\t'; - *dst++ = '%'; - *dst++ = *src; - *dst = '\0'; - if (*src++ == '?') { - src = fmt_complex(dst, src, level+1); - dst += strlen(dst); - } else if (level == 1) { - _nc_warning("%%%c without %%?", *src); - } - continue; - } - break; - case ';': /* "endif" */ - if (percent) { - percent = 0; - if (level > 1) { - dst[-1] = '\n'; - for (n = 0; n < level; n++) - *dst++ = '\t'; - *dst++ = '%'; - *dst++ = *src++; - *dst = '\0'; - return src; - } - _nc_warning("%%; without %%?"); - } - break; - case 'p': - if (percent && params) { - dst[-1] = '\n'; - for (n = 0; n <= level; n++) - *dst++ = '\t'; - *dst++ = '%'; - } - percent = 0; - break; - default: - percent = 0; - break; + int percent = 0; + int n; + bool if_then = strstr(src, "%?") != 0; + bool params = !if_then && (strlen(src) > 50) && (strstr(src, "%p") != 0); + + dst += strlen(dst); + while (*src != '\0') { + switch (*src) { + case '\\': + percent = 0; + *dst++ = *src++; + break; + case '%': + percent = 1; + break; + case '?': /* "if" */ + case 't': /* "then" */ + case 'e': /* "else" */ + if (percent) { + percent = 0; + dst[-1] = '\n'; + for (n = 0; n <= level; n++) + *dst++ = '\t'; + *dst++ = '%'; + *dst++ = *src; + *dst = '\0'; + if (*src++ == '?') { + src = fmt_complex(dst, src, level + 1); + dst += strlen(dst); + } else if (level == 1) { + _nc_warning("%%%c without %%?", *src); + } + continue; + } + break; + case ';': /* "endif" */ + if (percent) { + percent = 0; + if (level > 1) { + dst[-1] = '\n'; + for (n = 0; n < level; n++) + *dst++ = '\t'; + *dst++ = '%'; + *dst++ = *src++; + *dst = '\0'; + return src; } - *dst++ = *src++; + _nc_warning("%%; without %%?"); + } + break; + case 'p': + if (percent && params) { + dst[-1] = '\n'; + for (n = 0; n <= level; n++) + *dst++ = '\t'; + *dst++ = '%'; + } + percent = 0; + break; + default: + percent = 0; + break; } - *dst = '\0'; - return src; + *dst++ = *src++; + } + *dst = '\0'; + return src; } -int fmt_entry(TERMTYPE *tterm, - int (*pred)(int type, int idx), - bool suppress_untranslatable, - bool infodump, - int numbers) +int +fmt_entry(TERMTYPE * tterm, + int (*pred) (int type, int idx), + bool suppress_untranslatable, + bool infodump, + int numbers) { -int i, j; -char buffer[MAX_TERMINFO_LENGTH]; -NCURSES_CONST char *name; -int predval, len; -int num_bools = 0; -int num_values = 0; -int num_strings = 0; -bool outcount = 0; + int i, j; + char buffer[MAX_TERMINFO_LENGTH]; + NCURSES_CONST char *name; + int predval, len; + int num_bools = 0; + int num_values = 0; + int num_strings = 0; + bool outcount = 0; #define WRAP_CONCAT \ wrap_concat(buffer); \ @@ -511,13 +514,13 @@ bool outcount = 0; column = out_used; force_wrap(); - for_each_boolean(j,tterm) { + for_each_boolean(j, tterm) { i = BoolIndirect(j); - name = ExtBoolname(tterm,i,bool_names); + name = ExtBoolname(tterm, i, bool_names); if (!version_filter(BOOLEAN, i)) continue; - else if (isObsolete(outform,name)) + else if (isObsolete(outform, name)) continue; predval = pred(BOOLEAN, i); @@ -534,13 +537,13 @@ bool outcount = 0; if (column != INDENT) force_wrap(); - for_each_number(j,tterm) { + for_each_number(j, tterm) { i = NumIndirect(j); - name = ExtNumname(tterm,i,num_names); + name = ExtNumname(tterm, i, num_names); if (!version_filter(NUMBER, i)) continue; - else if (isObsolete(outform,name)) + else if (isObsolete(outform, name)) continue; predval = pred(NUMBER, i); @@ -560,19 +563,19 @@ bool outcount = 0; force_wrap(); len += num_bools - + num_values * 2 - + strlen(tterm->term_names) + 1; + + num_values * 2 + + strlen(tterm->term_names) + 1; if (len & 1) - len++; + len++; repair_acsc(tterm); for_each_string(j, tterm) { i = StrIndirect(j); - name = ExtStrname(tterm,i,str_names); + name = ExtStrname(tterm, i, str_names); if (!version_filter(STRING, i)) continue; - else if (isObsolete(outform,name)) + else if (isObsolete(outform, name)) continue; /* @@ -580,35 +583,31 @@ bool outcount = 0; * for ich/ich1 to work. If they're not defined, force * them to be output as defined and empty. */ - if (outform==F_TERMCAP) - { + if (outform == F_TERMCAP) { #undef CUR #define CUR tterm-> - if (insert_character || parm_ich) - { + if (insert_character || parm_ich) { if (&tterm->Strings[i] == &enter_insert_mode - && enter_insert_mode == ABSENT_STRING) - { + && enter_insert_mode == ABSENT_STRING) { (void) strcpy(buffer, "im="); goto catenate; } if (&tterm->Strings[i] == &exit_insert_mode - && exit_insert_mode == ABSENT_STRING) - { + && exit_insert_mode == ABSENT_STRING) { (void) strcpy(buffer, "ei="); goto catenate; } } if (init_3string != 0 - && termcap_reset != 0 - && !strcmp(init_3string, termcap_reset)) + && termcap_reset != 0 + && !strcmp(init_3string, termcap_reset)) DISCARD(init_3string); if (reset_2string != 0 - && termcap_reset != 0 - && !strcmp(reset_2string, termcap_reset)) + && termcap_reset != 0 + && !strcmp(reset_2string, termcap_reset)) DISCARD(reset_2string); } @@ -616,42 +615,51 @@ bool outcount = 0; buffer[0] = '\0'; if (predval != FAIL) { if (tterm->Strings[i] != ABSENT_STRING - && i + 1 > num_strings) + && i + 1 > num_strings) num_strings = i + 1; if (!VALID_STRING(tterm->Strings[i])) sprintf(buffer, "%s@", name); - else if (outform == F_TERMCAP || outform == F_TCONVERR) - { + else if (outform == F_TERMCAP || outform == F_TCONVERR) { char *srccap = _nc_tic_expand(tterm->Strings[i], TRUE, numbers); char *cv = _nc_infotocap(name, srccap, parametrized[i]); - if (cv == 0) - { + if (cv == 0) { if (outform == F_TCONVERR) - sprintf(buffer, "%s=!!! %s WILL NOT CONVERT !!!", name, srccap); + sprintf(buffer, "%s=!!! %s WILL NOT CONVERT !!!", + name, srccap); else if (suppress_untranslatable) continue; - else - sprintf(buffer, "..%s=%s", name, srccap); - } - else + else { + char *s = srccap, *d = buffer; + sprintf(d, "..%s=", name); + d += strlen(d); + while ((*d = *s++) != 0) { + if (*d == ':') { + *d++ = '\\'; + *d = ':'; + } else if (*d == '\\') { + *++d = *s++; + } + d++; + } + } + } else sprintf(buffer, "%s=%s", name, cv); len += strlen(tterm->Strings[i]) + 1; - } - else - { - char *src = _nc_tic_expand(tterm->Strings[i], outform==F_TERMINFO, numbers); + } else { + char *src = _nc_tic_expand(tterm->Strings[i], + outform == F_TERMINFO, numbers); sprintf(buffer, "%s=", name); if (pretty - && (outform == F_TERMINFO - || outform == F_VARIABLE)) + && (outform == F_TERMINFO + || outform == F_VARIABLE)) fmt_complex(buffer + strlen(buffer), src, 1); else strcat(buffer, src); len += strlen(tterm->Strings[i]) + 1; } - catenate: + catenate: WRAP_CONCAT; } } @@ -662,46 +670,38 @@ bool outcount = 0; * postprocess_terminfo and postprocess_terminfo in parse_entry.c. * Much more work should be done on this to support dumping termcaps. */ - if (tversion == V_HPUX) - { - if (memory_lock) - { + if (tversion == V_HPUX) { + if (memory_lock) { (void) sprintf(buffer, "meml=%s", memory_lock); WRAP_CONCAT; } - if (memory_unlock) - { + if (memory_unlock) { (void) sprintf(buffer, "memu=%s", memory_unlock); WRAP_CONCAT; } - } - else if (tversion == V_AIX) - { - if (VALID_STRING(acs_chars)) - { - bool box_ok = TRUE; - const char *acstrans = "lqkxjmwuvtn"; - const char *cp; - char *tp, *sp, boxchars[11]; + } else if (tversion == V_AIX) { + if (VALID_STRING(acs_chars)) { + bool box_ok = TRUE; + const char *acstrans = "lqkxjmwuvtn"; + const char *cp; + char *tp, *sp, boxchars[11]; tp = boxchars; - for (cp = acstrans; *cp; cp++) - { + for (cp = acstrans; *cp; cp++) { sp = strchr(acs_chars, *cp); if (sp) *tp++ = sp[1]; - else - { + else { box_ok = FALSE; break; } } tp[0] = '\0'; - if (box_ok) - { + if (box_ok) { (void) strcpy(buffer, "box1="); - (void) strcat(buffer, _nc_tic_expand(boxchars, outform==F_TERMINFO, numbers)); + (void) strcat(buffer, _nc_tic_expand(boxchars, + outform == F_TERMINFO, numbers)); WRAP_CONCAT; } } @@ -711,30 +711,28 @@ bool outcount = 0; * kludge: trim off trailer to avoid an extra blank line * in infocmp -u output when there are no string differences */ - if (outcount) - { + if (outcount) { j = out_used; if (j >= 2 - && outbuf[j-1] == '\t' - && outbuf[j-2] == '\n') { + && outbuf[j - 1] == '\t' + && outbuf[j - 2] == '\n') { out_used -= 2; } else if (j >= 4 - && outbuf[j-1] == ':' - && outbuf[j-2] == '\t' - && outbuf[j-3] == '\n' - && outbuf[j-4] == '\\') { + && outbuf[j - 1] == ':' + && outbuf[j - 2] == '\t' + && outbuf[j - 3] == '\n' + && outbuf[j - 4] == '\\') { out_used -= 4; } outbuf[out_used] = '\0'; column = oldcol; } - #if 0 fprintf(stderr, "num_bools = %d\n", num_bools); fprintf(stderr, "num_values = %d\n", num_values); fprintf(stderr, "num_strings = %d\n", num_strings); fprintf(stderr, "term_names=%s, len=%d, strlen(outbuf)=%d, outbuf=%s\n", - tterm->term_names, len, out_used, outbuf); + tterm->term_names, len, out_used, outbuf); #endif /* * Here's where we use infodump to trigger a more stringent length check @@ -743,36 +741,34 @@ bool outcount = 0; * It gives an idea of which entries are deadly to even *scan past*, * as opposed to *use*. */ - return(infodump ? len : termcap_length(outbuf)); + return (infodump ? len : termcap_length(outbuf)); } -int dump_entry(TERMTYPE *tterm, bool limited, int numbers, int (*pred)(int type, int idx)) +int +dump_entry(TERMTYPE * tterm, bool limited, int numbers, int (*pred) (int + type, int idx)) /* dump a single entry */ { - int len, critlen; - const char *legend; - bool infodump; + int len, critlen; + const char *legend; + bool infodump; - if (outform==F_TERMCAP || outform==F_TCONVERR) - { + if (outform == F_TERMCAP || outform == F_TCONVERR) { critlen = MAX_TERMCAP_LENGTH; legend = "older termcap"; infodump = FALSE; set_obsolete_termcaps(tterm); - } - else - { + } else { critlen = MAX_TERMINFO_LENGTH; legend = "terminfo"; infodump = TRUE; } - if (((len = fmt_entry(tterm, pred, FALSE, infodump, numbers)) > critlen) && limited) - { + if (((len = fmt_entry(tterm, pred, FALSE, infodump, numbers)) > critlen) + && limited) { (void) printf("# (untranslatable capabilities removed to fit entry within %d bytes)\n", - critlen); - if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) - { + critlen); + if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) { /* * We pick on sgr because it's a nice long string capability that * is really just an optimization hack. @@ -780,24 +776,23 @@ int dump_entry(TERMTYPE *tterm, bool limited, int numbers, int (*pred)(int type, char *oldsgr = set_attributes; set_attributes = ABSENT_STRING; (void) printf("# (sgr removed to fit entry within %d bytes)\n", - critlen); - if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) - { + critlen); + if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) { int oldversion = tversion; tversion = V_BSD; (void) printf("# (terminfo-only capabilities suppressed to fit entry within %d bytes)\n", - critlen); + critlen); - if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) > critlen) - { + if ((len = fmt_entry(tterm, pred, TRUE, infodump, numbers)) + > critlen) { (void) fprintf(stderr, - "warning: %s entry is %d bytes long\n", - _nc_first_name(tterm->term_names), - len); + "warning: %s entry is %d bytes long\n", + _nc_first_name(tterm->term_names), + len); (void) printf( - "# WARNING: this entry, %d bytes long, may core-dump %s libraries!\n", - len, legend); + "# WARNING: this entry, %d bytes long, may core-dump %s libraries!\n", + len, legend); } tversion = oldversion; } @@ -809,58 +804,57 @@ int dump_entry(TERMTYPE *tterm, bool limited, int numbers, int (*pred)(int type, return len; } -int dump_uses(const char *name, bool infodump) +int +dump_uses(const char *name, bool infodump) /* dump "use=" clauses in the appropriate format */ { char buffer[MAX_TERMINFO_LENGTH]; append_output(0); - (void)sprintf(buffer, "%s%s", infodump ? "use=" : "tc=", name); + (void) sprintf(buffer, "%s%s", infodump ? "use=" : "tc=", name); wrap_concat(buffer); (void) fputs(outbuf, stdout); return out_used; } -void compare_entry(void (*hook)(int t, int i, const char *name), TERMTYPE *tp GCC_UNUSED) +void +compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp GCC_UNUSED) /* compare two entries */ { - int i, j; - NCURSES_CONST char * name; + int i, j; + NCURSES_CONST char *name; (void) fputs(" comparing booleans.\n", stdout); - for_each_boolean(j,tp) - { + for_each_boolean(j, tp) { i = BoolIndirect(j); - name = ExtBoolname(tp,i,bool_names); + name = ExtBoolname(tp, i, bool_names); - if (isObsolete(outform,name)) + if (isObsolete(outform, name)) continue; - (*hook)(BOOLEAN, i, name); + (*hook) (BOOLEAN, i, name); } (void) fputs(" comparing numbers.\n", stdout); - for_each_number(j,tp) - { + for_each_number(j, tp) { i = NumIndirect(j); - name = ExtNumname(tp,i,num_names); + name = ExtNumname(tp, i, num_names); - if (isObsolete(outform,name)) + if (isObsolete(outform, name)) continue; - (*hook)(NUMBER, i, name); + (*hook) (NUMBER, i, name); } (void) fputs(" comparing strings.\n", stdout); - for_each_string(j,tp) - { + for_each_string(j, tp) { i = StrIndirect(j); - name = ExtStrname(tp,i,str_names); + name = ExtStrname(tp, i, str_names); - if (isObsolete(outform,name)) + if (isObsolete(outform, name)) continue; - (*hook)(STRING, i, name); + (*hook) (STRING, i, name); } } @@ -874,7 +868,8 @@ void compare_entry(void (*hook)(int t, int i, const char *name), TERMTYPE *tp GC #undef CUR #define CUR tp-> -static void set_obsolete_termcaps(TERMTYPE *tp) +static void +set_obsolete_termcaps(TERMTYPE * tp) { #include "capdefaults.c" } @@ -883,46 +878,47 @@ static void set_obsolete_termcaps(TERMTYPE *tp) * Convert an alternate-character-set string to canonical form: sorted and * unique. */ -static void repair_acsc(TERMTYPE *tp) +static void +repair_acsc(TERMTYPE * tp) { - if (VALID_STRING(acs_chars)) { - size_t n, m; - char mapped[256]; - char extra = 0; - unsigned source; - unsigned target; - bool fix_needed = FALSE; - - for (n = 0, source = 0; acs_chars[n] != 0; n++) { - target = acs_chars[n]; - if (source >= target) { - fix_needed = TRUE; - break; - } - source = target; - if (acs_chars[n+1]) - n++; + if (VALID_STRING(acs_chars)) { + size_t n, m; + char mapped[256]; + char extra = 0; + unsigned source; + unsigned target; + bool fix_needed = FALSE; + + for (n = 0, source = 0; acs_chars[n] != 0; n++) { + target = acs_chars[n]; + if (source >= target) { + fix_needed = TRUE; + break; } - if (fix_needed) { - memset(mapped, 0, sizeof(mapped)); - for (n = 0; acs_chars[n] != 0; n++) { - source = acs_chars[n]; - if ((target = (unsigned char)acs_chars[n+1]) != 0) { - mapped[source] = target; - n++; - } else { - extra = source; - } + source = target; + if (acs_chars[n + 1]) + n++; + } + if (fix_needed) { + memset(mapped, 0, sizeof(mapped)); + for (n = 0; acs_chars[n] != 0; n++) { + source = acs_chars[n]; + if ((target = (unsigned char) acs_chars[n + 1]) != 0) { + mapped[source] = target; + n++; + } else { + extra = source; } - for (n = m = 0; n < sizeof(mapped); n++) { - if (mapped[n]) { - acs_chars[m++] = n; - acs_chars[m++] = mapped[n]; - } + } + for (n = m = 0; n < sizeof(mapped); n++) { + if (mapped[n]) { + acs_chars[m++] = n; + acs_chars[m++] = mapped[n]; } - if (extra) - acs_chars[m++] = extra; /* garbage in, garbage out */ - acs_chars[m] = 0; } + if (extra) + acs_chars[m++] = extra; /* garbage in, garbage out */ + acs_chars[m] = 0; } + } } diff --git a/usr.bin/tic/infotocap.1 b/usr.bin/tic/infotocap.1 new file mode 100644 index 00000000000..48418b580a1 --- /dev/null +++ b/usr.bin/tic/infotocap.1 @@ -0,0 +1,74 @@ +'\" t +.\" $OpenBSD: infotocap.1,v 1.1 1999/12/12 04:49:19 millert Exp $ +.\"*************************************************************************** +.\" Copyright (c) 1999 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 * +.\" "Software"), to deal in the Software without restriction, including * +.\" without limitation the rights to use, copy, modify, merge, publish, * +.\" distribute, distribute with modifications, sublicense, and/or sell * +.\" copies of the Software, and to permit persons to whom the Software is * +.\" furnished to do so, subject to the following conditions: * +.\" * +.\" The above copyright notice and this permission notice shall be included * +.\" in all copies or substantial portions of the Software. * +.\" * +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * +.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * +.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * +.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * +.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * +.\" * +.\" Except as contained in this notice, the name(s) of the above copyright * +.\" holders shall not be used in advertising or otherwise to promote the * +.\" sale, use or other dealings in this Software without prior written * +.\" authorization. * +.\"*************************************************************************** +.\" +.\" $From: infotocap.1m,v 1.1 1999/12/11 19:25:27 tom Exp $ +.TH infotocap 1M "" +.ds n 5 +.ds d /usr/share/terminfo +.SH NAME +\fBinfotocap\fR - convert a \fIterminfo\fR description into a \fItermcap\fR description +.SH SYNOPSIS +\fBinfotocap\fR [\fB-v\fR\fIn\fR \fIwidth\fR] [\fB-V\fR] [\fB-1\fR] [\fB-w\fR \fIwidth\fR] \fIfile\fR . . . +.SH DESCRIPTION +\fBinfotocap\fR looks in \fIfile\fR for \fBterminfo\fR descriptions. For each +one found, an equivalent \fBtermcap\fR description is written to standard +output. Terminfo \fBuse\fR capabilities are translated directly to termcap +\fBtc\fR capabilities. +.TP 5 +\fB-v\fR +print out tracing information on standard error as the program runs. +.TP 5 +\fB-V\fR +print out the version of the program in use on standard error and exit. +.TP 5 +\fB-1\fR +cause the fields to print out one to a line. Otherwise, the fields +will be printed several to a line to a maximum width of 60 +characters. +.TP 5 +\fB-w\fR +change the output to \fIwidth\fR characters. +.SH FILES +.TP 20 +\*d +Compiled terminal description database. +.SH NOTES +This utility is actually a link to \fItic\fR(1M), running in \fI-C\fR mode. +.SH SEE ALSO +\fBcurses\fR(3X), +\fBtic\fR(1M), +\fBinfocmp\fR(1M), +\fBterminfo\fR(\*n) +.\"# +.\"# The following sets edit modes for GNU EMACS +.\"# Local Variables: +.\"# mode:nroff +.\"# fill-column:79 +.\"# End: diff --git a/usr.bin/tic/tic.1 b/usr.bin/tic/tic.1 index 40f48fbb449..a1e9e457907 100644 --- a/usr.bin/tic/tic.1 +++ b/usr.bin/tic/tic.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tic.1,v 1.7 1999/06/05 01:21:43 aaron Exp $ +.\" $OpenBSD: tic.1,v 1.8 1999/12/12 04:49:19 millert Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -272,7 +272,7 @@ System V does not compile entries to or read entries from your \fB\*d/?/*\fR Compiled terminal description database. .SH SEE ALSO -\fBinfocmp\fR(1), \fBcaptoinfo\fR(1), \fBcurses\fR(3), \fBterminfo\fR(\*n). +\fBinfocmp\fR(1), \fBinfotocap\fR(1), \fBcaptoinfo\fR(1), \fBcurses\fR(3), \fBterminfo\fR(\*n). .\"# .\"# The following sets edit modes for GNU EMACS .\"# Local Variables: diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c index 1f29d9770cd..a60cc9b53e0 100644 --- a/usr.bin/tic/tic.c +++ b/usr.bin/tic/tic.c @@ -1,5 +1,3 @@ -/* $OpenBSD: tic.c,v 1.13 1999/12/06 02:14:34 millert Exp $ */ - /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * * * @@ -44,43 +42,47 @@ #include <dump_entry.h> #include <term_entry.h> -MODULE_ID("$From: tic.c,v 1.53 1999/12/04 22:45:52 tom Exp $") +MODULE_ID("$From: tic.c,v 1.55 1999/12/11 20:20:54 tom Exp $") const char *_nc_progname = "tic"; -static FILE *log_fp; -static FILE *tmp_fp; -static bool showsummary = FALSE; -static const char *to_remove; +static FILE *log_fp; +static FILE *tmp_fp; +static bool showsummary = FALSE; +static const char *to_remove; -static void (*save_check_termtype)(TERMTYPE *); -static void check_termtype(TERMTYPE *tt); +static void (*save_check_termtype) (TERMTYPE *); +static void check_termtype(TERMTYPE * tt); -static const char usage_string[] = "[-h] [-v[n]] [-e names] [-CILNRTcfrswx1] source-file\n"; +static const char usage_string[] = "[-h] [-v[n]] [-e names] [-CILNRTcfrswx1] source-file\n"; -static void cleanup(void) +static void +cleanup(void) { - if (tmp_fp != 0) - fclose(tmp_fp); - if (to_remove != 0) { + if (tmp_fp != 0) + fclose(tmp_fp); + if (to_remove != 0) { #if HAVE_REMOVE - remove(to_remove); + remove(to_remove); #else - unlink(to_remove); + unlink(to_remove); #endif - } + } } -static void failed(const char *msg) +static void +failed(const char *msg) { - perror(msg); - cleanup(); - exit(EXIT_FAILURE); + perror(msg); + cleanup(); + exit(EXIT_FAILURE); } -static void usage(void) +static void +usage(void) { - static const char *const tbl[] = { + static const char *const tbl[] = + { "Options:", " -1 format translation output one capability per line", " -C translate entries to termcap source form", @@ -105,69 +107,71 @@ static void usage(void) "", "Parameters:", " <file> file to translate or compile" - }; - size_t j; + }; + size_t j; - printf("Usage: %s %s\n", _nc_progname, usage_string); - for (j = 0; j < sizeof(tbl)/sizeof(tbl[0]); j++) - puts(tbl[j]); - exit(EXIT_FAILURE); + printf("Usage: %s %s\n", _nc_progname, usage_string); + for (j = 0; j < sizeof(tbl) / sizeof(tbl[0]); j++) + puts(tbl[j]); + exit(EXIT_FAILURE); } #define L_BRACE '{' #define R_BRACE '}' #define S_QUOTE '\''; -static void write_it(ENTRY *ep) +static void +write_it(ENTRY * ep) { - unsigned n; - int ch; - char *s, *d, *t; - char result[MAX_ENTRY_SIZE]; - - /* - * Look for strings that contain %{number}, convert them to %'char', - * which is shorter and runs a little faster. - */ - for (n = 0; n < STRCOUNT; n++) { - s = ep->tterm.Strings[n]; - if (VALID_STRING(s) - && strchr(s, L_BRACE) != 0) { - d = result; - t = s; - while ((ch = *t++) != 0) { - *d++ = ch; - if (ch == '\\') { - *d++ = *t++; - } else if ((ch == '%') - && (*t == L_BRACE)) { - char *v = 0; - long value = strtol(t+1, &v, 0); - if (v != 0 - && *v == R_BRACE - && value > 0 - && value != '\\' /* FIXME */ - && value < 127 - && isprint((int)value)) { - *d++ = S_QUOTE; - *d++ = (int)value; - *d++ = S_QUOTE; - t = (v + 1); - } - } - } - *d = 0; - if (strlen(result) < strlen(s)) - strcpy(s, result); + unsigned n; + int ch; + char *s, *d, *t; + char result[MAX_ENTRY_SIZE]; + + /* + * Look for strings that contain %{number}, convert them to %'char', + * which is shorter and runs a little faster. + */ + for (n = 0; n < STRCOUNT; n++) { + s = ep->tterm.Strings[n]; + if (VALID_STRING(s) + && strchr(s, L_BRACE) != 0) { + d = result; + t = s; + while ((ch = *t++) != 0) { + *d++ = ch; + if (ch == '\\') { + *d++ = *t++; + } else if ((ch == '%') + && (*t == L_BRACE)) { + char *v = 0; + long value = strtol(t + 1, &v, 0); + if (v != 0 + && *v == R_BRACE + && value > 0 + && value != '\\' /* FIXME */ + && value < 127 + && isprint((int) value)) { + *d++ = S_QUOTE; + *d++ = (int) value; + *d++ = S_QUOTE; + t = (v + 1); + } } + } + *d = 0; + if (strlen(result) < strlen(s)) + strcpy(s, result); } + } - _nc_set_type(_nc_first_name(ep->tterm.term_names)); - _nc_curr_line = ep->startline; - _nc_write_entry(&ep->tterm); + _nc_set_type(_nc_first_name(ep->tterm.term_names)); + _nc_curr_line = ep->startline; + _nc_write_entry(&ep->tterm); } -static bool immedhook(ENTRY *ep GCC_UNUSED) +static bool +immedhook(ENTRY * ep GCC_UNUSED) /* write out entries with no use capabilities immediately to save storage */ { #ifndef HAVE_BIG_CORE @@ -204,519 +208,505 @@ static bool immedhook(ENTRY *ep GCC_UNUSED) * make tic a bit faster (because the resolution code won't have to do * disk I/O nearly as often). */ - if (ep->nuses == 0) - { - int oldline = _nc_curr_line; + if (ep->nuses == 0) { + int oldline = _nc_curr_line; write_it(ep); _nc_curr_line = oldline; free(ep->tterm.str_table); - return(TRUE); + return (TRUE); } #endif /* HAVE_BIG_CORE */ - return(FALSE); + return (FALSE); } -static void put_translate(int c) +static void +put_translate(int c) /* emit a comment char, translating terminfo names to termcap names */ { static bool in_name = FALSE; - static char namebuf[132], suffix[132], *sp; - - if (!in_name) - { - if (c == '<') - { - in_name = TRUE; - sp = namebuf; + static size_t have, used; + static char *namebuf, *suffix; + + if (in_name) { + if (used + 1 >= have) { + have += 132; + namebuf = (namebuf != 0) ? realloc(namebuf, have) : malloc(have); + suffix = (suffix != 0) ? realloc(suffix, have) : malloc(have); } - else + if (c == '\n' || c == '@') { + namebuf[used++] = '\0'; + (void) putchar('<'); + (void) fputs(namebuf, stdout); putchar(c); - } - else if (c == '\n' || c == '@') - { - *sp++ = '\0'; - (void) putchar('<'); - (void) fputs(namebuf, stdout); - putchar(c); - in_name = FALSE; - } - else if (c != '>') - *sp++ = c; - else /* ah! candidate name! */ - { - char *up; - NCURSES_CONST char *tp; - - *sp++ = '\0'; - in_name = FALSE; - - suffix[0] = '\0'; - if ((up = strchr(namebuf, '#')) != 0 - || (up = strchr(namebuf, '=')) != 0 - || ((up = strchr(namebuf, '@')) != 0 && up[1] == '>')) - { - (void) strcpy(suffix, up); - *up = '\0'; - } + in_name = FALSE; + } else if (c != '>') { + namebuf[used++] = c; + } else { /* ah! candidate name! */ + char *up; + NCURSES_CONST char *tp; + + namebuf[used++] = '\0'; + in_name = FALSE; + + suffix[0] = '\0'; + if ((up = strchr(namebuf, '#')) != 0 + || (up = strchr(namebuf, '=')) != 0 + || ((up = strchr(namebuf, '@')) != 0 && up[1] == '>')) { + (void) strcpy(suffix, up); + *up = '\0'; + } - if ((tp = nametrans(namebuf)) != 0) - { - (void) putchar(':'); - (void) fputs(tp, stdout); - (void) fputs(suffix, stdout); - (void) putchar(':'); + if ((tp = nametrans(namebuf)) != 0) { + (void) putchar(':'); + (void) fputs(tp, stdout); + (void) fputs(suffix, stdout); + (void) putchar(':'); + } else { + /* couldn't find a translation, just dump the name */ + (void) putchar('<'); + (void) fputs(namebuf, stdout); + (void) fputs(suffix, stdout); + (void) putchar('>'); + } } - else - { - /* couldn't find a translation, just dump the name */ - (void) putchar('<'); - (void) fputs(namebuf, stdout); - (void) fputs(suffix, stdout); - (void) putchar('>'); + } else { + used = 0; + if (c == '<') { + in_name = TRUE; + } else { + putchar(c); } - } } /* Returns a string, stripped of leading/trailing whitespace */ -static char *stripped(char *src) +static char * +stripped(char *src) { - while (isspace(*src)) - src++; - if (*src != '\0') { - char *dst = strcpy(malloc(strlen(src)+1), src); - size_t len = strlen(dst); - while (--len != 0 && isspace(dst[len])) - dst[len] = '\0'; - return dst; - } - return 0; + while (isspace(*src)) + src++; + if (*src != '\0') { + char *dst = strcpy(malloc(strlen(src) + 1), src); + size_t len = strlen(dst); + while (--len != 0 && isspace(dst[len])) + dst[len] = '\0'; + return dst; + } + return 0; } /* Parse the "-e" option-value into a list of names */ -static const char **make_namelist(char *src) +static const char ** +make_namelist(char *src) { - const char **dst = 0; - - char *s, *base; - unsigned pass, n, nn; - char buffer[BUFSIZ]; - - if (src == 0) { - /* EMPTY */; - } else if (strchr(src, '/') != 0) { /* a filename */ - FILE *fp = fopen(src, "r"); - if (fp == 0) - failed(src); - - for (pass = 1; pass <= 2; pass++) { - nn = 0; - while (fgets(buffer, sizeof(buffer), fp) != 0) { - if ((s = stripped(buffer)) != 0) { - if (dst != 0) - dst[nn] = s; - nn++; - } - } - if (pass == 1) { - dst = (const char **)calloc(nn+1, sizeof(*dst)); - rewind(fp); - } - } - fclose(fp); - } else { /* literal list of names */ - for (pass = 1; pass <= 2; pass++) { - for (n = nn = 0, base = src; ; n++) { - int mark = src[n]; - if (mark == ',' || mark == '\0') { - if (pass == 1) { - nn++; - } else { - src[n] = '\0'; - if ((s = stripped(base)) != 0) - dst[nn++] = s; - base = &src[n+1]; - } - } - if (mark == '\0') - break; - } - if (pass == 1) - dst = (const char **)calloc(nn+1, sizeof(*dst)); + const char **dst = 0; + + char *s, *base; + unsigned pass, n, nn; + char buffer[BUFSIZ]; + + if (src == 0) { + /* EMPTY */ ; + } else if (strchr(src, '/') != 0) { /* a filename */ + FILE *fp = fopen(src, "r"); + if (fp == 0) + failed(src); + + for (pass = 1; pass <= 2; pass++) { + nn = 0; + while (fgets(buffer, sizeof(buffer), fp) != 0) { + if ((s = stripped(buffer)) != 0) { + if (dst != 0) + dst[nn] = s; + nn++; } + } + if (pass == 1) { + dst = (const char **) calloc(nn + 1, sizeof(*dst)); + rewind(fp); + } } - if (showsummary) { - fprintf(log_fp, "Entries that will be compiled:\n"); - for (n = 0; dst[n] != 0; n++) - fprintf(log_fp, "%d:%s\n", n+1, dst[n]); + fclose(fp); + } else { /* literal list of names */ + for (pass = 1; pass <= 2; pass++) { + for (n = nn = 0, base = src;; n++) { + int mark = src[n]; + if (mark == ',' || mark == '\0') { + if (pass == 1) { + nn++; + } else { + src[n] = '\0'; + if ((s = stripped(base)) != 0) + dst[nn++] = s; + base = &src[n + 1]; + } + } + if (mark == '\0') + break; + } + if (pass == 1) + dst = (const char **) calloc(nn + 1, sizeof(*dst)); } - return dst; + } + if (showsummary) { + fprintf(log_fp, "Entries that will be compiled:\n"); + for (n = 0; dst[n] != 0; n++) + fprintf(log_fp, "%d:%s\n", n + 1, dst[n]); + } + return dst; } -static bool matches(const char **needle, const char *haystack) +static bool +matches(const char **needle, const char *haystack) /* does entry in needle list match |-separated field in haystack? */ { - bool code = FALSE; - size_t n; - - if (needle != 0) - { - for (n = 0; needle[n] != 0; n++) - { - if (_nc_name_match(haystack, needle[n], "|")) - { - code = TRUE; - break; - } - } - } - else + bool code = FALSE; + size_t n; + + if (needle != 0) { + for (n = 0; needle[n] != 0; n++) { + if (_nc_name_match(haystack, needle[n], "|")) { code = TRUE; - return(code); + break; + } + } + } else + code = TRUE; + return (code); } -int main (int argc, char *argv[]) +int +main(int argc, char *argv[]) { -char my_tmpname[PATH_MAX]; -int v_opt = -1, debug_level; -int smart_defaults = TRUE; -char *termcap; -ENTRY *qp; - -int this_opt, last_opt = '?'; - -int outform = F_TERMINFO; /* output format */ -int sortmode = S_TERMINFO; /* sort_mode */ - -int fd; -int width = 60; -bool formatted = FALSE; /* reformat complex strings? */ -int numbers = 0; /* format "%'char'" to/from "%{number}" */ -bool infodump = FALSE; /* running as captoinfo? */ -bool capdump = FALSE; /* running as infotocap? */ -bool forceresolve = FALSE; /* force resolution */ -bool limited = TRUE; -char *tversion = (char *)NULL; -const char *source_file = "terminfo"; -const char **namelst = 0; -char *outdir = (char *)NULL; -bool check_only = FALSE; - - log_fp = stderr; - - if ((_nc_progname = strrchr(argv[0], '/')) == NULL) - _nc_progname = argv[0]; - else - _nc_progname++; - - if ((infodump = (strcmp(_nc_progname, "captoinfo") == 0)) != FALSE) { - outform = F_TERMINFO; - sortmode = S_TERMINFO; - } - if ((capdump = (strcmp(_nc_progname, "infotocap") == 0)) != FALSE) { - outform = F_TERMCAP; - sortmode = S_TERMCAP; - } + char my_tmpname[PATH_MAX]; + int v_opt = -1, debug_level; + int smart_defaults = TRUE; + char *termcap; + ENTRY *qp; + + int this_opt, last_opt = '?'; + + int outform = F_TERMINFO; /* output format */ + int sortmode = S_TERMINFO; /* sort_mode */ + + int fd; + int width = 60; + bool formatted = FALSE; /* reformat complex strings? */ + int numbers = 0; /* format "%'char'" to/from "%{number}" */ + bool infodump = FALSE; /* running as captoinfo? */ + bool capdump = FALSE; /* running as infotocap? */ + bool forceresolve = FALSE; /* force resolution */ + bool limited = TRUE; + char *tversion = (char *) NULL; + const char *source_file = "terminfo"; + const char **namelst = 0; + char *outdir = (char *) NULL; + bool check_only = FALSE; + + log_fp = stderr; + + if ((_nc_progname = strrchr(argv[0], '/')) == NULL) + _nc_progname = argv[0]; + else + _nc_progname++; + + if ((infodump = (strcmp(_nc_progname, "captoinfo") == 0)) != FALSE) { + outform = F_TERMINFO; + sortmode = S_TERMINFO; + } + if ((capdump = (strcmp(_nc_progname, "infotocap") == 0)) != FALSE) { + outform = F_TERMCAP; + sortmode = S_TERMCAP; + } #if NCURSES_XNAMES - use_extended_names(FALSE); + use_extended_names(FALSE); #endif - /* - * Processing arguments is a little complicated, since someone made a - * design decision to allow the numeric values for -w, -v options to - * be optional. - */ - while ((this_opt = getopt(argc, argv, "0123456789CILNR:TVce:fGgo:rsvwx")) != -1) { - if (isdigit(this_opt)) { - switch (last_opt) { - case 'v': - v_opt = (v_opt * 10) + (this_opt - '0'); - break; - case 'w': - width = (width * 10) + (this_opt - '0'); - break; - default: - if (this_opt != '1') - usage(); - last_opt = this_opt; - width = 0; - } - continue; - } - switch (this_opt) { - case 'C': - capdump = TRUE; - outform = F_TERMCAP; - sortmode = S_TERMCAP; - break; - case 'I': - infodump = TRUE; - outform = F_TERMINFO; - sortmode = S_TERMINFO; - break; - case 'L': - infodump = TRUE; - outform = F_VARIABLE; - sortmode = S_VARIABLE; - break; - case 'N': - smart_defaults = FALSE; - break; - case 'R': - tversion = optarg; - break; - case 'T': - limited = FALSE; - break; - case 'V': - puts(NCURSES_VERSION); - return EXIT_SUCCESS; - case 'c': - check_only = TRUE; - break; - case 'e': - namelst = make_namelist(optarg); - break; - case 'f': - formatted = TRUE; - break; - case 'G': - numbers = 1; - break; - case 'g': - numbers = -1; - break; - case 'o': - outdir = optarg; - break; - case 'r': - forceresolve = TRUE; - break; - case 's': - showsummary = TRUE; - break; - case 'v': - v_opt = 0; - break; - case 'w': - width = 0; - break; + /* + * Processing arguments is a little complicated, since someone made a + * design decision to allow the numeric values for -w, -v options to + * be optional. + */ + while ((this_opt = getopt(argc, argv, + "0123456789CILNR:TVce:fGgo:rsvwx")) != -1) { + if (isdigit(this_opt)) { + switch (last_opt) { + case 'v': + v_opt = (v_opt * 10) + (this_opt - '0'); + break; + case 'w': + width = (width * 10) + (this_opt - '0'); + break; + default: + if (this_opt != '1') + usage(); + last_opt = this_opt; + width = 0; + } + continue; + } + switch (this_opt) { + case 'C': + capdump = TRUE; + outform = F_TERMCAP; + sortmode = S_TERMCAP; + break; + case 'I': + infodump = TRUE; + outform = F_TERMINFO; + sortmode = S_TERMINFO; + break; + case 'L': + infodump = TRUE; + outform = F_VARIABLE; + sortmode = S_VARIABLE; + break; + case 'N': + smart_defaults = FALSE; + break; + case 'R': + tversion = optarg; + break; + case 'T': + limited = FALSE; + break; + case 'V': + puts(NCURSES_VERSION); + return EXIT_SUCCESS; + case 'c': + check_only = TRUE; + break; + case 'e': + namelst = make_namelist(optarg); + break; + case 'f': + formatted = TRUE; + break; + case 'G': + numbers = 1; + break; + case 'g': + numbers = -1; + break; + case 'o': + outdir = optarg; + break; + case 'r': + forceresolve = TRUE; + break; + case 's': + showsummary = TRUE; + break; + case 'v': + v_opt = 0; + break; + case 'w': + width = 0; + break; #if NCURSES_XNAMES - case 'x': - use_extended_names(TRUE); - break; + case 'x': + use_extended_names(TRUE); + break; #endif - default: - usage(); - } - last_opt = this_opt; + default: + usage(); } + last_opt = this_opt; + } - debug_level = (v_opt > 0) ? v_opt : (v_opt == 0); - _nc_tracing = (1 << debug_level) - 1; - - if (_nc_tracing) - { - save_check_termtype = _nc_check_termtype; - _nc_check_termtype = check_termtype; - } + debug_level = (v_opt > 0) ? v_opt : (v_opt == 0); + _nc_tracing = (1 << debug_level) - 1; + if (_nc_tracing) { + save_check_termtype = _nc_check_termtype; + _nc_check_termtype = check_termtype; + } #ifndef HAVE_BIG_CORE - /* - * Aaargh! immedhook seriously hoses us! - * - * One problem with immedhook is it means we can't do -e. Problem - * is that we can't guarantee that for each terminal listed, all the - * terminals it depends on will have been kept in core for reference - * resolution -- in fact it's certain the primitive types at the end - * of reference chains *won't* be in core unless they were explicitly - * in the select list themselves. - */ - if (namelst && (!infodump && !capdump)) - { - (void) fprintf(stderr, - "Sorry, -e can't be used without -I or -C\n"); - cleanup(); - return EXIT_FAILURE; - } + /* + * Aaargh! immedhook seriously hoses us! + * + * One problem with immedhook is it means we can't do -e. Problem + * is that we can't guarantee that for each terminal listed, all the + * terminals it depends on will have been kept in core for reference + * resolution -- in fact it's certain the primitive types at the end + * of reference chains *won't* be in core unless they were explicitly + * in the select list themselves. + */ + if (namelst && (!infodump && !capdump)) { + (void) fprintf(stderr, + "Sorry, -e can't be used without -I or -C\n"); + cleanup(); + return EXIT_FAILURE; + } #endif /* HAVE_BIG_CORE */ + if (optind < argc) { + source_file = argv[optind++]; if (optind < argc) { - source_file = argv[optind++]; - if (optind < argc) { - fprintf (stderr, - "%s: Too many file names. Usage:\n\t%s %s", - _nc_progname, - _nc_progname, - usage_string); - return EXIT_FAILURE; - } - } else { - if (infodump == TRUE) { - /* captoinfo's no-argument case */ - source_file = "/usr/share/misc/termcap"; - if ((termcap = getenv("TERMCAP")) != 0 - && (namelst = make_namelist(getenv("TERM"))) != 0) { - if (access(termcap, F_OK) == 0) { - /* file exists */ - source_file = termcap; - } else - if (strcpy(my_tmpname, "/tmp/tic.XXXXXXXX") - && (fd = mkstemp(my_tmpname)) != -1 - && (tmp_fp = fdopen(fd, "w")) != 0) { - fprintf(tmp_fp, "%s\n", termcap); - fclose(tmp_fp); - tmp_fp = fopen(source_file, "r"); - to_remove = source_file; - } else { - failed("mkstemp"); - } - } + fprintf(stderr, + "%s: Too many file names. Usage:\n\t%s %s", + _nc_progname, + _nc_progname, + usage_string); + return EXIT_FAILURE; + } + } else { + if (infodump == TRUE) { + /* captoinfo's no-argument case */ + source_file = "/usr/share/misc/termcap"; + if ((termcap = getenv("TERMCAP")) != 0 + && (namelst = make_namelist(getenv("TERM"))) != 0) { + if (access(termcap, F_OK) == 0) { + /* file exists */ + source_file = termcap; + } else if (strcpy(my_tmpname, "/tmp/tic.XXXXXXXX") + && (fd = mkstemp(my_tmpname)) != -1 + && (tmp_fp = fdopen(fd, "w")) != 0) { + fprintf(tmp_fp, "%s\n", termcap); + fclose(tmp_fp); + tmp_fp = fopen(source_file, "r"); + to_remove = source_file; } else { - /* tic */ - fprintf (stderr, - "%s: File name needed. Usage:\n\t%s %s", - _nc_progname, - _nc_progname, - usage_string); - cleanup(); - return EXIT_FAILURE; + failed("mkstemp"); } + } + } else { + /* tic */ + fprintf(stderr, + "%s: File name needed. Usage:\n\t%s %s", + _nc_progname, + _nc_progname, + usage_string); + cleanup(); + return EXIT_FAILURE; } + } - if (tmp_fp == 0 - && (tmp_fp = fopen(source_file, "r")) == 0) { - fprintf (stderr, "%s: Can't open %s\n", _nc_progname, source_file); - return EXIT_FAILURE; - } + if (tmp_fp == 0 + && (tmp_fp = fopen(source_file, "r")) == 0) { + fprintf(stderr, "%s: Can't open %s\n", _nc_progname, source_file); + return EXIT_FAILURE; + } - if (infodump) - dump_init(tversion, - smart_defaults - ? outform - : F_LITERAL, - sortmode, width, debug_level, formatted); - else if (capdump) - dump_init(tversion, - outform, - sortmode, width, debug_level, FALSE); - - /* parse entries out of the source file */ - _nc_set_source(source_file); + if (infodump) + dump_init(tversion, + smart_defaults + ? outform + : F_LITERAL, + sortmode, width, debug_level, formatted); + else if (capdump) + dump_init(tversion, + outform, + sortmode, width, debug_level, FALSE); + + /* parse entries out of the source file */ + _nc_set_source(source_file); #ifndef HAVE_BIG_CORE - if (!(check_only || infodump || capdump)) - _nc_set_writedir(outdir); + if (!(check_only || infodump || capdump)) + _nc_set_writedir(outdir); #endif /* HAVE_BIG_CORE */ - _nc_read_entry_source(tmp_fp, (char *)NULL, - !smart_defaults, FALSE, - (check_only || infodump || capdump) ? NULLHOOK : immedhook); - - /* do use resolution */ - if (check_only || (!infodump && !capdump) || forceresolve) { - if (!_nc_resolve_uses() && !check_only) { - cleanup(); - return EXIT_FAILURE; + _nc_read_entry_source(tmp_fp, (char *) NULL, + !smart_defaults, FALSE, + (check_only || infodump || capdump) ? NULLHOOK : immedhook); + + /* do use resolution */ + if (check_only || (!infodump && !capdump) || forceresolve) { + if (!_nc_resolve_uses() && !check_only) { + cleanup(); + return EXIT_FAILURE; + } + } + + /* length check */ + if (check_only && (capdump || infodump)) { + for_entry_list(qp) { + if (matches(namelst, qp->tterm.term_names)) { + int len = fmt_entry(&qp->tterm, NULL, TRUE, infodump, numbers); + + if (len > (infodump ? MAX_TERMINFO_LENGTH : MAX_TERMCAP_LENGTH)) + (void) fprintf(stderr, + "warning: resolved %s entry is %d bytes long\n", + _nc_first_name(qp->tterm.term_names), + len); } } + } - /* length check */ - if (check_only && (capdump || infodump)) - { + /* write or dump all entries */ + if (!check_only) { + if (!infodump && !capdump) { + _nc_set_writedir(outdir); for_entry_list(qp) - { if (matches(namelst, qp->tterm.term_names)) - { - int len = fmt_entry(&qp->tterm, NULL, TRUE, infodump, numbers); - - if (len>(infodump?MAX_TERMINFO_LENGTH:MAX_TERMCAP_LENGTH)) - (void) fprintf(stderr, - "warning: resolved %s entry is %d bytes long\n", - _nc_first_name(qp->tterm.term_names), - len); - } - } - } + write_it(qp); + } else { + /* this is in case infotocap() generates warnings */ + _nc_curr_col = _nc_curr_line = -1; + + for_entry_list(qp) { + if (matches(namelst, qp->tterm.term_names)) { + int j = qp->cend - qp->cstart; + int len = 0; + + /* this is in case infotocap() generates warnings */ + _nc_set_type(_nc_first_name(qp->tterm.term_names)); + + (void) fseek(tmp_fp, qp->cstart, SEEK_SET); + while (j--) { + if (infodump) + (void) putchar(fgetc(tmp_fp)); + else + put_translate(fgetc(tmp_fp)); + } - /* write or dump all entries */ - if (!check_only) - { - if (!infodump && !capdump) - { - _nc_set_writedir(outdir); - for_entry_list(qp) - if (matches(namelst, qp->tterm.term_names)) - write_it(qp); + len = dump_entry(&qp->tterm, limited, numbers, NULL); + for (j = 0; j < qp->nuses; j++) + len += dump_uses((char *) (qp->uses[j].parent), !capdump); + (void) putchar('\n'); + if (debug_level != 0 && !limited) + printf("# length=%d\n", len); + } } - else - { - /* this is in case infotocap() generates warnings */ - _nc_curr_col = _nc_curr_line = -1; - - for_entry_list(qp) - if (matches(namelst, qp->tterm.term_names)) - { - int j = qp->cend - qp->cstart; - int len = 0; - - /* this is in case infotocap() generates warnings */ - _nc_set_type(_nc_first_name(qp->tterm.term_names)); - - (void) fseek(tmp_fp, qp->cstart, SEEK_SET); - while (j-- ) - if (infodump) - (void) putchar(fgetc(tmp_fp)); - else - put_translate(fgetc(tmp_fp)); - - len = dump_entry(&qp->tterm, limited, numbers, NULL); - for (j = 0; j < qp->nuses; j++) - len += dump_uses((char *)(qp->uses[j].parent), !capdump); - (void) putchar('\n'); - if (debug_level != 0 && !limited) - printf("# length=%d\n", len); - } - if (!namelst) - { - int c, oldc = '\0'; - bool in_comment = FALSE; - bool trailing_comment = FALSE; - - (void) fseek(tmp_fp, _nc_tail->cend, SEEK_SET); - while ((c = fgetc(tmp_fp)) != EOF) - { - if (oldc == '\n') { - if (c == '#') { - trailing_comment = TRUE; - in_comment = TRUE; - } else { - in_comment = FALSE; - } + if (!namelst) { + int c, oldc = '\0'; + bool in_comment = FALSE; + bool trailing_comment = FALSE; + + (void) fseek(tmp_fp, _nc_tail->cend, SEEK_SET); + while ((c = fgetc(tmp_fp)) != EOF) { + if (oldc == '\n') { + if (c == '#') { + trailing_comment = TRUE; + in_comment = TRUE; + } else { + in_comment = FALSE; } - if (trailing_comment - && (in_comment || (oldc == '\n' && c == '\n'))) - putchar(c); - oldc = c; } + if (trailing_comment + && (in_comment || (oldc == '\n' && c == '\n'))) + putchar(c); + oldc = c; } } } + } - /* Show the directory into which entries were written, and the total - * number of entries - */ - if (showsummary - && (!(check_only || infodump || capdump))) { - int total = _nc_tic_written(); - if (total != 0) - fprintf(log_fp, "%d entries written to %s\n", - total, - _nc_tic_dir((char *)0)); - else - fprintf(log_fp, "No entries written\n"); - } - cleanup(); - return(EXIT_SUCCESS); + /* Show the directory into which entries were written, and the total + * number of entries + */ + if (showsummary + && (!(check_only || infodump || capdump))) { + int total = _nc_tic_written(); + if (total != 0) + fprintf(log_fp, "%d entries written to %s\n", + total, + _nc_tic_dir((char *) 0)); + else + fprintf(log_fp, "No entries written\n"); + } + cleanup(); + return (EXIT_SUCCESS); } /* @@ -725,7 +715,7 @@ bool check_only = FALSE; * precisely what's needed (see comp_parse.c). */ -TERMINAL *cur_term; /* tweak to avoid linking lib_cur_term.c */ +TERMINAL *cur_term; /* tweak to avoid linking lib_cur_term.c */ #undef CUR #define CUR tp-> @@ -733,90 +723,91 @@ TERMINAL *cur_term; /* tweak to avoid linking lib_cur_term.c */ /* other sanity-checks (things that we don't want in the normal * logic that reads a terminfo entry) */ -static void check_termtype(TERMTYPE *tp) +static void +check_termtype(TERMTYPE * tp) { - bool conflict = FALSE; - unsigned j, k; - char fkeys[STRCOUNT]; - - /* - * A terminal entry may contain more than one keycode assigned to - * a given string (e.g., KEY_END and KEY_LL). But curses will only - * return one (the last one assigned). - */ - memset(fkeys, 0, sizeof(fkeys)); - for (j = 0; _nc_tinfo_fkeys[j].code; j++) { - char *a = tp->Strings[_nc_tinfo_fkeys[j].offset]; - bool first = TRUE; - if (!VALID_STRING(a)) + bool conflict = FALSE; + unsigned j, k; + char fkeys[STRCOUNT]; + + /* + * A terminal entry may contain more than one keycode assigned to + * a given string (e.g., KEY_END and KEY_LL). But curses will only + * return one (the last one assigned). + */ + memset(fkeys, 0, sizeof(fkeys)); + for (j = 0; _nc_tinfo_fkeys[j].code; j++) { + char *a = tp->Strings[_nc_tinfo_fkeys[j].offset]; + bool first = TRUE; + if (!VALID_STRING(a)) + continue; + for (k = j + 1; _nc_tinfo_fkeys[k].code; k++) { + char *b = tp->Strings[_nc_tinfo_fkeys[k].offset]; + if (!VALID_STRING(b) + || fkeys[k]) continue; - for (k = j+1; _nc_tinfo_fkeys[k].code; k++) { - char *b = tp->Strings[_nc_tinfo_fkeys[k].offset]; - if (!VALID_STRING(b) - || fkeys[k]) - continue; - if (!strcmp(a,b)) { - fkeys[j] = 1; - fkeys[k] = 1; - if (first) { - if (!conflict) { - _nc_warning("Conflicting key definitions (using the last)"); - conflict = TRUE; - } - fprintf(stderr, "... %s is the same as %s", - keyname(_nc_tinfo_fkeys[j].code), - keyname(_nc_tinfo_fkeys[k].code)); - first = FALSE; - } else { - fprintf(stderr, ", %s", - keyname(_nc_tinfo_fkeys[k].code)); + if (!strcmp(a, b)) { + fkeys[j] = 1; + fkeys[k] = 1; + if (first) { + if (!conflict) { + _nc_warning("Conflicting key definitions (using the last)"); + conflict = TRUE; } + fprintf(stderr, "... %s is the same as %s", + keyname(_nc_tinfo_fkeys[j].code), + keyname(_nc_tinfo_fkeys[k].code)); + first = FALSE; + } else { + fprintf(stderr, ", %s", + keyname(_nc_tinfo_fkeys[k].code)); } } - if (!first) - fprintf(stderr, "\n"); } + if (!first) + fprintf(stderr, "\n"); + } + + /* + * Quick check for color. We could also check if the ANSI versus + * non-ANSI strings are misused. + */ + if ((max_colors > 0) != (max_pairs > 0) + || (max_colors > max_pairs)) + _nc_warning("inconsistent values for max_colors and max_pairs"); + + PAIRED(set_foreground, set_background) + PAIRED(set_a_foreground, set_a_background) - /* - * Quick check for color. We could also check if the ANSI versus - * non-ANSI strings are misused. - */ - if ((max_colors > 0) != (max_pairs > 0) - || (max_colors > max_pairs)) - _nc_warning("inconsistent values for max_colors and max_pairs"); - - PAIRED(set_foreground, set_background) - PAIRED(set_a_foreground, set_a_background) - - /* - * These may be mismatched because the terminal description relies on - * restoring the cursor visibility by resetting it. - */ - ANDMISSING(cursor_invisible, cursor_normal) - ANDMISSING(cursor_visible, cursor_normal) - - /* - * From XSI & O'Reilly, we gather that sc/rc are required if csr is - * given, because the cursor position after the scrolling operation is - * performed is undefined. - */ - ANDMISSING(change_scroll_region, save_cursor) - ANDMISSING(change_scroll_region, restore_cursor) - - /* - * Some standard applications (e.g., vi) and some non-curses - * applications (e.g., jove) get confused if we have both ich/ich1 and - * smir/rmir. Let's be nice and warn about that, too, even though - * ncurses handles it. - */ + /* + * These may be mismatched because the terminal description relies on + * restoring the cursor visibility by resetting it. + */ + ANDMISSING(cursor_invisible, cursor_normal) + ANDMISSING(cursor_visible, cursor_normal) + + /* + * From XSI & O'Reilly, we gather that sc/rc are required if csr is + * given, because the cursor position after the scrolling operation is + * performed is undefined. + */ + ANDMISSING(change_scroll_region, save_cursor) + ANDMISSING(change_scroll_region, restore_cursor) + + /* + * Some standard applications (e.g., vi) and some non-curses + * applications (e.g., jove) get confused if we have both ich/ich1 and + * smir/rmir. Let's be nice and warn about that, too, even though + * ncurses handles it. + */ if ((PRESENT(enter_insert_mode) || PRESENT(exit_insert_mode)) - && (PRESENT(insert_character) || PRESENT(parm_ich))) { - _nc_warning("non-curses applications may be confused by ich/ich1 with smir/rmir"); - } + && (PRESENT(insert_character) || PRESENT(parm_ich))) { + _nc_warning("non-curses applications may be confused by ich/ich1 with smir/rmir"); + } - /* - * Finally, do the non-verbose checks - */ - if (save_check_termtype != 0) - save_check_termtype(tp); + /* + * Finally, do the non-verbose checks + */ + if (save_check_termtype != 0) + save_check_termtype(tp); } |