Index: ChangeLog
===================================================================
RCS file: /home/cvs/cln/ChangeLog,v
retrieving revision 1.171
diff -u -r1.171 ChangeLog
--- ChangeLog	8 Apr 2007 21:29:47 -0000	1.171
+++ ChangeLog	17 May 2007 22:37:32 -0000
@@ -1,3 +1,8 @@
+2007-05-xx  Richard B. Kreckel  <kreckel@ginac.de>
+
+	Remove exception hooks in favor of C++ exceptions:
+	* ...
+
 2007-04-09  Richard B. Kreckel  <kreckel@ginac.de>
 
 	More memory efficient constants:
Index: NEWS
===================================================================
RCS file: /home/cvs/cln/NEWS,v
retrieving revision 1.28
diff -u -r1.28 NEWS
--- NEWS	2 Apr 2007 20:41:11 -0000	1.28
+++ NEWS	17 May 2007 22:37:33 -0000
@@ -1,10 +1,11 @@
-2006-mm-dd, version 1.2.0
+2007-mm-dd, version 1.2.0
 =========================
 
 Implementation changes
 ----------------------
 
 * Added support for huge numbers...
+* CLN now uses C++ exceptions for error handling.
 * Dropped the cln-config script. Please use pkg-config instead.
 
 
Index: include/cln/number_io.h
===================================================================
RCS file: /home/cvs/cln/include/cln/number_io.h,v
retrieving revision 1.1
diff -u -r1.1 number_io.h
--- include/cln/number_io.h	28 Aug 2000 22:08:04 -0000	1.1
+++ include/cln/number_io.h	17 May 2007 22:37:33 -0000
@@ -3,6 +3,8 @@
 #ifndef _CL_NUMBER_IO_H
 #define _CL_NUMBER_IO_H
 
+#include <stdexcept>
+
 #include "cln/io.h"
 #include "cln/number.h"
 
@@ -10,26 +12,29 @@
 
 // Input.
 
+class read_number_error : public std::runtime_error {
+public:
+	explicit read_number_error(const std::string & what)
+		: std::runtime_error(what) {}
+};
+
 // Finish with bad syntax.
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, read_number_bad_syntax, (const char * string, const char * string_limit));
-#else
-extern void read_number_bad_syntax (const char * string, const char * string_limit);
-#endif
+class read_number_bad_syntax : public read_number_error {
+public:
+	explicit read_number_bad_syntax(const char * string, const char * string_limit);
+};
 
 // Finish with junk after the number.
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, read_number_junk, (const char * string_rest, const char * string, const char * string_limit));
-#else
-extern void read_number_junk (const char * string_rest, const char * string, const char * string_limit);
-#endif
+class read_number_junk : public read_number_error {
+public:
+	explicit read_number_junk(const char * string_rest, const char * string, const char * string_limit);
+};
 
 // Finish with EOF.
-#ifdef _CL_MACROS_H
-nonreturning_function(extern, read_number_eof, (void));
-#else
-extern void read_number_eof (void);
-#endif
+class read_number_eof : public read_number_error {
+public:
+	explicit read_number_eof();
+};
 
 struct cl_read_flags;
 
Index: src/base/input/cl_read_err_bad.cc
===================================================================
RCS file: /home/cvs/cln/src/base/input/cl_read_err_bad.cc,v
retrieving revision 1.3
diff -u -r1.3 cl_read_err_bad.cc
--- src/base/input/cl_read_err_bad.cc	24 Nov 2000 20:51:20 -0000	1.3
+++ src/base/input/cl_read_err_bad.cc	17 May 2007 22:37:34 -0000
@@ -9,18 +9,25 @@
 
 // Implementation.
 
+#include <sstream>
 #include "cln/io.h"
 #include "cln/abort.h"
 
 namespace cln {
 
-void read_number_bad_syntax (const char * string, const char * string_limit)
+static inline const std::string
+read_number_bad_syntax_msg (const char * string, const char * string_limit)
 {
-	fprint(std::cerr, "Illegal number syntax: \"");
+	std::ostringstream buf;
+	fprint(buf, "Illegal number syntax: \"");
 	for (const char * ptr = string; ptr != string_limit; ptr++)
-		fprintchar(std::cerr, *ptr);
-	fprint(std::cerr, "\"\n");
-	cl_abort();
+		fprintchar(buf, *ptr);
+	fprint(buf, "\"");
+	return buf.str();
 }
 
+read_number_bad_syntax::read_number_bad_syntax (const char * string, const char * string_limit)
+	: read_number_error(read_number_bad_syntax_msg(string, string_limit))
+{}
+
 }  // namespace cln
Index: src/base/input/cl_read_err_eof.cc
===================================================================
RCS file: /home/cvs/cln/src/base/input/cl_read_err_eof.cc,v
retrieving revision 1.3
diff -u -r1.3 cl_read_err_eof.cc
--- src/base/input/cl_read_err_eof.cc	24 Nov 2000 20:51:20 -0000	1.3
+++ src/base/input/cl_read_err_eof.cc	17 May 2007 22:37:34 -0000
@@ -14,10 +14,8 @@
 
 namespace cln {
 
-void read_number_eof (void)
-{
-	fprint(std::cerr, "read_number: end of stream encountered\n");
-	cl_abort();
-}
+read_number_eof::read_number_eof ()
+	: read_number_error("read_number: end of stream encountered")
+{}
 
 }  // namespace cln
Index: src/base/input/cl_read_err_junk.cc
===================================================================
RCS file: /home/cvs/cln/src/base/input/cl_read_err_junk.cc,v
retrieving revision 1.3
diff -u -r1.3 cl_read_err_junk.cc
--- src/base/input/cl_read_err_junk.cc	24 Nov 2000 20:51:20 -0000	1.3
+++ src/base/input/cl_read_err_junk.cc	17 May 2007 22:37:34 -0000
@@ -9,23 +9,30 @@
 
 // Implementation.
 
+#include <sstream>
 #include "cln/io.h"
 #include "cln/abort.h"
 
 namespace cln {
 
-void read_number_junk (const char * string_rest, const char * string, const char * string_limit)
+static inline const std::string
+read_number_junk_msg (const char * string_rest, const char * string, const char * string_limit)
 {
-	fprint(std::cerr, "Junk after number: ");
+	std::ostringstream buf;
+	fprint(buf, "Junk after number: ");
 	{ for (const char * ptr = string; ptr != string_rest; ptr++)
-		fprintchar(std::cerr, *ptr);
+		fprintchar(buf, *ptr);
 	}
-	fprint(std::cerr, "\"");
+	fprint(buf, "\"");
 	{ for (const char * ptr = string_rest; ptr != string_limit; ptr++)
-		fprintchar(std::cerr, *ptr);
+		fprintchar(buf, *ptr);
 	}
-	fprint(std::cerr, "\"\n");
-	cl_abort();
+	fprint(buf, "\"");
+	return buf.str();
 }
 
+read_number_junk::read_number_junk (const char * string_rest, const char * string, const char * string_limit)
+	: read_number_error(read_number_junk_msg(string_rest, string, string_limit))
+{}
+
 }  // namespace cln
Index: src/complex/input/cl_N_read.cc
===================================================================
RCS file: /home/cvs/cln/src/complex/input/cl_N_read.cc,v
retrieving revision 1.8
diff -u -r1.8 cl_N_read.cc
--- src/complex/input/cl_N_read.cc	24 Apr 2006 22:55:26 -0000	1.8
+++ src/complex/input/cl_N_read.cc	17 May 2007 22:37:35 -0000
@@ -59,7 +59,7 @@
   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((ptr),string,string_limit); } }
 
 const cl_N read_complex (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
 {
@@ -297,7 +297,7 @@
 		*end_of_parse = string;
 		return 0; // dummy return
 	}
-	read_number_bad_syntax(string,string_limit);
+	throw read_number_bad_syntax(string,string_limit);
 }
 
 static const cl_N read_complex_number_rest (const cl_read_flags& flags, const char * string_rest, const char * string, const char * string_limit, const char * * end_of_parse, const cl_R& x)
Index: src/complex/input/cl_N_read_stream.cc
===================================================================
RCS file: /home/cvs/cln/src/complex/input/cl_N_read_stream.cc,v
retrieving revision 1.5
diff -u -r1.5 cl_N_read_stream.cc
--- src/complex/input/cl_N_read_stream.cc	25 Oct 2004 23:19:19 -0000	1.5
+++ src/complex/input/cl_N_read_stream.cc	17 May 2007 22:37:35 -0000
@@ -108,10 +108,10 @@
 
 	// Handle syntax error.
 syntax1:	buffer.push(c);
-syntax:	read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+syntax:	throw read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
 
 	// Handle premature EOF.
-eof:	read_number_eof();
+eof:	throw read_number_eof();
 }
 
 }  // namespace cln
Index: src/float/input/cl_F_read.cc
===================================================================
RCS file: /home/cvs/cln/src/float/input/cl_F_read.cc,v
retrieving revision 1.6
diff -u -r1.6 cl_F_read.cc
--- src/float/input/cl_F_read.cc	11 Dec 2006 17:31:06 -0000	1.6
+++ src/float/input/cl_F_read.cc	17 May 2007 22:37:35 -0000
@@ -51,7 +51,7 @@
   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((ptr),string,string_limit); } }
 
 const cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
 {
@@ -175,7 +175,7 @@
 		*end_of_parse = string;
 		return cl_F(); // dummy return
 	}
-	read_number_bad_syntax(string,string_limit);
+	throw read_number_bad_syntax(string,string_limit);
 }
 
 }  // namespace cln
Index: src/float/input/cl_F_read_stream.cc
===================================================================
RCS file: /home/cvs/cln/src/float/input/cl_F_read_stream.cc,v
retrieving revision 1.5
diff -u -r1.5 cl_F_read_stream.cc
--- src/float/input/cl_F_read_stream.cc	25 Oct 2004 23:19:19 -0000	1.5
+++ src/float/input/cl_F_read_stream.cc	17 May 2007 22:37:36 -0000
@@ -98,10 +98,10 @@
 
 	// Handle syntax error.
 syntax1:	buffer.push(c);
-	read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+	throw read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
 
 	// Handle premature EOF.
-eof:	read_number_eof();
+eof:	throw read_number_eof();
 }
 
 }  // namespace cln
Index: src/integer/input/cl_I_read.cc
===================================================================
RCS file: /home/cvs/cln/src/integer/input/cl_I_read.cc,v
retrieving revision 1.6
diff -u -r1.6 cl_I_read.cc
--- src/integer/input/cl_I_read.cc	22 Mar 2006 21:45:15 -0000	1.6
+++ src/integer/input/cl_I_read.cc	17 May 2007 22:37:36 -0000
@@ -47,7 +47,7 @@
   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((ptr),string,string_limit); } }
 
 const cl_I read_integer (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
 {
@@ -127,7 +127,7 @@
 		*end_of_parse = string;
 		return 0; // dummy return
 	}
-	read_number_bad_syntax(string,string_limit);
+	throw read_number_bad_syntax(string,string_limit);
 }
 
 }  // namespace cln
Index: src/integer/input/cl_I_read_stream.cc
===================================================================
RCS file: /home/cvs/cln/src/integer/input/cl_I_read_stream.cc,v
retrieving revision 1.5
diff -u -r1.5 cl_I_read_stream.cc
--- src/integer/input/cl_I_read_stream.cc	25 Oct 2004 23:19:19 -0000	1.5
+++ src/integer/input/cl_I_read_stream.cc	17 May 2007 22:37:36 -0000
@@ -98,10 +98,10 @@
 
 	// Handle syntax error.
 syntax1:	buffer.push(c);
-	read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+	throw read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
 
 	// Handle premature EOF.
-eof:	read_number_eof();
+eof:	throw read_number_eof();
 }
 
 }  // namespace cln
Index: src/rational/input/cl_RA_read.cc
===================================================================
RCS file: /home/cvs/cln/src/rational/input/cl_RA_read.cc,v
retrieving revision 1.6
diff -u -r1.6 cl_RA_read.cc
--- src/rational/input/cl_RA_read.cc	22 Mar 2006 21:45:15 -0000	1.6
+++ src/rational/input/cl_RA_read.cc	17 May 2007 22:37:37 -0000
@@ -49,7 +49,7 @@
   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((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)
 {
@@ -146,7 +146,7 @@
 		*end_of_parse = string;
 		return 0; // dummy return
 	}
-	read_number_bad_syntax(string,string_limit);
+	throw read_number_bad_syntax(string,string_limit);
 }
 
 }  // namespace cln
Index: src/rational/input/cl_RA_read_stream.cc
===================================================================
RCS file: /home/cvs/cln/src/rational/input/cl_RA_read_stream.cc,v
retrieving revision 1.5
diff -u -r1.5 cl_RA_read_stream.cc
--- src/rational/input/cl_RA_read_stream.cc	25 Oct 2004 23:19:19 -0000	1.5
+++ src/rational/input/cl_RA_read_stream.cc	17 May 2007 22:37:37 -0000
@@ -99,10 +99,10 @@
 
 	// Handle syntax error.
 syntax1:	buffer.push(c);
-	read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+	throw read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
 
 	// Handle premature EOF.
-eof:	read_number_eof();
+eof:	throw read_number_eof();
 }
 
 }  // namespace cln
Index: src/real/input/cl_R_read.cc
===================================================================
RCS file: /home/cvs/cln/src/real/input/cl_R_read.cc,v
retrieving revision 1.8
diff -u -r1.8 cl_R_read.cc
--- src/real/input/cl_R_read.cc	24 Apr 2006 22:55:27 -0000	1.8
+++ src/real/input/cl_R_read.cc	17 May 2007 22:37:38 -0000
@@ -56,7 +56,7 @@
   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((ptr),string,string_limit); } }
 
 const cl_R read_real (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)
 {
@@ -264,7 +264,7 @@
 		*end_of_parse = string;
 		return 0; // dummy return
 	}
-	read_number_bad_syntax(string,string_limit);
+	throw read_number_bad_syntax(string,string_limit);
 }
 
 }  // namespace cln
Index: src/real/input/cl_R_read_stream.cc
===================================================================
RCS file: /home/cvs/cln/src/real/input/cl_R_read_stream.cc,v
retrieving revision 1.5
diff -u -r1.5 cl_R_read_stream.cc
--- src/real/input/cl_R_read_stream.cc	25 Oct 2004 23:19:19 -0000	1.5
+++ src/real/input/cl_R_read_stream.cc	17 May 2007 22:37:38 -0000
@@ -98,10 +98,10 @@
 
 	// Handle syntax error.
 syntax1:	buffer.push(c);
-	read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
+	throw read_number_bad_syntax(buffer.start_pointer(),buffer.end_pointer());
 
 	// Handle premature EOF.
-eof:	read_number_eof();
+eof:	throw read_number_eof();
 }
 
 }  // namespace cln
