From 9bce25a02d0f80998b9fd731601a04064546fca6 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 3 Nov 2023 09:40:22 -0700 Subject: [PATCH] Updates to 1990/tbr - alt code Properly document the fact that there is alt code. This involved a note about the fixes in 2023 as the alt code had to have fixes applied too and it was referred to in the description of it (that was not referred to as alt code). I have not yet checked the README.md file for formatting or typo issues. --- 1990/tbr/README.md | 58 +++++++++++++++++++++++++++++++++++++-------- thanks-for-fixes.md | 6 +++-- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/1990/tbr/README.md b/1990/tbr/README.md index 58adf3059..3784fd566 100644 --- a/1990/tbr/README.md +++ b/1990/tbr/README.md @@ -13,6 +13,27 @@ US make all ``` +There is an [alternate version](#alternate-code) to this program. + + +### A note about the fixes of this entry in 2023: + +In 2023 it was noticed that in some systems like macOS there was confusing +output due to a warning at runtime that was interspersed with the output of the +program. For instance it would show: + +```sh +$ ./tbr +$ warning: this program uses gets(), which is unsafe. +``` + +which kind of hid the prompt. Thus the entry was changed to use `fgets(3)` which +is referred to later in this file. + +Also `exit(3)` returns void but the entry was using it in a binary expression so +this entry would not compile in modern systems. This fix is also referred to +below, in the [alternate version](#alternate-code) section. + ## To use: @@ -54,14 +75,7 @@ The authors include a section called [BUGS](#bugs) that, because they were documented, are not considered bugs as such in the context of the contest. -## Judges' remarks: - -This program touches on a well known Unix utility, the 6th edition Bourne Shell -(`/bin/sh`), whose original source was considered to be extremely obfuscated by -many people (although Steve Bourne might disagree). Did you know that the Bourne -Shell source was a major inspiration for the formation of the IOCCC back in -1984? - +## Alternate code: The authors supplied us with a slightly smaller unformatted version of the program which we include below: @@ -79,8 +93,32 @@ r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):5;} ``` -It has the `exit()` returns void fix as well as the `gets()` to `fgets()` fix -applied to it to make it functionally equivalent like the authors intended. +and in the [alternate source](tbr.alt.c). It has the `exit()` returns void fix +as well as the `gets()` to `fgets()` fix applied to it to make it functionally +equivalent like the authors intended. + + +### Alternate build: + +```sh +make alt +``` + + +### Alternate use: + +```sh +./tbr.alt +``` + + +## Judges' remarks: + +This program touches on a well known Unix utility, the 6th edition Bourne Shell +(`/bin/sh`), whose original source was considered to be extremely obfuscated by +many people (although Steve Bourne might disagree). Did you know that the Bourne +Shell source was a major inspiration for the formation of the IOCCC back in +1984? ## Authors' remarks: diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 4d0aed584..9bb649664 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1000,8 +1000,10 @@ like the same as the original. Additionally, Cody fixed the shortened version provided by the author in the same way as the original entry, first the compile fix and then later on making it look more like the original by redefining `exit` and also redefining `gets()` -to be `fgets()` in the same way that the original entry is. This way the alt -version is equivalent in function, like the author intended, but more compact. +to be `fgets()` in the same way that the original entry is. This way the [alt +version](1990/tbr/README.md#alternate-code) is equivalent in function, like the +author intended, but more compact. + ## [1990/theorem](1990/theorem/theorem.c) ([README.md](1990/theorem/README.md]))