diff liboctave/lo-utils.cc @ 6194:0d2ff0dfb159

[project @ 2006-12-01 05:25:38 by jwe]
author jwe
date Fri, 01 Dec 2006 05:25:38 +0000
parents ace8d8d26933
children e5ed0d1edddc
line wrap: on
line diff
--- 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;
     }