From 9c94c7df738784c13fd1a06a1ef967de76ddcbbd Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 06:20:41 -0800 Subject: [PATCH 01/10] Fix 1990/jaw/Makefile, improve try.sh + bugs.md The optimiser was left disabled by accident. The try.sh now adds another file in the archive. Add entry to bugs.md. There are two issues, or at least one. One issue might not be an issue but it appears to be. The one that appears to be was supposed to be added to the bugs.md file ages ago but was missed by accident. --- 1990/jaw/Makefile | 2 +- 1990/jaw/try.sh | 2 +- bugs.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/1990/jaw/Makefile b/1990/jaw/Makefile index d0a88b309..86fa254e4 100644 --- a/1990/jaw/Makefile +++ b/1990/jaw/Makefile @@ -67,7 +67,7 @@ CINCLUDE= # Optimization # -OPT= +OPT= -O3 # Default flags for ANSI C compilation # diff --git a/1990/jaw/try.sh b/1990/jaw/try.sh index 84e6591ae..1398ce7aa 100755 --- a/1990/jaw/try.sh +++ b/1990/jaw/try.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash echo "Running shark.sh:" -./shark.sh shark.sh README.md jaw.c try.sh > receive || exit 1 +./shark.sh atob shark.sh README.md jaw.c try.sh > receive || exit 1 echo "Done." diff --git a/bugs.md b/bugs.md index 9e1f65e40..e805b2da8 100644 --- a/bugs.md +++ b/bugs.md @@ -667,6 +667,60 @@ Enjoy! :-) # 1990 +## 1990 jaw + +### STATUS: known bug - please help us fix +### Source code: [1990/jaw/jaw.c](1990/jaw/jaw.c) +### Information: [1990/jaw/README.md](1990/jaw/README.md) + +[Cody Boone Ferguson](https://www.ioccc.org/winners.html#Cody_Boone_Ferguson) +fixed some issues in this program and [Yusuke +Endoh](https://www.ioccc.org/winners.html#Yusuke_Endoh) provided the `btoa` +script but it appears there is a bug in this entry. The judges wrote that to +test the entry one can do: + +```sh +echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw +``` + +which should apply the identity transformation to a minimal holoalphabetic +sentence. + +But doing this shows instead: + +```sh +echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw +a얖?)V...?????777??hC??h??-? )SSSSXXX????r?L=???*?-???ppp,,,?R +?j +111-)))? '..F@E + ???b111? +..F..F.?n,,,,,L@E$ +``` + +Notice how there's no newline at the end: that final `$` is the prompt. + +If one does, however: + +```sh +echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw | ./jaw +``` + +they will get just + +``` +oops +``` + +which seems to be an error message (one of the fixes was to make it not use +`perror(3)` - this fixed something else though it's no longer known what). + +The script [shark.sh](/1990/jaw/shark.sh) has some issues too in that due to +path not having `.` (this and maybe some other things were fixed) and `tar` not +wanting to accept reading from `stdin` (this in particular) even with the right +options used, seemingly, it has to write to disk the tarball which seems to +defeat the purpose. This would ideally be fixed. + + ## 1990 theorem ### STATUS: INABIAF - please **DO NOT** fix From fed6b32f0a19fd49178222bf7f923f7423db0005 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 08:26:07 -0800 Subject: [PATCH 02/10] Remove redundancy in 2000/tomx/try.sh After doing make all || exit 1 it checked for the existence of tomx and it being executable but that should not be necessary after compilation. --- 2000/tomx/try.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/2000/tomx/try.sh b/2000/tomx/try.sh index e3bb764dc..82e9dcdc8 100755 --- a/2000/tomx/try.sh +++ b/2000/tomx/try.sh @@ -15,11 +15,6 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -if [[ ! -f "tomx" || ! -e "tomx" ]]; then - echo "Compiling tomx.c:" 1>&2 - make all || exit 1 -fi - echo "Running tomx:" 1>&2 echo "$ ./tomx" 1>&2 ./tomx From 54c5271117e2ef5040db002a349fa56af9512e43 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:07:37 -0800 Subject: [PATCH 03/10] Add 1992/gson/try.sh, add note about optimiser The optimiser must be disabled due to it otherwise crashing in macOS in some invocations. This has been added to the Makefile, the use of -O0 is forced and a note has been added to the README.md file. The bugs.md file has been updated on details of how it uses gets() and that text has been removed from the thanks file. Minor format fixes in README.md. The script added makes use of the author's script (that I added as mkdict.sh for easier use) after first trying to find a dictionary file. But one can override the dictionary file with the DICT environmental variable. This entry should now truly be done. --- 1992/gson/Makefile | 11 ++-- 1992/gson/README.md | 7 ++- 1992/gson/try.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++ bugs.md | 13 ++++- thanks-for-help.md | 24 ++++----- 5 files changed, 158 insertions(+), 20 deletions(-) create mode 100755 1992/gson/try.sh diff --git a/1992/gson/Makefile b/1992/gson/Makefile index 860cc36a2..9c28a4e73 100644 --- a/1992/gson/Makefile +++ b/1992/gson/Makefile @@ -42,7 +42,7 @@ CSILENCE= -Wno-bitwise-op-parentheses -Wno-char-subscripts \ -Wno-deprecated-declarations -Wno-empty-body -Wno-error \ -Wno-implicit-function-declaration -Wno-parentheses -Wno-pedantic \ -Wno-return-type -Wno-unused-parameter -Wno-unused-value \ - -Wno-deprecated-non-prototype + -Wno-deprecated-non-prototype -Wno-implicit-int # Common C compiler warning flags # @@ -69,7 +69,9 @@ CINCLUDE= # Optimization # -OPT= +# We DISABLE the optimiser because having it enabled will cause a crash in some +# invocations in some systems. +OPT= -O0 # Default flags for ANSI C compilation # @@ -133,8 +135,11 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto +# We DISABLE THE OPTIMISER because when it's enabled in some conditions it +# crashes. +# ${PROG}: ${PROG}.c - ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} -O0 $< -o $@ ${LDFLAGS} ag: ${PROG} ${RM} -f $@ diff --git a/1992/gson/README.md b/1992/gson/README.md index 743386ab9..914027a1c 100644 --- a/1992/gson/README.md +++ b/1992/gson/README.md @@ -4,6 +4,10 @@ make all ``` +NOTE: we DISABLE the optimiser because having it enabled causes some invocations +to crash in some systems. + + ### Bugs and (Mis)features: The current status of this entry is: @@ -127,13 +131,14 @@ Instead, it tries to achieve both its speed and its obscurity through a careful choice of algorithms. Some of the finer points of those algorithms are outlined in the spoiler below. + ### How it works: Here follows a description of some of the data structures and algorithms used by AG. It is by no means complete, but it may help you get an idea about the general principles. --- +--- Internally, AG represents words and sentences as arrays of 32 4-bit integer elements. Each element represents the number of diff --git a/1992/gson/try.sh b/1992/gson/try.sh new file mode 100755 index 000000000..04c9b17bf --- /dev/null +++ b/1992/gson/try.sh @@ -0,0 +1,123 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1992/gson +# + +# 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 + +# attempt to find a dictionary file if DICT unset or not a regular readable file +# +if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then + DICT="/usr/share/dict/words" + + if [[ ! -r "$DICT" ]]; then + DICT="/usr/share/lib/spell/words" + + if [[ ! -r "$DICT" ]]; then + DICT="/usr/ucblib/dict/words" + + if [[ ! -r "$DICT" ]]; then + DICT="/dev/null" + fi + fi + fi +fi + +# safety check that DICT is not empty and is a readable file +# +if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then + echo "No dictionary file found, try specifying one like:" 1>&2 + echo 1>&2 + echo " DICT=dict ./try.sh" 1>&2 + echo 1>&2 + exit 1 +fi + +echo "$ ./ag free software foundation < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag obfuscated c contest < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag unix international < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag unix international < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag george bush < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag george bush < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag bill clinton < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag ross perot < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag ross perot < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag paul e tsongas < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF + +# now try making our own dictionary with mkdict.sh: +# +rm -f words +cat README.md try.sh Makefile | ./mkdict.sh > words +DICT="words" + +read -r -n 1 -p "Press any key to use our own dict from mkdict.sh: " +echo 1>&2 + +echo "$ ./ag free software foundation < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag obfuscated c contest < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag unix international < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag unix international < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag george bush < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag george bush < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag bill clinton < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag ross perot < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag ross perot < "$DICT" 2>/dev/null | less -rEXF + +echo "$ ./ag paul e tsongas < $DICT" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF diff --git a/bugs.md b/bugs.md index e805b2da8..28c7d8989 100644 --- a/bugs.md +++ b/bugs.md @@ -893,7 +893,18 @@ problem of `gets()` being used in a more complex way. It would be ideal if it were to use `fgets()` though. This will probably be looked at later but you're welcome to try and fix this too! A tip on how -`gets()` is being used is in the [FAQ](/faq.md#gets) file. +`gets()` is being used from Cody: + +Previously it had a buffer size of 256 which could easily overflow. In this +entry `gets(3)` is used in a more complicated way: first `m` is set to `*++p` in +a for loop where `p` is argv. Later `m` is set to point to `h` which was of size +256. `gets(3)` is called as `m = gets(m)`) but trying to change it to use +`fgets(3)` proved more a problem. Since the input must come from the command +line Cody changed the buffer size to `ARG_MAX+1` which should be enough (again +theoretically) especially since the command expects redirecting a dictionary +file as part of the command line. This also makes it possible for longer strings +to be read (in case the `gets(3)` was not used in a loop). + ## 1992 kivinen diff --git a/thanks-for-help.md b/thanks-for-help.md index 5c9298d79..1403e137b 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -1420,25 +1420,19 @@ commands that we suggested and some additional ones that provide for some fun. [Cody](#cody) fixed a crash that prevented this entry from working in some cases in some systems (like macOS) by disabling the optimiser in the Makefile. -Cody also changed the buffer size in such a way that `gets(3)` should be safe -(theoretically) as it comes from the command line (though it can also read input -from stdin after starting the program). Ideally `fgets(3)` would be used but this -is a more problematic. Previously it had a buffer size of 256 which could -easily overflow. In this entry `gets(3)` is used in a more complicated way: -first `m` is set to `*++p` in a for loop where `p` is argv. Later `m` is set to -point to `h` which was of size 256. `gets(3)` is called as `m = gets(m)`) but -trying to change it to use `fgets(3)` proved more a problem. Since the input must -come from the command line Cody changed the buffer size to `ARG_MAX+1` which -should be enough (again theoretically) especially since the command expects -redirecting a dictionary file as part of the command line. This also makes it -possible for longer strings to be read (in case the `gets(3)` was not used in a -loop). +Cody also added the [try.sh](/1992/gson/try.sh) script. Cody also added the [mkdict.sh](/1992/gson/mkdict.sh) script that the author included in their remarks. See the README.md for its purpose. It was NOT fixed for [ShellCheck](https://github.com/koalaman/shellcheck) -because the author deliberately obfuscated it so **PLEASE DO NOT -FIX THIS**. +because the author deliberately obfuscated it so **PLEASE *DO NOT* FIX THIS OR +MODERNISE IT**. + +Cody also changed the buffer size in such a way that `gets(3)` should be safe +(well, theoretically) as it comes from the command line (though it can also read input +from `stdin` after starting the program). Ideally `fgets(3)` would be used but this +is a more problematic. See [1992/gson in bugs.md](/bugs.md#1992-gson) for more +details if you're interested in trying to understand it (or fix?). ## [1992/imc](/1992/imc/imc.c) ([README.md](/1992/imc/README.md])) From a673c74b9219abf5334766bd9c92089311c03b49 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:16:56 -0800 Subject: [PATCH 04/10] Restore optimiser in 2001/anonymous --- 2001/anonymous/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2001/anonymous/Makefile b/2001/anonymous/Makefile index b22f85dba..ac0ab22e0 100644 --- a/2001/anonymous/Makefile +++ b/2001/anonymous/Makefile @@ -71,7 +71,7 @@ CINCLUDE= # Optimization # -OPT= +OPT= -O3 # Default flags for ANSI C compilation # From e0456a394bae63ff96ec85b402a805b6d7ea2edb Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:41:08 -0800 Subject: [PATCH 05/10] Improve 1992/gson/try.sh Don't exit if it can't find a 'normal' dictionary file, skipping the creation of one from mkdict.sh. Just use the one generated from mkdict.sh if no other file can be opened (which most likely won't happen but it can happen as not all systems have /usr/share/dict/words and the others are unlikely in modern systems). --- 1992/gson/try.sh | 72 ++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/1992/gson/try.sh b/1992/gson/try.sh index 04c9b17bf..b6c813483 100755 --- a/1992/gson/try.sh +++ b/1992/gson/try.sh @@ -35,49 +35,43 @@ fi # safety check that DICT is not empty and is a readable file # -if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then - echo "No dictionary file found, try specifying one like:" 1>&2 +if [[ -n "$DICT" && -f "$DICT" && -r "$DICT" ]]; then + echo "$ ./ag free software foundation < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 - echo " DICT=dict ./try.sh" 1>&2 + ./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF + + echo "$ ./ag obfuscated c contest < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 - exit 1 + ./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF + + echo "$ ./ag unix international < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag unix international < "$DICT" 2>/dev/null | less -rEXF + + echo "$ ./ag george bush < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag george bush < "$DICT" 2>/dev/null | less -rEXF + + echo "$ ./ag bill clinton < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF + + echo "$ ./ag ross perot < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag ross perot < "$DICT" 2>/dev/null | less -rEXF + + echo "$ ./ag paul e tsongas < $DICT" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF fi -echo "$ ./ag free software foundation < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag obfuscated c contest < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag unix international < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag unix international < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag george bush < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag george bush < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag bill clinton < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag ross perot < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag ross perot < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag paul e tsongas < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF - # now try making our own dictionary with mkdict.sh: # rm -f words From d2f02075f6f218201667fed8036c710efb60709e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:47:22 -0800 Subject: [PATCH 06/10] Re-enable optimiser in 2001/williams The bugs.md was updated to remind people when debugging crashes that it would be wise to have -O0 and -g (or if they can -ggdb3). That should be noted in general for debugging but it's especially useful for crashes and I'm trying to get this part done so I can resume 2019. --- 2001/williams/Makefile | 2 +- bugs.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/2001/williams/Makefile b/2001/williams/Makefile index 6e003cf2e..95cf1373a 100644 --- a/2001/williams/Makefile +++ b/2001/williams/Makefile @@ -68,7 +68,7 @@ CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11 # Optimization # -OPT= -ggdb3 +OPT= -O3 # Default flags for ANSI C compilation # diff --git a/bugs.md b/bugs.md index 28c7d8989..d61bffcaa 100644 --- a/bugs.md +++ b/bugs.md @@ -302,6 +302,9 @@ crashes. NOTE: this does NOT apply to entries under the INABIAF status (though they're not mutually exclusive in some cases). +REMINDER: if you're debugging a crash it will be very helpful to have `-O0 -g` +or if you can `-ggdb3` when compiling as that will help with debugging symbols. + ## STATUS: uses gets() - change to fgets() if possible From 526f04d84f354a63de0feb7c014ee4ba6d7c404a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:00:49 -0800 Subject: [PATCH 07/10] Force -O0 in 2004/burley - optimiser breaks it --- 2004/burley/Makefile | 7 +++++-- 2004/burley/README.md | 3 +++ thanks-for-help.md | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/2004/burley/Makefile b/2004/burley/Makefile index fe20f609b..79bc12f3f 100644 --- a/2004/burley/Makefile +++ b/2004/burley/Makefile @@ -66,7 +66,8 @@ CINCLUDE= -include stdio.h -include setjmp.h -include string.h -include time.h - # Optimization # -OPT= +# We DISABLE the optimiser because having it enabled BREAKS the program. +OPT= -O0 # Default flags for ANSI C compilation # @@ -131,8 +132,10 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto +# NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +# will not work with it enabled. ${PROG}: ${PROG}.c - ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} -O0 $< -o $@ ${LDFLAGS} # alternative executable # diff --git a/2004/burley/README.md b/2004/burley/README.md index 8f4e2259e..98c460975 100644 --- a/2004/burley/README.md +++ b/2004/burley/README.md @@ -4,6 +4,9 @@ make ``` +NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +will not work with it enabled. + ## To use: diff --git a/thanks-for-help.md b/thanks-for-help.md index 1403e137b..b9dd4193f 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2665,16 +2665,16 @@ For clang the problem was that `main()` had one arg, a `char *` and this is not allowed in any version of clang. In some versions it is allowed if the arg is an `int` but never if it's anything else. To get it to work took numerous changes. -First the inclusion of `setjmp.h` was necessary. Without this `longjmp()` -implicitly returned int which was used for the purpose of binary expression but +First the inclusion of `setjmp.h` was necessary. Without this `longjmp(3)` +implicitly returned `int` which was used for the purpose of binary expression but this no longer worked. But by including `setjmp.h` it naturally made the binary expressions invalid (as -it returns void which no longer is allowed in binary expressions) so the comma +it returns `void` which is not allowed in binary expressions) so the comma operator with `0` (`,0`) had to be used (`,1` was tried first but this did not work right). -`longjmp()` was being called with one arg which was an element +`longjmp(3)` was being called with one arg which was an element of an `int[4][1000]` which had to be changed to a `jmp_buf p[4]` (this due to the prototype being included). From a2e77e1ca6ddb33a183fc5d2dc25d9fcd8c820b2 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:04:10 -0800 Subject: [PATCH 08/10] Force -O0 in 2004/kopczynski --- 2004/kopczynski/Makefile | 7 +++++-- 2004/kopczynski/README.md | 22 +++++++--------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/2004/kopczynski/Makefile b/2004/kopczynski/Makefile index 589fed63c..a4fdf241e 100644 --- a/2004/kopczynski/Makefile +++ b/2004/kopczynski/Makefile @@ -66,7 +66,8 @@ CINCLUDE= # Optimization # -OPT= +# We DISABLE the optimiser because having it enabled BREAKS the program. +OPT= -O0 # Default flags for ANSI C compilation # @@ -129,8 +130,10 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto +# NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +# will not work with it enabled. ${PROG}: ${PROG}.c - ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} -O0 $< -o $@ ${LDFLAGS} # alternative executable # diff --git a/2004/kopczynski/README.md b/2004/kopczynski/README.md index 2ffcef98c..8d585eae1 100644 --- a/2004/kopczynski/README.md +++ b/2004/kopczynski/README.md @@ -4,6 +4,9 @@ make ``` +NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +will not work with it enabled. + ## To use: @@ -15,22 +18,9 @@ make ### Try: ```sh -./kopczynski < kopczynski-8a -./kopczynski < kopczynski-8b -./kopczynski < kopczynski-8c -./kopczynski < kopczynski-9 -./kopczynski < kopczynski-10 -./kopczynski < kopczynski-11 +./try ``` -Also try: - -```sh -./kopczynski < kopczynski-a -``` - -What happens? - What happens if you feed the program source to the program? Can you figure out why? @@ -38,7 +28,9 @@ why? ## Alternate code: The judges modified the program to print its result. The original -program returned the result as an exit code: +program returned the result as an exit code which is what the alternate version +does. + ### Alternate build: From c7a10649ab593af66d818c29687496d0563ad619 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:07:06 -0800 Subject: [PATCH 09/10] Force -O0 in 2005/giljade - optimiser breaks it --- 2005/giljade/Makefile | 7 +++++-- 2005/giljade/README.md | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/2005/giljade/Makefile b/2005/giljade/Makefile index df5d6c7ae..cb200f713 100644 --- a/2005/giljade/Makefile +++ b/2005/giljade/Makefile @@ -69,8 +69,9 @@ CDEFINE= CINCLUDE= -include stdio.h -include string.h -include unistd.h -include stdlib.h # Optimization +# We DISABLE the optimiser because having it enabled BREAKS the program. # -OPT= +OPT= -O0 # Default flags for ANSI C compilation # @@ -135,8 +136,10 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto +# NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +# will not work with it enabled. ${PROG}: ${PROG}.c - ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} -O0 $< -o $@ ${LDFLAGS} test: ${PROG} test.sh ./test.sh diff --git a/2005/giljade/README.md b/2005/giljade/README.md index 19a2f4fe5..652729ac6 100644 --- a/2005/giljade/README.md +++ b/2005/giljade/README.md @@ -4,6 +4,9 @@ make ``` +NOTE: We FORCE the use of -O0 even if someone overrides it because this entry +will not work with it enabled. + ### Bugs and (Mis)features: From 155b2d54887733af0fd5b63bf1b8fcd3e6b29a79 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 10:08:43 -0800 Subject: [PATCH 10/10] Restore optimiser in 2011/richards --- 2011/richards/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2011/richards/Makefile b/2011/richards/Makefile index d736a7f06..d767f98a4 100644 --- a/2011/richards/Makefile +++ b/2011/richards/Makefile @@ -66,7 +66,7 @@ CINCLUDE= -include stdlib.h -include string.h -include stdio.h -include ctype.h # Optimization # -OPT= +OPT= -O3 # Default flags for ANSI C compilation #