# HG changeset patch # User John W. Eaton # Date 1403884548 14400 # Node ID 589354cf668fb2a60c87a85d13010a8746924856 # Parent 95b69b880b19ef14887e6fc8d70b7a543e6f4419# Parent c457a84bc7d393c11c44d1613f8eabcaec47e5a6 maint: Periodic merge of stable to gui-release. diff -r 95b69b880b19 -r 589354cf668f libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Thu Jun 26 14:42:55 2014 -0400 +++ b/libinterp/corefcn/data.cc Fri Jun 27 11:55:48 2014 -0400 @@ -568,6 +568,9 @@ %! [f, e] = log2 (complex (zeros (3, 2), [0,-1; 2,-4; Inf,-Inf])); %! assert (f, complex (zeros (3, 2), [0,-0.5; 0.5,-0.5; Inf,-Inf])); %! assert (e(1:2,:), [0,1; 2,3]); + +# bug #42583 +%!assert (all (log2 (pow2 (-1074:1023)) == -1074:1023)) */ DEFUN (rem, args, , diff -r 95b69b880b19 -r 589354cf668f libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc Thu Jun 26 14:42:55 2014 -0400 +++ b/libinterp/corefcn/load-save.cc Fri Jun 27 11:55:48 2014 -0400 @@ -265,9 +265,10 @@ file.clear (); file.seekg (0, std::ios::beg); - std::string tmp = extract_keyword (file, "name"); + std::string name_val = extract_keyword (file, "name"); + std::string type_val = extract_keyword (file, "type"); - if (! tmp.empty ()) + if (name_val.empty () != true && type_val.empty () != true) retval = LS_ASCII; else { diff -r 95b69b880b19 -r 589354cf668f liboctave/array/Range.cc --- a/liboctave/array/Range.cc Thu Jun 26 14:42:55 2014 -0400 +++ b/liboctave/array/Range.cc Fri Jun 27 11:55:48 2014 -0400 @@ -387,12 +387,12 @@ Range operator - (const Range& r) { - return Range (-r.base (), -r.inc (), r.nelem ()); + return Range (-r.base (), -r.limit (), -r.inc (), r.nelem ()); } Range operator + (double x, const Range& r) { - Range result (x + r.base (), r.inc (), r.nelem ()); + Range result (x + r.base (), x + r.limit (), r.inc (), r.nelem ()); if (result.rng_nelem < 0) result.cache = x + r.matrix_value (); @@ -401,7 +401,7 @@ Range operator + (const Range& r, double x) { - Range result (r.base () + x, r.inc (), r.nelem ()); + Range result (r.base () + x, r.limit () + x, r.inc (), r.nelem ()); if (result.rng_nelem < 0) result.cache = r.matrix_value () + x; @@ -410,7 +410,7 @@ Range operator - (double x, const Range& r) { - Range result (x - r.base (), -r.inc (), r.nelem ()); + Range result (x - r.base (), x - r.limit (), -r.inc (), r.nelem ()); if (result.rng_nelem < 0) result.cache = x - r.matrix_value (); @@ -419,7 +419,7 @@ Range operator - (const Range& r, double x) { - Range result (r.base () - x, r.inc (), r.nelem ()); + Range result (r.base () - x, r.limit () - x, r.inc (), r.nelem ()); if (result.rng_nelem < 0) result.cache = r.matrix_value () - x; @@ -428,7 +428,7 @@ Range operator * (double x, const Range& r) { - Range result (x * r.base (), x * r.inc (), r.nelem ()); + Range result (x * r.base (), x * r.limit (), x * r.inc (), r.nelem ()); if (result.rng_nelem < 0) result.cache = x * r.matrix_value (); @@ -437,7 +437,7 @@ Range operator * (const Range& r, double x) { - Range result (r.base () * x, r.inc () * x, r.nelem ()); + Range result (r.base () * x, r.limit () * x, r.inc () * x, r.nelem ()); if (result.rng_nelem < 0) result.cache = r.matrix_value () * x; diff -r 95b69b880b19 -r 589354cf668f liboctave/array/Range.h --- a/liboctave/array/Range.h Thu Jun 26 14:42:55 2014 -0400 +++ b/liboctave/array/Range.h Fri Jun 27 11:55:48 2014 -0400 @@ -54,7 +54,7 @@ : rng_base (b), rng_limit (b + (n-1) * i), rng_inc (i), rng_nelem (n), cache () { - if (! xfinite (b) || ! xfinite (i)) + if (! xfinite (b) || ! xfinite (i) | ! xfinite (rng_limit)) rng_nelem = -2; } @@ -145,6 +145,16 @@ void clear_cache (void) const { cache.resize (0, 0); } +protected: + + // For operators' usage (to allow all values to be set directly). + Range (double b, double l, double i, octave_idx_type n) + : rng_base (b), rng_limit (l), rng_inc (i), + rng_nelem (n), cache () + { + if (! xfinite (b) || ! xfinite (i) || ! xfinite (l)) + rng_nelem = -2; + } }; extern OCTAVE_API Range operator - (const Range& r); diff -r 95b69b880b19 -r 589354cf668f scripts/io/strread.m --- a/scripts/io/strread.m Thu Jun 26 14:42:55 2014 -0400 +++ b/scripts/io/strread.m Fri Jun 27 11:55:48 2014 -0400 @@ -192,6 +192,10 @@ error ("strread: STR and FORMAT arguments must be strings"); endif + if (strcmp (typeinfo (format), "sq_string")) + format = do_string_escapes (format); + endif + ## Parse format string to compare number of conversion fields and nargout nfields = length (strfind (format, "%")) - length (strfind (format, "%*")); ## If str only has numeric fields, a (default) format ("%f") will do. @@ -391,6 +395,15 @@ white_spaces = strrep (white_spaces, eol_char, ''); endif + ii = numel (fmt_words); + while (ii > 0) + if (ismember (fmt_words{ii}, delimiter_str)(1)) + fmt_words(ii) = []; + --num_words_per_line; + endif + --ii; + endwhile + pad_out = 0; ## Trim whitespace if needed if (! isempty (white_spaces)) @@ -974,6 +987,34 @@ %!test %! assert (strread (",2,,4\n5,,7,", "", "delimiter", ","), [NaN; 2; NaN; 4; 5; NaN; 7]); +%% Test #1 bug #42609 +%!test +%! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", "%f %f %f\n"); +%! assert (a, [1; 4; 7]); +%! assert (b, [2; 5; 8]); +%! assert (c, [3; 6; 9]); + +%% Test #2 bug #42609 +%!test +%! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", "%f %f\n%f"); +%! assert (a, [1;4;7]); +%! assert (b, [2; 5; 8]); +%! assert (c, [3; 6; 9]); + +%% Test #3 bug #42609 +%!test +%! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", '%f %f %f\n'); +%! assert (a, [1; 4; 7]); +%! assert (b, [2; 5; 8]); +%! assert (c, [3; 6; 9]); + +%% Test #3 bug #42609 +%!test +%! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", '%f %f\n%f'); +%! assert (a, [1;4;7]); +%! assert (b, [2; 5; 8]); +%! assert (c, [3; 6; 9]); + %% Unsupported format specifiers %!test %!error strread ("a", "%c")