Mercurial > octave
changeset 29910:0f41e117789f stable
disable getopt error reporting in wrapper program (bug #60886)
* getopt-wrapper.h, getopt-wrapper.c (octave_get_opterr_wrapper,
octave_set_opterr_wrapper): New functions.
* main.in.cc (main): Call octave_set_opterr_wrapper to disable getopt
error reporting.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 22 Jul 2021 13:52:49 -0400 |
parents | 3583b11e151b |
children | 218716316e62 09b36aa7088a |
files | liboctave/wrappers/getopt-wrapper.c 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:04:52 2021 +0200 +++ b/liboctave/wrappers/getopt-wrapper.c Thu Jul 22 13:52:49 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:04:52 2021 +0200 +++ b/liboctave/wrappers/getopt-wrapper.h Thu Jul 22 13:52:49 2021 -0400 @@ -52,6 +52,9 @@ extern 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:04:52 2021 +0200 +++ b/src/main.in.cc Thu Jul 22 13:52:49 2021 -0400 @@ -245,6 +245,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;