Change how 1985/sicherman alt code is managed
Removed the original sicherman.alt.c (which was the original code that requires -traditional-cpp or an older compiler) and make sicherman.alt2.c it instead which is a slight modification of sicherman.c: it has two args to main() in case some compilers (like clang) eventually object to having one arg (like it does for 4 args and claims it does for 1 even though it does not). Since the sicherman.alt.c is built automatically if compilation fails in the sicherman rule it will compile to sicherman. However if it is built manually like 'make alt' then it's built as sicherman.alt. This makes it easier to use but also allows one to build the alt version should they wish and not have it overwrite sicherman. The try.alt.sh script was added in the case of manual compilation of sicherman.alt.c.
This commit is contained in:
1 parent
5292717f04
commit
8ad90e157e
6 files changed
+77
-61
No files matched your search
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.alt.sh - demonstrate IOCCC winner 1985/sicherman.alt alt code
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c: "
|
||||
echo 1>&2
|
||||
./sicherman.alt < sicherman.alt.c
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: echo IOCCC | ./sicherman.alt: "
|
||||
echo 1>&2
|
||||
echo IOCCC | ./sicherman.alt
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt: "
|
||||
echo 1>&2
|
||||
./sicherman.alt < sicherman.alt.c | ./sicherman.alt
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c: "
|
||||
echo 1>&2
|
||||
./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c
|
||||
Reference in new issue
Block a user