X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;ds=sidebyside;f=test%2Ftestaddch.c;h=e393c3cc5190504be93d0f5d49380eabd2403bb8;hb=2bcad5fdfc4aa83a1479bd1d21dadc32dad8c2a8;hp=d39109894173ddb95f9749ba81cf9e6cff7b05dd;hpb=c6f54649ed4bf49ec27a522816984d2290201438;p=ncurses.git diff --git a/test/testaddch.c b/test/testaddch.c index d3910989..e393c3cc 100644 --- a/test/testaddch.c +++ b/test/testaddch.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc. * + * Copyright 2020,2022 Thomas E. Dickey * + * Copyright 1998-2013,2014 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 +30,7 @@ * This is an example written by Alexander V. Lukyanov , * to demonstrate an inconsistency between ncurses and SVr4 curses. * - * $Id: testaddch.c,v 1.10 2014/07/27 00:24:49 tom Exp $ + * $Id: testaddch.c,v 1.15 2022/12/10 23:44:18 tom Exp $ */ #include @@ -40,13 +41,45 @@ attr_addstr(const char *s, chtype a) addch(((unsigned char) (*s++)) | a); } +static void +usage(int ok) +{ + static const char *msg[] = + { + "Usage: testaddch [options]" + ,"" + ,USAGE_COMMON + }; + size_t n; + + for (n = 0; n < SIZEOF(msg); n++) + fprintf(stderr, "%s\n", msg[n]); + + ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE); +} +/* *INDENT-OFF* */ +VERSION_COMMON() +/* *INDENT-ON* */ + int -main( - int argc GCC_UNUSED, - char *argv[]GCC_UNUSED) +main(int argc, char *argv[]) { unsigned i; chtype back, set, attr; + int ch; + + while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) { + switch (ch) { + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); + default: + usage(ch == OPTS_USAGE); + /* NOTREACHED */ + } + } + if (optind < argc) + usage(FALSE); setlocale(LC_ALL, ""); @@ -66,7 +99,7 @@ main( attr = (chtype) ((i & 4) ? COLOR_PAIR(4) : 0); bkgdset(back); - (void) attrset(set); + (void) attrset(AttrArg(set, 0)); attr_addstr("Test string with spaces -> <-\n", attr); } @@ -77,7 +110,7 @@ main( attr = (chtype) ((i & 4) ? (chtype) COLOR_PAIR(4) : 0); bkgdset(back); - (void) attrset(set); + (void) attrset(AttrArg(set, 0)); attr_addstr("Test string with spaces -> <-\n", attr); }