]> www.ginac.de Git - cln.git/commitdiff
Fix compilation with GCC 4.4.
authorRichard B. Kreckel <kreckel@ginac.de>
Sun, 21 Dec 2008 19:10:23 +0000 (20:10 +0100)
committerRichard B. Kreckel <kreckel@ginac.de>
Sun, 21 Dec 2008 19:10:23 +0000 (20:10 +0100)
Use std::iostream functions instead of EOF and cl_EOF macros.
This enables us to get rid of the freadchar and funreadchar functions.
While at it, removed the extra signatures introduced for CLN-1.2.0
compatibilty. After all, the soname has been bumped.

Also updated largest known Mersenne prime in examples/perfnum.cc.

19 files changed:
TODO
doc/cln.texi
examples/perfnum.cc
include/cln/io.h
src/base/string/input/cl_st_get1.cc
src/base/string/input/cl_st_get2.cc
src/base/string/input/cl_st_getline1.cc
src/base/string/input/cl_st_getline2.cc
src/base/string/input/cl_st_gettoken.cc
src/complex/input/cl_N_read_stream.cc
src/float/dfloat/conv/cl_DF_from_double.cc
src/float/ffloat/conv/cl_FF_from_float.cc
src/float/input/cl_F_read_stream.cc
src/float/input/cl_F_readparsed.cc
src/integer/input/cl_I_read_stream.cc
src/integer/input/cl_I_readparsed.cc
src/rational/input/cl_RA_read_stream.cc
src/rational/input/cl_RA_readparsed.cc
src/real/input/cl_R_read_stream.cc

diff --git a/TODO b/TODO
index 3dc8212e8d53169150983710445fa0e7d1e72359..ec02f339bbcd052349b294121349b984ac8b2de1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,9 +1,3 @@
-ABI Issues:
-
-Remove extra signatures in cl_FF_from_float.cc, cl_DF_from_double.cc,
-cl_F_readparsed.cc, cl_I_readparsed.cc, and cl_RA_readparsed.cc.
-
-
 Algorithms:
 
 Niels Moeller's subquadratic GCD
index 546d788c4608be4abfc01a8f0719055591a2379a..8434cb15849989987e7aa3fb7df80478434cb29c 100644 (file)
@@ -2661,30 +2661,7 @@ In Common Lisp notation: @code{#C(@var{realpart} @var{imagpart})}.
 @node Input functions
 @section Input functions
 
-Including @code{<cln/io.h>} defines a number of simple input functions
-that read from @code{std::istream&}:
-
-@table @code
-@item int freadchar (std::istream& stream)
-Reads a character from @code{stream}. Returns @code{cl_EOF} (not a @samp{char}!)
-if the end of stream was encountered or an error occurred.
-
-@item int funreadchar (std::istream& stream, int c)
-Puts back @code{c} onto @code{stream}. @code{c} must be the result of the
-last @code{freadchar} operation on @code{stream}.
-@end table
-
-Each of the classes @code{cl_N}, @code{cl_R}, @code{cl_RA}, @code{cl_I},
-@code{cl_F}, @code{cl_SF}, @code{cl_FF}, @code{cl_DF}, @code{cl_LF}
-defines, in @code{<cln/@var{type}_io.h>}, the following input function:
-
-@table @code
-@item std::istream& operator>> (std::istream& stream, @var{type}& result)
-Reads a number from @code{stream} and stores it in the @code{result}.
-@end table
-
-The most flexible input functions, defined in @code{<cln/@var{type}_io.h>},
-are the following:
+Including @code{<cln/io.h>} defines flexible input functions:
 
 @table @code
 @item cl_N read_complex (std::istream& stream, const cl_read_flags& flags)
index 50d8a0dfa00d6fee1e3a1187be23d9e5bdc257e0..08d7b7b74c3c769faa3173c0acc6a78b05ada69e 100644 (file)
@@ -8,8 +8,9 @@ using namespace cln;
 
 int main ()
 {
-       // previous ones were 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, 30402457
-       int p = 32582657;
+       // previous ones were 1257787, 1398269, 2976221, 3021377, 6972593,
+       // 13466917, 20996011, 24036583, 25964951, 30402457, 32582657, 37156667
+       int p = 43112609;
        cl_I x = (((cl_I)1 << p) - 1) << (p-1);
        cout << x << endl;
 }
index 435490e8545756110bf222eec06595ecc99c7b98..43a5f10a01a3132a153901c43496ee00c1dee4d0 100644 (file)
@@ -24,27 +24,6 @@ typedef std::ostream& cl_ostream;
 extern std::ostream* cl_debugout_stream;
 #define cl_debugout  (*cl_debugout_stream)
 
-// Elementary operations on std::istream&
-
-#define cl_EOF  (-1)
-
-inline int freadchar (std::istream& stream)
-{
-       char c;
-       if (stream.get(c))
-               return c;
-       else
-               // EOF or error
-               return cl_EOF;
-}
-
-inline int funreadchar (std::istream& stream, int c)
-{
-       if (c != cl_EOF)
-               stream.putback((char)c);
-       return c;
-}
-
 // Elementary operations on std::ostream&
 
 inline void fprintchar (std::ostream& stream, char c)
index 917ecc4c78a2cff74e4c24c013688c643f2e5cb2..b0e445a98c78e058dac269c4bd0a7ccc5b11f578 100644 (file)
@@ -17,11 +17,11 @@ namespace cln {
 const cl_string cl_fget (std::istream& stream, char delim)
 {
        var cl_spushstring buffer;
-       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.get()==EOF).
+       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
        while (stream.good()) {
                var int c = stream.get();
-               if (c==EOF)
-                       break;  // std::ios::eofbit already set
+               if (stream.eof())
+                       break;
                if (c==delim) {
                        stream.unget();
                        break;
index d89f3e427cef87524e7a6446dab1e69e2e7a5e26..52b0afc2afb0fb8876ea5be409ee14347e073f7d 100644 (file)
@@ -17,11 +17,11 @@ namespace cln {
 const cl_string cl_fget (std::istream& stream, int n, char delim)
 {
        var cl_spushstring buffer;
-       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.get()==EOF).
+       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
        while (stream.good()) {
                var int c = stream.get();
-               if (c==EOF)
-                       break;  // ios::eofbit already set
+               if (stream.eof())
+                       break;
                if (c==delim) {
                        stream.unget();
                        break;
index 5f9ac88836563f349d010c8522f7f52efe16271b..da0f0d012c6746d97147d6fbd2323a8b9be2498a 100644 (file)
@@ -17,11 +17,11 @@ namespace cln {
 const cl_string cl_fgetline (std::istream& stream, char delim)
 {
        var cl_spushstring buffer;
-       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.get()==EOF).
+       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
        while (stream.good()) {
                var int c = stream.get();
-               if (c==EOF)
-                       break;  // std::ios::eofbit already set
+               if (stream.eof())
+                       break;
                if (c==delim)
                        break;
                buffer.push(c);
index d2316e0fe602a045176eadac7ab812706abd1f6c..5f5616956e0da18a6febffb78acd929a6878f8e4 100644 (file)
@@ -17,11 +17,11 @@ namespace cln {
 const cl_string cl_fgetline (std::istream& stream, int n, char delim)
 {
        var cl_spushstring buffer;
-       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.get()==EOF).
+       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
        while (stream.good()) {
                var int c = stream.get();
-               if (c==EOF)
-                       break;  // std::ios::eofbit already set
+               if (stream.eof())
+                       break;
                if (c==delim)
                        break;
                if (--n <= 0) {
index 30e7817ee952d5835b248287dbd7f1c53e759b35..9361ee727a6459f2123648be51d3468bfc82e7c7 100644 (file)
@@ -19,12 +19,12 @@ std::istream& operator>> (std::istream& stream, cl_string& str)
 {
        var cl_spushstring buffer;
        var int n = stream.width();
-       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.get()==EOF).
+       // Handling of eofp is tricky: EOF is reached when (!stream.good()) || (stream.eof()).
        int c;
        // Skip whitespace.
        while (stream.good()) {
                c = stream.get();
-               if (c==EOF)
+               if (stream.eof())
                        break;
                if (!isspace(c)) {
                        if (--n == 0) {
@@ -40,7 +40,7 @@ std::istream& operator>> (std::istream& stream, cl_string& str)
        // Read non-whitespace.
        while (stream.good()) {
                c = stream.get();
-               if (c==EOF)
+               if (stream.eof())
                        break;
                if (isspace(c)) {
                        stream.unget();
index fa1f594dabb2356475c36c587747ecde0f454ec4..139af04d20d2d841c380282aacbd9a9a5182a07e 100644 (file)
@@ -46,8 +46,8 @@ const cl_N read_complex (std::istream& stream, const cl_read_flags& flags)
        var int c;
        // Skip whitespace at the beginning.
        loop {
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
                if ((c == ' ') || (c == '\t') || (c == '\n'))
                        continue;
                else
@@ -62,8 +62,8 @@ const cl_N read_complex (std::istream& stream, const cl_read_flags& flags)
                buffer.push(c);
                // Read some digits, then a letter, then a list or token.
                loop {
-                       c = freadchar(stream);
-                       if (c == cl_EOF) goto eof;
+                       c = stream.get();
+                       if (stream.eof() || stream.fail()) goto eof;
                        buffer.push(c);
                        if ((c >= '0') && (c <= '9'))
                                continue;
@@ -72,8 +72,8 @@ const cl_N read_complex (std::istream& stream, const cl_read_flags& flags)
                }
                if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
                        goto syntax1;
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
                if (c == '(') {
                        var uintL paren_level = 0;
                        loop {
@@ -81,8 +81,8 @@ const cl_N read_complex (std::istream& stream, const cl_read_flags& flags)
                                if (c == '(') paren_level++;
                                else if (c == ')') paren_level--;
                                if (paren_level == 0) goto done;
-                               c = freadchar(stream);
-                               if ((c == cl_EOF) || (c == '\n')) goto syntax;
+                               c = stream.get();
+                               if (stream.eof() || stream.fail() || c == '\n') goto syntax;
                        }
                }
        }
@@ -91,11 +91,11 @@ const cl_N read_complex (std::istream& stream, const cl_read_flags& flags)
                goto syntax1;
        loop {
                buffer.push(c);
-               c = freadchar(stream);
-               if (c == cl_EOF)
+               c = stream.get();
+               if (stream.eof() || stream.fail())
                        break;
                if (!number_char_p(c)) {
-                       funreadchar(stream,c);
+                       stream.putback(c);
                        break;
                }
        }
index aa0df539104b41ad43bf956672227aea6954dd5d..37a8f807001ac40ec9ed08fe05c7833382ff8d2b 100644 (file)
 
 namespace cln {
 
-cl_heap_dfloat* cl_double_to_DF_pointer (const dfloatjanus& val_)
-{
-      // XXX: This signature is for binary compatibility with CLN-1.2.0 only.
-      return cl_double_to_DF_pointer(*(double *)(&val_));
-}
-
 cl_heap_dfloat* cl_double_to_DF_pointer (const double x)
 {
       var union { dfloat eksplicit; double machine_double; } u;
index de9f01df4e93c323d57a3e1a08ac02d4debe5300..57b59f711c99137cc2d930faf94602c69e35da70 100644 (file)
@@ -10,12 +10,6 @@ namespace cln {
 
 // Implementation.
 
-cl_private_thing cl_float_to_FF_pointer (const ffloatjanus& val_)
-{
-      // XXX: This signature is for binary compatibility with CLN-1.2.0 only.
-      return cl_float_to_FF_pointer(*(float *)(&val_));
-}
-
 cl_private_thing cl_float_to_FF_pointer (const float x)
 {
       var union { ffloat eksplicit; float machine_float; } u;
index cd49e97e16c27c0feeea9a54c7c431505ca1364a..baafc3bb24a961c240fcbd110629944676512742 100644 (file)
@@ -48,8 +48,8 @@ const cl_F read_float (std::istream& stream, const cl_read_flags& flags)
        var int c;
        // Skip whitespace at the beginning.
        loop {
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
                if ((c == ' ') || (c == '\t') || (c == '\n'))
                        continue;
                else
@@ -64,8 +64,8 @@ const cl_F read_float (std::istream& stream, const cl_read_flags& flags)
                buffer.push(c);
                // Read some digits, then a letter, then a token.
                loop {
-                       c = freadchar(stream);
-                       if (c == cl_EOF) goto eof;
+                       c = stream.get();
+                       if (stream.eof() || stream.fail()) goto eof;
                        buffer.push(c);
                        if ((c >= '0') && (c <= '9'))
                                continue;
@@ -74,19 +74,19 @@ const cl_F read_float (std::istream& stream, const cl_read_flags& flags)
                }
                if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
                        goto syntax1;
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
        }
        // Read a number token.
        if (!number_char_p(c))
                goto syntax1;
        loop {
                buffer.push(c);
-               c = freadchar(stream);
-               if (c == cl_EOF)
+               c = stream.get();
+               if (stream.eof() || stream.fail())
                        break;
                if (!number_char_p(c)) {
-                       funreadchar(stream,c);
+                       stream.putback(c);
                        break;
                }
        }
index 2097985cf8a791e2b990f51663d4de1a084b5354..c80885fe461b104c6953697c088c5247e544e0e5 100644 (file)
 
 namespace cln {
 
-#if intCsize > intLsize
-const cl_F read_float (unsigned int base, float_format_t prec, cl_signean sign, const char * string, uintL index1, uintL index4, uintL index2, uintL index3)
-{
-       // XXX: This signature is for binary compatibility with CLN-1.2.0 only.
-       return read_float(base, prec, sign, string, uintC(index1), uintC(index4), uintC(index2), uintC(index3));
-}
-#endif
-
 const cl_F read_float (unsigned int base, float_format_t prec, cl_signean sign, const char * string, uintC index1, uintC index4, uintC index2, uintC index3)
 {
        var cl_I exponent;
index 2f4e3dba7308bc8e2817a08dba8aa4995ccd33e3..227d845be9e70ff3961079fee504fc67fc033be6 100644 (file)
@@ -48,8 +48,8 @@ const cl_I read_integer (std::istream& stream, const cl_read_flags& flags)
        var int c;
        // Skip whitespace at the beginning.
        loop {
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
                if ((c == ' ') || (c == '\t') || (c == '\n'))
                        continue;
                else
@@ -64,8 +64,8 @@ const cl_I read_integer (std::istream& stream, const cl_read_flags& flags)
                buffer.push(c);
                // Read some digits, then a letter, then a token.
                loop {
-                       c = freadchar(stream);
-                       if (c == cl_EOF) goto eof;
+                       c = stream.get();
+                       if (stream.eof() || stream.fail()) goto eof;
                        buffer.push(c);
                        if ((c >= '0') && (c <= '9'))
                                continue;
@@ -74,19 +74,19 @@ const cl_I read_integer (std::istream& stream, const cl_read_flags& flags)
                }
                if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
                        goto syntax1;
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
        }
        // Read a number token.
        if (!number_char_p(c))
                goto syntax1;
        loop {
                buffer.push(c);
-               c = freadchar(stream);
-               if (c == cl_EOF)
+               c = stream.get();
+               if (stream.eof() || stream.fail())
                        break;
                if (!number_char_p(c)) {
-                       funreadchar(stream,c);
+                       stream.putback(c);
                        break;
                }
        }
index 9ed4f9a35d7a7f48dc2e1eab242a7dcacd049ef9..bb71b083a5276bfa3646979078bcb950f44e11fd 100644 (file)
 
 namespace cln {
 
-#if intCsize > intLsize
-const cl_I read_integer (unsigned int base, cl_signean sign, const char* string, uintL index1, uintL index2)
-{
-       // XXX: This signature is for binary compatibility with CLN-1.2.0 only.
-       return read_integer(base, sign, string, uintC(index1), uintC(index2));
-}
-#endif
-
 const cl_I read_integer (unsigned int base, cl_signean sign, const char * string, uintC index1, uintC index2)
 {
        var cl_I x = digits_to_I(&string[index1],index2-index1,(uintD)base);
index d283095175b5c51a876154dfc14a9d3e7e762391..bba1d030828743bcc635c6b2b1b6e985f77008bc 100644 (file)
@@ -49,8 +49,8 @@ const cl_RA read_rational (std::istream& stream, const cl_read_flags& flags)
        var int c;
        // Skip whitespace at the beginning.
        loop {
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
                if ((c == ' ') || (c == '\t') || (c == '\n'))
                        continue;
                else
@@ -65,8 +65,8 @@ const cl_RA read_rational (std::istream& stream, const cl_read_flags& flags)
                buffer.push(c);
                // Read some digits, then a letter, then a token.
                loop {
-                       c = freadchar(stream);
-                       if (c == cl_EOF) goto eof;
+                       c = stream.get();
+                       if (stream.eof() || stream.fail()) goto eof;
                        buffer.push(c);
                        if ((c >= '0') && (c <= '9'))
                                continue;
@@ -75,19 +75,19 @@ const cl_RA read_rational (std::istream& stream, const cl_read_flags& flags)
                }
                if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
                        goto syntax1;
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
        }
        // Read a number token.
        if (!number_char_p(c))
                goto syntax1;
        loop {
                buffer.push(c);
-               c = freadchar(stream);
-               if (c == cl_EOF)
+               c = stream.get();
+               if (stream.eof() || stream.fail())
                        break;
                if (!number_char_p(c)) {
-                       funreadchar(stream,c);
+                       stream.putback(c);
                        break;
                }
        }
index afe6602f5ddd651c1bd9318aaaeadeffa3888123..7a8a85a56022b97909c434fd7a6931d7b7c59f78 100644 (file)
 
 namespace cln {
 
-#if intCsize > intLsize
-const cl_RA read_rational (unsigned int base, cl_signean sign, const char * string, uintL index1, uintL index3, uintL index2)
-{
-       // XXX: This signature is for binary compatibility with CLN-1.2.0 only.
-       return read_rational(base, sign, string, uintC(index1), uintC(index3), uintC(index2));
-}
-#endif
-
 const cl_RA read_rational (unsigned int base, cl_signean sign, const char * string, uintC index1, uintC index3, uintC index2)
 {
        var uintC index3_1 = index3+1; // Index der ersten Nennerziffer
index 873bad7c425189707b301e0dfaeb338e913ddd46..56b01d32381e2ec744af2582ea268362cc2ef993 100644 (file)
@@ -48,8 +48,8 @@ const cl_R read_real (std::istream& stream, const cl_read_flags& flags)
        var int c;
        // Skip whitespace at the beginning.
        loop {
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
                if ((c == ' ') || (c == '\t') || (c == '\n'))
                        continue;
                else
@@ -64,8 +64,8 @@ const cl_R read_real (std::istream& stream, const cl_read_flags& flags)
                buffer.push(c);
                // Read some digits, then a letter, then a token.
                loop {
-                       c = freadchar(stream);
-                       if (c == cl_EOF) goto eof;
+                       c = stream.get();
+                       if (stream.eof() || stream.fail()) goto eof;
                        buffer.push(c);
                        if ((c >= '0') && (c <= '9'))
                                continue;
@@ -74,19 +74,19 @@ const cl_R read_real (std::istream& stream, const cl_read_flags& flags)
                }
                if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
                        goto syntax1;
-               c = freadchar(stream);
-               if (c == cl_EOF) goto eof;
+               c = stream.get();
+               if (stream.eof() || stream.fail()) goto eof;
        }
        // Read a number token.
        if (!number_char_p(c))
                goto syntax1;
        loop {
                buffer.push(c);
-               c = freadchar(stream);
-               if (c == cl_EOF)
+               c = stream.get();
+               if (stream.eof() || stream.fail())
                        break;
                if (!number_char_p(c)) {
-                       funreadchar(stream,c);
+                       stream.putback(c);
                        break;
                }
        }