changeset 14313:7a7ce92cff56

maint: periodic merge of stable to default
author John W. Eaton <jwe@octave.org>
date Thu, 02 Feb 2012 11:59:50 -0500
parents 6cb3b158e973 (current diff) 1734c3a48f31 (diff)
children 17de694961f5
files scripts/plot/waitbar.m src/DLD-FUNCTIONS/convhulln.cc src/graphics.cc
diffstat 6 files changed, 105 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/__delaunayn__.cc
+++ b/src/DLD-FUNCTIONS/__delaunayn__.cc
@@ -121,10 +121,20 @@
 
       sprintf (flags, "qhull d %s", options.c_str ());
 
-      // Replace the 0 pointer with stdout for debugging information
-      FILE *outfile = 0;
+      // Replace the outfile pointer with stdout for debugging information.
+#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
+      FILE *outfile = gnulib::fopen ("NUL", "w");
+#else
+      FILE *outfile = gnulib::fopen ("/dev/null", "w");
+#endif
       FILE *errfile = stderr;
-      
+          
+      if  (! outfile)
+        {
+          error ("__delaunayn__: Unable to create temporary file for output.");
+          return retval;
+        }
+
       int exitcode = qh_new_qhull (dim, n, pt_array, 
                                    ismalloc, flags, outfile, errfile);
       if (! exitcode)
--- a/src/DLD-FUNCTIONS/__voronoi__.cc
+++ b/src/DLD-FUNCTIONS/__voronoi__.cc
@@ -115,9 +115,19 @@
 
   boolT ismalloc = false;
 
-  // Replace the 0 pointer with stdout for debugging information
-  FILE *outfile = 0;
+  // Replace the outfile pointer with stdout for debugging information.
+#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
+  FILE *outfile = gnulib::fopen ("NUL", "w");
+#else
+  FILE *outfile = gnulib::fopen ("/dev/null", "w");
+#endif
   FILE *errfile = stderr;
+      
+  if  (! outfile)
+    {
+      error ("__voronoi__: Unable to create temporary file for output.");
+      return retval;
+    }
 
   // qh_new_qhull command and points arguments are not const...
 
--- a/src/DLD-FUNCTIONS/convhulln.cc
+++ b/src/DLD-FUNCTIONS/convhulln.cc
@@ -128,10 +128,20 @@
 
   boolT ismalloc = false;
 
-  // Replace the 0 pointer with stdout for debugging information.
-  FILE *outfile = 0;
+  // Replace the outfile pointer with stdout for debugging information.
+#if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
+  FILE *outfile = gnulib::fopen ("NUL", "w");
+#else
+  FILE *outfile = gnulib::fopen ("/dev/null", "w");
+#endif
   FILE *errfile = stderr;
       
+  if  (! outfile)
+    {
+      error ("convhulln: Unable to create temporary file for output.");
+      return retval;
+    }
+
   // qh_new_qhull command and points arguments are not const...
 
   std::string cmd = "qhull" + options;
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -5977,12 +5977,6 @@
         }
       lims = tmp_lims;
     }
-  else
-    {
-      // adjust min and max tics if they are out of limits
-      i1 = static_cast<int> (std::ceil (lo / tick_sep));
-      i2 = static_cast<int> (gnulib::floor (hi / tick_sep));
-    }
 
   Matrix tmp_ticks (1, i2-i1+1);
   for (int i = 0; i <= i2-i1; i++)
@@ -6564,6 +6558,58 @@
     { return x; }
 }
 
+static Matrix
+do_zoom (double val, double factor, const Matrix& lims, bool is_logscale)
+{
+  Matrix new_lims = lims;
+
+  double lo = lims(0);
+  double hi = lims(1);
+
+  bool is_negative = lo < 0 && hi < 0;
+
+  if (is_logscale)
+    {
+      if (is_negative)
+        {
+          double tmp = hi;
+          hi = std::log10 (-lo);
+          lo = std::log10 (-tmp);
+          val = std::log10 (-val);
+        }
+      else
+        {
+          hi = std::log10 (hi);
+          lo = std::log10 (lo);
+          val = std::log10 (val);
+        }
+    }
+
+  // Perform the zooming
+  lo = val + factor * (lo - val);
+  hi = val + factor * (hi - val);
+
+  if (is_logscale)
+    {
+      if (is_negative)
+        {
+          double tmp = -std::pow (10.0, hi);
+          hi = -std::pow (10.0, lo);
+          lo = tmp;
+        }
+      else
+        {
+          lo = std::pow (10.0, lo);
+          hi = std::pow (10.0, hi);
+        }
+    }
+
+  new_lims(0) = lo;
+  new_lims(1) = hi;
+
+  return new_lims;
+}
+
 void
 axes::properties::zoom_about_point (double x, double y, double factor,
                                     bool push_to_zoom_stack)
@@ -6586,11 +6632,8 @@
   double max_neg_y = -octave_Inf;
   get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
 
-  // Perform the zooming
-  xlims (0) = x + factor * (xlims (0) - x);
-  xlims (1) = x + factor * (xlims (1) - x);
-  ylims (0) = y + factor * (ylims (0) - y);
-  ylims (1) = y + factor * (ylims (1) - y);
+  xlims = do_zoom (x, factor, xlims, xscale_is ("log"));
+  ylims = do_zoom (y, factor, ylims, yscale_is ("log"));
 
   zoom (xlims, ylims, push_to_zoom_stack);
 }
@@ -6637,10 +6680,17 @@
   double max_neg_y = -octave_Inf;
   get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
 
-  xlims (0) += delta_x;
-  xlims (1) += delta_x;
-  ylims (0) += delta_y;
-  ylims (1) += delta_y;
+  if (! xscale_is ("log"))
+    {
+      xlims (0) += delta_x;
+      xlims (1) += delta_x;
+    }
+
+  if (! yscale_is ("log"))
+    {
+      ylims (0) += delta_y;
+      ylims (1) += delta_y;
+    }
 
   zoom (xlims, ylims, false);
 }
--- a/src/load-save.cc
+++ b/src/load-save.cc
@@ -649,7 +649,7 @@
   std::string orig_fname = "";
 
   // Function called with Matlab-style ["filename", options] syntax
-  if (argc > 1 && argv[1].at(0) != '-')
+  if (argc > 1 && ! argv[1].empty () && argv[1].at(0) != '-')
     {
       orig_fname = argv[1];
       i++;
--- a/test/test_io.m
+++ b/test/test_io.m
@@ -227,6 +227,8 @@
 %!
 %! delete matrix.ascii;
 
+%!error <unable to find file> load ("")
+
 %% FIXME: This test is disabled as it writes to stdout and there is no easy
 %% way to recover output.  Need to spawn new octave process and pipe stdout
 %% somewhere to treat this case.