# HG changeset patch # User Max Brister # Date 1338388598 18000 # Node ID 3b40dbc145722de93c348cd8e050dff6ea4b42e5 # Parent aebd296a15c4a76166461da006fbd1ffc773deaf# Parent a08f6e17336ef7a0316f9082cdf1dda65441bc44 maint: periodic merge of default to jit diff --git a/src/DLD-FUNCTIONS/str2double.cc b/src/DLD-FUNCTIONS/str2double.cc --- a/src/DLD-FUNCTIONS/str2double.cc +++ b/src/DLD-FUNCTIONS/str2double.cc @@ -54,15 +54,15 @@ c = is.peek (); } - if (c == 'I') + if (std::toupper (c) == 'I') { // It's infinity. is.get (); char c1 = is.get (), c2 = is.get (); - if (c1 == 'n' && c2 == 'f') + if (std::tolower (c1) == 'n' && std::tolower (c2) == 'f') { num = octave_Inf; - is.peek (); // May sets EOF bit. + is.peek (); // May set EOF bit. } else is.setstate (std::ios::failbit); // indicate that read has failed. @@ -127,13 +127,37 @@ c = is.peek (); } - // It's i*num or just i. - if (is_imag_unit (c)) + // Imaginary number (i*num or just i), or maybe 'inf'. + if (c == 'i') { - imag = true; + // possible infinity. is.get (); c = is.peek (); + if (is.eof ()) + { + // just 'i' and string is finished. Return immediately. + imag = true; + num = 1.0; + if (negative) + num = -num; + return is; + } + else + { + if (std::tolower (c) != 'n') + imag = true; + is.unget (); + } + } + else if (c == 'j') + imag = true; + + // It's i*num or just i + if (imag) + { + is.get (); + c = is.peek (); // Skip spaces after imaginary unit. while (isspace (c)) { @@ -369,8 +393,10 @@ %!assert (str2double ("NaN"), NaN) %!assert (str2double ("NA"), NA) %!assert (str2double ("Inf"), Inf) +%!assert (str2double ("iNF"), Inf) %!assert (str2double ("-Inf"), -Inf) %!assert (str2double ("Inf*i"), complex (0, Inf)) +%!assert (str2double ("iNF*i"), complex (0, Inf)) %!assert (str2double ("NaN + Inf*i"), complex (NaN, Inf)) %!assert (str2double ("Inf - Inf*i"), complex (Inf, -Inf)) %!assert (str2double ("-i*NaN - Inf"), complex (-Inf, -NaN)) diff --git a/test/fntests.m b/test/fntests.m --- a/test/fntests.m +++ b/test/fntests.m @@ -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"); diff --git a/test/test_system.m b/test/test_system.m --- a/test/test_system.m +++ b/test/test_system.m @@ -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