changeset 6880:e00a8f661f06

[project @ 2007-09-07 21:39:55 by dbateman]
author dbateman
date Fri, 07 Sep 2007 21:39:56 +0000
parents 28f3be713c1d
children cd2c6a69a70d
files src/ChangeLog src/DLD-FUNCTIONS/__delaunayn__.cc src/DLD-FUNCTIONS/__voronoi__.cc src/DLD-FUNCTIONS/convhulln.cc
diffstat 4 files changed, 25 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Sep 07 21:35:44 2007 +0000
+++ b/src/ChangeLog	Fri Sep 07 21:39:56 2007 +0000
@@ -1,4 +1,9 @@
-2007-09-06  John W. Eaton  <jwe@octave.org>
+2007-09-06  David Bateman  <dbateman@free.fr>
+
+	* DLD-FUNCTIONS/__delaunay__.cc, DLD-FUNCRIONS/__voronoi__.cc,
+	DLD-FUNCTIONS/convhulln.cc: Avoid variables in global scope
+
+2007-09-06  David Bateman  <dbateman@free.fr>
 
 	* Makefile.in (stamp-prereq): Add graphics.h to the dependency list.
 
--- a/src/DLD-FUNCTIONS/__delaunayn__.cc	Fri Sep 07 21:35:44 2007 +0000
+++ b/src/DLD-FUNCTIONS/__delaunayn__.cc	Fri Sep 07 21:39:56 2007 +0000
@@ -56,9 +56,6 @@
 #ifdef NEED_QHULL_VERSION
 char qh_version[] = "__delaunayn__.oct 2007-08-21";
 #endif
-FILE *outfile = stdout;
-FILE *errfile = stderr;
-char flags[250];
 #endif
 
 DEFUN_DLD (__delaunayn__, args, ,
@@ -128,18 +125,23 @@
 
   //octave_stdout << "options " << options << std::endl;
 
-  if (n > dim) 
+  if (n > dim + 1) 
     {
       p = p.transpose();
       double *pt_array = p.fortran_vec();
       boolT ismalloc = False;
 
+      OCTAVE_LOCAL_BUFFER (char, flags, 250);
+
       sprintf(flags,"qhull d %s",options.c_str());
 
       // If you want some debugging information replace the NULL
       // pointer with outfile.
 
-      int exitcode =  qh_new_qhull (dim, n, pt_array, ismalloc,flags, 
+      FILE *outfile = stdout;
+      FILE *errfile = stderr;
+
+      int exitcode =  qh_new_qhull (dim, n, pt_array, ismalloc, flags, 
 				    NULL, errfile);
 
       if (exitcode)
--- a/src/DLD-FUNCTIONS/__voronoi__.cc	Fri Sep 07 21:35:44 2007 +0000
+++ b/src/DLD-FUNCTIONS/__voronoi__.cc	Fri Sep 07 21:39:56 2007 +0000
@@ -46,11 +46,6 @@
 #ifdef NEED_QHULL_VERSION
 char qh_version[] = "__voronoi__.oct 2007-07-24";
 #endif
-
-FILE *outfile = stdout;
-FILE *errfile = stderr;
-char flags[250];
-const char *options;
 #endif
 
 DEFUN_DLD (__voronoi__, args, ,
@@ -71,6 +66,8 @@
       return retval;
     }
 
+  const char *options;
+
   if (nargin == 2) 
     {
       if (!args (1).is_string ()) 
@@ -101,8 +98,16 @@
 
   boolT ismalloc = false;
 
+  OCTAVE_LOCAL_BUFFER(char, flags, 250);
+
   // hmm  lot's of options for qhull here
   sprintf(flags,"qhull v Fv T0 %s",options);
+
+  // If you want some debugging information replace the NULL
+  // pointer with outfile.
+  FILE *outfile = stdout;
+  FILE *errfile = stderr;
+
   if (!qh_new_qhull (dim, np, pt_array, ismalloc, flags, NULL, errfile)) 
     {
 
--- a/src/DLD-FUNCTIONS/convhulln.cc	Fri Sep 07 21:35:44 2007 +0000
+++ b/src/DLD-FUNCTIONS/convhulln.cc	Fri Sep 07 21:39:56 2007 +0000
@@ -50,7 +50,6 @@
 #ifdef NEED_QHULL_VERSION
 char qh_version[] = "convhulln.oct 2007-07-24";
 #endif
-char flags[250];
 #endif
 
 DEFUN_DLD (convhulln, args, ,
@@ -116,6 +115,8 @@
 
   boolT ismalloc = False;
 
+  OCTAVE_LOCAL_BUFFER (char, flags, 250);
+
   // hmm, lots of options for qhull here
   // QJ guarantees that the output will be triangles
   snprintf(flags, sizeof(flags), "qhull QJ %s", options.c_str());