diff options
author | 1999-06-27 08:14:21 +0000 | |
---|---|---|
committer | 1999-06-27 08:14:21 +0000 | |
commit | 24dc1c5e148b865950fd90786c4d6bbc53d0845d (patch) | |
tree | aaa1d4fed3e16aef81b955da078846acb5cc5b27 | |
parent | Use a.b.c.d/nn syntax for encap route output. (diff) | |
download | wireguard-openbsd-24dc1c5e148b865950fd90786c4d6bbc53d0845d.tar.xz wireguard-openbsd-24dc1c5e148b865950fd90786c4d6bbc53d0845d.zip |
ncurses-5.0-990626
-rw-r--r-- | lib/libcurses/SigAction.h | 12 | ||||
-rw-r--r-- | lib/libcurses/base/sigaction.c | 12 | ||||
-rw-r--r-- | lib/libcurses/curses.h | 8 | ||||
-rw-r--r-- | lib/libcurses/curses.priv.h | 9 | ||||
-rw-r--r-- | lib/libcurses/ncurses_cfg.h | 3 | ||||
-rw-r--r-- | lib/libcurses/tinfo/MKfallback.sh | 11 | ||||
-rw-r--r-- | lib/libcurses/tinfo/comp_hash.c | 7 | ||||
-rw-r--r-- | lib/libcurses/tty/lib_mvcur.c | 22 | ||||
-rw-r--r-- | lib/libcurses/tty/lib_tstp.c | 24 | ||||
-rw-r--r-- | lib/libform/form_field_buffer.3 | 11 | ||||
-rw-r--r-- | usr.bin/infocmp/infocmp.1tbl | 24 | ||||
-rw-r--r-- | usr.bin/infocmp/infocmp.c | 267 | ||||
-rw-r--r-- | usr.bin/tic/tic.c | 11 |
13 files changed, 282 insertions, 139 deletions
diff --git a/lib/libcurses/SigAction.h b/lib/libcurses/SigAction.h index 3e8e38376a5..1f06fc2c3b6 100644 --- a/lib/libcurses/SigAction.h +++ b/lib/libcurses/SigAction.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SigAction.h,v 1.1 1998/07/23 21:17:25 millert Exp $ */ +/* $OpenBSD: SigAction.h,v 1.2 1999/06/27 08:15:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $From: SigAction.h,v 1.4 1998/02/11 12:13:55 tom Exp $ + * $From: SigAction.h,v 1.5 1999/06/19 23:00:54 tom Exp $ * * This file exists to handle non-POSIX systems which don't have <unistd.h>, * and usually no sigaction() nor <termios.h> @@ -43,6 +43,14 @@ #ifndef _SIGACTION_H #define _SIGACTION_H +#ifndef HAVE_SIGACTION +#define HAVE_SIGACTION 0 +#endif + +#ifndef HAVE_SIGVEC +#define HAVE_SIGVEC 0 +#endif + #if HAVE_SIGACTION #if !HAVE_TYPE_SIGACTION diff --git a/lib/libcurses/base/sigaction.c b/lib/libcurses/base/sigaction.c index b07ee1c333d..71ab97bbaf7 100644 --- a/lib/libcurses/base/sigaction.c +++ b/lib/libcurses/base/sigaction.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sigaction.c,v 1.2 1999/03/18 16:46:58 millert Exp $ */ +/* $OpenBSD: sigaction.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -35,14 +35,15 @@ #include <curses.priv.h> +#include <signal.h> +#include <SigAction.h> + /* This file provides sigaction() emulation using sigvec() */ /* Use only if this is non POSIX system */ -#if !HAVE_SIGACTION -#include <signal.h> -#include <SigAction.h> +#if !HAVE_SIGACTION && HAVE_SIGVEC -MODULE_ID("$From: sigaction.c,v 1.8 1999/03/18 02:12:04 tom Exp $") +MODULE_ID("$From: sigaction.c,v 1.9 1999/06/19 23:05:16 tom Exp $") int sigaction (int sig, sigaction_t * sigact, sigaction_t * osigact) @@ -100,6 +101,7 @@ sigismember (sigset_t * mask, int sig) { return (*mask & sigmask (sig)) != 0; } + #else extern void _nc_sigaction(void); /* quiet's gcc warning */ void _nc_sigaction(void) { } /* nonempty for strict ANSI compilers */ diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h index d28dc650c06..cd69f07907a 100644 --- a/lib/libcurses/curses.h +++ b/lib/libcurses/curses.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.h,v 1.32 1999/06/15 03:07:48 millert Exp $ */ +/* $OpenBSD: curses.h,v 1.33 1999/06/27 08:15:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -33,7 +33,7 @@ * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ -/* $From: curses.h.in,v 1.82 1999/06/06 00:38:49 tom Exp $ */ +/* $From: curses.h.in,v 1.83 1999/06/16 00:25:26 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H @@ -50,7 +50,7 @@ /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 5 #define NCURSES_VERSION_MINOR 0 -#define NCURSES_VERSION_PATCH 990614 +#define NCURSES_VERSION_PATCH 990626 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION @@ -87,7 +87,7 @@ typedef unsigned long chtype; #undef FALSE #define FALSE 0 -#if !defined(__cplusplus) || !1 +#if !defined(__cplusplus) #undef bool typedef char bool; #endif diff --git a/lib/libcurses/curses.priv.h b/lib/libcurses/curses.priv.h index e73eef31890..0d88a7ad442 100644 --- a/lib/libcurses/curses.priv.h +++ b/lib/libcurses/curses.priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curses.priv.h,v 1.18 1999/06/14 17:26:04 millert Exp $ */ +/* $OpenBSD: curses.priv.h,v 1.19 1999/06/27 08:15:19 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -35,7 +35,7 @@ /* - * $From: curses.priv.h,v 1.140 1999/06/12 21:19:47 tom Exp $ + * $From: curses.priv.h,v 1.141 1999/06/26 22:00:49 tom Exp $ * * curses.priv.h * @@ -671,6 +671,11 @@ extern void _nc_screen_init(void); extern void _nc_screen_resume(void); extern void _nc_screen_wrap(void); +#if !HAVE_STRSTR +#define strstr _nc_strstr +extern char *_nc_strstr(const char *, const char *); +#endif + /* lib_mouse.c */ extern int _nc_has_mouse(void); diff --git a/lib/libcurses/ncurses_cfg.h b/lib/libcurses/ncurses_cfg.h index cf253af5a83..f9ce6be4980 100644 --- a/lib/libcurses/ncurses_cfg.h +++ b/lib/libcurses/ncurses_cfg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ncurses_cfg.h,v 1.13 1999/05/29 18:27:36 millert Exp $ */ +/* $OpenBSD: ncurses_cfg.h,v 1.14 1999/06/27 08:15:19 millert Exp $ */ /* include/ncurses_cfg.h. Generated automatically by configure. */ /**************************************************************************** @@ -86,6 +86,7 @@ #define HAVE_SIGVEC 1 #define HAVE_SIZECHANGE 1 #define HAVE_STRDUP 1 +#define HAVE_STRSTR 1 #define HAVE_SYMLINK 1 #define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_PARAM_H 1 diff --git a/lib/libcurses/tinfo/MKfallback.sh b/lib/libcurses/tinfo/MKfallback.sh index d6631b2ca8a..0c1eaef70c7 100644 --- a/lib/libcurses/tinfo/MKfallback.sh +++ b/lib/libcurses/tinfo/MKfallback.sh @@ -1,6 +1,6 @@ #!/bin/sh -# $OpenBSD: MKfallback.sh,v 1.1 1999/01/18 19:10:12 millert Exp $ -# $From: MKfallback.sh,v 1.8 1996/09/15 01:44:13 tom Exp $ +# $OpenBSD: MKfallback.sh,v 1.2 1999/06/27 08:14:21 millert Exp $ +# $From: MKfallback.sh,v 1.9 1999/06/15 22:57:45 tom Exp $ # # MKfallback.sh -- create fallback table for entry reads # @@ -25,7 +25,14 @@ then #include <tic.h> /* fallback entries for: $* */ +EOF + for x in $* + do + echo "/* $x */" + infocmp -E $x + done + cat <<EOF static const TERMTYPE fallbacks[$#] = { EOF diff --git a/lib/libcurses/tinfo/comp_hash.c b/lib/libcurses/tinfo/comp_hash.c index 862dd21fb3e..be52efa37ab 100644 --- a/lib/libcurses/tinfo/comp_hash.c +++ b/lib/libcurses/tinfo/comp_hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_hash.c,v 1.3 1999/03/15 19:12:22 millert Exp $ */ +/* $OpenBSD: comp_hash.c,v 1.4 1999/06/27 08:14:21 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -51,7 +51,7 @@ #define DEBUG(level, params) /*nothing*/ #endif -MODULE_ID("$From: comp_hash.c,v 1.20 1999/03/14 12:23:26 tom Exp $") +MODULE_ID("$From: comp_hash.c,v 1.21 1999/06/26 21:25:11 tom Exp $") static int hash_function(const char *); @@ -66,7 +66,8 @@ static int hash_function(const char *); #ifdef MAIN_PROGRAM -#undef USE_RCS_IDS +#undef MODULE_ID +#define MODULE_ID(id) /*nothing*/ #include <tinfo/doalloc.c> static void _nc_make_hash_table(struct name_table_entry *table, diff --git a/lib/libcurses/tty/lib_mvcur.c b/lib/libcurses/tty/lib_mvcur.c index a096cb6b16d..29e9f89d266 100644 --- a/lib/libcurses/tty/lib_mvcur.c +++ b/lib/libcurses/tty/lib_mvcur.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_mvcur.c,v 1.2 1999/02/11 00:09:37 millert Exp $ */ +/* $OpenBSD: lib_mvcur.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -155,7 +155,7 @@ #include <term.h> #include <ctype.h> -MODULE_ID("$From: lib_mvcur.c,v 1.56 1999/02/01 12:04:15 tom Exp $") +MODULE_ID("$From: lib_mvcur.c,v 1.57 1999/06/26 22:16:04 tom Exp $") #define STRLEN(s) (s != 0) ? strlen(s) : 0 @@ -177,6 +177,24 @@ static float diff; static int normalized_cost(const char *const cap, int affcnt); +#if !HAVE_STRSTR +char * _nc_strstr(const char *haystack, const char *needle) +{ + size_t len1 = strlen(haystack); + size_t len2 = strlen(needle); + char *result = 0; + + while ((len1 != 0) && (len1-- >= len2)) { + if (!strncmp(haystack, needle, len2)) { + result = haystack; + break; + } + haystack++; + } + return result; +} +#endif + /**************************************************************************** * * Initialization/wrapup (including cost pre-computation) diff --git a/lib/libcurses/tty/lib_tstp.c b/lib/libcurses/tty/lib_tstp.c index 11455deff2c..6941f460f21 100644 --- a/lib/libcurses/tty/lib_tstp.c +++ b/lib/libcurses/tty/lib_tstp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib_tstp.c,v 1.2 1999/01/31 20:17:10 millert Exp $ */ +/* $OpenBSD: lib_tstp.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -50,7 +50,13 @@ #define _POSIX_SOURCE #endif -MODULE_ID("$From: lib_tstp.c,v 1.17 1999/01/31 01:06:14 tom Exp $") +MODULE_ID("$From: lib_tstp.c,v 1.18 1999/06/19 23:00:06 tom Exp $") + +#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) +#define USE_SIGTSTP 1 +#else +#define USE_SIGTSTP 0 +#endif /* * Note: This code is fragile! Its problem is that different OSs @@ -95,7 +101,7 @@ MODULE_ID("$From: lib_tstp.c,v 1.17 1999/01/31 01:06:14 tom Exp $") * the future. If nothing else, it's simpler... */ -#ifdef SIGTSTP +#if USE_SIGTSTP static void tstp(int dummy GCC_UNUSED) { sigset_t mask, omask; @@ -190,7 +196,7 @@ static void tstp(int dummy GCC_UNUSED) /* Reset the signals. */ (void)sigprocmask(SIG_SETMASK, &omask, NULL); } -#endif /* defined(SIGTSTP) */ +#endif /* USE_SIGTSTP */ static void cleanup(int sig) { @@ -257,9 +263,9 @@ static int CatchIfDefault(int sig, sigaction_t *act) return FALSE; } #else -static int CatchIfDefault(int sig, RETSIGTYPE (*handler)()) +static int CatchIfDefault(int sig, RETSIGTYPE (*handler)(int)) { - void (*ohandler)(); + void (*ohandler)(int); ohandler = signal(sig, SIG_IGN); if (ohandler == SIG_DFL @@ -289,7 +295,7 @@ static int CatchIfDefault(int sig, RETSIGTYPE (*handler)()) */ void _nc_signal_handler(bool enable) { -#ifdef SIGTSTP /* Xenix 2.x doesn't have this */ +#if USE_SIGTSTP /* Xenix 2.x doesn't have SIGTSTP, for example */ static sigaction_t act, oact; static int ignore; @@ -325,7 +331,7 @@ static int ignore; ignore = TRUE; } } -#else /* !SIGTSTP */ +#else /* !USE_SIGTSTP */ if (enable) { #if HAVE_SIGACTION || HAVE_SIGVEC @@ -351,5 +357,5 @@ static int ignore; #endif #endif /* !(HAVE_SIGACTION || HAVE_SIGVEC) */ } -#endif /* !SIGTSTP */ +#endif /* !USE_SIGTSTP */ } diff --git a/lib/libform/form_field_buffer.3 b/lib/libform/form_field_buffer.3 index 9a347eb4737..90ecf1f1963 100644 --- a/lib/libform/form_field_buffer.3 +++ b/lib/libform/form_field_buffer.3 @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: form_field_buffer.3,v 1.9 1999/05/08 20:29:03 millert Exp $ +.\" $OpenBSD: form_field_buffer.3,v 1.10 1999/06/27 08:16:02 millert Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998 Free Software Foundation, Inc. * @@ -29,7 +29,7 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $From: form_field_buffer.3x,v 1.7 1999/04/04 00:22:24 tom Exp $ +.\" $From: From: form_field_buffer.3x,v 1.8 1999/06/16 00:37:09 juergen Exp $ .TH form_field_buffer 3 "" .SH NAME \fBform_field_buffer\fR - field buffer control @@ -52,6 +52,13 @@ to contain a given string. Buffer 0 is the displayed value of the field; other numbered buffers may be allocated by applications through the \fBnbuf\fR argument of (see \fBform_field_new\fR(3)) but are not manipulated by the forms library. The function \fBfield_buffer\fR returns the address of the buffer. +Please note that this buffer has always the length of the buffer, that means +that it may typically contain trailing spaces. If you entered leading spaces +the buffer may also contain them. If you want the raw data, you must write your +own routine that copies the value out of the buffer and removes the leading +and trailing spaces. Please note also, that subsequent operations on the form +will probably change the content of the buffer. So don't use it for long term +storage of the entered form data. The function \fBset_field_status\fR sets the associated status flag of \fIfield\fR; \fBfield_status\fR gets the current value. The status flag diff --git a/usr.bin/infocmp/infocmp.1tbl b/usr.bin/infocmp/infocmp.1tbl index 26019b3ad85..d5dbd52ca6f 100644 --- a/usr.bin/infocmp/infocmp.1tbl +++ b/usr.bin/infocmp/infocmp.1tbl @@ -1,5 +1,5 @@ '\" t -.\" $OpenBSD: infocmp.1tbl,v 1.3 1999/03/11 21:08:07 millert Exp $ +.\" $OpenBSD: infocmp.1tbl,v 1.4 1999/06/27 08:17:46 millert Exp $ .\" .\"*************************************************************************** .\" Copyright (c) 1998 Free Software Foundation, Inc. * @@ -29,16 +29,18 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $From: infocmp.1m,v 1.20 1999/03/07 02:07:48 tom Exp $ +.\" $From: infocmp.1m,v 1.21 1999/06/15 23:12:25 tom Exp $ .TH infocmp 1 "" .ds n 5 .ds d /usr/share/terminfo .SH NAME \fBinfocmp\fR - compare or print out \fIterminfo\fR descriptions .SH SYNOPSIS -\fBinfocmp\fR [\fB-dcGgnpILCuV1\fR] [\fB-v\fR \fIn\fR] [\fB-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] +\fBinfocmp\fR [\fB-dceEGgnpILCuV1\fR] [\fB-v\fR \fIn\fR] [\fB-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] .br - [\fB-w\fR \fIwidth\fR] [\fB-A\fR \fIdirectory\fR] [\fB-B\fR \fIdirectory\fR] [\fItermname\fR...] + [\fB-w\fR\ \fIwidth\fR] [\fB-A\fR\ \fIdirectory\fR] [\fB-B\fR\ \fIdirectory\fR] +.br + [\fItermname\fR...] .SH DESCRIPTION \fBinfocmp\fR can be used to compare a binary \fBterminfo\fR entry with other terminfo entries, rewrite a \fBterminfo\fR description to take advantage of the @@ -241,6 +243,19 @@ Dump the capabilities of the given terminal as a C initializer for a TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR). This option is useful for preparing versions of the curses library hardwired for a given terminal type. +.TP 5 +\fB-E\fR +Dump the capabilities of the given terminal as tables, needed in +the C initializer for a +TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR). +This option is useful for preparing versions of the curses library hardwired +for a given terminal type. +The tables are all declared static, and are named according to the type +and the name of the corresponding terminal entry. +.sp +Before ncurses 5.0, the split between the \fB\-e\fP and \fB\-E\fP +options was not needed; but support for extended names required making +the arrays of terminal capabilities separate from the TERMTYPE structure. .TP \fB-f\fR Display complex terminfo strings which contain if/then/else/endif expressions @@ -318,6 +333,7 @@ Compiled terminal description database. .. .SH EXTENSIONS The +\fB-E\fR, \fB-F\fR, \fB-G\fR, \fB-R\fR, diff --git a/usr.bin/infocmp/infocmp.c b/usr.bin/infocmp/infocmp.c index 1ae556f29fc..92b2225028b 100644 --- a/usr.bin/infocmp/infocmp.c +++ b/usr.bin/infocmp/infocmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: infocmp.c,v 1.4 1999/05/08 20:30:44 millert Exp $ */ +/* $OpenBSD: infocmp.c,v 1.5 1999/06/27 08:17:46 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <term_entry.h> #include <dump_entry.h> -MODULE_ID("$From: infocmp.c,v 1.42 1999/04/03 23:18:23 tom Exp $") +MODULE_ID("$From: infocmp.c,v 1.44 1999/06/16 00:39:48 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -802,7 +802,8 @@ static void usage(void) ," -V print version" ," -c list common capabilities" ," -d list different capabilities" - ," -e format output as C initializer" + ," -e format output for C initializer" + ," -E format output as C tables" ," -f with -1, format complex strings" ," -G format %{number} to %'char'" ," -g format %'char' to %{number}" @@ -831,6 +832,158 @@ static void usage(void) exit(EXIT_FAILURE); } +static char * name_initializer(const char *type) +{ + static char *initializer; + char *s; + + if (initializer == 0) + initializer = malloc(strlen(term->term_names) + 20); + + (void) sprintf(initializer, "%s_data_%s", type, term->term_names); + for (s = initializer; *s != 0 && *s != '|'; s++) + { + if (!isalnum(*s)) + *s = '_'; + } + *s = 0; + return initializer; +} + +/* dump C initializers for the terminal type */ +static void dump_initializers(void) +{ + int n; + const char *str = 0; + int size; + + (void) printf("static bool %s[] = %s\n", name_initializer("bool"), L_CURL); + + for_each_boolean(n,term) + { + switch((int)(term->Booleans[n])) + { + case TRUE: + str = "TRUE"; + break; + + case FALSE: + str = "FALSE"; + break; + + case ABSENT_BOOLEAN: + str = "ABSENT_BOOLEAN"; + break; + + case CANCELLED_BOOLEAN: + str = "CANCELLED_BOOLEAN"; + break; + } + (void) printf("\t/* %3d: %-8s */\t%s,\n", + n, ExtBoolname(term,n,boolnames), str); + } + (void) printf("%s;\n", R_CURL); + + (void) printf("static short %s[] = %s\n", name_initializer("number"), L_CURL); + + for_each_number(n,term) + { + char buf[BUFSIZ]; + switch (term->Numbers[n]) + { + case ABSENT_NUMERIC: + str = "ABSENT_NUMERIC"; + break; + case CANCELLED_NUMERIC: + str = "CANCELLED_NUMERIC"; + break; + default: + sprintf(buf, "%d", term->Numbers[n]); + str = buf; + break; + } + (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtNumname(term,n,numnames), str); + } + (void) printf("%s;\n", R_CURL); + + size = sizeof(TERMTYPE) + + (NUM_BOOLEANS(term) * sizeof(term->Booleans[0])) + + (NUM_NUMBERS(term) * sizeof(term->Numbers[0])); + + (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL); + + for_each_string(n,term) + { + char buf[BUFSIZ], *sp, *tp; + + if (term->Strings[n] == ABSENT_STRING) + str = "ABSENT_STRING"; + else if (term->Strings[n] == CANCELLED_STRING) + str = "CANCELLED_STRING"; + else + { + tp = buf; + *tp++ = '"'; + for (sp = term->Strings[n]; *sp; sp++) + { + if (isascii(*sp) && isprint(*sp) && *sp !='\\' && *sp != '"') + *tp++ = *sp; + else + { + (void) sprintf(tp, "\\%03o", *sp & 0xff); + tp += 4; + } + } + *tp++ = '"'; + *tp = '\0'; + size += (strlen(term->Strings[n]) + 1); + str = buf; + } +#if NCURSES_XNAMES + if (n == STRCOUNT) + { + (void) printf("%s;\n", R_CURL); + + (void) printf("static char * %s[] = %s\n", name_initializer("string_ext"), L_CURL); + } +#endif + (void) printf("\t/* %3d: %-8s */\t%s,\n", n, ExtStrname(term,n,strnames), str); + } + (void) printf("%s;\n", R_CURL); +} + +/* dump C initializers for the terminal type */ +static void dump_termtype(void) +{ + (void) printf("\t%s\n\t\t\"%s\",\n", L_CURL, term->term_names); + (void) printf("\t\t(char *)0,\t/* pointer to string table */\n"); + + (void) printf("\t\t%s,\n", name_initializer("bool")); + (void) printf("\t\t%s,\n", name_initializer("number")); + + (void) printf("\t\t%s,\n", name_initializer("string")); + +#if NCURSES_XNAMES + (void) printf("#if NCURSES_XNAMES\n"); + (void) printf("\t\t(char *)0,\t/* pointer to extended string table */\n"); + (void) printf("\t\t%s,\t/* ...corresponding names */\n", + (NUM_STRINGS(term) != STRCOUNT) + ? name_initializer("string_ext") + : "(char **)0"); + + (void) printf("\t\t%d,\t\t/* count total Booleans */\n", NUM_BOOLEANS(term)); + (void) printf("\t\t%d,\t\t/* count total Numbers */\n", NUM_NUMBERS(term)); + (void) printf("\t\t%d,\t\t/* count total Strings */\n", NUM_STRINGS(term)); + + (void) printf("\t\t%d,\t\t/* count extensions to Booleans */\n", NUM_BOOLEANS(term) - BOOLCOUNT); + (void) printf("\t\t%d,\t\t/* count extensions to Numbers */\n", NUM_NUMBERS(term) - NUMCOUNT); + (void) printf("\t\t%d,\t\t/* count extensions to Strings */\n", NUM_STRINGS(term) - STRCOUNT); + + (void) printf("#endif /* NCURSES_XNAMES */\n"); +#endif /* NCURSES_XNAMES */ + (void) printf("\t%s\n", R_CURL); +} + /*************************************************************************** * * Main sequence @@ -846,7 +999,7 @@ int main(int argc, char *argv[]) int c, i, len; bool formatted = FALSE; bool filecompare = FALSE; - bool initdump = FALSE; + int initdump = 0; bool init_analyze = FALSE; bool limited = TRUE; @@ -860,7 +1013,7 @@ int main(int argc, char *argv[]) /* where is the terminfo database location going to default to? */ restdir = firstdir = 0; - while ((c = getopt(argc, argv, "decCfFGgIinlLprR:s:uv:Vw:A:B:1T")) != EOF) + while ((c = getopt(argc, argv, "deEcCfFGgIinlLprR:s:uv:Vw:A:B:1T")) != EOF) switch (c) { case 'd': @@ -868,7 +1021,11 @@ int main(int argc, char *argv[]) break; case 'e': - initdump = TRUE; + initdump |= 1; + break; + + case 'E': + initdump |= 2; break; case 'c': @@ -1073,100 +1230,10 @@ int main(int argc, char *argv[]) /* dump as C initializer for the terminal type */ if (initdump) { - int n; - const char *str = 0; - int size; - - (void) printf("\t%s\n\t\t\"%s\",\n", - L_CURL, term->term_names); - (void) printf("\t\t(char *)0,\n"); - - (void) printf("\t\t%s /* BOOLEANS */\n", L_CURL); - for_each_boolean(n,term) - { - switch((int)(term->Booleans[n])) - { - case TRUE: - str = "TRUE"; - break; - - case FALSE: - str = "FALSE"; - break; - - case ABSENT_BOOLEAN: - str = "ABSENT_BOOLEAN"; - break; - - case CANCELLED_BOOLEAN: - str = "CANCELLED_BOOLEAN"; - break; - } - (void) printf("\t\t/* %s */\t%s%s,\n", - ExtBoolname(term,n,boolnames), str, - n == NUM_BOOLEANS(term)-1 ? R_CURL : ""); - } - - (void) printf("\t\t%s /* NUMERICS */\n", L_CURL); - for_each_number(n,term) - { - char buf[BUFSIZ]; - switch (term->Numbers[n]) - { - case ABSENT_NUMERIC: - str = "ABSENT_NUMERIC"; - break; - case CANCELLED_NUMERIC: - str = "CANCELLED_NUMERIC"; - break; - default: - sprintf(buf, "%d", term->Numbers[n]); - str = buf; - break; - } - (void) printf("\t\t/* %s */\t%s%s,\n", - numnames[n], str, - n == NUM_NUMBERS(term)-1 ? R_CURL : ""); - } - - size = sizeof(TERMTYPE) - + (NUM_BOOLEANS(term) * sizeof(term->Booleans[0])) - + (NUM_NUMBERS(term) * sizeof(term->Numbers[0])); - - (void) printf("\t\t%s /* STRINGS */\n", L_CURL); - for_each_string(n,term) - { - char buf[BUFSIZ], *sp, *tp; - - if (term->Strings[n] == ABSENT_STRING) - str = "ABSENT_STRING"; - else if (term->Strings[n] == CANCELLED_STRING) - str = "CANCELLED_STRING"; - else - { - tp = buf; - *tp++ = '"'; - for (sp = term->Strings[n]; *sp; sp++) - { - if (isascii(*sp) && isprint(*sp) && *sp !='\\' && *sp != '"') - *tp++ = *sp; - else - { - (void) sprintf(tp, "\\%03o", *sp & 0xff); - tp += 4; - } - } - *tp++ = '"'; - *tp = '\0'; - size += (strlen(term->Strings[n]) + 1); - str = buf; - } - (void) printf("\t\t/* %s */\t%s%s%s\n", - strnames[n], str, - n == NUM_STRINGS(term)-1 ? R_CURL : "", - n == NUM_STRINGS(term)-1 ? "" : ","); - } - (void) printf("\t%s /* size = %d */\n", R_CURL, size); + if (initdump & 1) + dump_termtype(); + if (initdump & 2) + dump_initializers(); ExitProgram(EXIT_SUCCESS); } diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c index 2fff7dd670a..cb1bdb8c845 100644 --- a/usr.bin/tic/tic.c +++ b/usr.bin/tic/tic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tic.c,v 1.10 1999/03/22 18:43:19 millert Exp $ */ +/* $OpenBSD: tic.c,v 1.11 1999/06/27 08:17:46 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998,1999 Free Software Foundation, Inc. * @@ -44,7 +44,7 @@ #include <dump_entry.h> #include <term_entry.h> -MODULE_ID("$From: tic.c,v 1.50 1999/03/16 01:12:04 tom Exp $") +MODULE_ID("$From: tic.c,v 1.51 1999/06/19 21:35:36 Philippe.De.Muyter Exp $") const char *_nc_progname = "tic"; @@ -62,8 +62,13 @@ static void cleanup(void) { if (tmp_fp != 0) fclose(tmp_fp); - if (to_remove != 0) + if (to_remove != 0) { +#if HAVE_REMOVE remove(to_remove); +#else + unlink(to_remove); +#endif + } } static void failed(const char *msg) |