diff options
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo')
28 files changed, 558 insertions, 288 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/MKfallback.sh b/contrib/ncurses/ncurses/tinfo/MKfallback.sh index de3e23a877c2..d1abcd2eed3f 100755 --- a/contrib/ncurses/ncurses/tinfo/MKfallback.sh +++ b/contrib/ncurses/ncurses/tinfo/MKfallback.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: MKfallback.sh,v 1.10 2000/12/10 00:14:39 tom Exp $ +# $Id: MKfallback.sh,v 1.11 2001/12/02 01:55:30 tom Exp $ # # MKfallback.sh -- create fallback table for entry reads # @@ -8,6 +8,28 @@ # from an on-disk terminfo tree) tries to match the type with one of a # specified list of types generated in. # + +terminfo_dir=$1 +shift + +terminfo_src=$1 +shift + +if test $# != 0 ; then + tmp_info=tmp_info + echo creating temporary terminfo directory... >&2 + + TERMINFO=`pwd`/$tmp_info + export TERMINFO + + TERMINFO_DIRS=$TERMINFO:$terminfo_dir + export TERMINFO_DIRS + + tic $terminfo_src >&2 +else + tmp_info= +fi + cat <<EOF /* * DO NOT EDIT THIS FILE BY HAND! It is generated by MKfallback.sh. @@ -73,3 +95,8 @@ cat <<EOF return((TERMTYPE *)0); } EOF + +if test -n "$tmp_info" ; then + echo removing temporary terminfo directory... >&2 + rm -rf $tmp_info +fi diff --git a/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh b/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh new file mode 100755 index 000000000000..98d5b1379a1c --- /dev/null +++ b/contrib/ncurses/ncurses/tinfo/MKkeys_list.sh @@ -0,0 +1,62 @@ +#! /bin/sh +# $Id: MKkeys_list.sh,v 1.2 2001/06/16 16:50:35 tom Exp $ +############################################################################## +# Copyright (c) 2001 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. # +############################################################################## +# +# MKkey_defs.sh -- generate list of function-keys for terminfo database +# +# Author: Thomas E. Dickey <dickey@herndon4.his.com> 2001 +# +# Extract function-key names from the Caps file +# +: ${AWK-awk} +DATA=${1-../../include/Caps} + +data=data$$ +trap 'rm -f $data' 0 1 2 5 15 +sed -e 's/[ ]\+/ /g' < $DATA >$data + +cat <<EOF +# These definitions were generated by $0 $DATA +KEY_BREAK +KEY_SRESET +KEY_RESET +KEY_RESIZE +EOF + +${AWK-awk} <$data ' +/^#/ {next;} +/^capalias/ {next;} +/^infoalias/ {next;} + +$5 != "-" { + if (substr($5, 1, 4) == "KEY_" ) { + printf "%s %s\n", $5, $1 + } +} +' diff --git a/contrib/ncurses/ncurses/tinfo/access.c b/contrib/ncurses/ncurses/tinfo/access.c index c8071d81dbe0..f5240c121c26 100644 --- a/contrib/ncurses/ncurses/tinfo/access.c +++ b/contrib/ncurses/ncurses/tinfo/access.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -27,13 +27,42 @@ ****************************************************************************/ /**************************************************************************** - * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000 * + * Author: Thomas E. Dickey <dickey@clark.net> 1998,2000,2001 * ****************************************************************************/ #include <curses.priv.h> #include <tic.h> +#include <nc_alloc.h> -MODULE_ID("$Id: access.c,v 1.7 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: access.c,v 1.9 2001/06/23 22:11:49 tom Exp $") + +#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c)) + +NCURSES_EXPORT(char *) +_nc_rootname(char *path) +{ + char *result = _nc_basename(path); +#if !defined(MIXEDCASE_FILENAMES) || defined(PROG_EXT) + static char *temp; + char *s; + + temp = strdup(result); + result = temp; +#if !defined(MIXEDCASE_FILENAMES) + int n; + for (s = result; *s != '\0'; ++s) { + *s = LOWERCASE(*s); + } +#endif +#if defined(PROG_EXT) + if ((s = strrchr(result, '.')) != 0) { + if (!strcmp(s, PROG_EXT)) + *s = '\0'; + } +#endif +#endif + return result; +} NCURSES_EXPORT(char *) _nc_basename(char *path) diff --git a/contrib/ncurses/ncurses/tinfo/alloc_entry.c b/contrib/ncurses/ncurses/tinfo/alloc_entry.c index e668e364f178..5c064cfd8246 100644 --- a/contrib/ncurses/ncurses/tinfo/alloc_entry.c +++ b/contrib/ncurses/ncurses/tinfo/alloc_entry.c @@ -47,14 +47,14 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$Id: alloc_entry.c,v 1.35 2001/01/13 22:40:17 tom Exp $") +MODULE_ID("$Id: alloc_entry.c,v 1.36 2001/09/22 21:10:26 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 #define MAX_STRTAB 4096 /* documented maximum entry size */ -static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */ +static char *stringbuf; /* buffer for string capabilities */ static size_t next_free; /* next free character in stringbuf */ NCURSES_EXPORT(void) @@ -63,6 +63,9 @@ _nc_init_entry(TERMTYPE * const tp) { int i; + if (stringbuf == 0) + stringbuf = malloc(MAX_STRTAB); + #if NCURSES_XNAMES tp->num_Booleans = BOOLCOUNT; tp->num_Numbers = NUMCOUNT; diff --git a/contrib/ncurses/ncurses/tinfo/captoinfo.c b/contrib/ncurses/ncurses/tinfo/captoinfo.c index 9b68cd2d25c3..bf3116ae24f9 100644 --- a/contrib/ncurses/ncurses/tinfo/captoinfo.c +++ b/contrib/ncurses/ncurses/tinfo/captoinfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -92,7 +92,7 @@ #include <ctype.h> #include <tic.h> -MODULE_ID("$Id: captoinfo.c,v 1.40 2000/11/05 00:22:36 tom Exp $") +MODULE_ID("$Id: captoinfo.c,v 1.41 2001/06/02 22:50:31 skimo Exp $") #define MAX_PUSHED 16 /* max # args we can push onto the stack */ @@ -194,7 +194,7 @@ cvtchar(register const char *sp) case '2': case '3': len = 1; - while (isdigit(CharOf(*sp))) { + while (isdigit(UChar(*sp))) { c = 8 * c + (*sp++ - '0'); len++; } @@ -294,9 +294,9 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized) capstart = 0; if (s == 0) s = ""; - if (parametrized >= 0 && isdigit(CharOf(*s))) + if (parametrized >= 0 && isdigit(UChar(*s))) for (capstart = s;; s++) - if (!(isdigit(CharOf(*s)) || *s == '*' || *s == '.')) + if (!(isdigit(UChar(*s)) || *s == '*' || *s == '.')) break; while (*s != '\0') { @@ -464,7 +464,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized) dp = save_char(dp, '%'); s--; _nc_warning("unknown %% code %s (%#x) in %s", - unctrl((chtype) * s), CharOf(*s), cap); + unctrl((chtype) * s), UChar(*s), cap); break; } break; @@ -545,7 +545,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parametrized) if (capstart) { dp = save_string(dp, "$<"); for (s = capstart;; s++) - if (isdigit(CharOf(*s)) || *s == '*' || *s == '.') + if (isdigit(UChar(*s)) || *s == '*' || *s == '.') dp = save_char(dp, *s); else break; @@ -569,8 +569,8 @@ bcd_expression(const char *str) char ch1, ch2; if (sscanf(str, fmt, &ch1, &ch2) == 2 - && isdigit(CharOf(ch1)) - && isdigit(CharOf(ch2)) + && isdigit(UChar(ch1)) + && isdigit(UChar(ch2)) && (ch1 == ch2)) { len = 28; #ifndef NDEBUG @@ -651,13 +651,13 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize padding = str + strlen(str) - 1; if (*padding == '>' && *--padding == '/') { --padding; - while (isdigit(CharOf(*padding)) || *padding == '.' || *padding == '*') + while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*') padding--; if (*padding == '<' && *--padding == '$') trimmed = padding; padding += 2; - while (isdigit(CharOf(*padding)) || *padding == '.' || *padding == '*') + while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*') bufptr = save_char(bufptr, *padding++); } @@ -669,7 +669,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize bufptr = save_char(bufptr, *++str); } else if (str[0] == '$' && str[1] == '<') { /* discard padding */ str += 2; - while (isdigit(CharOf(*str)) + while (isdigit(UChar(*str)) || *str == '.' || *str == '*' || *str == '/' @@ -737,7 +737,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parametrize case '8': case '9': bufptr = save_char(bufptr, '%'); - while (isdigit(CharOf(*str))) + while (isdigit(UChar(*str))) bufptr = save_char(bufptr, *str++); if (strchr("doxX.", *str)) { if (*str != 'd') /* termcap doesn't have octal, hex */ diff --git a/contrib/ncurses/ncurses/tinfo/comp_error.c b/contrib/ncurses/ncurses/tinfo/comp_error.c index a39de8114de2..e67cb795dd33 100644 --- a/contrib/ncurses/ncurses/tinfo/comp_error.c +++ b/contrib/ncurses/ncurses/tinfo/comp_error.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -40,16 +40,14 @@ #include <tic.h> -MODULE_ID("$Id: comp_error.c,v 1.21 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: comp_error.c,v 1.23 2001/09/23 00:58:30 tom Exp $") NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE; -NCURSES_EXPORT_VAR(int) -_nc_curr_line = 0; /* current line # in input */ -NCURSES_EXPORT_VAR(int) -_nc_curr_col = 0; /* current column # in input */ +NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */ +NCURSES_EXPORT_VAR(int) _nc_curr_col = 0; /* current column # in input */ - static const char *sourcename; - static char termtype[MAX_NAME_SIZE + 1]; +static const char *sourcename; +static char *termtype; NCURSES_EXPORT(void) _nc_set_source(const char *const name) @@ -60,15 +58,17 @@ _nc_set_source(const char *const name) NCURSES_EXPORT(void) _nc_set_type(const char *const name) { + if (termtype == 0) + termtype = _nc_doalloc(termtype, MAX_NAME_SIZE + 1); termtype[0] = '\0'; if (name) - strncat(termtype, name, sizeof(termtype) - 1); + strncat(termtype, name, MAX_NAME_SIZE); } NCURSES_EXPORT(void) _nc_get_type(char *name) { - strcpy(name, termtype); + strcpy(name, termtype != 0 ? termtype : ""); } static inline void @@ -79,7 +79,7 @@ where_is_problem(void) fprintf(stderr, ", line %d", _nc_curr_line); if (_nc_curr_col >= 0) fprintf(stderr, ", col %d", _nc_curr_col); - if (termtype[0]) + if (termtype != 0 && termtype[0] != '\0') fprintf(stderr, ", terminal '%s'", termtype); fputc(':', stderr); fputc(' ', stderr); diff --git a/contrib/ncurses/ncurses/tinfo/comp_expand.c b/contrib/ncurses/ncurses/tinfo/comp_expand.c index cf6339dcadec..7ba438aff8e2 100644 --- a/contrib/ncurses/ncurses/tinfo/comp_expand.c +++ b/contrib/ncurses/ncurses/tinfo/comp_expand.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 * @@ -35,7 +35,7 @@ #include <ctype.h> #include <tic.h> -MODULE_ID("$Id: comp_expand.c,v 1.15 2000/12/10 01:30:10 tom Exp $") +MODULE_ID("$Id: comp_expand.c,v 1.17 2001/09/22 19:16:52 tom Exp $") static int trailing_spaces(const char *src) @@ -46,9 +46,8 @@ trailing_spaces(const char *src) } /* this deals with differences over whether 0x7f and 0x80..0x9f are controls */ -#define CHAR_OF(s) (*(unsigned const char *)(s)) -#define REALCTL(s) (CHAR_OF(s) < 127 && iscntrl(CHAR_OF(s))) -#define REALPRINT(s) (CHAR_OF(s) < 127 && isprint(CHAR_OF(s))) +#define REALCTL(s) (UChar(*(s)) < 127 && iscntrl(UChar(*(s)))) +#define REALPRINT(s) (UChar(*(s)) < 127 && isprint(UChar(*(s)))) NCURSES_EXPORT(char *) _nc_tic_expand @@ -69,7 +68,7 @@ _nc_tic_expand } bufp = 0; - while ((ch = CharOf(*str)) != 0) { + while ((ch = UChar(*str)) != 0) { if (ch == '%' && REALPRINT(str + 1)) { buffer[bufp++] = *str++; /* @@ -99,7 +98,7 @@ _nc_tic_expand */ case 1: if (str[0] == L_BRACE - && isdigit(CharOf(str[1]))) { + && isdigit(UChar(str[1]))) { char *dst = 0; long value = strtol(str + 1, &dst, 0); if (dst != 0 @@ -169,7 +168,7 @@ _nc_tic_expand } #define UnCtl(c) ((c) + '@') else if (REALCTL(str) && ch != '\\' - && (!islong || isdigit(CharOf(str[1])))) { + && (!islong || isdigit(UChar(str[1])))) { (void) sprintf(&buffer[bufp], "^%c", UnCtl(ch)); bufp += 2; } else { diff --git a/contrib/ncurses/ncurses/tinfo/comp_hash.c b/contrib/ncurses/ncurses/tinfo/comp_hash.c index fb18e3ad4aec..9f2ee71041e4 100644 --- a/contrib/ncurses/ncurses/tinfo/comp_hash.c +++ b/contrib/ncurses/ncurses/tinfo/comp_hash.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 * @@ -48,7 +48,7 @@ #define DEBUG(level, params) /*nothing */ #endif -MODULE_ID("$Id: comp_hash.c,v 1.24 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: comp_hash.c,v 1.25 2001/06/02 22:50:42 skimo Exp $") static int hash_function(const char *); @@ -201,7 +201,7 @@ parse_columns(char *buffer) if (*buffer != '#') { while (*buffer != '\0') { char *s; - for (s = buffer; (*s != '\0') && !isspace(CharOf(*s)); s++) + for (s = buffer; (*s != '\0') && !isspace(UChar(*s)); s++) /*EMPTY */ ; if (s != buffer) { char mark = *s; @@ -216,7 +216,7 @@ parse_columns(char *buffer) col++; if (mark == '\0') break; - while (*++s && isspace(CharOf(*s))) + while (*++s && isspace(UChar(*s))) /*EMPTY */ ; buffer = s; } else diff --git a/contrib/ncurses/ncurses/tinfo/comp_parse.c b/contrib/ncurses/ncurses/tinfo/comp_parse.c index 917f95cdd1ca..d59e4a55348e 100644 --- a/contrib/ncurses/ncurses/tinfo/comp_parse.c +++ b/contrib/ncurses/ncurses/tinfo/comp_parse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -52,7 +52,7 @@ #include <tic.h> #include <term_entry.h> -MODULE_ID("$Id: comp_parse.c,v 1.48 2001/01/15 00:44:51 tom Exp $") +MODULE_ID("$Id: comp_parse.c,v 1.50 2001/06/16 17:52:18 tom Exp $") static void sanity_check(TERMTYPE *); NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check; @@ -180,7 +180,7 @@ _nc_read_entry_source(FILE * fp, char *buf, memset(&thisentry, 0, sizeof(thisentry)); if (_nc_parse_entry(&thisentry, literal, silent) == ERR) break; - if (!isalnum(CharOf(thisentry.tterm.term_names[0]))) + if (!isalnum(UChar(thisentry.tterm.term_names[0]))) _nc_err_abort("terminal names must start with letter or digit"); /* @@ -486,6 +486,8 @@ sanity_check(TERMTYPE * tp) PAIRED(enter_xon_mode, exit_xon_mode); PAIRED(enter_am_mode, exit_am_mode); ANDMISSING(label_off, label_on); +#ifdef remove_clock PAIRED(display_clock, remove_clock); +#endif ANDMISSING(set_color_pair, initialize_pair); } diff --git a/contrib/ncurses/ncurses/tinfo/comp_scan.c b/contrib/ncurses/ncurses/tinfo/comp_scan.c index a6ad55f4e269..52fb13a7f76e 100644 --- a/contrib/ncurses/ncurses/tinfo/comp_scan.c +++ b/contrib/ncurses/ncurses/tinfo/comp_scan.c @@ -50,7 +50,7 @@ #include <term_entry.h> #include <tic.h> -MODULE_ID("$Id: comp_scan.c,v 1.56 2001/04/21 18:53:34 tom Exp $") +MODULE_ID("$Id: comp_scan.c,v 1.59 2001/09/23 00:56:29 tom Exp $") /* * Maximum length of string capability we'll accept before raising an error. @@ -86,7 +86,7 @@ _nc_curr_token = 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; #if NCURSES_EXT_FUNCS NCURSES_EXPORT_VAR(bool) @@ -146,26 +146,28 @@ NCURSES_EXPORT(int) _nc_get_token(bool silent) { static const char terminfo_punct[] = "@%&*!#"; - long number; - int type; - int ch; + static char *buffer; + char *numchk; - char numbuf[80]; - unsigned found; - static char buffer[MAX_ENTRY_SIZE]; char *ptr; + char numbuf[80]; + int ch; int dot_flag = FALSE; + int type; + long number; long token_start; + unsigned found; if (pushtype != NO_PUSHBACK) { int retval = pushtype; - _nc_set_type(pushname); + _nc_set_type(pushname != 0 ? pushname : ""); DEBUG(3, ("pushed-back token: `%s', class %d", _nc_curr_token.tk_name, pushtype)); pushtype = NO_PUSHBACK; - pushname[0] = '\0'; + if (pushname != 0) + pushname[0] = '\0'; /* currtok wasn't altered by _nc_push_token() */ return (retval); @@ -218,6 +220,9 @@ _nc_get_token(bool silent) goto start_token; } + if (buffer == 0) + buffer = _nc_doalloc(buffer, MAX_ENTRY_SIZE); + ptr = buffer; *(ptr++) = ch; @@ -302,7 +307,7 @@ _nc_get_token(bool silent) * special characters can be dangerous due to shell expansion. */ for (ptr = buffer; ptr < desc; ptr++) { - if (isspace(CharOf(*ptr))) { + if (isspace(UChar(*ptr))) { if (!silent) _nc_warning("whitespace in name or alias field"); break; @@ -373,7 +378,7 @@ _nc_get_token(bool silent) break; case '=': - ch = _nc_trans_string(ptr, buffer + sizeof(buffer)); + ch = _nc_trans_string(ptr, buffer + MAX_ENTRY_SIZE); if (!silent && ch != separator) _nc_warning("Missing separator"); _nc_curr_token.tk_name = buffer; @@ -629,10 +634,12 @@ _nc_push_token(int tokclass) /* * This implementation is kind of bogus, it will fail if we ever do more * than one pushback at a time between get_token() calls. It relies on the - * fact that curr_tok is static storage that nothing but get_token() - * touches. + * fact that _nc_curr_token is static storage that nothing but + * _nc_get_token() touches. */ pushtype = tokclass; + if (pushname == 0) + pushname = _nc_doalloc(pushname, MAX_NAME_SIZE + 1); _nc_get_type(pushname); DEBUG(3, ("pushing token: `%s', class %d", @@ -680,7 +687,8 @@ NCURSES_EXPORT(void) _nc_reset_input(FILE * fp, char *buf) { pushtype = NO_PUSHBACK; - pushname[0] = '\0'; + if (pushname != 0) + pushname[0] = '\0'; yyin = fp; bufstart = bufptr = buf; _nc_curr_file_pos = 0L; @@ -699,7 +707,7 @@ last_char(void) { size_t len = strlen(bufptr); while (len--) { - if (!isspace(CharOf(bufptr[len]))) + if (!isspace(UChar(bufptr[len]))) return bufptr[len]; } return 0; diff --git a/contrib/ncurses/ncurses/tinfo/lib_acs.c b/contrib/ncurses/ncurses/tinfo/lib_acs.c index 54554a8edd7c..b84d8e262a2f 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_acs.c +++ b/contrib/ncurses/ncurses/tinfo/lib_acs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -34,12 +34,23 @@ #include <curses.priv.h> #include <term.h> /* ena_acs, acs_chars */ -MODULE_ID("$Id: lib_acs.c,v 1.18 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_acs.c,v 1.21 2001/12/23 00:15:10 tom Exp $") +#if BROKEN_LINKER +NCURSES_EXPORT_VAR(chtype *) +_nc_acs_map(void) +{ + static chtype *the_map = 0; + if (the_map == 0) + the_map = typeCalloc(chtype, ACS_LEN); + return the_map; +} +#else NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] = { 0 }; +#endif NCURSES_EXPORT(void) _nc_init_acs(void) @@ -143,11 +154,11 @@ _nc_init_acs(void) */ if (_nc_tracing & TRACE_CALLS) { size_t n, m; - char show[SIZEOF(acs_map) + 1]; - for (n = 1, m = 0; n < SIZEOF(acs_map); n++) { + char show[ACS_LEN + 1]; + for (n = 1, m = 0; n < ACS_LEN; n++) { if (acs_map[n] != 0) { show[m++] = (char) n; - show[m++] = TextOf(acs_map[n]); + show[m++] = ChCharOf(acs_map[n]); } } show[m] = 0; diff --git a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c index ec6281023591..523892414367 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_baudrate.c +++ b/contrib/ncurses/ncurses/tinfo/lib_baudrate.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2002 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 * @@ -69,13 +69,14 @@ #undef B115200 #undef B230400 #undef B460800 +#undef B921600 #define USE_OLD_TTY #include <sys/ttydev.h> #else #undef USE_OLD_TTY #endif /* USE_OLD_TTY */ -MODULE_ID("$Id: lib_baudrate.c,v 1.21 2001/06/30 22:59:22 tom Exp $") +MODULE_ID("$Id: lib_baudrate.c,v 1.22 2002/01/19 23:07:53 Andrey.A.Chernov Exp $") /* * int @@ -132,6 +133,9 @@ static struct speed const speeds[] = #ifdef B460800 {B460800, 460800}, #endif +#ifdef B921600 + {B921600, 921600}, +#endif }; NCURSES_EXPORT(int) @@ -203,14 +207,14 @@ baudrate(void) #ifdef USE_OLD_TTY result = cfgetospeed(&cur_term->Nttyb); ospeed = _nc_ospeed(result); -#else +#else /* !USE_OLD_TTY */ #ifdef TERMIOS ospeed = cfgetospeed(&cur_term->Nttyb); #else ospeed = cur_term->Nttyb.sg_ospeed; #endif result = _nc_baudrate(ospeed); -#endif /* __FreeBSD__ */ +#endif if (cur_term != 0) cur_term->_baudrate = result; diff --git a/contrib/ncurses/ncurses/tinfo/lib_kernel.c b/contrib/ncurses/ncurses/tinfo/lib_kernel.c index ab8e4db7d283..b4d3c7f45aca 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_kernel.c +++ b/contrib/ncurses/ncurses/tinfo/lib_kernel.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,6 +29,7 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * and: Thomas E. Dickey 2002 * ****************************************************************************/ /* @@ -47,7 +48,28 @@ #include <curses.priv.h> #include <term.h> /* cur_term */ -MODULE_ID("$Id: lib_kernel.c,v 1.21 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_kernel.c,v 1.22 2002/05/11 20:32:18 tom Exp $") + +static int +_nc_vdisable(void) +{ + int value; +#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H) + value = _POSIX_VDISABLE; +#endif +#if defined(_PC_VDISABLE) + if (value == -1) { + value = fpathconf(0, _PC_VDISABLE); + if (value == -1) { + value = 0377; + } + } +#elif defined(VDISABLE) + if (value == -1) + value = VDISABLE; +#endif + return value; +} /* * erasechar() @@ -59,16 +81,19 @@ MODULE_ID("$Id: lib_kernel.c,v 1.21 2000/12/10 02:55:07 tom Exp $") NCURSES_EXPORT(char) erasechar(void) { + int result = ERR; T((T_CALLED("erasechar()"))); if (cur_term != 0) { #ifdef TERMIOS - returnCode(cur_term->Ottyb.c_cc[VERASE]); + result = cur_term->Ottyb.c_cc[VERASE]; + if (result == _nc_vdisable()) + result = ERR; #else - returnCode(cur_term->Ottyb.sg_erase); + result = cur_term->Ottyb.sg_erase; #endif } - returnCode(ERR); + returnCode(result); } /* @@ -81,16 +106,19 @@ erasechar(void) NCURSES_EXPORT(char) killchar(void) { + int result = ERR; T((T_CALLED("killchar()"))); if (cur_term != 0) { #ifdef TERMIOS - returnCode(cur_term->Ottyb.c_cc[VKILL]); + result = cur_term->Ottyb.c_cc[VKILL]; + if (result == _nc_vdisable()) + result = ERR; #else - returnCode(cur_term->Ottyb.sg_kill); + result = cur_term->Ottyb.sg_kill; #endif } - returnCode(ERR); + returnCode(result); } /* diff --git a/contrib/ncurses/ncurses/tinfo/lib_napms.c b/contrib/ncurses/ncurses/tinfo/lib_napms.c index df1c2e459c41..20537be4dfe0 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_napms.c +++ b/contrib/ncurses/ncurses/tinfo/lib_napms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -45,20 +45,9 @@ #if HAVE_SYS_TIME_H #include <sys/time.h> /* needed for MacOS X DP3 */ #endif -#elif USE_FUNC_POLL -#if HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#elif HAVE_SELECT -#if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT -#include <sys/time.h> -#endif -#if HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif #endif -MODULE_ID("$Id: lib_napms.c,v 1.11 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_napms.c,v 1.12 2001/12/22 22:20:40 tom Exp $") NCURSES_EXPORT(int) napms(int ms) @@ -72,18 +61,9 @@ napms(int ms) ts.tv_nsec = (ms % 1000) * 1000000; nanosleep(&ts, NULL); } -#elif USE_FUNC_POLL - { - struct pollfd fds[1]; - poll(fds, 0, ms); - } -#elif HAVE_SELECT - { - struct timeval tval; - tval.tv_sec = ms / 1000; - tval.tv_usec = (ms % 1000) * 1000; - select(0, NULL, NULL, NULL, &tval); - } +#else + _nc_timed_wait(0, ms, (int *) 0); #endif + returnCode(OK); } diff --git a/contrib/ncurses/ncurses/tinfo/lib_options.c b/contrib/ncurses/ncurses/tinfo/lib_options.c index 581357df9944..05bd47685dd6 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_options.c +++ b/contrib/ncurses/ncurses/tinfo/lib_options.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001,2002 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 <term.h> -MODULE_ID("$Id: lib_options.c,v 1.42 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_options.c,v 1.46 2002/02/02 19:40:54 tom Exp $") NCURSES_EXPORT(int) idlok(WINDOW *win, bool flag) @@ -115,6 +115,7 @@ wtimeout(WINDOW *win, int delay) if (win) { win->_delay = delay; } + returnVoid; } NCURSES_EXPORT(int) @@ -251,5 +252,6 @@ _nc_keypad(bool flag) _nc_init_keytry(); SP->_tried = TRUE; } + SP->_keypad_on = flag; return (OK); } diff --git a/contrib/ncurses/ncurses/tinfo/lib_print.c b/contrib/ncurses/ncurses/tinfo/lib_print.c index 291e84cf34b0..01540eacdc14 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_print.c +++ b/contrib/ncurses/ncurses/tinfo/lib_print.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2000,2002 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 * @@ -35,7 +35,7 @@ #include <term.h> -MODULE_ID("$Id: lib_print.c,v 1.13 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_print.c,v 1.14 2002/03/16 21:45:08 tom Exp $") NCURSES_EXPORT(int) mcprint(char *data, int len) @@ -66,7 +66,7 @@ mcprint(char *data, int len) } (void) strcpy(mybuf, switchon); - memcpy(mybuf + onsize, data, len); + memcpy(mybuf + onsize, data, (unsigned) len); if (offsize) (void) strcpy(mybuf + onsize + len, prtr_off); diff --git a/contrib/ncurses/ncurses/tinfo/lib_raw.c b/contrib/ncurses/ncurses/tinfo/lib_raw.c index 0a65b8f46464..97cf0cbd0249 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_raw.c +++ b/contrib/ncurses/ncurses/tinfo/lib_raw.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -48,7 +48,7 @@ #include <curses.priv.h> #include <term.h> /* cur_term */ -MODULE_ID("$Id: lib_raw.c,v 1.10 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_raw.c,v 1.12 2001/08/04 17:18:38 tom Exp $") #if SVR4_TERMIO && !defined(_POSIX_SOURCE) #define _POSIX_SOURCE @@ -140,8 +140,8 @@ qiflush(void) cur_term->Nttyb.c_lflag &= ~(NOFLSH); AFTER("qiflush"); (void) _nc_set_tty_mode(&cur_term->Nttyb); - returnVoid; #endif + returnVoid; } NCURSES_EXPORT(int) @@ -205,8 +205,8 @@ noqiflush(void) cur_term->Nttyb.c_lflag |= NOFLSH; AFTER("noqiflush"); (void) _nc_set_tty_mode(&cur_term->Nttyb); - returnVoid; #endif + returnVoid; } NCURSES_EXPORT(int) diff --git a/contrib/ncurses/ncurses/tinfo/lib_setup.c b/contrib/ncurses/ncurses/tinfo/lib_setup.c index e73e7e0300aa..1e49b2b6ce07 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_setup.c +++ b/contrib/ncurses/ncurses/tinfo/lib_setup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -48,7 +48,7 @@ #include <term.h> /* lines, columns, cur_term */ -MODULE_ID("$Id: lib_setup.c,v 1.64 2000/12/10 02:55:07 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.68 2001/12/08 22:14:18 tom Exp $") /**************************************************************************** * @@ -97,18 +97,17 @@ static void do_prototype(void); NCURSES_EXPORT(void) use_env(bool f) { + T((T_CALLED("use_env()"))); _use_env = f; + returnVoid; } -NCURSES_EXPORT_VAR(int) -LINES = 0; -NCURSES_EXPORT_VAR(int) -COLS = 0; -NCURSES_EXPORT_VAR(int) -TABSIZE = 0; +NCURSES_EXPORT_VAR(int) LINES = 0; +NCURSES_EXPORT_VAR(int) COLS = 0; +NCURSES_EXPORT_VAR(int) TABSIZE = 0; - static void - _nc_get_screensize(int *linep, int *colp) +static void +_nc_get_screensize(int *linep, int *colp) /* Obtain lines/columns values from the environment and/or terminfo entry */ { /* figure out the size of the screen */ @@ -178,8 +177,10 @@ TABSIZE = 0; } /* the ultimate fallback, assume fixed 24x80 size */ - if (*linep <= 0 || *colp <= 0) { + if (*linep <= 0) { *linep = 24; + } + if (*colp <= 0) { *colp = 80; } @@ -235,7 +236,7 @@ _nc_update_screensize(void) exit(EXIT_FAILURE);\ } -#if USE_DATABASE +#if USE_DATABASE || USE_TERMCAP static int grab_entry(const char *const tn, TERMTYPE * const tp) /* return 1 if entry found, 0 if not found, -1 if database not accessible */ @@ -249,6 +250,7 @@ grab_entry(const char *const tn, TERMTYPE * const tp) if (strchr(tn, '/')) return 0; +#if USE_DATABASE if ((status = _nc_read_entry(tn, filename, tp)) != 1) { #if !PURE_TERMINFO @@ -262,6 +264,9 @@ grab_entry(const char *const tn, TERMTYPE * const tp) #endif /* PURE_TERMINFO */ } +#else + status = _nc_read_termcap_entry(tn, tp); +#endif /* * If we have an entry, force all of the cancelled strings to null @@ -295,8 +300,7 @@ NCURSES_EXPORT_VAR(char) ttytype[NAMESIZE] = ""; */ NCURSES_EXPORT(int) -setupterm -(NCURSES_CONST char *tname, int Filedes, int *errret) +setupterm(NCURSES_CONST char *tname, int Filedes, int *errret) { struct term *term_ptr; int status; @@ -321,7 +325,7 @@ setupterm if (term_ptr == 0) { ret_error0(-1, "Not enough memory to create terminal structure.\n"); } -#if USE_DATABASE +#if USE_DATABASE || USE_TERMCAP status = grab_entry(tname, &term_ptr->type); #else status = 0; diff --git a/contrib/ncurses/ncurses/tinfo/lib_termcap.c b/contrib/ncurses/ncurses/tinfo/lib_termcap.c index c88887b45426..c647b9730a58 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_termcap.c +++ b/contrib/ncurses/ncurses/tinfo/lib_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,27 +29,80 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * + * * + * some of the code in here was contributed by: * + * Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93) * ****************************************************************************/ #include <curses.priv.h> #include <termcap.h> #include <tic.h> +#include <ctype.h> #define __INTERNAL_CAPS_VISIBLE #include <term_entry.h> -MODULE_ID("$Id: lib_termcap.c,v 1.39 2000/12/10 02:56:30 tom Exp $") +MODULE_ID("$Id: lib_termcap.c,v 1.42 2001/09/22 19:17:31 tom Exp $") + +#define CSI 233 +#define ESC 033 /* ^[ */ +#define L_BRACK '[' +#define SHIFT_OUT 017 /* ^N */ + +NCURSES_EXPORT_VAR(char *) UP = 0; +NCURSES_EXPORT_VAR(char *) BC = 0; + +static char *fix_me = 0; + +static char * +set_attribute_9(int flag) +{ + const char *result; + + if ((result = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag)) == 0) + result = ""; + return strdup(result); +} -/* - some of the code in here was contributed by: - Magnus Bengtsson, d6mbeng@dtek.chalmers.se -*/ +static int +is_csi(char *s) +{ + if (UChar(s[0]) == CSI) + return 1; + else if (s[0] == ESC && s[1] == L_BRACK) + return 2; + return 0; +} -NCURSES_EXPORT_VAR(char *) -UP = 0; -NCURSES_EXPORT_VAR(char *) -BC = 0; +static char * +skip_zero(char *s) +{ + if (s[0] == '0') { + if (s[1] == ';') + s += 2; + else if (isalpha(UChar(s[1]))) + s += 1; + } + return s; +} + +static bool +similar_sgr(char *a, char *b) +{ + int csi_a = is_csi(a); + int csi_b = is_csi(b); + + if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) { + a += csi_a; + b += csi_b; + if (*a != *b) { + a = skip_zero(a); + b = skip_zero(b); + } + } + return strcmp(a, b) == 0; +} /*************************************************************************** * @@ -67,8 +120,7 @@ BC = 0; ***************************************************************************/ NCURSES_EXPORT(int) -tgetent -(char *bufp GCC_UNUSED, const char *name) +tgetent(char *bufp GCC_UNUSED, const char *name) { int errcode; @@ -76,6 +128,11 @@ tgetent setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode); + PC = 0; + UP = 0; + BC = 0; + fix_me = 0; + if (errcode == 1) { if (cursor_left) @@ -90,6 +147,68 @@ tgetent if (backspace_if_not_bs != NULL) BC = backspace_if_not_bs; + /* + * While 'sgr0' is the "same" as termcap 'me', there is a compatibility + * issue. The sgr/sgr0 capabilities include setting/clearing alternate + * character set mode. A termcap application cannot use sgr, so sgr0 + * strings that reset alternate character set mode will be + * misinterpreted. Here, we remove those from the more common + * ISO/ANSI/VT100 entries, which have sgr0 agreeing with sgr. + */ + if (exit_attribute_mode != 0 + && set_attributes != 0) { + char *on = set_attribute_9(1); + char *off = set_attribute_9(0); + char *tmp; + size_t i, j, k; + + if (similar_sgr(off, exit_attribute_mode) + && !similar_sgr(off, on)) { + TR(TRACE_DATABASE, ("adjusting sgr0 : %s", _nc_visbuf(off))); + FreeIfNeeded(fix_me); + fix_me = off; + for (i = 0; off[i] != '\0'; ++i) { + if (on[i] != off[i]) { + j = strlen(off); + k = strlen(on); + while (j != 0 + && k != 0 + && off[j - 1] == on[k - 1]) { + --j, --k; + } + while (off[j] != '\0') { + off[i++] = off[j++]; + } + off[i] = '\0'; + break; + } + } + /* SGR 10 would reset to normal font */ + if ((i = is_csi(off)) != 0 + && off[strlen(off) - 1] == 'm') { + tmp = skip_zero(off + i); + if (tmp[0] == '1' + && skip_zero(tmp + 1) != tmp + 1) { + i = tmp - off; + if (off[i - 1] == ';') + i--; + j = skip_zero(tmp + 1) - off; + while (off[j] != '\0') { + off[i++] = off[j++]; + } + off[i] = '\0'; + } + } + TR(TRACE_DATABASE, ("...adjusted me : %s", _nc_visbuf(fix_me))); + if (!strcmp(fix_me, exit_attribute_mode)) { + TR(TRACE_DATABASE, ("...same result, discard")); + free(fix_me); + fix_me = 0; + } + } + free(on); + } + (void) baudrate(); /* sets ospeed as a side-effect */ /* LINT_PREPRO @@ -169,10 +288,10 @@ tgetnum(NCURSES_CONST char *id) ***************************************************************************/ NCURSES_EXPORT(char *) -tgetstr -(NCURSES_CONST char *id, char **area) +tgetstr(NCURSES_CONST char *id, char **area) { int i; + char *result = NULL; T((T_CALLED("tgetstr(%s,%p)"), id, area)); if (cur_term != 0) { @@ -180,17 +299,24 @@ tgetstr for_each_string(i, tp) { const char *capname = ExtStrname(tp, i, strcodes); if (!strncmp(id, capname, 2)) { - TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(tp->Strings[i]))); + result = tp->Strings[i]; + TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(result))); /* setupterm forces canceled strings to null */ - if (area != 0 - && *area != 0 - && VALID_STRING(tp->Strings[i])) { - (void) strcpy(*area, tp->Strings[i]); - *area += strlen(*area) + 1; + if (VALID_STRING(result)) { + if (result == exit_attribute_mode + && fix_me != 0) { + result = fix_me; + TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result))); + } + if (area != 0 + && *area != 0) { + (void) strcpy(*area, result); + *area += strlen(*area) + 1; + } } - returnPtr(tp->Strings[i]); + break; } } } - returnPtr(NULL); + returnPtr(result); } diff --git a/contrib/ncurses/ncurses/tinfo/lib_termname.c b/contrib/ncurses/ncurses/tinfo/lib_termname.c index 6b287e06c890..57ce807a9e5f 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_termname.c +++ b/contrib/ncurses/ncurses/tinfo/lib_termname.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,7 +29,7 @@ #include <curses.priv.h> #include <tic.h> /* for MAX_ALIAS */ -MODULE_ID("$Id: lib_termname.c,v 1.6 2000/12/10 02:55:08 tom Exp $") +MODULE_ID("$Id: lib_termname.c,v 1.7 2001/08/04 19:29:38 tom Exp $") NCURSES_EXPORT(char *) termname(void) @@ -37,12 +37,12 @@ termname(void) char *name = getenv("TERM"); static char ret[MAX_ALIAS + 1]; - T(("termname() called")); + T((T_CALLED("termname()"))); if (name != 0) { ret[0] = '\0'; (void) strncat(ret, name, sizeof(ret) - 1); name = ret; } - return name; + returnPtr(name); } diff --git a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c index 19edb4f31a11..17649d53f68f 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_tgoto.c +++ b/contrib/ncurses/ncurses/tinfo/lib_tgoto.c @@ -35,7 +35,7 @@ #include <ctype.h> #include <termcap.h> -MODULE_ID("$Id: lib_tgoto.c,v 1.7 2001/03/24 22:25:55 tom Exp $") +MODULE_ID("$Id: lib_tgoto.c,v 1.8 2001/06/02 22:44:42 tom Exp $") #if !PURE_TERMINFO static bool @@ -112,7 +112,7 @@ tgoto_internal(const char *string, int x, int y) *value %= 1000; break; case '+': - *value += CharOf(*++string); + *value += UChar(*++string); /* FALLTHRU */ case '.': /* diff --git a/contrib/ncurses/ncurses/tinfo/lib_tparm.c b/contrib/ncurses/ncurses/tinfo/lib_tparm.c index e62b824e5bc6..931669e933bd 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_tparm.c +++ b/contrib/ncurses/ncurses/tinfo/lib_tparm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 <term.h> #include <tic.h> -MODULE_ID("$Id: lib_tparm.c,v 1.52 2001/03/11 15:12:48 tom Exp $") +MODULE_ID("$Id: lib_tparm.c,v 1.53 2001/06/02 22:53:59 tom Exp $") /* * char * @@ -301,7 +301,7 @@ parse_format(const char *s, char *format, int *len) } break; default: - if (isdigit(CharOf(*s))) { + if (isdigit(UChar(*s))) { value = (value * 10) + (*s - '0'); if (value > 10000) err = TRUE; diff --git a/contrib/ncurses/ncurses/tinfo/lib_tputs.c b/contrib/ncurses/ncurses/tinfo/lib_tputs.c index 63dbbd9a736b..26d805ba4025 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_tputs.c +++ b/contrib/ncurses/ncurses/tinfo/lib_tputs.c @@ -45,7 +45,7 @@ #include <termcap.h> /* ospeed */ #include <tic.h> -MODULE_ID("$Id: lib_tputs.c,v 1.56 2001/04/21 18:53:53 tom Exp $") +MODULE_ID("$Id: lib_tputs.c,v 1.59 2001/09/22 18:35:23 tom Exp $") NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */ @@ -104,72 +104,6 @@ _nc_outch(int ch) return OK; } -#if USE_WIDEC_SUPPORT -/* - * Reference: The Unicode Standard 2.0 - * - * No surrogates supported (we're storing only one 16-bit Unicode value per - * cell). - */ -NCURSES_EXPORT(int) -_nc_utf8_outch(int ch) -{ - static const unsigned byteMask = 0xBF; - static const unsigned otherMark = 0x80; - static const unsigned firstMark[] = - {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; - - int result[7], *ptr; - int count = 0; - - if ((unsigned int) ch < 0x80) - count = 1; - else if ((unsigned int) ch < 0x800) - count = 2; - else if ((unsigned int) ch < 0x10000) - count = 3; - else if ((unsigned int) ch < 0x200000) - count = 4; - else if ((unsigned int) ch < 0x4000000) - count = 5; - else if ((unsigned int) ch <= 0x7FFFFFFF) - count = 6; - else { - count = 3; - ch = 0xFFFD; - } - ptr = result + count; - switch (count) { - case 6: - *--ptr = (ch | otherMark) & byteMask; - ch >>= 6; - /* FALLTHRU */ - case 5: - *--ptr = (ch | otherMark) & byteMask; - ch >>= 6; - /* FALLTHRU */ - case 4: - *--ptr = (ch | otherMark) & byteMask; - ch >>= 6; - /* FALLTHRU */ - case 3: - *--ptr = (ch | otherMark) & byteMask; - ch >>= 6; - /* FALLTHRU */ - case 2: - *--ptr = (ch | otherMark) & byteMask; - ch >>= 6; - /* FALLTHRU */ - case 1: - *--ptr = (ch | firstMark[count]); - break; - } - while (count--) - _nc_outch(*ptr++); - return OK; -} -#endif - NCURSES_EXPORT(int) putp(const char *string) { @@ -228,19 +162,19 @@ tputs * (like nethack) actually do the likes of tputs("50") to get delays. */ trailpad = 0; - if (isdigit(*string)) { - while (isdigit(*string)) { + if (isdigit(UChar(*string))) { + while (isdigit(UChar(*string))) { trailpad = trailpad * 10 + (*string - '0'); string++; } trailpad *= 10; if (*string == '.') { string++; - if (isdigit(*string)) { + if (isdigit(UChar(*string))) { trailpad += (*string - '0'); string++; } - while (isdigit(*string)) + while (isdigit(UChar(*string))) string++; } @@ -265,7 +199,7 @@ tputs bool mandatory; string++; - if ((!isdigit(CharOf(*string)) && *string != '.') + if ((!isdigit(UChar(*string)) && *string != '.') || !strchr(string, '>')) { (*outc) ('$'); (*outc) ('<'); @@ -273,18 +207,18 @@ tputs } number = 0; - while (isdigit(CharOf(*string))) { + while (isdigit(UChar(*string))) { number = number * 10 + (*string - '0'); string++; } number *= 10; if (*string == '.') { string++; - if (isdigit(CharOf(*string))) { + if (isdigit(UChar(*string))) { number += (*string - '0'); string++; } - while (isdigit(CharOf(*string))) + while (isdigit(UChar(*string))) string++; } diff --git a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c index d72df2d4dff3..e71be893fbb9 100644 --- a/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c +++ b/contrib/ncurses/ncurses/tinfo/lib_ttyflags.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,2000,2001 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 * @@ -38,7 +38,7 @@ #include <curses.priv.h> #include <term.h> /* cur_term */ -MODULE_ID("$Id: lib_ttyflags.c,v 1.5 2000/12/10 02:55:08 tom Exp $") +MODULE_ID("$Id: lib_ttyflags.c,v 1.6 2001/12/16 01:19:01 tom Exp $") #undef tabs @@ -121,7 +121,7 @@ reset_prog_mode(void) if (cur_term != 0) { _nc_set_tty_mode(&cur_term->Nttyb); if (SP) { - if (stdscr && stdscr->_use_keypad) + if (SP->_keypad_on) _nc_keypad(TRUE); NC_BUFFERED(TRUE); } diff --git a/contrib/ncurses/ncurses/tinfo/name_match.c b/contrib/ncurses/ncurses/tinfo/name_match.c index 934b24a29dde..e7205d5ec8ab 100644 --- a/contrib/ncurses/ncurses/tinfo/name_match.c +++ b/contrib/ncurses/ncurses/tinfo/name_match.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1999,2000,2001 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 * @@ -34,7 +34,7 @@ #include <term.h> #include <tic.h> -MODULE_ID("$Id: name_match.c,v 1.10 2000/12/10 02:55:08 tom Exp $") +MODULE_ID("$Id: name_match.c,v 1.11 2001/09/22 21:11:34 tom Exp $") /* * _nc_first_name(char *names) @@ -46,10 +46,12 @@ NCURSES_EXPORT(char *) _nc_first_name(const char *const sp) /* get the first name from the given name list */ { - static char buf[MAX_NAME_SIZE + 1]; + static char *buf; register unsigned n; - for (n = 0; n < sizeof(buf) - 1; n++) { + if (buf == 0) + buf = _nc_doalloc(buf, MAX_NAME_SIZE + 1); + for (n = 0; n < MAX_NAME_SIZE; n++) { if ((buf[n] = sp[n]) == '\0' || (buf[n] == '|')) break; diff --git a/contrib/ncurses/ncurses/tinfo/parse_entry.c b/contrib/ncurses/ncurses/tinfo/parse_entry.c index ef66b30ecb4e..797974cb1642 100644 --- a/contrib/ncurses/ncurses/tinfo/parse_entry.c +++ b/contrib/ncurses/ncurses/tinfo/parse_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2001,2002 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 * @@ -47,7 +47,7 @@ #define __INTERNAL_CAPS_VISIBLE #include <term_entry.h> -MODULE_ID("$Id: parse_entry.c,v 1.53 2001/03/03 21:13:09 Todd.C.Miller Exp $") +MODULE_ID("$Id: parse_entry.c,v 1.55 2002/04/22 00:01:30 tom Exp $") #ifdef LINT static short const parametrized[] = @@ -243,7 +243,7 @@ _nc_parse_entry (base == entryp->tterm.term_names) ? "primary name" : "alias", - ptr - base, base); + (int) (ptr - base), base); } } @@ -482,7 +482,7 @@ _nc_capcmp(const char *s, const char *t) for (;;) { if (s[0] == '$' && s[1] == '<') { for (s += 2;; s++) - if (!(isdigit(CharOf(*s)) + if (!(isdigit(UChar(*s)) || *s == '.' || *s == '*' || *s == '/' @@ -492,7 +492,7 @@ _nc_capcmp(const char *s, const char *t) if (t[0] == '$' && t[1] == '<') { for (t += 2;; t++) - if (!(isdigit(CharOf(*t)) + if (!(isdigit(UChar(*t)) || *t == '.' || *t == '*' || *t == '/' diff --git a/contrib/ncurses/ncurses/tinfo/read_termcap.c b/contrib/ncurses/ncurses/tinfo/read_termcap.c index da88f0b149ab..c6e7e358ad91 100644 --- a/contrib/ncurses/ncurses/tinfo/read_termcap.c +++ b/contrib/ncurses/ncurses/tinfo/read_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998,1999,2000,2001 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 * @@ -52,10 +52,12 @@ #include <curses.priv.h> #include <ctype.h> +#include <sys/types.h> +#include <sys/stat.h> #include <tic.h> #include <term_entry.h> -MODULE_ID("$Id: read_termcap.c,v 1.55 2000/12/10 02:55:08 tom Exp $") +MODULE_ID("$Id: read_termcap.c,v 1.58 2001/10/28 01:11:34 tom Exp $") #if !PURE_TERMINFO @@ -72,6 +74,17 @@ MODULE_ID("$Id: read_termcap.c,v 1.55 2000/12/10 02:55:08 tom Exp $") #define TC_SYS_ERR -3 #define TC_REF_LOOP -4 +static char * +get_termpath(void) +{ + char *result; + + if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0) + result = TERMPATH; + T(("TERMPATH is %s", result)); + return result; +} + #if USE_GETCAP #if HAVE_BSD_CGETENT @@ -125,13 +138,7 @@ static int _nc_nfcmp(const char *, char *); #define BFRAG 1024 #define BSIZE 1024 -#define ESC ('[' & 037) /* ASCII ESC */ #define MAX_RECURSION 32 /* maximum getent recursion */ -#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */ - -#define RECOK (char)0 -#define TCERR (char)1 -#define SHADOW (char)2 static size_t topreclen; /* toprec length */ static char *toprec; /* Additional record specified by cgetset() */ @@ -797,9 +804,9 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name) */ _nc_str_init(&desc, pathbuf, sizeof(pathbuf)); if (cp == NULL) { - _nc_safe_strcpy(&desc, "/etc/termcap /usr/share/misc/termcap"); + _nc_safe_strcpy(&desc, get_termpath()); } else if (!is_pathname(cp)) { /* TERMCAP holds an entry */ - if ((termpath = getenv("TERMPATH")) != 0) { + if ((termpath = get_termpath()) != 0) { _nc_safe_strcat(&desc, termpath); } else { char temp[PBUFSIZ]; @@ -812,8 +819,8 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name) /* if no $HOME look in current directory */ strcat(temp, ".termcap"); _nc_safe_strcat(&desc, temp); - _nc_safe_strcat(&desc, " /etc/termcap"); - _nc_safe_strcat(&desc, " /usr/share/misc/termcap"); + _nc_safe_strcat(&desc, " "); + _nc_safe_strcat(&desc, get_termpath()); } } else { /* user-defined name in TERMCAP */ _nc_safe_strcat(&desc, cp); /* still can be tokenized */ @@ -908,18 +915,24 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name) static int add_tc(char *termpaths[], char *path, int count) { + char *save = strchr(path, NCURSES_PATHSEP); + if (save != 0) + *save = '\0'; if (count < MAXPATHS - && _nc_access(path, R_OK) == 0) + && _nc_access(path, R_OK) == 0) { termpaths[count++] = path; + T(("Adding termpath %s", path)); + } termpaths[count] = 0; + if (save != 0) + *save = NCURSES_PATHSEP; return count; } #define ADD_TC(path, count) filecount = add_tc(termpaths, path, count) #endif /* !USE_GETCAP */ NCURSES_EXPORT(int) -_nc_read_termcap_entry -(const char *const tn, TERMTYPE * const tp) +_nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp) { int found = FALSE; ENTRY *ep; @@ -931,6 +944,7 @@ _nc_read_termcap_entry static char *source; static int lineno; + T(("read termcap entry for %s", tn)); if (use_terminfo_vars() && (p = getenv("TERMCAP")) != 0 && !is_pathname(p) && _nc_name_match(p, tn, "|:")) { /* TERMCAP holds a termcap entry */ @@ -976,41 +990,38 @@ _nc_read_termcap_entry FILE *fp; char *tc, *termpaths[MAXPATHS]; int filecount = 0; + int j, k; bool use_buffer = FALSE; + bool normal = TRUE; char tc_buf[1024]; char pathbuf[PATH_MAX]; + char *copied = 0; + char *cp; + struct stat test_stat[MAXPATHS]; termpaths[filecount] = 0; if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != 0) { if (is_pathname(tc)) { /* interpret as a filename */ ADD_TC(tc, 0); + normal = FALSE; } else if (_nc_name_match(tc, tn, "|:")) { /* treat as a capability file */ use_buffer = TRUE; (void) sprintf(tc_buf, "%.*s\n", (int) sizeof(tc_buf) - 2, tc); - } else if ((tc = getenv("TERMPATH")) != 0) { - char *cp; - - for (cp = tc; *cp; cp++) { - if (*cp == NCURSES_PATHSEP) - *cp = '\0'; - else if (cp == tc || cp[-1] == '\0') { - ADD_TC(cp, filecount); - } - } + normal = FALSE; } - } else { /* normal case */ - char envhome[PATH_MAX], *h; + } - filecount = 0; + if (normal) { /* normal case */ + char envhome[PATH_MAX], *h; - /* - * Probably /etc/termcap is a symlink to /usr/share/misc/termcap. - * Avoid reading the same file twice. - */ - if (_nc_access("/etc/termcap", F_OK) == 0) - ADD_TC("/etc/termcap", filecount); - else - ADD_TC("/usr/share/misc/termcap", filecount); + copied = strdup(get_termpath()); + for (cp = copied; *cp; cp++) { + if (*cp == NCURSES_PATHSEP) + *cp = '\0'; + else if (cp == copied || cp[-1] == '\0') { + ADD_TC(cp, filecount); + } + } #define PRIVATE_CAP "%s/.termcap" @@ -1023,6 +1034,37 @@ _nc_read_termcap_entry } } + /* + * Probably /etc/termcap is a symlink to /usr/share/misc/termcap. + * Avoid reading the same file twice. + */ +#ifdef HAVE_LINK + for (j = 0; j < filecount; j++) { + bool omit = FALSE; + if (stat(termpaths[j], &test_stat[j]) != 0 + || (test_stat[j].st_mode & S_IFMT) != S_IFREG) { + omit = TRUE; + } else { + for (k = 0; k < j; k++) { + if (test_stat[k].st_dev == test_stat[j].st_dev + && test_stat[k].st_ino == test_stat[j].st_ino) { + omit = TRUE; + break; + } + } + } + if (omit) { + T(("Path %s is a duplicate", termpaths[j])); + for (k = j + 1; k < filecount; k++) { + termpaths[k - 1] = termpaths[k]; + test_stat[k - 1] = test_stat[k]; + } + --filecount; + --j; + } + } +#endif + /* parse the sources */ if (use_buffer) { _nc_set_source("TERMCAP"); @@ -1038,7 +1080,8 @@ _nc_read_termcap_entry for (i = 0; i < filecount; i++) { T(("Looking for %s in %s", tn, termpaths[i])); - if ((fp = fopen(termpaths[i], "r")) != (FILE *) 0) { + if (_nc_access(termpaths[i], R_OK) == 0 + && (fp = fopen(termpaths[i], "r")) != (FILE *) 0) { _nc_set_source(termpaths[i]); /* @@ -1052,6 +1095,8 @@ _nc_read_termcap_entry } } } + if (copied != 0) + free(copied); #endif /* USE_GETCAP */ if (_nc_head == 0) diff --git a/contrib/ncurses/ncurses/tinfo/write_entry.c b/contrib/ncurses/ncurses/tinfo/write_entry.c index ffcf4027f055..9750dffd5ffe 100644 --- a/contrib/ncurses/ncurses/tinfo/write_entry.c +++ b/contrib/ncurses/ncurses/tinfo/write_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2000,2002 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 * @@ -52,7 +52,7 @@ #define TRACE_OUT(p) /*nothing */ #endif -MODULE_ID("$Id: write_entry.c,v 1.56 2000/12/10 02:55:08 tom Exp $") +MODULE_ID("$Id: write_entry.c,v 1.58 2002/04/21 20:35:08 tom Exp $") static int total_written; @@ -214,6 +214,10 @@ _nc_write_entry(TERMTYPE * const tp) char linkname[PATH_MAX]; #if USE_SYMLINKS char symlinkname[PATH_MAX]; +#if !HAVE_LINK +#undef HAVE_LINK +#define HAVE_LINK 1 +#endif #endif /* USE_SYMLINKS */ static int call_count; static time_t start_time; /* time at start of writes */ @@ -361,10 +365,10 @@ _nc_write_entry(TERMTYPE * const tp) #define WRITE_STRING(str) (fwrite(str, sizeof(char), strlen(str) + 1, fp) == strlen(str) + 1) static int -compute_offsets(char **Strings, int strmax, short *offsets) +compute_offsets(char **Strings, unsigned strmax, short *offsets) { size_t nextfree = 0; - int i; + unsigned i; for (i = 0; i < strmax; i++) { if (Strings[i] == ABSENT_STRING) { @@ -381,9 +385,9 @@ compute_offsets(char **Strings, int strmax, short *offsets) } static void -convert_shorts(unsigned char *buf, short *Numbers, int count) +convert_shorts(unsigned char *buf, short *Numbers, unsigned count) { - int i; + unsigned i; for (i = 0; i < count; i++) { if (Numbers[i] == ABSENT_NUMERIC) { /* HI/LO won't work */ buf[2 * i] = buf[2 * i + 1] = 0377; |