# HG changeset patch # User jwe # Date 1164950738 0 # Node ID 0d2ff0dfb159410d12c59013e026481df909d7a9 # Parent ca97c6b26902e2b22c1c89bb8a90c2952dbac617 [project @ 2006-12-01 05:25:38 by jwe] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2006-11-30 John W. Eaton + + * lo-utils.cc (octave_read_double, read_inf_nan_na): + Also recognize [+-][Ii]nf. + 2006-11-28 David Bateman * oct-sparse.h: Allow sparse headers to also be in a sparsesuite diff --git a/liboctave/lo-utils.cc b/liboctave/lo-utils.cc --- a/liboctave/lo-utils.cc +++ b/liboctave/lo-utils.cc @@ -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; }