X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_terminfo.c;h=28c79f964100abe2315aab08343879cd6ef19ff7;hp=fd3362c2df2c81b594c282d892def57ab7688902;hb=1385381954c39dc95558adc87fad457046959cc1;hpb=cc0205ede8ab81605ec83e7f1ac9ec33e9328a40 diff --git a/test/demo_terminfo.c b/test/demo_terminfo.c index fd3362c2..28c79f96 100644 --- a/test/demo_terminfo.c +++ b/test/demo_terminfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * 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 * @@ -29,7 +29,7 @@ /* * 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.16 2013/01/19 19:30:58 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -70,7 +70,7 @@ 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, p - q, q); + sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q); return result; } @@ -283,7 +283,7 @@ demo_terminfo(char *name) } #endif } else { - char temp[10]; + char temp[80]; static const char *xterm_keys[] = { "kDC", "kDN", "kEND", "kHOM", "kIC", @@ -292,9 +292,9 @@ demo_terminfo(char *name) 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); } } @@ -325,6 +325,7 @@ usage(void) " -s print string-capabilities", #ifdef NCURSES_VERSION " -x print extended capabilities", + " -y disable extended capabilities", #endif }; unsigned n; @@ -341,8 +342,11 @@ main(int argc, char *argv[]) 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; @@ -372,7 +376,10 @@ main(int argc, char *argv[]) #ifdef NCURSES_VERSION case 'x': x_opt = TRUE; - use_extended_names(TRUE); + xy_opt = TRUE; + break; + case 'y': + xy_opt = FALSE; break; #endif default: @@ -381,6 +388,10 @@ main(int argc, char *argv[]) } } +#ifdef NCURSES_VERSION + use_extended_names(xy_opt); +#endif + if (!(b_opt || n_opt || s_opt || x_opt)) { b_opt = TRUE; n_opt = TRUE;