summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-01-14 09:23:57 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-01-14 09:23:57 -0800
commitfd41d24de546e69d12b2212e6176eb4d0ae1f858 (patch)
tree102e777301a0092eb092abf4eaa449c56052057a
parentb4493f63f7aa851c1205274d64ff92cf90694d76 (diff)
downloadhalt3-fd41d24de546e69d12b2212e6176eb4d0ae1f858.tar.gz
halt3-fd41d24de546e69d12b2212e6176eb4d0ae1f858.tar.bz2
halt3-fd41d24de546e69d12b2212e6176eb4d0ae1f858.zip
Include the deciders after the main program.halt3-1.4
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.
-rwxr-xr-xgenprog.sh10
1 files 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 <<!
ternary halting_decider(const char *, const char *);
-#include "$HALTING_DECIDER"
-
int main(int argc, char **argv)
{
if (argc != 3) {
@@ -159,6 +157,8 @@ int main(int argc, char **argv)
return 0;
}
+
+#include "$HALTING_DECIDER"
!
printf "compiling %s to %s\n" $STANDALONE_DECIDER_BASENAME.c $STANDALONE_DECIDER_BASENAME
gcc $CFLAGS $STANDALONE_DECIDER_BASENAME.c -o $STANDALONE_DECIDER_BASENAME