Update 1988/westley/try.sh

Allow one to specify CC=foo to compile with a different compiler. If CC
is empty it will be set to 'cc'. One can specify a path in which case
it'll be that path; otherwise the shell will work it out. Of course if
it's not a compiler that's another matter entirely.

Also remove check for 'westley' existing already because 'make' will do
that via the Makefile.

And although not strictly necessary the ints used in the program were
changed to floats as they are floats.

Updated CSILENCE in Makefile.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-14 02:43:14 -08:00
1 parent dd3c3b7f61
commit e71f9d61f7
4 files changed
+21 -11

No files matched your search

+2 -2
View File
@@ -39,7 +39,7 @@ include ../../var.mk
# Common C compiler warnings to silence # Common C compiler warnings to silence
# #
CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-return-type \ CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-return-type \
-Wno-strict-prototypes -Wno-strict-prototypes -Wno-implicit-int
# Common C compiler warning flags # Common C compiler warning flags
# #
@@ -62,7 +62,7 @@ CDEFINE=
# Include files that are needed to compile # Include files that are needed to compile
# #
CINCLUDE= CINCLUDE= -include stdio.h
# Optimization # Optimization
# #
+15 -8
View File
@@ -1,15 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1988/westley
#
clear # 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
if [[ ! -x "westley" ]]; then # way.
echo "$ cc westley.c -o westley" if [[ -z "$CC" ]]; then
cc -std=gnu89 -Wno-error -Wno-implicit-function-declaration -Wno-return-type -O3 westley.c -o westley || exit 1 CC="cc"
fi fi
echo "$ cat westley.c" make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ cat westley.c" 1>&2
cat westley.c cat westley.c
sleep 1 sleep 1
echo "$ ./westley" 1>&2
echo "$ ./westley"
./westley ./westley
+1 -1
View File
@@ -1,5 +1,5 @@
#define _ F-->00||-F-OO--; #define _ F-->00||-F-OO--;
int F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO() float F=00,OO=00;main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{ {
_-_-_-_ _-_-_-_
_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_
+3
View File
@@ -758,6 +758,9 @@ was fixed by Misha Dynin, based on the judges' remarks, so that this would work
with modern C compilers. We encourage you to try the alternate version to see with modern C compilers. We encourage you to try the alternate version to see
what happens with current compilers! See the README.md files for details. what happens with current compilers! See the README.md files for details.
Cody changed the `int`s to be `float` as that's what they are printed as: not
strictly necessary but nonetheless more correct, even if not warned against.
Cody added the [try.sh](1988/westley/try.sh) script to show the magic of the Cody added the [try.sh](1988/westley/try.sh) script to show the magic of the
entry as seeing the code with the result at once is far more beautiful. entry as seeing the code with the result at once is far more beautiful.