X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;ds=inline;f=src%2Frational%2Finput%2Fcl_RA_read.cc;h=4cda80250603be249f0c3dee84e04902294dea77;hb=d7b7862c5a2b5943d1ab8d2211e5b74f09ca6041;hp=db0a5446425c1db6511282deec1105f23cd506e7;hpb=a8369235e23acbacbad414dc1675be8c279e27a2;p=cln.git diff --git a/src/rational/input/cl_RA_read.cc b/src/rational/input/cl_RA_read.cc index db0a544..4cda802 100644 --- a/src/rational/input/cl_RA_read.cc +++ b/src/rational/input/cl_RA_read.cc @@ -4,7 +4,7 @@ // function code. // General includes. -#include "cl_sysdep.h" +#include "base/cl_sysdep.h" // Specification. #include "cln/rational_io.h" @@ -13,11 +13,12 @@ // Implementation. #include +#include #include "cln/input.h" #include "cln/integer.h" #include "cln/integer_io.h" -#include "cl_I.h" -#include "cln/abort.h" +#include "integer/cl_I.h" +#include "cln/exception.h" namespace cln { @@ -49,7 +50,7 @@ static const char * skip_digits (const char * ptr, const char * string_limit, un if (end_of_parse) \ { *end_of_parse = (ptr); } \ else \ - { if ((ptr) != string_limit) { read_number_junk((ptr),string,string_limit); } } + { if ((ptr) != string_limit) { throw read_number_junk_exception((ptr),string,string_limit); } } const cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse) { @@ -83,12 +84,12 @@ const cl_RA read_rational (const cl_read_flags& flags, const char * string, cons goto not_rational_syntax; var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr); if (!((base >= 2) && (base <= 36))) { - fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not "); - fprint(std::cerr, base); - fprint(std::cerr, "\n"); - cl_abort(); + std::ostringstream buf; + fprint(buf, "Base must be an integer in the range from 2 to 36, not "); + fprint(buf, base); + throw runtime_exception(buf.str()); } - rational_base = FN_to_UL(base); ptr = base_end_ptr; + rational_base = FN_to_UV(base); ptr = base_end_ptr; break; } ptr++; @@ -98,7 +99,7 @@ const cl_RA read_rational (const cl_read_flags& flags, const char * string, cons var cl_signean sign = 0; if (ptr == string_limit) goto not_rational_syntax; switch (*ptr) { - case '-': sign = ~sign; + case '-': sign = ~sign; // fallthrough case '+': ptr++; default: break; } @@ -141,13 +142,12 @@ const cl_RA read_rational (const cl_read_flags& flags, const char * string, cons } } not_rational_syntax: -bad_syntax: if (flags.syntax & syntax_maybe_bad) { ASSERT(end_of_parse); *end_of_parse = string; return 0; // dummy return } - read_number_bad_syntax(string,string_limit); + throw read_number_bad_syntax_exception(string,string_limit); } } // namespace cln