From fd41d24de546e69d12b2212e6176eb4d0ae1f858 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 14 Jan 2015 09:23:57 -0800 Subject: Include the deciders after the main program. The deciders could cheat by defining macros that affect the behavior of later code. So we put them after the main function and in particular, the halting_decider is placed last in the program so its macros are of no consequence. --- genprog.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/genprog.sh b/genprog.sh index bf941ee..6a78a2b 100755 --- a/genprog.sh +++ b/genprog.sh @@ -75,9 +75,6 @@ int error_decider(const char *, const char *, const char *); #define PG_SELF PG_BASE ".c" #define HD_NAME "$HALTING_DECIDER" -#include "$ERROR_DECIDER" -#include "$HALTING_DECIDER" - int main(int argc, char **argv) { const char *input; @@ -120,6 +117,9 @@ int main(int argc, char **argv) puts("internal error"); abort(); } + +#include "$ERROR_DECIDER" +#include "$HALTING_DECIDER" ! printf "compiling %s to %s\n" $PROGRAM_BASENAME.c $PROGRAM_BASENAME @@ -135,8 +135,6 @@ cat > $STANDALONE_DECIDER_BASENAME.c <