diff src/DLD-FUNCTIONS/convhulln.cc @ 10257:cd550069240e

assume vsnprintf from gnulib; use sstream instead of snprintf
author John W. Eaton <jwe@octave.org>
date Wed, 03 Feb 2010 06:34:29 -0500
parents 40dfc0c99116
children b2143d97c002
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/convhulln.cc	Wed Feb 03 05:31:47 2010 -0500
+++ b/src/DLD-FUNCTIONS/convhulln.cc	Wed Feb 03 06:34:29 2010 -0500
@@ -41,19 +41,13 @@
 #include "oct-obj.h"
 #include "parse.h"
 
-#ifdef HAVE_QHULL
-#if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF)
-#define snprintf _snprintf
-#endif
-
 extern "C" {
 #include <qhull/qhull_a.h>
 }
 
-#ifdef NEED_QHULL_VERSION
+#if defined (HAVE_QHULL) && defined (NEED_QHULL_VERSION)
 char qh_version[] = "convhulln.oct 2007-07-24";
 #endif
-#endif
 
 DEFUN_DLD (convhulln, args, nargout,
   "-*- texinfo -*-\n\
@@ -122,11 +116,20 @@
 
   boolT ismalloc = False;
 
-  OCTAVE_LOCAL_BUFFER (char, flags, 250);
+  std::ostringstream buf;
+
+  buf << "qhull QJ " << options;
+
+  std::string buf_string = buf.str ();
 
-  // hmm, lots of options for qhull here
-  // QJ guarantees that the output will be triangles
-  snprintf (flags, 250, "qhull QJ %s", options.c_str ());
+  // FIXME -- we can't just pass buf_string.c_str () to qh_new_qhull
+  // because the argument is not declared const.  Ugh.  Unless
+  // qh_new_qhull really needs to modify this argument, someone should
+  // fix QHULL.
+
+  OCTAVE_LOCAL_BUFFER (char, flags, buf_string.length () + 1);
+
+  strcpy (flags, buf_string.c_str ());
 
   if (! qh_new_qhull (dim, n, pt_array, ismalloc, flags, 0, stderr)) 
     {