]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/test_getstr.c
ncurses 5.9 - patch 20150523
[ncurses.git] / test / test_getstr.c
index 5710c1ab982bf7c61a388a09d1582d9df736613b..3f64c77b4858cb20931a0f62d85d10606bb58892 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2007 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2007-2009,2012 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_getstr.c,v 1.6 2007/07/28 19:46:43 tom Exp $
+ * $Id: test_getstr.c,v 1.10 2012/07/07 18:22:49 tom Exp $
  *
  * Author: Thomas E Dickey
  *
  *
  * Author: Thomas E Dickey
  *
@@ -44,6 +44,9 @@
 
 #include <test.priv.h>
 
 
 #include <test.priv.h>
 
+#if HAVE_CHGAT
+/* Solaris SVr4 curses lacks wchgat, mvgetnstr, mvwgetnstr */
+
 #define BASE_Y 6
 #define MAX_COLS 1024
 
 #define BASE_Y 6
 #define MAX_COLS 1024
 
@@ -55,6 +58,15 @@ typedef enum {
     eMaxFlavor
 } Flavors;
 
     eMaxFlavor
 } Flavors;
 
+/*
+ * Return-code is OK/ERR or a keyname.
+ */
+static const char *
+ok_keyname(int code)
+{
+    return ((code == OK) ? "OK" : ((code == ERR) ? "ERR" : keyname(code)));
+}
+
 static bool
 Quit(int ch)
 {
 static bool
 Quit(int ch)
 {
@@ -87,7 +99,7 @@ MovePrompt(WINDOW *txtwin, int limit, int y, int x)
 }
 
 static int
 }
 
 static int
-ShowFlavor(WINDOW *strwin, WINDOW *txtwin, Flavors flavor, int limit)
+ShowFlavor(WINDOW *strwin, WINDOW *txtwin, int flavor, int limit)
 {
     const char *name = "?";
     bool limited = FALSE;
 {
     const char *name = "?";
     bool limited = FALSE;
@@ -268,7 +280,7 @@ test_getstr(int level, char **argv, WINDOW *strwin)
            *buffer = '\0';
            rc = ERR;
            echo();
            *buffer = '\0';
            rc = ERR;
            echo();
-           wattrset(txtwin, A_REVERSE);
+           (void) wattrset(txtwin, A_REVERSE);
            switch (flavor) {
            case eGetStr:
                if (txtwin != stdscr) {
            switch (flavor) {
            case eGetStr:
                if (txtwin != stdscr) {
@@ -306,8 +318,8 @@ test_getstr(int level, char **argv, WINDOW *strwin)
                break;
            }
            noecho();
                break;
            }
            noecho();
-           wattrset(txtwin, A_NORMAL);
-           wprintw(strwin, "%d:%s", rc, buffer);
+           (void) wattrset(txtwin, A_NORMAL);
+           wprintw(strwin, "%s:%s", ok_keyname(rc), buffer);
            wnoutrefresh(strwin);
            break;
        default:
            wnoutrefresh(strwin);
            break;
        default:
@@ -349,3 +361,12 @@ main(int argc, char *argv[])
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
+
+#else
+int
+main(void)
+{
+    printf("This program requires the curses chgat function\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif