changeset 14927:3b40dbc14572

maint: periodic merge of default to jit
author Max Brister <max@2bass.com>
date Wed, 30 May 2012 09:36:38 -0500
parents aebd296a15c4 (current diff) a08f6e17336e (diff)
children 39d52aa37a08
files
diffstat 3 files changed, 41 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/str2double.cc	Tue May 29 13:51:02 2012 -0500
+++ b/src/DLD-FUNCTIONS/str2double.cc	Wed May 30 09:36:38 2012 -0500
@@ -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))
--- a/test/fntests.m	Tue May 29 13:51:02 2012 -0500
+++ b/test/fntests.m	Wed May 30 09:36:38 2012 -0500
@@ -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 13:51:02 2012 -0500
+++ b/test/test_system.m	Wed May 30 09:36:38 2012 -0500
@@ -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