# HG changeset patch # User Jaroslav Hajek # Date 1267453445 -3600 # Node ID f578e6468d0c7707fb9593851931e2325a5f8fc8 # Parent eeb6c09ec51a4fc3b32de48b09289c959cb516e0 use C++-0x code in str2double diff -r eeb6c09ec51a -r f578e6468d0c src/ChangeLog --- a/src/ChangeLog Mon Mar 01 09:49:56 2010 +0100 +++ b/src/ChangeLog Mon Mar 01 15:24:05 2010 +0100 @@ -1,3 +1,8 @@ +2010-03-01 Jaroslav Hajek + + * DLD-FUNCTIONS/str2double.cc (set_component): New helper func. + (str2double1): Use it here. + 2010-03-01 Jaroslav Hajek * DLD-FUNCTIONS/str2double.cc (str2double1): Use ISO-conformant code diff -r eeb6c09ec51a -r f578e6468d0c src/DLD-FUNCTIONS/str2double.cc --- a/src/DLD-FUNCTIONS/str2double.cc Mon Mar 01 09:49:56 2010 +0100 +++ b/src/DLD-FUNCTIONS/str2double.cc Mon Mar 01 15:24:05 2010 +0100 @@ -136,6 +136,23 @@ return is; } +static inline void +set_component (Complex& c, double num, bool imag) +{ + // FIXME: this is C++-0x. +#if defined (__GNUC__) || defined (__MSVC__) + if (imag) + c.imag (r); + else + c.real (r); +#else + if (imag) + c = Complex (c.real (), num); + else + c = Complex (num, c.imag ()); +#endif +} + static Complex str2double1 (std::string str) { @@ -156,38 +173,14 @@ val = octave_NaN; else { - if (i1) -#ifdef __GNUC__ - val.imag () = num; // GNU C++ -#else - val = Complex (val.real (), num); // ISO C++ -#endif - else -#ifdef __GNUC__ - val.real () = num; // GNU C++ -#else - val = Complex (num, val.imag ()); // ISO C++ -#endif + set_component (c, num, i1); if (! is.eof ()) { if (! extract_num (is, num, i2, s2) || i1 == i2 || ! s2) val = octave_NaN; else - { - if (i2) -#ifdef __GNUC__ - val.imag () = num; // GNU C++ -#else - val = Complex (val.real (), num); // ISO C++ -#endif - else -#ifdef __GNUC__ - val.real () = num; // GNU C++ -#else - val = Complex (num, val.imag ()); // ISO C++ -#endif - } + set_component (c, num, i2); } }