diff --git a/M2libc b/M2libc
index daec5ae..222726e 160000
--- a/M2libc
+++ b/M2libc
@@ -1 +1 @@
-Subproject commit daec5ae864c80535dac5d53f83c8718e677b9e2d
+Subproject commit 222726e4f8d6b3898da41e6052a95b6599e1c864
diff --git a/cc.c b/cc.c
index fd5fe12..ec0ab54 100644
--- a/cc.c
+++ b/cc.c
@@ -182,7 +182,7 @@ int main(int argc, char** argv, char** envp)
name = calloc(100, sizeof(char));
strcpy(name, "/tmp/M2-Mesoplanet-XXXXXX");
i = mkstemp(name);
- tempfile = fdopen(i, "w+");
+ tempfile = fdopen(i, "w");
if(NULL != tempfile)
{
/* Our preprocessed crap */
diff --git a/cc_macro.c b/cc_macro.c
index 3cdf397..3b3eb61 100644
--- a/cc_macro.c
+++ b/cc_macro.c
@@ -664,12 +664,21 @@ void macro_directive()
eat_current_token();
STDIO_USED = TRUE;
}
- eat_current_token();
- eat_current_token();
+ }
+ while(TRUE)
+ {
+ if(NULL == macro_token)
+ {
+ return;
+ }
+
+ if('\n' == macro_token->s[0])
+ {
+ return;
+ }
+
eat_current_token();
}
- else
- eat_current_token();
}
else
{
diff --git a/test/test1000/bootstrap.sh b/test/test1000/bootstrap.sh
new file mode 100755
index 0000000..3f5660c
--- /dev/null
+++ b/test/test1000/bootstrap.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+## Copyright (C) 2021 Jeremiah Orians
+## This file is part of M2-Planet.
+##
+## M2-Planet is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## M2-Planet is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with M2-Planet. If not, see .
+
+# Set the folling variables:
+# BUILDDIR for where the tempfiles are to go
+# BINDIR for where the final binary is to go.
+# BLOOD_FLAG for any arguments blood-elf might need
+# ARCH for the system architecture
+# ENDIAN_FLAG for the system endianness
+# BASE_ADDRESS for the system base address
+# TOOLS for where the tools needed to build are located
+# M2LIBC for where M2libc files are located
+
+# Bootstrap build
+${TOOLS}/M2-Planet --architecture ${ARCH} \
+ -f ${M2LIBC}/sys/types.h \
+ -f ${M2LIBC}/stddef.h \
+ -f ${M2LIBC}/${ARCH}/Linux/unistd.h \
+ -f ${M2LIBC}/${ARCH}/Linux/fcntl.h \
+ -f ${M2LIBC}/stdlib.c \
+ -f ${M2LIBC}/stdio.c \
+ -f ${M2LIBC}/bootstrappable.c \
+ -f ${M2LIBC}/string.c \
+ -f cc.h \
+ -f cc_globals.c \
+ -f cc_reader.c \
+ -f cc_core.c \
+ -f cc_macro.c \
+ -f cc_env.c \
+ -f cc_spawn.c \
+ -f cc.c \
+ --debug \
+ -o ${BUILDDIR}/M2-Mesoplanet.M1
+
+${TOOLS}/blood-elf \
+ -f ${BUILDDIR}/M2-Mesoplanet.M1 \
+ ${ENDIAN_FLAG} \
+ --entry _start \
+ -o ${BUILDDIR}/M2-Mesoplanet-footer.M1 ${BLOOD_FLAG}
+
+${TOOLS}/M1 \
+ -f ${M2LIBC}/${ARCH}/${ARCH}_defs.M1 \
+ -f ${M2LIBC}/${ARCH}/libc-full.M1 \
+ -f ${BUILDDIR}/M2-Mesoplanet.M1 \
+ -f ${BUILDDIR}/M2-Mesoplanet-footer.M1 \
+ ${ENDIAN_FLAG} \
+ --architecture ${ARCH} \
+ -o ${BUILDDIR}/M2-Mesoplanet.hex2
+
+${TOOLS}/hex2 \
+ -f ${M2LIBC}/${ARCH}/ELF-${ARCH}-debug.hex2 \
+ -f ${BUILDDIR}/M2-Mesoplanet.hex2 \
+ ${ENDIAN_FLAG} \
+ --architecture ${ARCH} \
+ --base-address ${BASE_ADDRESS} \
+ -o ${BINDIR}/M2-Mesoplanet
diff --git a/test/test1000/run_test.sh b/test/test1000/run_test.sh
new file mode 100755
index 0000000..f8a549f
--- /dev/null
+++ b/test/test1000/run_test.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+## Copyright (C) 2017 Jeremiah Orians
+## Copyright (C) 2020-2021 deesix
+## This file is part of M2-Planet.
+##
+## M2-Planet is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## M2-Planet is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with M2-Planet. If not, see .
+
+set -ex
+
+BUILDDIR="test/test1000/tmp"
+BINDIR="test/test1000/tmp"
+ARCH=$(get_machine)
+M2LIBC="./M2libc"
+TOOLS=" "
+BLOOD_FLAG=$(get_machine --blood)
+BASE_ADDRESS=$(get_machine --hex2)
+ENDIAN_FLAG=$(get_machine --endian)
+
+mkdir -p ${BUILDDIR}
+./test/test1000/bootstrap.sh
+
+## TODO FINISH WRITING TEST