/****************************************************************************
- * Copyright (c) 2009-2010,2012 Free Software Foundation, Inc. *
+ * Copyright (c) 2009-2012,2013 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 *
/*
* Author: Thomas E. Dickey
*
- * $Id: demo_terminfo.c,v 1.12 2012/06/30 22:03:22 tom Exp $
+ * $Id: demo_terminfo.c,v 1.19 2013/09/28 21:50:01 tom Exp $
*
* A simple demo of the terminfo interface.
*/
#define USE_TINFO
#include <test.priv.h>
-#ifdef NCURSES_VERSION
-#if !(defined(HAVE_TERM_ENTRY_H) && HAVE_TERM_ENTRY_H)
-#undef NCURSES_XNAMES
-#define NCURSES_XNAMES 0
-#endif
#if NCURSES_XNAMES
+#if HAVE_TERM_ENTRY_H
#include <term_entry.h>
+#else
+#undef NCURSES_XNAMES
+#define NCURSES_XNAMES 0
#endif
#endif
make_dbitem(char *p, char *q)
{
char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q));
- sprintf(result, "%s=%.*s", e_opt, p - q, q);
+ sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q);
return result;
}
}
#endif
} else {
- char temp[10];
+ char temp[80];
static const char *xterm_keys[] =
{
"kDC", "kDN", "kEND", "kHOM", "kIC",
for (n = 0; n < SIZEOF(xterm_keys); ++n) {
for (mod = 0; mod < 8; ++mod) {
if (mod == 0)
- strcpy(temp, xterm_keys[n]);
+ sprintf(temp, "%.*s", 8, xterm_keys[n]);
else
- sprintf(temp, "%s%d", xterm_keys[n], mod);
+ sprintf(temp, "%.*s%d", 8, xterm_keys[n], mod);
dumpit(temp);
}
}
" -s print string-capabilities",
#ifdef NCURSES_VERSION
" -x print extended capabilities",
+ " -y disable extended capabilities",
#endif
};
unsigned n;
int repeat;
char *name;
int r_opt = 1;
+#ifdef NCURSES_VERSION
+ bool xy_opt = TRUE; /* by default, use_extended_names is true */
+#endif
- while ((n = getopt(argc, argv, "bd:e:fnqr:sx")) != -1) {
+ while ((n = getopt(argc, argv, "bd:e:fnqr:sxy")) != -1) {
switch (n) {
case 'b':
b_opt = TRUE;
#ifdef NCURSES_VERSION
case 'x':
x_opt = TRUE;
- use_extended_names(TRUE);
+ xy_opt = TRUE;
+ break;
+ case 'y':
+ xy_opt = FALSE;
break;
#endif
default:
}
}
+#if NCURSES_XNAMES
+ use_extended_names(xy_opt);
+#endif
+
if (!(b_opt || n_opt || s_opt || x_opt)) {
b_opt = TRUE;
n_opt = TRUE;