Mercurial > hg > octave-lyh
comparison 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 |
comparison
equal
deleted
inserted
replaced
10256:c84186ad78f3 | 10257:cd550069240e |
---|---|
39 #include "defun-dld.h" | 39 #include "defun-dld.h" |
40 #include "error.h" | 40 #include "error.h" |
41 #include "oct-obj.h" | 41 #include "oct-obj.h" |
42 #include "parse.h" | 42 #include "parse.h" |
43 | 43 |
44 #ifdef HAVE_QHULL | |
45 #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF) | |
46 #define snprintf _snprintf | |
47 #endif | |
48 | |
49 extern "C" { | 44 extern "C" { |
50 #include <qhull/qhull_a.h> | 45 #include <qhull/qhull_a.h> |
51 } | 46 } |
52 | 47 |
53 #ifdef NEED_QHULL_VERSION | 48 #if defined (HAVE_QHULL) && defined (NEED_QHULL_VERSION) |
54 char qh_version[] = "convhulln.oct 2007-07-24"; | 49 char qh_version[] = "convhulln.oct 2007-07-24"; |
55 #endif | |
56 #endif | 50 #endif |
57 | 51 |
58 DEFUN_DLD (convhulln, args, nargout, | 52 DEFUN_DLD (convhulln, args, nargout, |
59 "-*- texinfo -*-\n\ | 53 "-*- texinfo -*-\n\ |
60 @deftypefn {Loadable Function} {@var{h} =} convhulln (@var{p})\n\ | 54 @deftypefn {Loadable Function} {@var{h} =} convhulln (@var{p})\n\ |
120 | 114 |
121 double *pt_array = p.fortran_vec (); | 115 double *pt_array = p.fortran_vec (); |
122 | 116 |
123 boolT ismalloc = False; | 117 boolT ismalloc = False; |
124 | 118 |
125 OCTAVE_LOCAL_BUFFER (char, flags, 250); | 119 std::ostringstream buf; |
126 | 120 |
127 // hmm, lots of options for qhull here | 121 buf << "qhull QJ " << options; |
128 // QJ guarantees that the output will be triangles | 122 |
129 snprintf (flags, 250, "qhull QJ %s", options.c_str ()); | 123 std::string buf_string = buf.str (); |
124 | |
125 // FIXME -- we can't just pass buf_string.c_str () to qh_new_qhull | |
126 // because the argument is not declared const. Ugh. Unless | |
127 // qh_new_qhull really needs to modify this argument, someone should | |
128 // fix QHULL. | |
129 | |
130 OCTAVE_LOCAL_BUFFER (char, flags, buf_string.length () + 1); | |
131 | |
132 strcpy (flags, buf_string.c_str ()); | |
130 | 133 |
131 if (! qh_new_qhull (dim, n, pt_array, ismalloc, flags, 0, stderr)) | 134 if (! qh_new_qhull (dim, n, pt_array, ismalloc, flags, 0, stderr)) |
132 { | 135 { |
133 // If you want some debugging information replace the NULL | 136 // If you want some debugging information replace the NULL |
134 // pointer with stdout | 137 // pointer with stdout |