X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_termcap.c;h=3e856489407b08217b2d39bfec26212dec317fe6;hp=20a38e7e075e88b35947552d342b98bbc61dd0e8;hb=95a30fbbfc81d5eb0a76e139c86e0a6505cad871;hpb=55ccd2b959766810cf7db8d1c4462f338ce0afc8 diff --git a/test/demo_termcap.c b/test/demo_termcap.c index 20a38e7e..3e856489 100644 --- a/test/demo_termcap.c +++ b/test/demo_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005 Free Software Foundation, Inc. * + * Copyright (c) 2005-2007,2008 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,12 +29,15 @@ /* * Author: Thomas E. Dickey * - * $Id: demo_termcap.c,v 1.2 2005/04/30 14:57:54 tom Exp $ + * $Id: demo_termcap.c,v 1.7 2008/02/09 18:08:36 tom Exp $ * * A simple demo of the termcap interface. */ +#define USE_TINFO #include +#if HAVE_TGETENT + #define isCapName(c) (isgraph(c) && strchr("^#=:\\", c) == 0) static void @@ -106,7 +109,7 @@ dumpit(char *cap) printf("\n"); } else if ((num = tgetnum(cap)) >= 0) { printf("num %s = %d\n", cap, num); - } else if ((num = tgetflag(cap)) != 0) { + } else if ((num = tgetflag(cap)) > 0) { printf("flg %s\n", cap); } fflush(stdout); @@ -118,7 +121,7 @@ demo_termcap(char *name) char buffer[1024]; printf("Terminal type %s\n", name); - if (tgetent(buffer, name)) { + if (tgetent(buffer, name) >= 0) { char cap[3]; int c1, c2; @@ -150,8 +153,19 @@ main(int argc, char *argv[]) } else if ((name = getenv("TERM")) != 0) { demo_termcap(name); } else { - demo_termcap("dumb"); + static char dumb[] = "dumb"; + demo_termcap(dumb); } ExitProgram(EXIT_SUCCESS); } + +#else +int +main(int argc GCC_UNUSED, + char *argv[]GCC_UNUSED) +{ + printf("This program requires termcap\n"); + exit(EXIT_FAILURE); +} +#endif