diff --git a/TODO b/TODO index 3dc8212..ec02f33 100644 --- 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 diff --git a/doc/cln.texi b/doc/cln.texi index 546d788..8434cb1 100644 --- a/doc/cln.texi +++ b/doc/cln.texi @@ -2661,30 +2661,7 @@ In Common Lisp notation: @code{#C(@var{realpart} @var{imagpart})}. @node Input functions @section Input functions -Including @code{} 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{}, 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{}, -are the following: +Including @code{} defines flexible input functions: @table @code @item cl_N read_complex (std::istream& stream, const cl_read_flags& flags) diff --git a/examples/perfnum.cc b/examples/perfnum.cc index 50d8a0d..08d7b7b 100644 --- a/examples/perfnum.cc +++ b/examples/perfnum.cc @@ -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; } diff --git a/include/cln/io.h b/include/cln/io.h index 435490e..43a5f10 100644 --- a/include/cln/io.h +++ b/include/cln/io.h @@ -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) diff --git a/src/base/string/input/cl_st_get1.cc b/src/base/string/input/cl_st_get1.cc index 917ecc4..b0e445a 100644 --- a/src/base/string/input/cl_st_get1.cc +++ b/src/base/string/input/cl_st_get1.cc @@ -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; diff --git a/src/base/string/input/cl_st_get2.cc b/src/base/string/input/cl_st_get2.cc index d89f3e4..52b0afc 100644 --- a/src/base/string/input/cl_st_get2.cc +++ b/src/base/string/input/cl_st_get2.cc @@ -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; diff --git a/src/base/string/input/cl_st_getline1.cc b/src/base/string/input/cl_st_getline1.cc index 5f9ac88..da0f0d0 100644 --- a/src/base/string/input/cl_st_getline1.cc +++ b/src/base/string/input/cl_st_getline1.cc @@ -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); diff --git a/src/base/string/input/cl_st_getline2.cc b/src/base/string/input/cl_st_getline2.cc index d2316e0..5f56169 100644 --- a/src/base/string/input/cl_st_getline2.cc +++ b/src/base/string/input/cl_st_getline2.cc @@ -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) { diff --git a/src/base/string/input/cl_st_gettoken.cc b/src/base/string/input/cl_st_gettoken.cc index 30e7817..9361ee7 100644 --- a/src/base/string/input/cl_st_gettoken.cc +++ b/src/base/string/input/cl_st_gettoken.cc @@ -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(); diff --git a/src/complex/input/cl_N_read_stream.cc b/src/complex/input/cl_N_read_stream.cc index fa1f594..139af04 100644 --- a/src/complex/input/cl_N_read_stream.cc +++ b/src/complex/input/cl_N_read_stream.cc @@ -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; } } diff --git a/src/float/dfloat/conv/cl_DF_from_double.cc b/src/float/dfloat/conv/cl_DF_from_double.cc index aa0df53..37a8f80 100644 --- a/src/float/dfloat/conv/cl_DF_from_double.cc +++ b/src/float/dfloat/conv/cl_DF_from_double.cc @@ -11,12 +11,6 @@ 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; diff --git a/src/float/ffloat/conv/cl_FF_from_float.cc b/src/float/ffloat/conv/cl_FF_from_float.cc index de9f01d..57b59f7 100644 --- a/src/float/ffloat/conv/cl_FF_from_float.cc +++ b/src/float/ffloat/conv/cl_FF_from_float.cc @@ -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; diff --git a/src/float/input/cl_F_read_stream.cc b/src/float/input/cl_F_read_stream.cc index cd49e97..baafc3b 100644 --- a/src/float/input/cl_F_read_stream.cc +++ b/src/float/input/cl_F_read_stream.cc @@ -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; } } diff --git a/src/float/input/cl_F_readparsed.cc b/src/float/input/cl_F_readparsed.cc index 2097985..c80885f 100644 --- a/src/float/input/cl_F_readparsed.cc +++ b/src/float/input/cl_F_readparsed.cc @@ -26,14 +26,6 @@ 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; diff --git a/src/integer/input/cl_I_read_stream.cc b/src/integer/input/cl_I_read_stream.cc index 2f4e3db..227d845 100644 --- a/src/integer/input/cl_I_read_stream.cc +++ b/src/integer/input/cl_I_read_stream.cc @@ -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; } } diff --git a/src/integer/input/cl_I_readparsed.cc b/src/integer/input/cl_I_readparsed.cc index 9ed4f9a..bb71b08 100644 --- a/src/integer/input/cl_I_readparsed.cc +++ b/src/integer/input/cl_I_readparsed.cc @@ -13,14 +13,6 @@ 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); diff --git a/src/rational/input/cl_RA_read_stream.cc b/src/rational/input/cl_RA_read_stream.cc index d283095..bba1d03 100644 --- a/src/rational/input/cl_RA_read_stream.cc +++ b/src/rational/input/cl_RA_read_stream.cc @@ -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; } } diff --git a/src/rational/input/cl_RA_readparsed.cc b/src/rational/input/cl_RA_readparsed.cc index afe6602..7a8a85a 100644 --- a/src/rational/input/cl_RA_readparsed.cc +++ b/src/rational/input/cl_RA_readparsed.cc @@ -15,14 +15,6 @@ 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 diff --git a/src/real/input/cl_R_read_stream.cc b/src/real/input/cl_R_read_stream.cc index 873bad7..56b01d3 100644 --- a/src/real/input/cl_R_read_stream.cc +++ b/src/real/input/cl_R_read_stream.cc @@ -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; } }