libncurses: Import https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz changes

Change-Id: I3433d30ca01359fd2e3623ede96b531f0b39cbfa
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/test/test_inwstr.c b/test/test_inwstr.c
index 3d2656f..c22add7 100644
--- a/test/test_inwstr.c
+++ b/test/test_inwstr.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 2007,2010 Free Software Foundation, Inc.                   *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 2007-2010,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            *
@@ -26,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_inwstr.c,v 1.4 2010/05/01 19:13:46 tom Exp $
+ * $Id: test_inwstr.c,v 1.8 2022/12/10 23:56:39 tom Exp $
  *
  * Author: Thomas E Dickey
  *
@@ -70,7 +71,7 @@
 }
 
 static int
-test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
+recursive_test(int level, char **argv, WINDOW *chrwin, WINDOW *strwin)
 {
     WINDOW *txtbox = 0;
     WINDOW *txtwin = 0;
@@ -151,7 +152,7 @@
 		beep();
 	    break;
 	case 'w':
-	    test_inchs(level + 1, argv, chrwin, strwin);
+	    recursive_test(level + 1, argv, chrwin, strwin);
 	    if (txtbox != 0) {
 		touchwin(txtbox);
 		wnoutrefresh(txtbox);
@@ -231,19 +232,49 @@
     return TRUE;
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+	"Usage: test_inwstr [options] [file1 [...]]"
+	,""
+	,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, char *argv[])
 {
     WINDOW *chrbox;
     WINDOW *chrwin;
     WINDOW *strwin;
+    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 */
+	}
+    }
 
     setlocale(LC_ALL, "");
 
-    if (argc < 2) {
-	fprintf(stderr, "usage: %s file\n", argv[0]);
-	return EXIT_FAILURE;
-    }
+    if (optind + 1 > argc)
+	usage(FALSE);
 
     initscr();
 
@@ -254,7 +285,7 @@
     chrwin = derwin(chrbox, 2, COLS - 2, 1, 1);
     strwin = derwin(chrbox, 2, COLS - 2, 3, 1);
 
-    test_inchs(1, argv, chrwin, strwin);
+    recursive_test(optind, argv, chrwin, strwin);
 
     endwin();
     ExitProgram(EXIT_SUCCESS);