Updates to 1989/westley

I have tried to make the README.md file less cluttered wrt the clang
defects and instead just show how to use the entry, referring to the
bugs.md for those who need to know.

Added script compile.sh which generates the files and tries to compile
them. The script sleeps (by default approximately 1 second) in between
commands but this can be changed to another value (including 0). One can
also change the compiler path in case their compiler is clang or in the
case of macOS gcc IS clang. The README.md refers to this and gives
examples.

The bugs.md and the thanks-for-fixes.md files have been updated for
these changes and additions.

For those who do not know of the clang defects it is discussed in the
bugs.md and unfortunately for this entry there might be little that can
be done. I haven't tried to understand the entry deeply and maybe doing
so would give some ideas for fixes (beyond what I already did which lets
the main program compile with clang - or at least versions that allow a
fourth arg to main()) but this seems less important for now.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-07 07:10:06 -07:00
1 parent ef456bfb1e
commit 4ef3afcd74
4 files changed
+134 -29

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
#
# compile.sh - compile westley.c, generate the alt versions and then attempt to
# compile them.
#
# To change what compiler is used you can do something like:
#
# CC=/path/to/cc ./compile.sh
#
# The following example was run on a MacBook Pro with the M1 Max which which
# could not normally compile everything because macOS's compiler, even when run
# as gcc, is actually clang:
#
# CC=/opt/local/bin/gcc-mp-12 ./compile.sh
#
# We sleep (by default) for approximately 1 second after each command so that
# the you can read what is being done. If this is too fast you can change it in
# a similar way to the above but using the variable DELAY like so:
#
# DELAY=2 ./compile.sh
#
# You can of course use both variables in the same command line like:
#
# CC=/opt/local/bin/gcc-mp-12 DELAY=2 ./compile.sh
# DELAY=2 CC=/opt/local/bin/gcc-mp-12 ./compile.sh
#
# ...and so on.
# get the compiler using default cc if not specified in the command line
#
# we cannot use the form '${CC:=cc}' because at least in some versions of bash
# it tries to invoke the command which would be an error by itself. Thus we just
# check if it's empty before we set it.
if [[ -z "$CC" ]]; then
CC="cc"
fi
# get sleep duration
# we cannot use the form '${DELAY:=5}' because at least in some versions of bash
# it tries to invoke the command and obviously that won't work. Thus we check if
# it's empty before setting the default.
if [[ -z "$DELAY" ]]; then
DELAY=2
fi
# make clobber to make the directory clean and then compile westley which we
# need to run everything else. Exit if make westley fails as there would be
# nothing further that could be done in that case:
echo "$ make clobber westley"
sleep "$DELAY"
make CC="$CC" clobber westley || exit 1
sleep "$DELAY"
# run commands previously in the try section of the README.md, showing what the
# commands are as we go:
echo "$ ./westley < westley.c > ver0.c" 1>&2
./westley < westley.c > ver0.c
sleep "$DELAY"
echo "$ ./westley 1 < westley.c > ver1.c" 1>&2
./westley 1 < westley.c > ver1.c
sleep "$DELAY"
echo "$ ./westley 1 2 < westley.c > ver2.c" 1>&2
./westley 1 2 < westley.c > ver2.c
sleep "$DELAY"
echo "$ ./westley 1 2 3 < westley.c > ver3.c" 1>&2
./westley 1 2 3 < westley.c > ver3.c
sleep "$DELAY"
# now compile the files by running make alt
#
echo "Compiling alt versions ..." 1>&2
sleep "$DELAY"
echo "$ make CC=$CC alt" 1>&2
sleep "$DELAY"
make CC="$CC" alt