changeset 29911:218716316e62

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Thu, 22 Jul 2021 13:53:43 -0400
parents 68fa4ac060ce (current diff) 0f41e117789f (diff)
children da5cc930ff10
files liboctave/wrappers/getopt-wrapper.h src/main.in.cc
diffstat 3 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/wrappers/getopt-wrapper.c	Thu Jul 22 19:06:00 2021 +0200
+++ b/liboctave/wrappers/getopt-wrapper.c	Thu Jul 22 13:53:43 2021 -0400
@@ -121,3 +121,20 @@
 {
   return optind;
 }
+
+int
+octave_get_opterr_wrapper (void)
+{
+  return opterr;
+}
+
+int
+octave_set_opterr_wrapper (int val)
+{
+  int retval = opterr;
+
+  opterr = val;
+
+  return retval;
+}
+
--- a/liboctave/wrappers/getopt-wrapper.h	Thu Jul 22 19:06:00 2021 +0200
+++ b/liboctave/wrappers/getopt-wrapper.h	Thu Jul 22 13:53:43 2021 -0400
@@ -52,6 +52,9 @@
 
 extern OCTAVE_API int octave_optind_wrapper (void);
 
+extern OCTAVE_API int octave_get_opterr_wrapper (void);
+extern OCTAVE_API int octave_set_opterr_wrapper (int val);
+
 #if defined __cplusplus
 }
 #endif
--- a/src/main.in.cc	Thu Jul 22 19:06:00 2021 +0200
+++ b/src/main.in.cc	Thu Jul 22 13:53:43 2021 -0400
@@ -278,6 +278,13 @@
   bool warn_display = true;
   bool no_display = false;
 
+  // Disable error reporting in getopt.  We want to silently recognize
+  // and process a few special arguments here and pass everything on to
+  // the real Octave program where incorrect usage errors may be
+  // reported.
+
+  octave_set_opterr_wrapper (0);
+
   while (true)
     {
       int long_idx;