# HG changeset patch # User jwe # Date 1035839131 0 # Node ID 7d9bda865012b640f28be1e0096753aca9061020 # Parent d38de1db36674bc5f273207a1e39afcbcc59b049 [project @ 2002-10-28 21:05:30 by jwe] diff -r d38de1db3667 -r 7d9bda865012 ChangeLog --- a/ChangeLog Mon Oct 28 17:55:39 2002 +0000 +++ b/ChangeLog Mon Oct 28 21:05:31 2002 +0000 @@ -1,3 +1,9 @@ +2002-10-28 John W. Eaton + + * Makeconf.in (HAVE_DLOPEN_API, HAVE_SHL_LOAD_API, + HAVE_LOADLIBRARY_API): Delete. + (do-subst-config-vals): Don't substitute them here. + 2002-10-25 John W. Eaton * configure.in (ENABLE_DYNAMIC_LINKING): Rename from diff -r d38de1db3667 -r 7d9bda865012 Makeconf.in --- a/Makeconf.in Mon Oct 28 17:55:39 2002 +0000 +++ b/Makeconf.in Mon Oct 28 21:05:31 2002 +0000 @@ -50,10 +50,6 @@ DEFAULT_PAGER = @DEFAULT_PAGER@ -HAVE_DLOPEN_API = @HAVE_DLOPEN_API@ -HAVE_SHL_LOAD_API = @HAVE_SHL_LOAD_API@ -HAVE_LOADLIBRARY_API = @HAVE_LOADLIBRARY_API@ - ENABLE_DYNAMIC_LINKING = @ENABLE_DYNAMIC_LINKING@ STATIC_LIBS = @STATIC_LIBS@ @@ -390,9 +386,6 @@ -e "s;%OCTAVE_CONF_FLIBS%;\"${FLIBS}\";" \ -e "s;%OCTAVE_CONF_FPICFLAG%;\"${FPICFLAG}\";" \ -e "s;%OCTAVE_CONF_GLOB_INCFLAGS%;\"${GLOB_INCFLAGS}\";" \ - -e "s;%OCTAVE_CONF_HAVE_DLOPEN_API%;\"${HAVE_DLOPEN_API}\";" \ - -e "s;%OCTAVE_CONF_HAVE_LOADLIBRARY_API%;\"${HAVE_LOADLIBRARY_API}\";" \ - -e "s;%OCTAVE_CONF_HAVE_SHL_LOAD_API%;\"${HAVE_SHL_LOAD_API}\";" \ -e "s;%OCTAVE_CONF_INCFLAGS%;\"${INCFLAGS}\";" \ -e "s;%OCTAVE_CONF_INCLUDE_LINK_DEPS%;\"${INCLUDE_LINK_DEPS}\";"\ -e "s;%OCTAVE_CONF_LD_CXX%;\"${LD_CXX}\";" \ diff -r d38de1db3667 -r 7d9bda865012 liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc Mon Oct 28 17:55:39 2002 +0000 +++ b/liboctave/CMatrix.cc Mon Oct 28 21:05:31 2002 +0000 @@ -2726,11 +2726,13 @@ std::ostream& operator << (std::ostream& os, const ComplexMatrix& a) { -// int field_width = os.precision () + 7; for (int i = 0; i < a.rows (); i++) { for (int j = 0; j < a.cols (); j++) - os << " " /* setw (field_width) */ << a.elem (i, j); + { + os << " "; + octave_write_complex (os, a.elem (i, j)); + } os << "\n"; } return os; @@ -2750,7 +2752,7 @@ for (int i = 0; i < nr; i++) for (int j = 0; j < nc; j++) { - is >> tmp; + tmp = octave_read_complex (is); if (is) a.elem (i, j) = tmp; else diff -r d38de1db3667 -r 7d9bda865012 liboctave/ChangeLog --- a/liboctave/ChangeLog Mon Oct 28 17:55:39 2002 +0000 +++ b/liboctave/ChangeLog Mon Oct 28 21:05:31 2002 +0000 @@ -1,3 +1,16 @@ +2002-10-28 John W. Eaton + + * lo-utils.cc (read_inf_nan_na, octave_read_double, + octave_read_complex, octave_write_double, octave_write_complex): + New functions. + * CMatrix.cc (operator << (std::ostream&, const ComplexMatrix&)): + Use octave_write_complex. + (operator >> (std::istream&, const ComplexMatrix&)): + Use octave_read_complex. + * dMatrix.cc (operator << (std::ostream&, double)): + Use octave_write_double. + (operator >> (std::istream&, double)): Use octave_read_double. + 2002-10-25 John W. Eaton * oct-kpse.c (octave_kpse_clear_dir_cache): Delete. diff -r d38de1db3667 -r 7d9bda865012 liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc Mon Oct 28 17:55:39 2002 +0000 +++ b/liboctave/dMatrix.cc Mon Oct 28 21:05:31 2002 +0000 @@ -2216,12 +2216,13 @@ std::ostream& operator << (std::ostream& os, const Matrix& a) { -// int field_width = os.precision () + 7; - for (int i = 0; i < a.rows (); i++) { for (int j = 0; j < a.cols (); j++) - os << " " /* setw (field_width) */ << a.elem (i, j); + { + os << " "; + octave_write_double (os, a.elem (i, j)); + } os << "\n"; } return os; @@ -2241,7 +2242,7 @@ for (int i = 0; i < nr; i++) for (int j = 0; j < nc; j++) { - is >> tmp; + tmp = octave_read_double (is); if (is) a.elem (i, j) = tmp; else diff -r d38de1db3667 -r 7d9bda865012 liboctave/lo-utils.cc --- a/liboctave/lo-utils.cc Mon Oct 28 17:55:39 2002 +0000 +++ b/liboctave/lo-utils.cc Mon Oct 28 21:05:31 2002 +0000 @@ -39,6 +39,7 @@ #endif #include "lo-error.h" +#include "lo-ieee.h" #include "lo-mappers.h" #include "lo-utils.h" @@ -175,6 +176,142 @@ return retval; } +static inline double +read_inf_nan_na (std::istream& is, char c) +{ + double d = 0.0; + + switch (c) + { + case 'i': case 'I': + { + is >> c; + if (c == 'n' || c == 'N') + { + is >> c; + if (c == 'f' || c == 'F') + d = octave_Inf; + else + is.putback (c); + } + else + is.putback (c); + } + break; + + case 'n': case 'N': + { + is >> c; + if (c == 'a' || c == 'A') + { + is >> c; + if (c == 'n' || c == 'N') + d = octave_NaN; + else + { + is.putback (c); + d = octave_NA; + } + } + else + is.putback (c); + } + break; + + default: + abort (); + } + + return d; +} + +double +octave_read_double (std::istream& is) +{ + double d = 0.0; + + char c = 0; + + is >> c; + switch (c) + { + case 'i': case 'I': + case 'n': case 'N': + d = read_inf_nan_na (is, c); + break; + + default: + is.putback (c); + is >> d; + } + + return d; +} + +Complex +octave_read_complex (std::istream& is) +{ + double re = 0.0, im = 0.0; + + Complex cx = 0.0; + + char ch = 0; + + is >> ch; + + if (ch == '(') + { + re = octave_read_double (is); + is >> ch; + + if (ch == ',') + { + im = octave_read_double (is); + is >> ch; + + if (ch == ')') + cx = Complex (re, im); + else + is.setstate (std::ios::failbit); + } + else if (ch == ')') + cx = re; + else + is.setstate (std::ios::failbit); + } + else + { + is.putback (ch); + cx = octave_read_double (is); + } + + return cx; + +} + +void +octave_write_double (std::ostream& os, double d) +{ + if (lo_ieee_is_NA (d)) + os << "NA"; + else if (lo_ieee_isnan (d)) + os << "NaN"; + else if (lo_ieee_isinf (d)) + os << (d < 0 ? "-Inf" : "Inf"); + else + os << d; +} + +void +octave_write_complex (std::ostream& os, const Complex& c) +{ + os << "("; + octave_write_double (os, real (c)); + os << ","; + octave_write_double (os, imag (c)); + os << ")"; +} + /* ;;; Local Variables: *** ;;; mode: C++ *** diff -r d38de1db3667 -r 7d9bda865012 liboctave/lo-utils.h --- a/liboctave/lo-utils.h Mon Oct 28 17:55:39 2002 +0000 +++ b/liboctave/lo-utils.h Mon Oct 28 21:05:31 2002 +0000 @@ -25,8 +25,11 @@ #include +#include #include +#include "oct-cmplx.h" + extern int NINT (double x); extern double D_NINT (double x); @@ -46,6 +49,12 @@ extern "C" char *oct_strptime (const char *buf, const char *format, struct tm *tm); +extern double octave_read_double (std::istream& is); +extern Complex octave_read_complex (std::istream& is); + +extern void octave_write_double (std::ostream& os, double d); +extern void octave_write_complex (std::ostream& os, const Complex& c); + #endif /* diff -r d38de1db3667 -r 7d9bda865012 src/ChangeLog --- a/src/ChangeLog Mon Oct 28 17:55:39 2002 +0000 +++ b/src/ChangeLog Mon Oct 28 21:05:31 2002 +0000 @@ -1,3 +1,15 @@ +2002-10-28 John W. Eaton + + * oct-conf.h.in (OCTAVE_CONF_HAVE_DLOPEN_API, + OCTAVE_CONF_HAVE_LOADLIBRARY_API, OCTAVE_CONF_HAVE_SHL_LOAD_API): + Delete. + * toplev.cc (octave_config_info): Delete them from the struct + + * load-save.cc (read_ascii_data): Use octave_read_double and + octave_read_complex so that we handle Inf, NaN, and NA. + (read_mat_ascii_data): Likewise. + (save_ascii_data): Use octave_write_double andoctave_write_complex. + 2002-10-25 John W. Eaton * toplev.cc (octave_config_info): Rename WITH_DYNAMIC_LINKING to diff -r d38de1db3667 -r 7d9bda865012 src/load-save.cc --- a/src/load-save.cc Mon Oct 28 17:55:39 2002 +0000 +++ b/src/load-save.cc Mon Oct 28 21:05:31 2002 +0000 @@ -595,8 +595,7 @@ if (strncmp (ptr, "scalar", 6) == 0) { - double tmp; - is >> tmp; + double tmp = octave_read_double (is); if (is) tc = tmp; else @@ -629,8 +628,7 @@ } else if (strncmp (ptr, "complex scalar", 14) == 0) { - Complex tmp; - is >> tmp; + Complex tmp = octave_read_complex (is); if (is) tc = tmp; else @@ -2032,7 +2030,7 @@ for (int j = 0; j < nc; j++) { - tmp_stream >> d; + d = octave_read_double (tmp_stream); if (tmp_stream) tmp.elem (i, j) = d; @@ -4498,10 +4496,13 @@ { ascii_save_type (os, "range", mark_as_global); Range tmp = tc.range_value (); - os << "# base, limit, increment\n" - << tmp.base () << " " - << tmp.limit () << " " - << tmp.inc () << "\n"; + os << "# base, limit, increment\n"; + octave_write_double (os, tmp.base ()); + os << " "; + octave_write_double (os, tmp.limit ()); + os << " "; + octave_write_double (os, tmp.inc ()); + os << "\n"; } else if (tc.is_real_scalar ()) { @@ -4519,7 +4520,8 @@ else { d = xisinf (d) ? (d > 0 ? OCT_RBV : -OCT_RBV) : d; - os << d << "\n"; + octave_write_double (os, d); + os << "\n"; } } else @@ -4530,7 +4532,8 @@ infnan_warned = true; } - os << d << "\n"; + octave_write_double (os, d); + os << "\n"; } } else if (tc.is_real_matrix ()) @@ -4575,7 +4578,8 @@ c = Complex (re, im); - os << c << "\n"; + octave_write_complex (os, c); + os << "\n"; } } else @@ -4586,7 +4590,8 @@ infnan_warned = true; } - os << c << "\n"; + octave_write_complex (os, c); + os << "\n"; } } else if (tc.is_complex_matrix ()) diff -r d38de1db3667 -r 7d9bda865012 src/oct-conf.h.in --- a/src/oct-conf.h.in Mon Oct 28 17:55:39 2002 +0000 +++ b/src/oct-conf.h.in Mon Oct 28 21:05:31 2002 +0000 @@ -144,18 +144,6 @@ #define OCTAVE_CONF_GLOB_INCFLAGS %OCTAVE_CONF_GLOB_INCFLAGS% #endif -#ifndef OCTAVE_CONF_HAVE_DLOPEN_API -#define OCTAVE_CONF_HAVE_DLOPEN_API %OCTAVE_CONF_HAVE_DLOPEN_API% -#endif - -#ifndef OCTAVE_CONF_HAVE_LOADLIBRARY_API -#define OCTAVE_CONF_HAVE_LOADLIBRARY_API %OCTAVE_CONF_HAVE_LOADLIBRARY_API% -#endif - -#ifndef OCTAVE_CONF_HAVE_SHL_LOAD_API -#define OCTAVE_CONF_HAVE_SHL_LOAD_API %OCTAVE_CONF_HAVE_SHL_LOAD_API% -#endif - #ifndef OCTAVE_CONF_INCFLAGS #define OCTAVE_CONF_INCFLAGS %OCTAVE_CONF_INCFLAGS% #endif diff -r d38de1db3667 -r 7d9bda865012 src/toplev.cc --- a/src/toplev.cc Mon Oct 28 17:55:39 2002 +0000 +++ b/src/toplev.cc Mon Oct 28 21:05:31 2002 +0000 @@ -679,9 +679,6 @@ m ["FLIBS"] = OCTAVE_CONF_FLIBS; m ["FPICFLAG"] = OCTAVE_CONF_FPICFLAG; m ["GLOB_INCFLAGS"] = OCTAVE_CONF_GLOB_INCFLAGS; - m ["HAVE_DLOPEN_API"] = OCTAVE_CONF_HAVE_DLOPEN_API; - m ["HAVE_LOADLIBRARY_API"] = OCTAVE_CONF_HAVE_LOADLIBRARY_API; - m ["HAVE_SHL_LOAD_API"] = OCTAVE_CONF_HAVE_SHL_LOAD_API; m ["INCFLAGS"] = OCTAVE_CONF_INCFLAGS; m ["LDFLAGS"] = OCTAVE_CONF_LDFLAGS; m ["LD_CXX"] = OCTAVE_CONF_LD_CXX;