changeset 14346:9b23169e2712

maint: periodic merge of stable to default
author John W. Eaton <jwe@octave.org>
date Wed, 08 Feb 2012 16:46:58 -0500
parents 4687ecec0586 (current diff) 06f706e92771 (diff)
children 12c70d00c04e
files configure.ac src/DLD-FUNCTIONS/convhulln.cc
diffstat 8 files changed, 114 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Wed Feb 08 16:37:40 2012 -0500
+++ b/configure.ac	Wed Feb 08 16:46:58 2012 -0500
@@ -1626,7 +1626,7 @@
 AC_CHECK_FUNCS(basename canonicalize_file_name \
   chmod dup2 endgrent endpwent execvp expm1 expm1f fork \
   getegid geteuid getgid getgrent getgrgid getgrnam getpgrp getpid \
-  getppid getpwent getpwuid getuid getwd _kbhit \
+  getppid getpwent getpwuid getuid getwd _kbhit kill \
   lgamma lgammaf lgamma_r lgammaf_r localtime_r log1p log1pf \
   mkstemp pipe putenv \
   realpath resolvepath rindex roundl select setgrent setlocale \
--- a/scripts/statistics/base/ols.m	Wed Feb 08 16:37:40 2012 -0500
+++ b/scripts/statistics/base/ols.m	Wed Feb 08 16:46:58 2012 -0500
@@ -121,6 +121,14 @@
     r = y - x * beta;
   endif
   if (isargout (2))
+
+    ## z is of full rank, avoid the SVD in rnk
+    if (p == 0)
+      rnk = columns (z);
+    else
+      rnk = rank (z);
+    endif
+
     sigma = r' * r / (nr - rnk);
   endif
 
@@ -133,6 +141,27 @@
 %! x = [x, ones(5,1)];
 %! assert (ols(y,x), [3; 2], 50*eps)
 
+%!test
+%! x = [1, 2; 3, 4];
+%! y = [1; 2];
+%! [b, s, r] = ols (x, y);
+%! assert (b, [1.4, 2], 2*eps);
+%! assert (s, [0.2, 0; 0, 0], 2*eps);
+%! assert (r, [-0.4, 0; 0.2, 0], 2*eps);
+
+%!test
+%! x = [1, 2; 3, 4];
+%! y = [1; 2];
+%! [b, s] = ols (x, y);
+%! assert (b, [1.4, 2], 2*eps);
+%! assert (s, [0.2, 0; 0, 0], 2*eps);
+
+%!test
+%! x = [1, 2; 3, 4];
+%! y = [1; 2];
+%! b = ols (x, y);
+%! assert (b, [1.4, 2], 2*eps);
+
 %% Test input validation
 %!error ols ();
 %!error ols (1);
--- a/src/DLD-FUNCTIONS/__delaunayn__.cc	Wed Feb 08 16:37:40 2012 -0500
+++ b/src/DLD-FUNCTIONS/__delaunayn__.cc	Wed Feb 08 16:46:58 2012 -0500
@@ -49,6 +49,7 @@
 #include "defun-dld.h"
 #include "error.h"
 #include "oct-obj.h"
+#include "unwind-prot.h"
 
 #if defined (HAVE_QHULL)
 # include "oct-qhull.h"
@@ -57,6 +58,12 @@
 # endif
 #endif
 
+static void
+close_fcn (FILE *f)
+{
+  gnulib::fclose (f);
+}
+
 DEFUN_DLD (__delaunayn__, args, ,
            "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {@var{T} =} __delaunayn__ (@var{pts})\n\
@@ -121,6 +128,8 @@
 
       sprintf (flags, "qhull d %s", options.c_str ());
 
+      unwind_protect frame;
+
       // 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");
@@ -128,10 +137,12 @@
       FILE *outfile = gnulib::fopen ("/dev/null", "w");
 #endif
       FILE *errfile = stderr;
-          
-      if  (! outfile)
+
+      if (outfile)
+        frame.add_fcn (close_fcn, outfile);
+      else
         {
-          error ("__delaunayn__: Unable to create temporary file for output.");
+          error ("__delaunayn__: unable to create temporary file for output");
           return retval;
         }
 
--- a/src/DLD-FUNCTIONS/__voronoi__.cc	Wed Feb 08 16:37:40 2012 -0500
+++ b/src/DLD-FUNCTIONS/__voronoi__.cc	Wed Feb 08 16:46:58 2012 -0500
@@ -44,6 +44,7 @@
 #include "defun-dld.h"
 #include "error.h"
 #include "oct-obj.h"
+#include "unwind-prot.h"
 
 #if defined (HAVE_QHULL)
 # include "oct-qhull.h"
@@ -52,6 +53,12 @@
 # endif
 #endif
 
+static void
+close_fcn (FILE *f)
+{
+  gnulib::fclose (f);
+}
+
 DEFUN_DLD (__voronoi__, args, ,
         "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts})\n\
@@ -115,6 +122,8 @@
 
   boolT ismalloc = false;
 
+  unwind_protect frame;
+
   // 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");
@@ -122,10 +131,12 @@
   FILE *outfile = gnulib::fopen ("/dev/null", "w");
 #endif
   FILE *errfile = stderr;
-      
-  if  (! outfile)
+
+  if (outfile)
+    frame.add_fcn (close_fcn, outfile);
+  else
     {
-      error ("__voronoi__: Unable to create temporary file for output.");
+      error ("__voronoi__: unable to create temporary file for output");
       return retval;
     }
 
--- a/src/DLD-FUNCTIONS/convhulln.cc	Wed Feb 08 16:37:40 2012 -0500
+++ b/src/DLD-FUNCTIONS/convhulln.cc	Wed Feb 08 16:46:58 2012 -0500
@@ -40,6 +40,7 @@
 #include "error.h"
 #include "oct-obj.h"
 #include "parse.h"
+#include "unwind-prot.h"
 
 #if defined (HAVE_QHULL)
 # include "oct-qhull.h"
@@ -48,6 +49,12 @@
 # endif
 #endif
 
+static void
+close_fcn (FILE *f)
+{
+  gnulib::fclose (f);
+}
+
 DEFUN_DLD (convhulln, args, nargout,
   "-*- texinfo -*-\n\
 @deftypefn  {Loadable Function} {@var{h} =} convhulln (@var{pts})\n\
@@ -128,6 +135,8 @@
 
   boolT ismalloc = false;
 
+  unwind_protect frame;
+
   // 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");
@@ -135,10 +144,12 @@
   FILE *outfile = gnulib::fopen ("/dev/null", "w");
 #endif
   FILE *errfile = stderr;
-      
-  if  (! outfile)
+
+  if (outfile)
+    frame.add_fcn (close_fcn, outfile);
+  else
     {
-      error ("convhulln: Unable to create temporary file for output.");
+      error ("convhulln: unable to create temporary file for output");
       return retval;
     }
 
--- a/src/profiler.cc	Wed Feb 08 16:37:40 2012 -0500
+++ b/src/profiler.cc	Wed Feb 08 16:46:58 2012 -0500
@@ -385,11 +385,11 @@
 profile_data_accumulator::query_time (void) const
 {
   octave_time now;
-  // FIXME -- this should be removed at some point...  See bug 34210.
-#if defined (__CYGWIN__) || defined (__MINGW32__)
-  volatile
-#endif
-    double dnow = now.double_value ();
+
+  // FIXME -- is this volatile declaration really needed?
+  // See bug #34210 for additional details.
+  volatile double dnow = now.double_value ();
+
   return dnow;
 }
 
--- a/src/pt-idx.cc	Wed Feb 08 16:37:40 2012 -0500
+++ b/src/pt-idx.cc	Wed Feb 08 16:46:58 2012 -0500
@@ -177,13 +177,13 @@
 
 static inline octave_value_list
 make_value_list (tree_argument_list *args, const string_vector& arg_nm,
-                 const octave_value *object)
+                 const octave_value *object, bool rvalue = true)
 {
   octave_value_list retval;
 
   if (args)
     {
-      if (object && args->has_magic_end () && object->is_undefined ())
+      if (rvalue && object && args->has_magic_end () && object->is_undefined ())
         gripe_invalid_inquiry_subscript ();
       else
         retval = args->convert_to_const_vector (object);
@@ -476,7 +476,7 @@
             case '(':
               {
                 octave_value_list tidx
-                  = make_value_list (*p_args, *p_arg_nm, &tmp);
+                  = make_value_list (*p_args, *p_arg_nm, &tmp, false);
 
                 idx.push_back (tidx);
 
@@ -496,7 +496,7 @@
             case '{':
               {
                 octave_value_list tidx
-                  = make_value_list (*p_args, *p_arg_nm, &tmp);
+                  = make_value_list (*p_args, *p_arg_nm, &tmp, false);
 
                 if (tmp.is_undefined ())
                   {
@@ -601,6 +601,18 @@
 
 /*
 %!test
+%! clear x
+%! clear y
+%! y = 3;
+%! x(y(end)) = 1;
+%! assert (x, [0, 0, 1]);
+%! clear x
+%! clear y
+%! y = {3};
+%! x(y{end}) = 1;
+%! assert (x, [0, 0, 1]);
+
+%!test
 %! x = {1, 2, 3};
 %! [x{:}] = deal (4, 5, 6);
 %! assert (x, {4, 5, 6});
--- a/src/sighandlers.cc	Wed Feb 08 16:37:40 2012 -0500
+++ b/src/sighandlers.cc	Wed Feb 08 16:46:58 2012 -0500
@@ -79,13 +79,25 @@
 #define BADSIG (void (*)(int))-1
 #endif
 
+// The following is a workaround for an apparent bug in GCC 4.1.2 and
+// possibly earlier versions.  See Octave bug report #30685 for details.
+#if defined (__GNUC__)
+# if ! (__GNUC__ > 4 \
+        || (__GNUC__ == 4 && (__GNUC_MINOR__ > 1 \
+                              || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 2))))
+#  undef GNULIB_NAMESPACE
+#  define GNULIB_NAMESPACE
+#  warning "disabling GNULIB_NAMESPACE for signal functions -- consider upgrading to a current version of GCC"
+# endif
+#endif
+
 #define BLOCK_SIGNAL(sig, nvar, ovar) \
   do \
     { \
-      gnulib::sigemptyset (&nvar); \
-      gnulib::sigaddset (&nvar, sig); \
-      gnulib::sigemptyset (&ovar); \
-      gnulib::sigprocmask (SIG_BLOCK, &nvar, &ovar); \
+      GNULIB_NAMESPACE::sigemptyset (&nvar); \
+      GNULIB_NAMESPACE::sigaddset (&nvar, sig); \
+      GNULIB_NAMESPACE::sigemptyset (&ovar); \
+      GNULIB_NAMESPACE::sigprocmask (SIG_BLOCK, &nvar, &ovar); \
     } \
   while (0)
 
@@ -94,7 +106,7 @@
 #endif
 
 #define BLOCK_CHILD(nvar, ovar) BLOCK_SIGNAL (SIGCHLD, nvar, ovar)
-#define UNBLOCK_CHILD(ovar) gnulib::sigprocmask (SIG_SETMASK, &ovar, 0)
+#define UNBLOCK_CHILD(ovar) GNULIB_NAMESPACE::sigprocmask (SIG_SETMASK, &ovar, 0)
 
 // Called from octave_quit () to actually do something about the signals
 // we have caught.
@@ -185,7 +197,7 @@
         {
           octave_set_signal_handler (sig_number, SIG_DFL);
 
-          gnulib::raise (sig_number);
+          GNULIB_NAMESPACE::raise (sig_number);
         }
     }
 }
@@ -216,10 +228,10 @@
     act.sa_flags |= SA_RESTART;
 #endif
 
-  gnulib::sigemptyset (&act.sa_mask);
-  gnulib::sigemptyset (&oact.sa_mask);
+  GNULIB_NAMESPACE::sigemptyset (&act.sa_mask);
+  GNULIB_NAMESPACE::sigemptyset (&oact.sa_mask);
 
-  gnulib::sigaction (sig, &act, &oact);
+  GNULIB_NAMESPACE::sigaction (sig, &act, &oact);
 
   return oact.sa_handler;
 }