summaryrefslogtreecommitdiff
path: root/usr.bin/tic
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-03-10 01:35:07 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-03-10 01:35:07 +0000
commit261ac7c5d4e5530264ff351b1a233f04029a8a6f (patch)
tree194864f15038dcdd201ca21529813de767f3fad8 /usr.bin/tic
parentd81f935ca5458507391f36a713d5bf0ccffbf725 (diff)
Update to ncurses-5.0-20000304
Diffstat (limited to 'usr.bin/tic')
-rw-r--r--usr.bin/tic/MKtermsort.sh9
-rw-r--r--usr.bin/tic/progs.priv.h9
-rw-r--r--usr.bin/tic/tic.c109
3 files changed, 110 insertions, 17 deletions
diff --git a/usr.bin/tic/MKtermsort.sh b/usr.bin/tic/MKtermsort.sh
index ae594a09bf0..58694bd9a9b 100644
--- a/usr.bin/tic/MKtermsort.sh
+++ b/usr.bin/tic/MKtermsort.sh
@@ -1,12 +1,17 @@
#!/bin/sh
-# $From: MKtermsort.sh,v 1.5 1999/12/04 21:45:35 tom Exp $
+# $OpenBSD: MKtermsort.sh,v 1.4 2000/03/10 01:35:06 millert Exp $
+# $From: MKtermsort.sh,v 1.6 2000/01/25 11:35:36 tom Exp $
#
# MKtermsort.sh -- generate indirection vectors for the various sort methods
#
# The output of this script is C source for nine arrays that list three sort
# orders for each of the three different classes of terminfo capabilities.
#
-# $OpenBSD: MKtermsort.sh,v 1.3 1999/12/06 02:14:33 millert Exp $
+# keep the order independent of locale:
+LANGUAGE=C
+LC_ALL=C
+export LANGUAGE
+export LC_ALL
#
AWK=${1-awk}
DATA=${2-../include/Caps}
diff --git a/usr.bin/tic/progs.priv.h b/usr.bin/tic/progs.priv.h
index 76172dcd199..5520e5ba5c4 100644
--- a/usr.bin/tic/progs.priv.h
+++ b/usr.bin/tic/progs.priv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: progs.priv.h,v 1.4 2000/01/02 21:48:13 millert Exp $ */
+/* $OpenBSD: progs.priv.h,v 1.5 2000/03/10 01:35:06 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998-2000 Free Software Foundation, Inc. *
@@ -32,7 +32,7 @@
* Author: Thomas E. Dickey <dickey@clark.net> 1997,1998 *
****************************************************************************/
/*
- * $From: progs.priv.h,v 1.20 2000/01/02 00:56:44 tom Exp $
+ * $From: progs.priv.h,v 1.21 2000/03/05 04:32:47 tom Exp $
*
* progs.priv.h
*
@@ -172,3 +172,8 @@ extern int optind;
# define isascii(c) 1 /* not really ascii anyway */
# endif
#endif
+
+#if !HAVE_STRDUP
+#define strdup _nc_strdup
+extern char *_nc_strdup(const char *);
+#endif /* not HAVE_STRDUP */
diff --git a/usr.bin/tic/tic.c b/usr.bin/tic/tic.c
index 2fb3b3ab033..acc0fde7bd3 100644
--- a/usr.bin/tic/tic.c
+++ b/usr.bin/tic/tic.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -42,7 +42,7 @@
#include <dump_entry.h>
#include <term_entry.h>
-MODULE_ID("$From: tic.c,v 1.57 2000/01/15 21:44:28 tom Exp $")
+MODULE_ID("$From: tic.c,v 1.63 2000/03/05 04:33:15 tom Exp $")
const char *_nc_progname = "tic";
@@ -378,6 +378,21 @@ matches(const char **needle, const char *haystack)
return (code);
}
+static FILE *
+open_tempfile(char *name)
+{
+ FILE *result = 0;
+#if HAVE_MKSTEMP
+ int fd = mkstemp(name);
+ if (fd >= 0)
+ result = fdopen(fd, "w");
+#else
+ if (tmpnam(name) != 0)
+ result = fopen(name, "w");
+#endif
+ return result;
+}
+
int
main(int argc, char *argv[])
{
@@ -392,7 +407,6 @@ main(int argc, char *argv[])
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}" */
@@ -562,9 +576,8 @@ main(int argc, char *argv[])
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) {
+ } else if ((tmp_fp = open_tempfile(my_tmpname)) != 0) {
+ source_file = my_tmpname;
fprintf(tmp_fp, "%s\n", termcap);
fclose(tmp_fp);
tmp_fp = fopen(source_file, "r");
@@ -722,6 +735,56 @@ TERMINAL *cur_term; /* tweak to avoid linking lib_cur_term.c */
#undef CUR
#define CUR tp->
+/*
+ * An sgr string may contain several settings other than the one we're
+ * interested in, essentially sgr0 + rmacs + whatever. As long as the
+ * "whatever" is contained in the sgr string, that is close enough for our
+ * sanity check.
+ */
+static bool
+similar_sgr(char *a, char *b)
+{
+ while (*b != 0) {
+ while (*a != *b) {
+ if (*a == 0)
+ return FALSE;
+ a++;
+ }
+ a++;
+ b++;
+ }
+ return TRUE;
+}
+
+static void
+check_sgr(TERMTYPE * tp, char *zero, int num, char *cap, char *name)
+{
+ char *test = tparm(set_attributes,
+ num == 1,
+ num == 2,
+ num == 3,
+ num == 4,
+ num == 5,
+ num == 6,
+ num == 7,
+ num == 8,
+ num == 9);
+ if (test != 0) {
+ if (PRESENT(cap)) {
+ if (!similar_sgr(test, cap)) {
+ _nc_warning("%s differs from sgr(%d): %s", name, num,
+ _nc_visbuf(test));
+ }
+ } else if (strcmp(test, zero)) {
+ _nc_warning("sgr(%d) present, but not %s", num, name);
+ }
+ } else if (PRESENT(cap)) {
+ _nc_warning("sgr(%d) missing, but %s present", num, name);
+ }
+}
+
+#define CHECK_SGR(num,name) check_sgr(tp, zero, num, name, #name)
+
/* other sanity-checks (things that we don't want in the normal
* logic that reads a terminfo entry)
*/
@@ -778,23 +841,43 @@ check_termtype(TERMTYPE * tp)
|| (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)
+ 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)
+ ANDMISSING(cursor_invisible, cursor_normal);
+ ANDMISSING(cursor_visible, cursor_normal);
+
+ if (PRESENT(cursor_visible) && PRESENT(cursor_normal)
+ && !strcmp(cursor_visible, cursor_normal))
+ _nc_warning("cursor_visible is same as 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)
+ ANDMISSING(change_scroll_region, save_cursor);
+ ANDMISSING(change_scroll_region, restore_cursor);
+
+ if (PRESENT(set_attributes)) {
+ char *zero = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ zero = strdup(zero);
+ CHECK_SGR(1, enter_standout_mode);
+ CHECK_SGR(2, enter_underline_mode);
+ CHECK_SGR(3, enter_reverse_mode);
+ CHECK_SGR(4, enter_blink_mode);
+ CHECK_SGR(5, enter_dim_mode);
+ CHECK_SGR(6, enter_bold_mode);
+ CHECK_SGR(7, enter_secure_mode);
+ CHECK_SGR(8, enter_protected_mode);
+ CHECK_SGR(9, enter_alt_charset_mode);
+ free(zero);
+ }
/*
* Some standard applications (e.g., vi) and some non-curses
@@ -802,7 +885,7 @@ check_termtype(TERMTYPE * tp)
* 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))
+ 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");
}