From 6cba59728737842b32077102280642d269b78d90 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 19 Mar 2008 13:39:40 +0100 Subject: [PATCH] Replaced FREE_PASCAL_RTE by a generic EXIT_CODE_HOOK. --- bin/lib | 34 +++++++++++++++++++++------------- config | 9 ++++++--- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/bin/lib b/bin/lib index f0476f2..16afaeb 100644 --- a/bin/lib +++ b/bin/lib @@ -244,20 +244,13 @@ function test-result [ -z "$SG" ] || M="$M (SIG$SG)" fi - # Translate Free Pascal runtime errors to readable strings + # Translate runtime errors to readable strings RE=${M#Exited with error status } - if [ "$FREE_PASCAL_RTE" == 1 -a "$RE" != "$M" ] ; then - N="Runtime error $RE" - case "$RE" in - 200) M="$N: Division by zero" ;; - 201) M="$N: Range check error" ;; - 202) M="$N: Stack overflow" ;; - 203) M="$N: Heap overflow" ;; - 205) M="$N: Floating point overflow" ;; - 215) M="$N: Arithmetic overflow" ;; - 216) M="$N: Segmentation fault" ;; - ???) M="$N" ;; - esac + if [ -n "$EXIT_CODE_HOOK" -a "$RE" != "$M" ] ; then + NEWMSG=`$EXIT_CODE_HOOK $RE` + if [ -n "$NEWMSG" ] ; then + M="Runtime error $RE: $NEWMSG" + fi fi echo "Verdict: $M" @@ -473,3 +466,18 @@ function open-locate fi [ -f "$SDIR/$SRCN" ] || fatal "Output file $SRCN not found" } + +# Translation of runtime error codes for various compilers + +function fpc-exit-code +{ + case "$1" in + 200) echo -n "Division by zero" ;; + 201) echo -n "Range check error" ;; + 202) echo -n "Stack overflow" ;; + 203) echo -n "Heap overflow" ;; + 205) echo -n "Floating point overflow" ;; + 215) echo -n "Arithmetic overflow" ;; + 216) echo -n "Segmentation fault" ;; + esac +} diff --git a/config b/config index 0297a06..052e999 100644 --- a/config +++ b/config @@ -50,6 +50,10 @@ COMP_SANDBOX_OPTS='-m262144 -w60 -e -i/dev/null' # Sandbox initialization commands for compilation COMP_SANDBOX_INIT= +# Translation of runtime errors: a function, which receives the exit code as an argument and +# if it is recognized as a runtime error code, it prints its name to the standard output. +EXIT_CODE_HOOK= + ## Settings for individual languages # C @@ -66,9 +70,8 @@ EXTRA_CXXFLAGS= EXT_p_COMP='/usr/bin/fpc -Ci -Cr -Ct -g -O2 -Sg -o$EXE $EXTRA_PFLAGS $SRC' EXT_pas_COMP="$EXT_p_COMP" EXTRA_PFLAGS= - -# Translate FreePascal exit codes to names of well-known runtime errors -FREE_PASCAL_RTE=1 +EXT_p_EXIT_CODE_HOOK=fpc-exit-code +EXT_pas_EXIT_CODE_HOOK=fpc-exit-code ### Per-task configuration variables (default values, override in per-task config) -- 2.39.2