changeset 14699:0bab96aeb995 gui

maint: Periodic merge of default to gui.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Tue, 29 May 2012 14:31:21 +0200
parents 79c9a6d06590 (current diff) c2411bff11c6 (diff)
children 7623bece76df
files configure.ac
diffstat 25 files changed, 124 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue May 29 14:29:05 2012 +0200
+++ b/.hgtags	Tue May 29 14:31:21 2012 +0200
@@ -65,3 +65,4 @@
 ba4d6343524b406b0d15aee34579f80783581c54 release-3-6-1
 704f7895eef03008dd79848eb9da4bfb40787d73 release-3-6-0
 f947d2922febf12dcd1fb6e21b356756ecb54e55 rc-3-6-2-0
+4460c4fb20e6a5d3b1972fa737d4e00eb921545a rc-3-6-2-2
--- a/build-aux/bootstrap.conf	Tue May 29 14:29:05 2012 +0200
+++ b/build-aux/bootstrap.conf	Tue May 29 14:31:21 2012 +0200
@@ -40,6 +40,7 @@
   link
   lstat
   mkdir
+  mkdir-p
   mkfifo
   mkostemp
   mkstemp
@@ -56,6 +57,7 @@
   rmdir
   round
   roundf
+  savewd
   sigaction
   signal
   sigprocmask
--- a/liboctave/file-ops.cc	Tue May 29 14:29:05 2012 +0200
+++ b/liboctave/file-ops.cc	Tue May 29 14:31:21 2012 +0200
@@ -48,6 +48,7 @@
 #include "quit.h"
 #include "singleton-cleanup.h"
 #include "str-vec.h"
+#include "lo-cutils.h"
 
 file_ops *file_ops::instance = 0;
 
@@ -361,22 +362,32 @@
        : dir + dir_sep_char () + file);
 }
 
+static int 
+make_ancestor (const char *, const char *component, void *options)
+{
+  mode_t* mode = reinterpret_cast<mode_t *>(options);
+  return gnulib::mkdir (component, *mode);
+}
 
 int
 octave_mkdir (const std::string& nm, mode_t md)
 {
   std::string msg;
-  return octave_mkdir (nm, md, msg);
+  return octave_mkdir (nm, md, msg, false);
 }
 
 int
-octave_mkdir (const std::string& name, mode_t mode, std::string& msg)
+octave_mkdir (const std::string& name, mode_t mode, std::string& msg, 
+              bool make_parents)
 {
   msg = std::string ();
 
   int status = -1;
 
-  status = gnulib::mkdir (name.c_str (), mode);
+  if (make_parents)
+    status = octave_mkdir_parents (name.c_str (), mode, make_ancestor);
+  else
+    status = gnulib::mkdir (name.c_str (), mode);
 
   if (status < 0)
     msg = gnulib::strerror (errno);
--- a/liboctave/file-ops.h	Tue May 29 14:29:05 2012 +0200
+++ b/liboctave/file-ops.h	Tue May 29 14:31:21 2012 +0200
@@ -122,7 +122,8 @@
 octave_mkdir (const std::string& nm, mode_t md);
 
 extern OCTAVE_API int
-octave_mkdir (const std::string& nm, mode_t md, std::string& msg);
+octave_mkdir (const std::string& nm, mode_t md, std::string& msg,
+              bool make_parents = false);
 
 extern OCTAVE_API int
 octave_mkfifo (const std::string& nm, mode_t md);
--- a/liboctave/lo-cutils.c	Tue May 29 14:29:05 2012 +0200
+++ b/liboctave/lo-cutils.c	Tue May 29 14:31:21 2012 +0200
@@ -32,6 +32,7 @@
 #endif
 
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include <stdlib.h>
@@ -41,6 +42,9 @@
 #include "lo-cutils.h"
 #include "syswait.h"
 
+#include "savewd.h"
+#include "mkdir-p.h"
+
 OCTAVE_API void
 octave_qsort (void *base, size_t n, size_t size,
               int (*cmp) (const void *, const void *))
@@ -76,3 +80,46 @@
 {
   return WAITPID (pid, status, options);
 }
+
+struct mkdir_options
+{
+  int (*make_ancestor_function) (const char *, const char *, void *);
+  mode_t ancestor_mode;
+  mode_t mode;
+  mode_t mode_bits;
+};
+
+static void
+announce_mkdir (const char *dir, void *options)
+{
+  /* Do nothing */
+}
+
+static int
+process_dir (char *dir, struct savewd *wd, void *options)
+{
+  struct mkdir_options const *o = options;
+  mode_t ancestor_mode = o->ancestor_mode;
+  return (make_dir_parents (dir, wd, o->make_ancestor_function, &ancestor_mode,
+                            o->mode, announce_mkdir, o->mode_bits, 
+                            (uid_t) -1, (gid_t) -1, false) ? 0 : -1);
+}
+
+OCTAVE_API int
+octave_mkdir_parents (const char *dir, mode_t mode,
+                      int (*make_ancestor) (const char *, const char *, void *))
+{
+  char *argv[1];
+  int retval;
+  char *dir2 = malloc (strlen (dir) + 1);
+  strcpy (dir2, dir); /* Make a copy to avoid passing a const char* as char* */
+  argv[0] = dir2;
+  struct mkdir_options o;
+  o.make_ancestor_function = make_ancestor;
+  o.ancestor_mode = mode | S_IWUSR | S_IXUSR; 
+  o.mode = mode | umask(0);
+  o.mode_bits = ~(mode & umask(0));
+  retval = (savewd_process_files (1, argv, process_dir, &o));
+  free (dir2);
+  return retval;
+}
--- a/liboctave/lo-cutils.h	Tue May 29 14:29:05 2012 +0200
+++ b/liboctave/lo-cutils.h	Tue May 29 14:31:21 2012 +0200
@@ -50,6 +50,10 @@
 OCTAVE_API pid_t
 octave_waitpid (pid_t pid, int *status, int options);
 
+OCTAVE_API int
+octave_mkdir_parents (const char *dir, mode_t mode,
+                      int (*make_ancestor) (char const *, char const *, void *));
+
 #ifdef __cplusplus
 }
 #endif
--- a/scripts/statistics/distributions/betarnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/betarnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,11 +84,8 @@
 
   if (isscalar (a) && isscalar (b))
     if ((a > 0) && (a < Inf) && (b > 0) && (b < Inf))
-      r = randg (a, sz);
-      rnd = r ./ (r + randg (b, sz));
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      r = randg (a, sz, cls);
+      rnd = r ./ (r + randg (b, sz, cls));
     else
       rnd = NaN (sz, cls);
     endif
@@ -96,8 +93,8 @@
     rnd = NaN (sz, cls);
 
     k = (a > 0) & (a < Inf) & (b > 0) & (b < Inf);
-    r = randg (a(k));
-    rnd(k) = r ./ (r + randg (b(k)));
+    r = randg (a(k), cls);
+    rnd(k) = r ./ (r + randg (b(k), cls));
   endif
 
 endfunction
--- a/scripts/statistics/distributions/cauchy_rnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/cauchy_rnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,7 +84,7 @@
 
   if (isscalar (location) && isscalar (scale))
     if (!isinf (location) && (scale > 0) && (scale < Inf))
-      rnd = location - cot (pi * rand (sz)) * scale;
+      rnd = location - cot (pi * rand (sz, cls)) * scale;
     else
       rnd = NaN (sz, cls);
     endif
@@ -92,7 +92,7 @@
     rnd = NaN (sz, cls);
 
     k = !isinf (location) & (scale > 0) & (scale < Inf);
-    rnd(k) = location(k)(:) - cot (pi * rand (sum (k(:)), 1)) .* scale(k)(:);
+    rnd(k) = location(k)(:) - cot (pi * rand (sum (k(:)), 1, cls)) .* scale(k)(:);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/chi2rnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/chi2rnd.m	Tue May 29 14:31:21 2012 +0200
@@ -77,10 +77,7 @@
 
   if (isscalar (n))
     if ((n > 0) && (n < Inf))
-      rnd = 2 * randg (n/2, sz);
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = 2 * randg (n/2, sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
@@ -88,7 +85,7 @@
     rnd = NaN (sz, cls);
 
     k = (n > 0) | (n < Inf);
-    rnd(k) = 2 * randg (n(k)/2);
+    rnd(k) = 2 * randg (n(k)/2, cls);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/exprnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/exprnd.m	Tue May 29 14:31:21 2012 +0200
@@ -77,7 +77,7 @@
 
   if (isscalar (lambda))
     if ((lambda > 0) && (lambda < Inf))
-      rnd = rande (sz) * lambda;
+      rnd = rande (sz, cls) * lambda;
     else
       rnd = NaN (sz, cls);
     endif
@@ -85,7 +85,7 @@
     rnd = NaN (sz, cls);
 
     k = (lambda > 0) & (lambda < Inf);
-    rnd(k) = rande (sum (k(:)), 1) .* lambda(k)(:);
+    rnd(k) = rande (sum (k(:)), 1, cls) .* lambda(k)(:);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/frnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/frnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,7 +84,7 @@
 
   if (isscalar (m) && isscalar (n))
     if ((m > 0) && (m < Inf) && (n > 0) && (n < Inf))
-      rnd = n/m * randg (m/2, sz) ./ randg (n/2, sz);
+      rnd = n/m * randg (m/2, sz, cls) ./ randg (n/2, sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
@@ -92,7 +92,7 @@
     rnd = NaN (sz, cls);
 
     k = (m > 0) & (m < Inf) & (n > 0) & (n < Inf);
-    rnd(k) = n(k) ./ m(k) .* randg (m(k)/2) ./ randg (n(k)/2);
+    rnd(k) = n(k) ./ m(k) .* randg (m(k)/2, cls) ./ randg (n(k)/2, cls);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/gamrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/gamrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,10 +84,7 @@
 
   if (isscalar (a) && isscalar (b))
     if ((a > 0) && (a < Inf) && (b > 0) && (b < Inf))
-      rnd = b * randg (a, sz);
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = b * randg (a, sz, cls);
     else 
       rnd = NaN (sz, cls);
     endif
@@ -95,7 +92,7 @@
     rnd = NaN (sz, cls);
 
     k = (a > 0) & (a < Inf) & (b > 0) & (b < Inf);
-    rnd(k) = b(k) .* randg (a(k));
+    rnd(k) = b(k) .* randg (a(k), cls);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/geornd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/geornd.m	Tue May 29 14:31:21 2012 +0200
@@ -77,7 +77,7 @@
 
   if (isscalar (p))
     if (p > 0 && p < 1);
-      rnd = floor (- rande (sz) ./ log (1 - p));
+      rnd = floor (- rande (sz, cls) ./ log (1 - p));
     elseif (p == 0)
       rnd = Inf (sz, cls);
     elseif (p == 1)
@@ -86,10 +86,10 @@
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = floor (- rande (sz) ./ log (1 - p));
+    rnd = floor (- rande (sz, cls) ./ log (1 - p));
 
     k = !(p >= 0) | !(p <= 1);
-  rnd(k) = NaN;
+    rnd(k) = NaN;
 
     k = (p == 0);
     rnd(k) = Inf;
--- a/scripts/statistics/distributions/lognrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/lognrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,12 +84,12 @@
 
   if (isscalar (mu) && isscalar (sigma))
     if ((sigma > 0) && (sigma < Inf))
-      rnd = exp (mu + sigma * randn (sz));
+      rnd = exp (mu + sigma * randn (sz, cls));
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = exp (mu + sigma .* randn (sz));
+    rnd = exp (mu + sigma .* randn (sz, cls));
 
     k = (sigma < 0) | (sigma == Inf);
     rnd(k) = NaN;
--- a/scripts/statistics/distributions/nbinrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/nbinrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,10 +84,7 @@
 
   if (isscalar (n) && isscalar (p))
     if ((n > 0) && (n < Inf) && (p > 0) && (p <= 1))
-      rnd = randp ((1 - p) ./ p .* randg (n, sz));
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = randp ((1 - p) ./ p .* randg (n, sz, cls), cls);
     elseif ((n > 0) && (n < Inf) && (p == 0))
       rnd = zeros (sz, cls);
     else
@@ -100,7 +97,7 @@
     rnd(k) = 0;
 
     k = (n > 0) & (n < Inf) & (p > 0) & (p <= 1);
-    rnd(k) = randp ((1 - p(k)) ./ p(k) .* randg (n(k)));
+    rnd(k) = randp ((1 - p(k)) ./ p(k) .* randg (n(k), cls));
   endif
 
 endfunction
--- a/scripts/statistics/distributions/normrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/normrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,12 +84,12 @@
 
   if (isscalar (mu) && isscalar (sigma))
     if (!isnan (mu) && !isinf (mu) && (sigma > 0) && (sigma < Inf))
-      rnd =  mu + sigma * randn (sz);
+      rnd =  mu + sigma * randn (sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = mu + sigma .* randn (sz);
+    rnd = mu + sigma .* randn (sz, cls);
     k = isnan (mu) | isinf (mu) | !(sigma > 0) | !(sigma < Inf);
     rnd(k) = NaN;
   endif
--- a/scripts/statistics/distributions/poissrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/poissrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -77,10 +77,7 @@
 
   if (isscalar (lambda))
     if (lambda >= 0 && lambda < Inf)
-      rnd = randp (lambda, sz);
-      if (strcmp (cls, "single"))
-        rnd = single (rnd);
-      endif
+      rnd = randp (lambda, sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
@@ -88,7 +85,7 @@
     rnd = NaN (sz, cls);
 
     k = (lambda >= 0) & (lambda < Inf);
-    rnd(k) = randp (lambda(k));
+    rnd(k) = randp (lambda(k), cls);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/trnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/trnd.m	Tue May 29 14:31:21 2012 +0200
@@ -77,7 +77,7 @@
 
   if (isscalar (n))
     if ((n > 0) && (n < Inf))
-      rnd = randn (sz) ./ sqrt (2*randg (n/2, sz) / n);
+      rnd = randn (sz, cls) ./ sqrt (2*randg (n/2, sz, cls) / n);
     else
       rnd = NaN (sz, cls);
     endif
@@ -85,7 +85,7 @@
     rnd = NaN (sz, cls);
 
     k = (n > 0) & (n < Inf);
-    rnd(k) = randn (sum (k(:)), 1) ./ sqrt (2*randg (n(k)/2) ./ n(k))(:);
+    rnd(k) = randn (sum (k(:)), 1, cls) ./ sqrt (2*randg (n(k)/2, cls) ./ n(k))(:);
   endif
 
 endfunction
--- a/scripts/statistics/distributions/unidrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/unidrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -77,12 +77,12 @@
 
   if (isscalar (n))
     if (n > 0 && n == fix (n))
-      rnd = ceil (rand (sz) * n);
+      rnd = ceil (rand (sz, cls) * n);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = ceil (rand (sz) .* n);
+    rnd = ceil (rand (sz, cls) .* n);
 
     k = ! (n > 0 & n == fix (n));
     rnd(k) = NaN;
--- a/scripts/statistics/distributions/unifrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/unifrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,12 +84,12 @@
 
   if (isscalar (a) && isscalar (b))
     if ((-Inf < a) && (a < b) && (b < Inf))
-      rnd =  a + (b - a) * rand (sz);
+      rnd =  a + (b - a) * rand (sz, cls);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd =  a + (b - a) .* rand (sz);
+    rnd =  a + (b - a) .* rand (sz, cls);
 
     k = !(-Inf < a) | !(a < b) | !(b < Inf);
     rnd(k) = NaN;
--- a/scripts/statistics/distributions/wblrnd.m	Tue May 29 14:29:05 2012 +0200
+++ b/scripts/statistics/distributions/wblrnd.m	Tue May 29 14:31:21 2012 +0200
@@ -84,12 +84,12 @@
 
   if (isscalar (scale) && isscalar (shape))
     if ((scale > 0) && (scale < Inf) && (shape > 0) && (shape < Inf))
-      rnd = scale * rande (sz) .^ (1/shape);
+      rnd = scale * rande (sz, cls) .^ (1/shape);
     else
       rnd = NaN (sz, cls);
     endif
   else
-    rnd = scale .* rande (sz) .^ (1./shape);
+    rnd = scale .* rande (sz, cls) .^ (1./shape);
 
     k = (scale <= 0) | (scale == Inf) | (shape <= 0) | (shape == Inf);
     rnd(k) = NaN;
--- a/src/dirfns.cc	Tue May 29 14:29:05 2012 +0200
+++ b/src/dirfns.cc	Tue May 29 14:31:21 2012 +0200
@@ -271,7 +271,7 @@
         }
       else
         {
-          int status = octave_mkdir (dirname, 0777, msg);
+          int status = octave_mkdir (dirname, 0777, msg, true);
 
           if (status < 0)
             {
--- a/src/graphics.cc	Tue May 29 14:29:05 2012 +0200
+++ b/src/graphics.cc	Tue May 29 14:31:21 2012 +0200
@@ -5928,8 +5928,17 @@
           // FIXME -- maybe this test should also be relative?
           if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON))
             {
-              min_val *= 0.9;
-              max_val *= 1.1;
+              // Widen range when too small
+              if (min_val >= 0)
+                {
+                  min_val *= 0.9;
+                  max_val *= 1.1;
+                }
+              else
+                {
+                  min_val *= 1.1;
+                  max_val *= 0.9;
+                }
             }
           if (min_val > 0)
             {
--- a/test/fntests.m	Tue May 29 14:29:05 2012 +0200
+++ b/test/fntests.m	Tue May 29 14:31:21 2012 +0200
@@ -242,7 +242,7 @@
 warning ("on", "quiet");
 try
   page_screen_output (0);
-  warning ("off", "Octave:deprecated-functions");
+  warning ("off", "Octave:deprecated-function");
   fid = fopen ("fntests.log", "wt");
   if (fid < 0)
     error ("could not open fntests.log for writing");
--- a/test/test_system.m	Tue May 29 14:29:05 2012 +0200
+++ b/test/test_system.m	Tue May 29 14:31:21 2012 +0200
@@ -124,11 +124,19 @@
 
 %% test/octave.test/system/mk-rm-dir-1.m
 %!test
+%! ## FIXME: saving and restoring of pwd in olldir is a hack
+%! ##        'mkdir' should not change pwd but it does since
+%! ##        changeset 14679:a543ed02e673
+%! ##        which created 'mkdir -p' capabilities.  
+%! ##        When 'mkdir' has been corrected, delete this FIXME
+%! ##        and any lines with 'HACK'.
+%! olddir = pwd;   # HACK Line #1
 %! nm = tmpnam ();
 %! e1 = mkdir (nm);
 %! [s2, e2] = stat (nm);
 %! e3 = rmdir (nm);
 %! [s4, e4] = stat (nm);
+%! cd (olddir);    # HACK Line #2
 %! assert ((e1 && strcmp (s2.modestr(1), "d") && e3 && e4 < 0));
 
 %% test/octave.test/system/mkdir-1.m