#include "cl_sysdep.h"
// Specification.
-#include "cl_real_io.h"
+#include "cln/real_io.h"
// Implementation.
-#include "cl_io.h"
+#include "cln/io.h"
#include "cl_spushstring.h"
-#include "cl_input.h"
+#include "cln/input.h"
+
+namespace cln {
// We read an entire token (or even more, if it begins with #C) into a
// buffer and then call read_real() on the buffer.
char* end_pointer (void) { return buffer+index; }
};
-static cl_boolean number_char_p (char c)
+static bool number_char_p (char c)
{
if ((c >= '0') && (c <= '9'))
- return cl_true;
+ return true;
if (((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')))
- return cl_true;
+ return true;
switch (c) {
- case '+': case '-': case '.': case '/':
- return cl_true;
+ case '+': case '-': case '.': case '_': case '/':
+ return true;
default:
- return cl_false;
+ return false;
}
}
-const cl_R read_real (cl_istream stream, const cl_read_flags& flags)
+const cl_R read_real (std::istream& stream, const cl_read_flags& flags)
{
// One pre-allocated buffer. This reduces the allocation/free cost.
static pushstring_hack buffer;
}
if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))))
goto syntax1;
- buffer.push(c);
c = freadchar(stream);
if (c == cl_EOF) goto eof;
}
// Handle syntax error.
syntax1: buffer.push(c);
- read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+ throw read_number_bad_syntax_exception(buffer.start_pointer(),buffer.end_pointer());
// Handle premature EOF.
-eof: read_number_eof();
+eof: throw read_number_eof_exception();
}
+
+} // namespace cln