[COMMITTED] algol68: consolidate runtime error messages in libga68

Jose E. Marchesi jemarch@gnu.org
Tue Mar 18 11:32:47 GMT 2025


This patch makes libga68 to emit runtime errors using the same general
form used by other GCC runtime libraries such as the sanitizers.
---
 libga68/ga68-error.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/libga68/ga68-error.c b/libga68/ga68-error.c
index c75b8bd68f7..4a538afca64 100644
--- a/libga68/ga68-error.c
+++ b/libga68/ga68-error.c
@@ -25,7 +25,17 @@
 
 #include "ga68.h"
 
-/* Run-time error handling.  */
+/* Run-time error handling.
+
+   Please use the following format when outputing runtime error messages:
+
+     FILE:LINE:[COLUMN:] TEXT
+
+   This keeps the output aligned with other runtime libraries such as the
+   sanitizers.  */
+
+/* Emit a formatted error message to the standard output and then terminate the
+   process with an error code.  */
 
 void
 _libga68_abort (const char *fmt, ...)
@@ -43,7 +53,7 @@ _libga68_abort (const char *fmt, ...)
 void
 _libga68_assert (const char *filename, unsigned int lineno)
 {
-  _libga68_abort ("run-time error: ASSERT failure at %s:%u\n",
+  _libga68_abort ("%s:%u: runtime error: ASSERT failure\n",
 		 filename, lineno);
 }
 
@@ -52,7 +62,7 @@ _libga68_assert (const char *filename, unsigned int lineno)
 void
 _libga68_derefnil (const char *filename, unsigned int lineno)
 {
-  _libga68_abort ("run-time error: attempt to dereference NIL at %s:%d\n",
+  _libga68_abort ("%s:%d: runtime error: attempt to dereference NIL\n",
 		  filename, lineno);
 }
 
@@ -62,8 +72,8 @@ void
 _libga68_bitsboundserror (const char *filename, unsigned int lineno,
 			  ssize_t pos)
 {
-  _libga68_abort ("run-time error: bound %d out of range in ELEM at %s:%d\n",
-		  pos, filename, lineno);
+  _libga68_abort ("%s:%d: runtime error: bound %d out of range in ELEM\n",
+		  filename, lineno, pos);
 }
 
 /* Unreachable error.  */
@@ -71,7 +81,7 @@ _libga68_bitsboundserror (const char *filename, unsigned int lineno,
 void
 _libga68_unreachable (const char *filename, unsigned int lineno)
 {
-  _libga68_abort ("run-time error: unreachable reached at %s:%d\n",
+  _libga68_abort ("%s:%d: runtime error: unreachable reached\n",
 		  filename, lineno);
 }
 
@@ -80,8 +90,8 @@ _libga68_unreachable (const char *filename, unsigned int lineno)
 void _libga68_lower_bound (const char *filename, unsigned int lineno,
 			   ssize_t index, ssize_t lower_bound)
 {
-  _libga68_abort ("run-time error: lower bound %d must be >= %d at %s:%d\n",
-		  index, lower_bound, filename, lineno);
+  _libga68_abort ("%s:%d: runtime error: lower bound %d must be >= %d\n",
+		  filename, lineno, index, lower_bound);
 }
 
 /* Upper bound failure.  */
@@ -89,8 +99,8 @@ void _libga68_lower_bound (const char *filename, unsigned int lineno,
 void _libga68_upper_bound (const char *filename, unsigned int lineno,
 			   ssize_t index, ssize_t upper_bound)
 {
-  _libga68_abort ("run-time error: upper bound %d must be <= %d at %s:%d\n",
-		  index, upper_bound, filename, lineno);
+  _libga68_abort ("%s:%d: runtime error: upper bound %d must be <= %d\n",
+		  filename, lineno, index, upper_bound);
 }
 
 /* Bounds failure.  */
@@ -99,6 +109,6 @@ void
 _libga68_bounds (const char *filename, unsigned int lineno,
 		 ssize_t index, ssize_t lower_bound, ssize_t upper_bound)
 {
-  _libga68_abort ("run-time error: bound %d out of range [%d:%d] at %s:%d\n",
-		 index, lower_bound, upper_bound, filename, lineno);
+  _libga68_abort ("%s:%d: runtime error: bound %d out of range [%d:%d]\n",
+		  filename, lineno, index, lower_bound, upper_bound);
 }
-- 
2.30.2



More information about the Algol68 mailing list