# HG changeset patch # User John W. Eaton # Date 1420235674 18000 # Node ID fc03d6e0d84276074d227f7d4d2b83e242e15030 # Parent 53ba58536f09b5f8aa64248c2acae29316c08232# Parent 78c0241306b5ded6cf1cee376bef4f8bf003bbed maint: Merge default to temporary audio-gsoc branch. diff -r 53ba58536f09 -r fc03d6e0d842 bootstrap.conf --- a/bootstrap.conf Fri Jan 02 16:53:31 2015 -0500 +++ b/bootstrap.conf Fri Jan 02 16:54:34 2015 -0500 @@ -93,6 +93,7 @@ sys_stat sys_time sys_times + tempname time times tmpfile diff -r 53ba58536f09 -r fc03d6e0d842 doc/interpreter/io.txi --- a/doc/interpreter/io.txi Fri Jan 02 16:53:31 2015 -0500 +++ b/doc/interpreter/io.txi Fri Jan 02 16:54:34 2015 -0500 @@ -621,12 +621,15 @@ Octave will emit an error and stop if it sees such code. When the string variable to be processed cannot be guaranteed to be free of potential format codes it is better to use the two argument form of any of the @code{printf} -functions and set the format string to @code{%s}. +functions and set the format string to @code{%s}. Alternatively, for code +which is not required to be backwards-compatible with @sc{matlab} the +Octave function @code{puts} or @code{disp} can be used. @example @group printf (strvar); # Unsafe if strvar contains format codes printf ("%s", strvar); # Safe +puts (strvar); # Safe @end group @end example diff -r 53ba58536f09 -r fc03d6e0d842 doc/interpreter/plot.txi --- a/doc/interpreter/plot.txi Fri Jan 02 16:53:31 2015 -0500 +++ b/doc/interpreter/plot.txi Fri Jan 02 16:54:34 2015 -0500 @@ -233,6 +233,8 @@ @DOCSTRING(area) +@DOCSTRING(fill) + @DOCSTRING(comet) @DOCSTRING(comet3) @@ -1022,45 +1024,46 @@ @anchor{XREFgraphics structures} The graphics functions use pointers, which are of class graphics_handle, in -order to address the data structures which control graphical displays. A -graphics handle may point any one of a number of different object types. The -objects are the graphics data structures. The types of objects are: -@code{figure}, @code{axes}, @code{line}, @code{text}, @code{patch}, -@code{surface}, @code{text} and @code{image}. - -Each of these objects has a function by the same name. and, each of these -functions returns a graphics handle pointing to an object of corresponding +order to address the data structures which control visual display. A +graphics handle may point to any one of a number of different base object +types and these objects are the graphics data structures themselves. The +primitive graphic object types are: @code{figure}, @code{axes}, @code{line}, +@code{text}, @code{patch}, @code{surface}, @code{text}, and @code{image}. + +Each of these objects has a function by the same name, and, each of these +functions returns a graphics handle pointing to an object of the corresponding type. In addition there are several functions which operate on properties of -the graphics objects and which return handles: the functions @code{ plot} and -@code{plot3} return a handle pointing to an object of type line, the function -@code{subplot} returns a handle pointing to an object of type axes, the -function @code{fill} returns a handle pointing to an object of type patch, the -functions @code{area}, @code{bar}, @code{barh}, @code{contour}, +the graphics objects and which also return handles: the functions @code{plot} +and @code{plot3} return a handle pointing to an object of type line, the +function @code{subplot} returns a handle pointing to an object of type axes, +the function @code{fill} returns a handle pointing to an object of type patch, +the functions @code{area}, @code{bar}, @code{barh}, @code{contour}, @code{contourf}, @code{contour3}, @code{surf}, @code{mesh}, @code{surfc}, @code{meshc}, @code{errorbar}, @code{quiver}, @code{quiver3}, @code{scatter}, @code{scatter3}, @code{stair}, @code{stem}, @code{stem3} each return a handle -as documented in @ref{XREFdatasources,,Data Sources}. - +to a complex data structure as documented in +@ref{XREFdatasources,,Data Sources}. The graphics objects are arranged in a hierarchy: -1. The root is at 0. i.e., @code{get (0)} returns the properties of the root - object. +1. The root is at 0. In other words, @code{get (0)} returns the properties of +the root object. 2. Below the root are @code{figure} objects. -3. Below the @code{figure} objects are @code{axes}. - -4. Below the @code{axes} objects are -@code{line}, @code{text}, @code{patch}, +3. Below the @code{figure} objects are @code{axes} objects. + +4. Below the @code{axes} objects are @code{line}, @code{text}, @code{patch}, @code{surface}, and @code{image} objects. Graphics handles may be distinguished from function handles (@pxref{Function Handles}) by means of the function @code{ishandle}. @code{ishandle} returns true if its argument is a handle of a graphics object. -In addition, the figure object may be tested using @code{isfigure}. -@code{isfigure} returns true only if its argument is a handle of a figure. The -@code{whos} function can be used to show the object type of each currently +In addition, a figure or axes object may be tested using @code{isfigure} or +@code{isaxes} respectively. The test functions return true only if the +argument is both a handle and of the correct type (figure or axes). + +The @code{whos} function can be used to show the object type of each currently defined graphics handle. (Note: this is not true today, but it is, I hope, considered an error in whos. It may be better to have whos just show graphics_handle as the class, and provide a new function which, given a @@ -1187,9 +1190,20 @@ @subsubsection Creating Graphics Objects @cindex creating graphics objects -You can create axes, line, patch, and surface objects directly using the -@code{axes}, @code{line}, @code{patch}, @code{fill}, and @code{surface} -functions. These objects become children of the current axes object. +You can create any graphics object primitive by calling the function of the +same name as the object; In other words, @code{figure}, @code{axes}, +@code{line}, @code{text}, @code{image}, @code{patch}, and @code{surface} +functions. These fundamental graphic objects automatically become children +of the current axes object as if @code{hold on} was in place. Seperately, axes +will automatically become children of the current figure object and figures +will become children of the root object 0. + +If this auto-joining feature is not desired then it is important to call +@code{newplot} first to prepare a new figure and axes for plotting. +Alternatively, the easier way is to call a high-level graphics routine which +will both create the plot and then populate it with low-level graphics objects. +Instead of calling @code{line}, use @code{plot}. Or use @code{surf} instead of +@code{surface}. Or use @code{fill} instead of @code{patch}. @DOCSTRING(axes) @@ -1197,8 +1211,6 @@ @DOCSTRING(patch) -@DOCSTRING(fill) - @DOCSTRING(surface) @subsubsection Handle Functions diff -r 53ba58536f09 -r fc03d6e0d842 libinterp/dldfcn/__init_fltk__.cc --- a/libinterp/dldfcn/__init_fltk__.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/libinterp/dldfcn/__init_fltk__.cc Fri Jan 02 16:54:34 2015 -0500 @@ -857,7 +857,9 @@ void show_canvas (void) { - if (fp.is_visible ()) + if (! canvas->can_do ()) + error ("unable to plot due to insufficient OpenGL support"); + else if (fp.is_visible ()) { canvas->show (); canvas->make_current (); @@ -1867,11 +1869,13 @@ if (win != windows.end ()) { if (is_visible) - win->second->show (); + { + win->second->show (); + win->second->show_canvas (); + } else win->second->hide (); - win->second->redraw (); } } diff -r 53ba58536f09 -r fc03d6e0d842 libinterp/parse-tree/pt-cell.cc --- a/libinterp/parse-tree/pt-cell.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/libinterp/parse-tree/pt-cell.cc Fri Jan 02 16:54:34 2015 -0500 @@ -44,7 +44,7 @@ Cell val; - int i = 0; + octave_idx_type i = 0; for (iterator p = begin (); p != end (); p++) { @@ -65,10 +65,15 @@ { octave_idx_type this_nc = row.length (); - if (nc != this_nc) + if (this_nc != nc) { - ::error ("number of columns must match"); - return retval; + if (this_nc == 0) + continue; // blank line + else + { + ::error ("number of columns must match"); + return retval; + } } } @@ -78,6 +83,8 @@ i++; } + if (i < nr) + val.resize (dim_vector (i, nc)); // there were blank rows retval = val; return retval; diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/array/CMatrix.cc --- a/liboctave/array/CMatrix.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/array/CMatrix.cc Fri Jan 02 16:54:34 2015 -0500 @@ -1973,8 +1973,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'U'; - char dia = 'N'; + uplo = 'U'; + dia = 'N'; Array z (dim_vector (2 * nc, 1)); Complex *pz = z.fortran_vec (); @@ -2069,8 +2069,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'L'; - char dia = 'N'; + uplo = 'L'; + dia = 'N'; Array z (dim_vector (2 * nc, 1)); Complex *pz = z.fortran_vec (); diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/array/dMatrix.cc --- a/liboctave/array/dMatrix.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/array/dMatrix.cc Fri Jan 02 16:54:34 2015 -0500 @@ -1612,8 +1612,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'U'; - char dia = 'N'; + uplo = 'U'; + dia = 'N'; Array z (dim_vector (3 * nc, 1)); double *pz = z.fortran_vec (); @@ -1707,8 +1707,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'L'; - char dia = 'N'; + uplo = 'L'; + dia = 'N'; Array z (dim_vector (3 * nc, 1)); double *pz = z.fortran_vec (); diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/array/fCMatrix.cc --- a/liboctave/array/fCMatrix.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/array/fCMatrix.cc Fri Jan 02 16:54:34 2015 -0500 @@ -1977,8 +1977,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'U'; - char dia = 'N'; + uplo = 'U'; + dia = 'N'; Array z (dim_vector (2 * nc, 1)); FloatComplex *pz = z.fortran_vec (); @@ -2073,8 +2073,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'L'; - char dia = 'N'; + uplo = 'L'; + dia = 'N'; Array z (dim_vector (2 * nc, 1)); FloatComplex *pz = z.fortran_vec (); diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/array/fMatrix.cc --- a/liboctave/array/fMatrix.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/array/fMatrix.cc Fri Jan 02 16:54:34 2015 -0500 @@ -1624,8 +1624,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'U'; - char dia = 'N'; + uplo = 'U'; + dia = 'N'; Array z (dim_vector (3 * nc, 1)); float *pz = z.fortran_vec (); @@ -1721,8 +1721,8 @@ if (calc_cond) { char norm = '1'; - char uplo = 'L'; - char dia = 'N'; + uplo = 'L'; + dia = 'N'; Array z (dim_vector (3 * nc, 1)); float *pz = z.fortran_vec (); diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/system/file-ops.cc --- a/liboctave/system/file-ops.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/system/file-ops.cc Fri Jan 02 16:54:34 2015 -0500 @@ -39,6 +39,10 @@ #include "pathmax.h" #include "canonicalize.h" +extern "C" { +#include +} + #include "dir-ops.h" #include "file-ops.h" #include "file-stat.h" @@ -678,53 +682,37 @@ std::string retval; - const char *pdir = dir.empty () ? 0 : dir.c_str (); - - const char *ppfx = pfx.empty () ? 0 : pfx.c_str (); - - char *tmp = tempnam (pdir, ppfx); + // get dir path to use for template + std::string templatename; + if (dir.empty ()) + templatename = octave_env::get_temp_directory (); + else if (! file_stat (dir, false).is_dir ()) + templatename = octave_env::get_temp_directory (); + else + templatename = dir; - if (tmp) - { - retval = tmp; - free (tmp); - - if (! dir.empty ()) - { - // Check that environment variable hasn't overridden dir argument - size_t pos = retval.rfind (file_ops::dir_sep_char ()); - std::string tmpdir = retval.substr (0, pos); - std::string dirarg = dir; - if (*dirarg.rbegin () == file_ops::dir_sep_char ()) - dirarg.erase (--dirarg.end ()); + // add dir sep char if it is not there + if (*templatename.rbegin () != file_ops::dir_sep_char ()) + templatename += file_ops::dir_sep_char (); - if (tmpdir != dirarg) - { - // A different TMPDIR was used. - // Replace TMPDIR with given dir if is valid - file_stat fs (dirarg, false); - if (fs && fs.is_dir ()) - retval.replace (0, pos, dirarg); + if (pfx.empty ()) + templatename += "file"; + else + templatename += pfx; + + // add the required XXXXXX for the template + templatename += "XXXXXX"; - // since we have changed the directory, it is possible that the name - // we are using is no longer unique, so check/modify - std::string tmppath = retval; - int attempt = 0; - while (++attempt < TMP_MAX && file_stat (tmppath, false).exists ()) - { - char file_postfix[16]; + // create and copy template to char array for call to gen_tempname + char tname [templatename.length () + 1]; - sprintf(file_postfix, "t%d", attempt); + strcpy (tname, templatename.c_str ()); - tmppath = retval + file_postfix; - } - retval = tmppath; - } - } - } + if (gen_tempname (tname, 0, 0, GT_NOCREATE) == -1) + msg = gnulib::strerror (errno); else - msg = gnulib::strerror (errno); - + retval = tname; + return retval; } diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/system/oct-env.cc --- a/liboctave/system/oct-env.cc Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/system/oct-env.cc Fri Jan 02 16:54:34 2015 -0500 @@ -150,6 +150,13 @@ } std::string +octave_env::get_temp_directory () +{ + return (instance_ok ()) + ? instance->do_get_temp_directory () : std::string (); +} + +std::string octave_env::get_program_name (void) { return (instance_ok ()) @@ -184,6 +191,45 @@ ? instance->do_get_host_name () : std::string (); } +std::string +octave_env::do_get_temp_directory (void) const +{ + std::string tempd; + +#if defined (__MINGW32__) || defined (_MSC_VER) + + tempd = do_getenv ("TEMP"); + + if (tempd.empty ()) + tempd = do_getenv ("TMP"); + + #if defined (P_tmpdir) + if (tempd.empty ()) + tempd = P_tmpdir; + #endif + + // Some versions of MinGW and MSVC either don't define P_tmpdir, or + // define it to a single backslash. In such cases just use C:\temp. + if (tempd.empty () || tempd == "\\") + tempd = "c:\\temp"; + +#else // Unix-like OS + + tempd = do_getenv ("TMP"); + + #if defined (P_tmpdir) + if (tempd.empty ()) + tempd = P_tmpdir; + #else + if (tempd.empty ()) + tempd = "/tmp"; + #endif + +#endif + + return tempd; +} + // FIXME: this leaves no way to distinguish between a // variable that is not set and one that is set to the empty string. // Is this a problem? diff -r 53ba58536f09 -r fc03d6e0d842 liboctave/system/oct-env.h --- a/liboctave/system/oct-env.h Fri Jan 02 16:53:31 2015 -0500 +++ b/liboctave/system/oct-env.h Fri Jan 02 16:54:34 2015 -0500 @@ -51,6 +51,8 @@ static std::string get_home_directory (void); + static std::string get_temp_directory (void); + static std::string get_program_name (void); static std::string get_program_invocation_name (void); @@ -88,6 +90,8 @@ std::string do_get_home_directory (void) const; + std::string do_get_temp_directory (void) const; + std::string do_get_user_name (void) const; std::string do_get_host_name (void) const; diff -r 53ba58536f09 -r fc03d6e0d842 scripts/statistics/base/meansq.m --- a/scripts/statistics/base/meansq.m Fri Jan 02 16:53:31 2015 -0500 +++ b/scripts/statistics/base/meansq.m Fri Jan 02 16:54:34 2015 -0500 @@ -31,7 +31,7 @@ ## ## @example ## @group -## std (x) = 1/N SUM_i x(i)^2 +## meansq (x) = 1/N SUM_i x(i)^2 ## @end group ## @end example ## diff -r 53ba58536f09 -r fc03d6e0d842 test/parser.tst --- a/test/parser.tst Fri Jan 02 16:53:31 2015 -0500 +++ b/test/parser.tst Fri Jan 02 16:54:34 2015 -0500 @@ -19,6 +19,7 @@ ## Tests for parser problems belong in this file. ## We need many more tests here! +## Test cell construction operator {} %!assert ({1 2 {3 4}}, {1,2,{3,4}}) %!assert ({1, 2 {3 4}}, {1,2,{3,4}}) %!assert ({1 2, {3 4}}, {1,2,{3,4}}) @@ -28,6 +29,14 @@ %!assert ({1 2,{3,4}}, {1,2,{3,4}}) %!assert ({1,2,{3 4}}, {1,2,{3,4}}) +## bug #43113 using null comma-separated list in constructor +%!test +%! z = cell (1,2,3,0,5); +%! assert ({1, z{:}, 2}, {1, 2}); +%! assert ({1; z{:}; 2}, {1; 2}); +%! assert ({1 2; z{:}; 3 4}, {1, 2; 3 4}); +%! assert ({1 2; 5 z{:} 6; 3 4}, {1, 2; 5 6; 3 4}); + ## Tests for operator precedence as documented in section 8.8 of manual ## There are 13 levels of precedence from "parentheses and indexing" (highest) ## down to "statement operators" (lowest).