/****************************************************************************
- * Copyright (c) 2009-2015,2016 Free Software Foundation, Inc. *
+ * Copyright (c) 2009-2016,2017 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.41 2016/06/04 23:19:32 tom Exp $
+ * $Id: demo_terminfo.c,v 1.45 2017/03/18 22:03:07 tom Exp $
*
* A simple demo of the terminfo interface.
*/
static char *
make_dbitem(char *p, char *q)
{
- char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q));
- sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q);
+ size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
+ char *result = malloc(need);
+ _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q);
return result;
}
del_curterm(cur_term);
}
+#if USE_CODE_LISTS
+#define fullname(type,n) f_opt ? type##fnames[n] : cap
+#else
+#define fullname(type,n) cap
+#endif
+
static void
demo_terminfo(char *name)
{
cap = my_boolcodes[n];
if (cap == 0)
break;
- dumpit(cap, f_opt ? boolfnames[n] : cap);
+ dumpit(cap, fullname(bool, n));
}
}
cap = my_numcodes[n];
if (cap == 0)
break;
- dumpit(cap, f_opt ? numfnames[n] : cap);
+ dumpit(cap, fullname(num, n));
}
}
cap = my_strcodes[n];
if (cap == 0)
break;
- dumpit(cap, f_opt ? strfnames[n] : cap);
+ dumpit(cap, fullname(str, n));
}
}
#ifdef NCURSES_VERSION
int mod;
if (y_opt) {
#if NCURSES_XNAMES
- TERMTYPE *term = &(cur_term->type);
+ TERMTYPE *term = (TERMTYPE *) cur_term;
if (term != 0
&& ((NUM_BOOLEANS(term) != BOOLCOUNT)
|| (NUM_NUMBERS(term) != NUMCOUNT)
!strcmp(xterm_keys[n], "kRIT")) {
continue;
}
- sprintf(temp, "%.*s", 8, xterm_keys[n]);
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ "%.*s", 8, xterm_keys[n]);
} else {
- sprintf(temp, "%.*s%d", 8, xterm_keys[n], mod);
+ _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+ "%.*s%d", 8, xterm_keys[n], mod);
}
dumpit(temp, NULL);
}
length += chunk;
} else {
result[count] = unused;
- strcpy(unused, list[count]);
+ _nc_STRCPY(unused, list[count], length);
unused += chunk;
}
}