changeset 29517:78ccd8bf439c

Suppress extraneous error messages from Qhull (bug #57727). * __delaunayn__.cc (F__delaunay__): Pass a FILE pointer to "/dev/null" to Qhull library to use for stderr reporting. Pass a "nullptr" to Qhull library to use for stdout reporting which disables status messages. * __voronoi__.cc (F__voronoi__): Pass a "nullptr" to Qhull library to use for stdout reporting which disables status messages. Remove unnecessary code to open file to "/dev/null" and unwind_action to close said file at end of fcn. * convhulln.cc (Fconvhulln): Pass a "nullptr" to Qhull library to use for stdout reporting which disables status messages. Remove unnecessary code to open file to "/dev/null" and unwind_action to close said file at end of fcn.
author Rik <rik@octave.org>
date Fri, 09 Apr 2021 06:38:21 -0700
parents 9f0649b4e912
children e8a0d4a91fb4
files libinterp/dldfcn/__delaunayn__.cc libinterp/dldfcn/__voronoi__.cc libinterp/dldfcn/convhulln.cc
diffstat 3 files changed, 14 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/__delaunayn__.cc	Wed Apr 07 20:18:21 2021 +0200
+++ b/libinterp/dldfcn/__delaunayn__.cc	Fri Apr 09 06:38:21 2021 -0700
@@ -160,19 +160,21 @@
 
       sprintf (flags, "qhull d %s", options.c_str ());
 
-      // Replace the outfile pointer with stdout for debugging information.
+      // Set the outfile pointer to stdout for status information.
+      FILE *outfile = nullptr;
+
+      // Set the errfile pointer to stderr for errors and summary information.
+      // Note: pointer cannot be NULL to disable reporting, unlike outfile.
 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
-      FILE *outfile = std::fopen ("NUL", "w");
+      FILE *errfile = std::fopen ("NUL", "w");
 #else
-      FILE *outfile = std::fopen ("/dev/null", "w");
+      FILE *errfile = std::fopen ("/dev/null", "w");
 #endif
-      FILE *errfile = stderr;
 
-      if (! outfile)
-        error ("__delaunayn__: unable to create temporary file for output");
+      if (! errfile)
+        error ("__delaunayn__: unable to redirect Qhull errors to /dev/null");
 
-      octave::unwind_action close_outfile
-        ([outfile] () { std::fclose (outfile); });
+      octave::unwind_action close_errfile ([=] () { std::fclose (errfile); });
 
       int exitcode = qh_new_qhull (dim, n, pt_array,
                                    ismalloc, flags, outfile, errfile);
--- a/libinterp/dldfcn/__voronoi__.cc	Wed Apr 07 20:18:21 2021 +0200
+++ b/libinterp/dldfcn/__voronoi__.cc	Fri Apr 09 06:38:21 2021 -0700
@@ -152,21 +152,11 @@
 
   boolT ismalloc = false;
 
-  // Replace the outfile pointer with stdout for debugging information.
-#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
-  FILE *outfile = std::fopen ("NUL", "w");
-#else
-  FILE *outfile = std::fopen ("/dev/null", "w");
-#endif
+  // Set the outfile pointer to stdout for status information.
+  FILE *outfile = nullptr;
   FILE *errfile = stderr;
 
-  if (! outfile)
-    error ("__voronoi__: unable to create temporary file for output");
-
-  octave::unwind_action close_outfile ([outfile] () { std::fclose (outfile); });
-
   // qh_new_qhull command and points arguments are not const...
-
   std::string cmd = "qhull v" + options;
 
   OCTAVE_LOCAL_BUFFER (char, cmd_str, cmd.length () + 1);
--- a/libinterp/dldfcn/convhulln.cc	Wed Apr 07 20:18:21 2021 +0200
+++ b/libinterp/dldfcn/convhulln.cc	Fri Apr 09 06:38:21 2021 -0700
@@ -167,19 +167,10 @@
 
   boolT ismalloc = false;
 
-  // Replace the outfile pointer with stdout for debugging information.
-#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
-  FILE *outfile = std::fopen ("NUL", "w");
-#else
-  FILE *outfile = std::fopen ("/dev/null", "w");
-#endif
+  // Set the outfile pointer to stdout for status information.
+  FILE *outfile = nullptr;
   FILE *errfile = stderr;
 
-  if (! outfile)
-    error ("convhulln: unable to create temporary file for output");
-
-  octave::unwind_action close_outfile ([=] () { std::fclose (outfile); });
-
   // qh_new_qhull command and points arguments are not const...
 
   std::string cmd = "qhull" + options;