changeset 6194:0d2ff0dfb159

[project @ 2006-12-01 05:25:38 by jwe]
author jwe
date Fri, 01 Dec 2006 05:25:38 +0000
parents ca97c6b26902
children c50a125a6c81
files liboctave/ChangeLog liboctave/lo-utils.cc
diffstat 2 files changed, 40 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Thu Nov 30 22:57:15 2006 +0000
+++ b/liboctave/ChangeLog	Fri Dec 01 05:25:38 2006 +0000
@@ -1,3 +1,8 @@
+2006-11-30  John W. Eaton  <jwe@octave.org>
+
+	* lo-utils.cc (octave_read_double, read_inf_nan_na):
+	Also recognize [+-][Ii]nf.
+
 2006-11-28  David Bateman  <dbateman@free.fr>
 
 	* oct-sparse.h: Allow sparse headers to also be in a sparsesuite
--- a/liboctave/lo-utils.cc	Thu Nov 30 22:57:15 2006 +0000
+++ b/liboctave/lo-utils.cc	Fri Dec 01 05:25:38 2006 +0000
@@ -210,7 +210,7 @@
 }
 
 static inline double
-read_inf_nan_na (std::istream& is, char c)
+read_inf_nan_na (std::istream& is, char c, char sign = '+')
 {
   double d = 0.0;
 
@@ -223,7 +223,7 @@
 	  {
 	    is >> c;
 	    if (c == 'f' || c == 'F')
-	      d = octave_Inf;
+	      d = sign == '-' ? -octave_Inf : octave_Inf;
 	    else
 	      is.putback (c);
 	  }
@@ -263,18 +263,46 @@
 {
   double d = 0.0;
 
-  char c = 0;
+  char c1 = 0;
 
-  is >> c;
-  switch (c)
+  is >> c1;
+  switch (c1)
     {
+    case '-':
+      {
+	char c2 = 0;
+	is >> c2;
+	if (c2 == 'i' || c2 == 'I')
+	  d = read_inf_nan_na (is, c2, c1);
+	else
+	  {
+	    is.putback (c2);
+	    is.putback (c1);
+	  }
+      }
+      break;
+
+    case '+':
+      {
+	char c2 = 0;
+	is >> c2;
+	if (c2 == 'i' || c2 == 'I')
+	  d = read_inf_nan_na (is, c2, c1);
+	else
+	  {
+	    is.putback (c2);
+	    is.putback (c1);
+	  }
+      }
+      break;
+
     case 'i': case 'I':
     case 'n': case 'N':
-      d = read_inf_nan_na (is, c);
+      d = read_inf_nan_na (is, c1);
       break;
 
     default:
-      is.putback (c);
+      is.putback (c1);
       is >> d;
     }