From 42ac9a45ade1332bd99cc9c9e0790a16bd9f0ab8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 05:01:54 -0700 Subject: [PATCH 01/10] Rename how-to-bugfix.md to how-to-help.md This is because it doesn't really say how to fix a bug (how could it when the bugs can be all sorts of different things) but rather a more general how to help with bugs and other things. It's not just bugs but other issues with entries or even the website. Thus how-to-help.md is a better name. --- how-to-help.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 how-to-help.md diff --git a/how-to-help.md b/how-to-help.md new file mode 100644 index 000000000..acaa96877 --- /dev/null +++ b/how-to-help.md @@ -0,0 +1,39 @@ +# How to submit a fix to an IOCCC entry + +If you see a problem with an IOCCC entry, first check the [known bugs](bugs.md) +file. In some cases what you might think of as a bug is instead a known +feature. In some cases the bug is known, but no fix has ever been submitted. +In other cases you may have found a new problem. + +If you do have a fix, and the [known bugs](bugs.md) file **does not recommend +against fixing it**, then please consider opening a [GitHub pull +request](https://github.com/ioccc-src/winner/pulls) against the master +[branch](https://github.com/ioccc-src/winner/branches) of the [ioccc-src/winner +repo](https://github.com/ioccc-src/winner) repo. + +BTW: A **problem** is not limited to the code itself. Fixing typos in files +such as "_README.md_" files, fixing issues in a "_Makefile_", or otherwise +correcting an IOCCC winner is **VERY MUCH WELCOME**! Please use the same +[GitHub pull request](https://github.com/ioccc-src/winner/pulls) process against +the master [branch](https://github.com/ioccc-src/winner/branches) of the +[ioccc-src/winner repo](https://github.com/ioccc-src/winner) repo. + +NOTE: some of the issues in the [bugs.md](/bugs.md) file includes just missing +files and we welcome these too! + +**Please also help us fix typos and / or otherwise improve the write-up** of how +IOCCC winning entries are presented! + +In any event we will happily add you to the +[thanks-for-fixes.md](/thanks-for-fixes.md) file for your help! + +And of course, an IOCCC winner may update their own entries +(metadata as well as source code and any extra files) by opening a +[GitHub pull request](https://github.com/ioccc-src/winner/pulls) +against the master [branch](https://github.com/ioccc-src/winner/branches) +of the [ioccc-src/winner repo](https://github.com/ioccc-src/winner) +repo. + +Note that we're much more inclined to accept an author's fixes but the judges +have the final say in the matter. + From a97374cfb0aff23db99c67c239edb7b4dc7d5fd7 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 05:21:08 -0700 Subject: [PATCH 02/10] Commit how-to-bugfix.md for renaming it --- how-to-bugfix.md | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 how-to-bugfix.md diff --git a/how-to-bugfix.md b/how-to-bugfix.md deleted file mode 100644 index acaa96877..000000000 --- a/how-to-bugfix.md +++ /dev/null @@ -1,39 +0,0 @@ -# How to submit a fix to an IOCCC entry - -If you see a problem with an IOCCC entry, first check the [known bugs](bugs.md) -file. In some cases what you might think of as a bug is instead a known -feature. In some cases the bug is known, but no fix has ever been submitted. -In other cases you may have found a new problem. - -If you do have a fix, and the [known bugs](bugs.md) file **does not recommend -against fixing it**, then please consider opening a [GitHub pull -request](https://github.com/ioccc-src/winner/pulls) against the master -[branch](https://github.com/ioccc-src/winner/branches) of the [ioccc-src/winner -repo](https://github.com/ioccc-src/winner) repo. - -BTW: A **problem** is not limited to the code itself. Fixing typos in files -such as "_README.md_" files, fixing issues in a "_Makefile_", or otherwise -correcting an IOCCC winner is **VERY MUCH WELCOME**! Please use the same -[GitHub pull request](https://github.com/ioccc-src/winner/pulls) process against -the master [branch](https://github.com/ioccc-src/winner/branches) of the -[ioccc-src/winner repo](https://github.com/ioccc-src/winner) repo. - -NOTE: some of the issues in the [bugs.md](/bugs.md) file includes just missing -files and we welcome these too! - -**Please also help us fix typos and / or otherwise improve the write-up** of how -IOCCC winning entries are presented! - -In any event we will happily add you to the -[thanks-for-fixes.md](/thanks-for-fixes.md) file for your help! - -And of course, an IOCCC winner may update their own entries -(metadata as well as source code and any extra files) by opening a -[GitHub pull request](https://github.com/ioccc-src/winner/pulls) -against the master [branch](https://github.com/ioccc-src/winner/branches) -of the [ioccc-src/winner repo](https://github.com/ioccc-src/winner) -repo. - -Note that we're much more inclined to accept an author's fixes but the judges -have the final say in the matter. - From 6f87b6be8f1f1ec1c47e4a969c55bfee4a330494 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 05:24:23 -0700 Subject: [PATCH 03/10] Restore 2012/grothe original code from archive --- 2012/grothe/grothe.orig.c | 51 +++++++++++++++++++++------------------ thanks-for-fixes.md | 3 +++ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/2012/grothe/grothe.orig.c b/2012/grothe/grothe.orig.c index 1d2c651fc..646746991 100644 --- a/2012/grothe/grothe.orig.c +++ b/2012/grothe/grothe.orig.c @@ -2,26 +2,31 @@ #include #include -int u,z,q[0400],O[0x101],o[0401],I[257],w[258][0403],W[0x100],Z[0x103],c[0403],k -,i,j,n,l,p,m;const char*J[0416],*M[0400];FILE*K[280],*s[0x102];void f(char*n,int -a){char*e=n;while(*e!='\0'){if(tolower((int)*e)!=*e)fputc(040,stderr);fputc((*e) --a,stderr);e+=1;}(void)fputc('\n',stderr);}int y(int a,int b);int t(int i,int j) -{int k=i&j,l=i^j,n,m=1;for(n=1;k>=n;n<<=1)if(k&n)m=y(m,1<1 -?y(m,1<>i;++i)for(j=0x0;b>>j;j++)if(((a>>i)&1)&&((b>>j)&1))n^=t(i,j);return w[a][b]=w[ -b][a]=n;}void a(void){for(i=0;i=toupper('0'))&&(T[k][l] -<=tolower('9'));l++){p=p*10+(T[k][l]-'0');if(p>=256)X(1,0);}if(T[k][l]=='-'){for -(m=0;m=256)X(4,0); O[z]=p;M[z]=T[k]+l+1;s[z]= -fopen(M[z],"w");if(!s[z])X(5,0);z++;}else X(6,0);}if(!(u!=0))X(7,0);if(!(z!= 0)) -X(8,0);for(i=0;i>i;++i)for(j=0x0;b>>j;j++)if(((a>>i)&1)&&((b>>j)&1))n^=x[i][j]; +return n;}static void a(void){for(i=0;i= +toupper('0'))&&(T[k][l]<=tolower('9'));l++){p=p*10+(T[k][l]-'0');if(p>=256)X(1,0 +);}if(T[k][l]=='-'){for(m=0;m=256)X(4,0);O[z] +=p;M[z]=T[k]+l+1;s[z]=fopen(M[z],"w");if(!s[z])X(5,0);z++;}else X(6,0);}if(!(u!= +0))X(7,0);if(!(z!=0))X(8,0);for(i=0;i Date: Wed, 25 Oct 2023 05:26:17 -0700 Subject: [PATCH 04/10] Fix typo in 2012/endoh2/find-font-table.rb --- 2012/endoh2/find-font-table.rb | 2 +- thanks-for-fixes.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/2012/endoh2/find-font-table.rb b/2012/endoh2/find-font-table.rb index d3b529048..95108da4d 100644 --- a/2012/endoh2/find-font-table.rb +++ b/2012/endoh2/find-font-table.rb @@ -91,5 +91,5 @@ u, v, d, s = find_params(fonts) puts "Found." puts puts "Let s = %p." % s -puts "You can get the font data of dicimal character 'n' (0--9):" +puts "You can get the font data of decimal character 'n' (0--9):" puts " %d * s[n+10] - %d * s[n] - %d" % [u, v, d] diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 939759f80..3fb9e2fb4 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1963,6 +1963,12 @@ implicitly (linux doesn't seem to but macOS does). Cody added explicit linking of libm (`-lm`) as not all systems do this implicitly (linux doesn't seem to but macOS does). +## [2012/endoh2](2012/endoh2/endoh2.c) ([README.md](2012/endoh2/README.md)) + +Cody fixed a typo in the ruby script +[find-font-table.rb](2012/endoh2/find-font-table.rb). + + ## [2012/grothe](2012/grothe/grothe.c) ([README.md](2012/grothe/README.md)) Cody restored the original code from the archive. From cfca178b140acb6234c06d943a344543d17abaef Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 05:33:37 -0700 Subject: [PATCH 05/10] Improve test script (now scripts) for 1995/garry Added alt test script to use alt code (though in this case it has no real use other than to be complete). It makes sure to compile the alt code before trying to use it, exiting if it fails. The original test script now also makes sure to compile the program before use, exiting if it fails. I also fixed the thanks file with this: I didn't fix the main entry; that already compiled. I had fixed the alt code which did not compile (partly because I agreed with the judges that it looked like a rat dumping core). Why an alt test script instead of just adding an environmental variable like I did with others? Because it felt like it'd be easier to type. It might be that I end up doing this with the scripts I added a way to specify the program, when I come across it, if it seems worth it (which for some it might very well be worth it). --- 1995/garry/README.md | 19 +++++++++++++++++-- 1995/garry/garry.test.sh | 5 ++++- thanks-for-fixes.md | 19 +++++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/1995/garry/README.md b/1995/garry/README.md index 7dc612526..fcb7aacde 100644 --- a/1995/garry/README.md +++ b/1995/garry/README.md @@ -35,13 +35,28 @@ judges noted that the C pre-processed version (with the `#include`s left intact) looked very much like a rat "dropping core". See [garry.alt.c](garry.alt.c) and judge for yourself! -To use try: +#### To build: + ```sh make alt ``` -Use `garry.alt` as you would `garry` above. +#### To use: + +```sh +./garry.alt output_file +``` + +#### Try: + +```sh + +GARRY=garry.alt ./garry.test.sh + +./garry.alt < README.md +``` + ## Judges' remarks: diff --git a/1995/garry/garry.test.sh b/1995/garry/garry.test.sh index a8b33e56d..50adf04aa 100755 --- a/1995/garry/garry.test.sh +++ b/1995/garry/garry.test.sh @@ -1,10 +1,13 @@ #!/usr/bin/env sh # -# garry.test - example of how to use garry +# garry.test.sh - example of how to use garry EXAMPLEON="\33\133\61\73\67\155" EXAMPLEOFF="\33\133\155" DOLLAR="$" export EXAMPLEON EXAMPLEOFF DOLLAR +# make sure code is built, first +make all || exit 1 + ./garry Date: Wed, 25 Oct 2023 05:37:43 -0700 Subject: [PATCH 06/10] Fix 1995/vanschnitz/README.md about LEVEL For some reason when I tried it I had a problem with LEVEL being a certain amount but it must have been something else in the system at the time. Naturally modern systems are much more capable so it can accept a much higher level before it gets slower. Even the judges' statement of 15 causing a slow/bad time is not a problem so I reworded it to remind readers that this was back in 1995 and is no longer the case. --- 1995/vanschnitz/README.md | 12 +++++++----- thanks-for-fixes.md | 10 ++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/1995/vanschnitz/README.md b/1995/vanschnitz/README.md index 871aa2558..679d8f4bf 100644 --- a/1995/vanschnitz/README.md +++ b/1995/vanschnitz/README.md @@ -31,16 +31,18 @@ make clobber all LEVEL=6 The authors provided a spoiler version of the program. Originally uuencoded we have decoded it for the wider audience in [spoiler.c](spoiler.c). The `uuencode`d blob is still available in their remarks below. They encourage you -to first try and figure it out without it. +to first try and figure out the program without the spoiler. ## Judges' remarks: -Warning: in the past, values of LEVEL>8 have been known to cause compilers (and -in one case a system) to crash during compilation. We tested it in 2023 on a -MacBook Pro with the M1 chip and found that LEVEL > 6 caused problems. +Back in 1995, values of `LEVEL>8` caused some compilers (and in one case a +system) to crash during compilation. In 2023 with modern systems this is not +really a problem. + +Back in 1995 we also suggested that for a bad/slow time to try `LEVEL=15` but +this is not a big deal in 2023 either. -For a bad/slow time try LEVEL=15. ## Authors' remarks: diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 60a37d5a3..8ef91315f 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1144,8 +1144,6 @@ easier to see the program do what it does in systems that are too fast ... if there is such a thing anyway :-) ). See the README.md for details on this. - - ## [1995/garry](1995/garry/garry.c) ([README.md](1995/garry/README.md])) Cody fixed the alt code so that it will compile with modern compilers. The @@ -1171,6 +1169,14 @@ which only allows `main()` to have 0, 2 or 3 args. This is done by a new function (`pain()` as it's annoying that clang is this way :-) ) that main() calls which has the four args. +## [1995/vanschnitz](1995/vanschnitz/vanschnitz.c) ([README.md](1995/vanschnitz/README.md)) + +Cody added the authors' spoiler as a C file as in 2023 we have decided that in +most cases all the code should be available for the wider audience, without +having to extract it. The exception is when the files are created by the entry +or the entry decrypts the text or whatever else. + + ## [1996/august](1996/august/august.c) ([README.md](1996/august/README.md])) Cody fixed a segfault in this program that prevented it from working right but From ea2cad4fb89ff242d89d0440b4b60827d66364c7 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 05:56:25 -0700 Subject: [PATCH 07/10] Slight format fixes in 1990/baruch/README.md This file is NOT finished. It should have been committed when making the code look slightly more like the original code. --- 1990/baruch/README.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/1990/baruch/README.md b/1990/baruch/README.md index f8a750f1a..56c3b0dc6 100644 --- a/1990/baruch/README.md +++ b/1990/baruch/README.md @@ -1,15 +1,9 @@ # Best Small Program Baruch Nissenbaum\ -Tel-Aviv University\ -The Faculty of Engineering\ -Tel-Aviv\ Israel Doron Osovlanski\ -CADTECH - CAD/CAM Systems Ltd\ -24 Ben-Yosef St.\ -Givat-Shmuel 51905\ Israel ## To build: @@ -59,7 +53,7 @@ Use `baruch.alt` as you would `baruch`. ## Judges' remarks: -This program reads an integer between 4 and 99 from the stdin. +This program reads an integer between 4 and 99 from the `stdin`. NOTE: The original program did not have a newline at the end of the file. We added a final newline to the file to make unpacking easy. @@ -95,7 +89,7 @@ long enough.. ### For PC users: -In order to compile the program under Turbo-C or MSC, `'int '` should be inserted +In order to compile the program under Turbo-C or MSC, `int ` should be inserted at the beginning of the program. For better looking results it is recommended to replace the `" #Q"` string with `" \261\2"`. From 1cb070de20a8c49b9ea573e06a17c5fa468607f0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 06:00:36 -0700 Subject: [PATCH 08/10] Add missing ':' to Alternate code sections This was done as: sgit -e 's/\(# Alternate code\)$/\1:/g' '*README.md' The heading levels and other things to do with alternate code that are being discussed have not been addressed here. That will come later. This is, as noted, just adding the missing ':' where it was missing. The command does NOT touch it when it is not prefixed with '# ' because there are cases where normal lines end with 'Alternate code' (these will be turned into links later on). --- 1988/dale/README.md | 2 +- 1993/lmfjyh/README.md | 2 +- 2004/arachnid/README.md | 2 +- 2004/hoyle/README.md | 2 +- 2004/kopczynski/README.md | 2 +- 2012/konno/README.md | 2 +- 2012/zeitak/README.md | 2 +- 2015/duble/README.md | 2 +- 2015/howe/README.md | 2 +- 2020/kurdyukov1/README.md | 2 +- 2020/kurdyukov3/README.md | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/1988/dale/README.md b/1988/dale/README.md index 40142f2be..22b06c7b1 100644 --- a/1988/dale/README.md +++ b/1988/dale/README.md @@ -38,7 +38,7 @@ behaviour? ./dale "$(printf "the following files exist in this directory:\n%s\n" *)" ``` -### Alternate code +### Alternate code: If you have an old enough compiler you can try the original version in [dale.alt.c](dale.alt.c). To use: diff --git a/1993/lmfjyh/README.md b/1993/lmfjyh/README.md index 2b532a5d1..6cc947c17 100644 --- a/1993/lmfjyh/README.md +++ b/1993/lmfjyh/README.md @@ -39,7 +39,7 @@ If you have gcc < 2.3.3 (i.e. the entry can compile): ``` -### Alternate code +### Alternate code: To use: diff --git a/2004/arachnid/README.md b/2004/arachnid/README.md index 7a57ff874..76cf1080f 100644 --- a/2004/arachnid/README.md +++ b/2004/arachnid/README.md @@ -36,7 +36,7 @@ QWERTY keyboards. Rogue players, vi users, and Dvorak typists are invited to get lost (or use the alt version)! -### Alternate code +### Alternate code: To use: diff --git a/2004/hoyle/README.md b/2004/hoyle/README.md index eed4d2be9..592c258d4 100644 --- a/2004/hoyle/README.md +++ b/2004/hoyle/README.md @@ -24,7 +24,7 @@ make ./hoyle 2 0 1 0 -0.001 ``` -### Alternate code +### Alternate code: An alternate version of this entry, [hoyle.alt.c](hoyle.alt.c), is provided. This alternate code has a missing newline and used a non-standard tab stop size. diff --git a/2004/kopczynski/README.md b/2004/kopczynski/README.md index fb01eb7c9..decc3c940 100644 --- a/2004/kopczynski/README.md +++ b/2004/kopczynski/README.md @@ -42,7 +42,7 @@ What happens if you feed the program source to the program? Can you figure out why? -### Alternate code +### Alternate code: The judges modified the program to print its result. The original program returned the result as an exit code: diff --git a/2012/konno/README.md b/2012/konno/README.md index 4aa4283ce..560d46e70 100644 --- a/2012/konno/README.md +++ b/2012/konno/README.md @@ -24,7 +24,7 @@ NOTE: N is an integer from 0 to 255. ./konno 30 ``` -### Alternate code +### Alternate code: An alternate version of this entry, [konno.alt.c](konno.alt.c), is provided. This alternate code is an unobfuscated version of the winning code. diff --git a/2012/zeitak/README.md b/2012/zeitak/README.md index 11d86fdad..5c2f48552 100644 --- a/2012/zeitak/README.md +++ b/2012/zeitak/README.md @@ -28,7 +28,7 @@ try [incorrect.c](incorrect.c) and the program itself. NOTE: it prints an error and exits on the first nesting error so it will not detect multiple issues! -### Alternate code +### Alternate code: An alternate version of this entry, [zeitak.alt.c](zeitak.alt.c), is provided. The file [zeitak.alt.c](zeitak.alt.c) provides a version that has been slightly diff --git a/2015/duble/README.md b/2015/duble/README.md index 8fbd72269..d075444fc 100644 --- a/2015/duble/README.md +++ b/2015/duble/README.md @@ -29,7 +29,7 @@ DRAFT=1 ./prog < prog.c ./prog < prog.c ``` -## Alternate code +## Alternate code: An alternate version of this entry, prog.alt.c, is provided. This alternate code is discussed below in the "prog.c vs prog.alt.c" section of the Author's diff --git a/2015/howe/README.md b/2015/howe/README.md index 42b86a960..d6e1d04a3 100644 --- a/2015/howe/README.md +++ b/2015/howe/README.md @@ -44,7 +44,7 @@ cp war-and-peace.txt nuked.tmp ./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp ``` -### Alternate code +### Alternate code: An alternate version of this entry, `prog.alt.c`, is provided. This alternate code does not use a 64 bit FNV hash. diff --git a/2020/kurdyukov1/README.md b/2020/kurdyukov1/README.md index dc2e08681..760148016 100644 --- a/2020/kurdyukov1/README.md +++ b/2020/kurdyukov1/README.md @@ -25,7 +25,7 @@ echo IOCCC | ./prog ./prog < prog.x86_64.asm ``` -### Alternate code +### Alternate code: An even smaller alternate version of this entry, prog.alt.c, is provided. This code does not contain any headers, nor any workaround for WIN32 based platforms. diff --git a/2020/kurdyukov3/README.md b/2020/kurdyukov3/README.md index 20d039f5f..82fb50794 100644 --- a/2020/kurdyukov3/README.md +++ b/2020/kurdyukov3/README.md @@ -28,7 +28,7 @@ echo International Obfuscated C Code Contest | ./prog ./prog < input.txt ``` -### Alternate code +### Alternate code: There is an alternate version of this code in `prog.alt.c` where the main code is a macro. From 2469510d3397fe89a9935ce96c107550f534e7bf Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 07:58:01 -0700 Subject: [PATCH 09/10] Add scripts to 2012/kang Add try.sh which runs the judges' try commands, showing what the commands are and then the output, to simplify trying the entry out. The scripts en.alt.sh and de.alt.sh are like en.sh and de.sh except it defaults to the kang.alt version, which as noted can help one appreciate the entry even more. Although not documented one can specify which version for the alt scripts and the other scripts. --- 2012/kang/README.md | 32 ++++++++++++++++++++++---------- 2012/kang/de.alt.sh | 33 +++++++++++++++++++++++++++++++++ 2012/kang/en.alt.sh | 28 ++++++++++++++++++++++++++++ 2012/kang/try.sh | 18 ++++++++++++++++++ thanks-for-fixes.md | 36 +++++++++++++++++++++++------------- 5 files changed, 124 insertions(+), 23 deletions(-) create mode 100755 2012/kang/de.alt.sh create mode 100755 2012/kang/en.alt.sh create mode 100755 2012/kang/try.sh diff --git a/2012/kang/README.md b/2012/kang/README.md index 4505b8c12..5161fa8fb 100644 --- a/2012/kang/README.md +++ b/2012/kang/README.md @@ -24,11 +24,7 @@ echo "full spelling of an English cardinal numeral less than a quadrillion" | ./ ## Try: ```sh -echo Nineteen hundred and eighty-four | ./kang -echo uno | ./kang -echo trois | ./kang -echo fier | ./kang # notice the issue here, see alternate code instead -echo "shest'" | ./kang +./try.sh # try various languages ./en.sh # English 0 through 13 @@ -42,8 +38,11 @@ How does it have no `u` or `o` in a string in the source code and yet it gets This alternate code fixes the program that would throw off those who know German where the sound of 'V' is 'F' and so the program had the letter be 'F'. A -problem, however, with changing it is that it breaks other words. Thus there is -the alternate version instead which fixes the problem. +problem, however, with changing it is that it breaks other words including in +German. Thus there is the alternate version instead which fixes a problem for +Germans that causes other problems for Germans so if you're German you'll just +have to deal with it :-) It is, however, good as you can appreciate the entry +even more. #### To build: @@ -58,12 +57,12 @@ echo vier | ./kang.alt echo uno | ./kang.alt ``` -#### Also try: +#### Try: ```sh -KANG=kang.alt ./de.sh # German 0 through 13 both with and without umlaut -KANG=kang.alt ./en.sh # English 0 through 13 +./de.alt.sh # German 0 through 13 both with and without umlaut +./en.alt.sh # English 0 through 13 ``` What does it get right? What does it get wrong? How does it compare to the @@ -83,6 +82,19 @@ colloquial year numbers of the last millennium. We've added a linefeed to the print format for convenience. +Can you explain why: + +```sh +echo f hundr|./kang +``` + +correctly reports 500 but: + +```sh +echo hundr|./kang +``` + +does not report 100, instead printing 0? ## Author's remarks: diff --git a/2012/kang/de.alt.sh b/2012/kang/de.alt.sh new file mode 100755 index 000000000..fd5de0723 --- /dev/null +++ b/2012/kang/de.alt.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# +# run 2012/kang with German words for 0 through 13 +# +# For five, fünf, it uses both ue and umlaut (ü) form, and for twelve, zwölf, it +# uses both oe and ö. +# +# What does it get right and what does it get wrong? Why does it get what it +# gets wrong wrong? + +make everything || exit 1 + +# set up path to program if not set +if [[ -z "$KANG" ]]; then + KANG="kang.alt" +fi + +# first set up translation (for those who don't know German): +declare -a NUMBERS +j=0 +for i in 0 1 2 3 4 5 5 6 7 8 9 10 11 12 12 13; do + NUMBERS["$j"]="$i"; + ((j++)) +done + + +j=0 +for i in Null eins zwei drei vier fünf fuenf sechs sieben acht neun zehn elf zwoelf zwölf dreizehn ; \ +do + echo -n "$i (${NUMBERS[$j]}): " + echo "$i"|"./$KANG" + ((j++)) +done diff --git a/2012/kang/en.alt.sh b/2012/kang/en.alt.sh new file mode 100755 index 000000000..afc61e430 --- /dev/null +++ b/2012/kang/en.alt.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# run 2012/kang with English words for 1 through 13 +# +# What does it get right and what does it get wrong? Why does it get what it +# gets wrong wrong? + +make everything || exit 1 + +# set up path to program if not set +if [[ -z "$KANG" ]]; then + KANG="kang.alt" +fi + +declare -a NUMBERS +j=0 +for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13; do + NUMBERS["$j"]="$i"; + ((j++)) +done + +j=0 +for i in zero one two three four five six seven eight nine ten eleven twelve thirteen ; \ +do + echo -n "$i (${NUMBERS[$j]}): " + echo "$i"|"./$KANG" + ((j++)) +done diff --git a/2012/kang/try.sh b/2012/kang/try.sh new file mode 100755 index 000000000..97bec68f4 --- /dev/null +++ b/2012/kang/try.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +make everything || exit 1 + +echo "$ echo Nineteen hundred and eighty-four | ./kang" +echo Nineteen hundred and eighty-four | ./kang + +echo "$ echo uno | ./kang" +echo uno | ./kang + +echo "$ echo trois | ./kang" +echo trois | ./kang + +echo "$ echo fier | ./kang # notice the issue here, see alternate code instead" +echo fier | ./kang # notice the issue here, see alternate code instead + +echo "$ echo \"shest'\" | ./kang" +echo "shest'" | ./kang diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 8ef91315f..f565fb465 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1992,20 +1992,30 @@ Cody restored the original code from the archive. ## [2012/kang](2012/kang/kang.c) ([README.md](2012/kang/README.md])) -Cody added alt code that fixes the problem where in German 'v' sounds like 'f' -which the program has as 'f'. Thus with the original version it would translate -'fier' to '4' when the word is 'vier'. Originally this was updated in the -original code but it was noticed that this caused _other_ words to be incorrect -so it was set as an alt version since the code was already there. It might also -be considered a feature and not a bug so an alt version is the better way to go -about it. Using both allows one to experience different capabilities and also -enjoy or appreciate the entry more. +Cody added alt code that fixes a problem where in German 'v' sounds like 'f' +which the program has as 'f': with the original version it would translate +'fier' to '4' when the word is 'vier'. But see below. -Cody also added two scripts, [en.sh](2012/kang/en.sh) and -[de.sh](2012/kang/de.sh) which counts from 0 through 13 in English and German. -In the German script it uses the umlaut and also does it without the umlaut (add -an 'e'). Both scripts can use either version to see the differences. See the -README.md file for details. +Originally this was updated in the original code but it was noticed that this +caused _other_ German (and maybe other languages?) words to be incorrect so it +was set as an alt version since the code was already there. It might also be +considered a feature and not a bug so an alt version is the better way to go +about it. Using both, however, allows one to experience different capabilities +and also enjoy or appreciate the entry even more, given how simple the +difference is. + +Cody also added five scripts: [en.sh](2012/kang/en.sh), +[de.sh](2012/kang/de.sh), [en.alt.sh](2012/kang/en.alt.sh) and +[de.alt.sh](2012/de.alt.sh) which count from 0 through 13 in English and German +using the original entry and the alt version respectively. + +In the German scripts it uses the umlaut and also does it without the umlaut +(add an 'e'). Notice how the program picks up on this! All scripts can use +either version but the `.alt.sh` versions default to the `alt` version whereas +the other defaults to the submitted entry. See the README.md for details. + +The fifth script, [try.sh](2012/kang/try.sh), runs a sequence of commands to +show different languages and numbers. ## [2012/vik](2012/vik/vik.c) ([README.md](2012/vik/README.md])) From e51a012aa8725deb99f4f27c4523624daddb6443 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:05:21 -0700 Subject: [PATCH 10/10] Add alt code 1989/westley Unfortunately the fix to let the main program compile with clang even breaks some versions generated (see compile.sh) in syntax error so even gcc cannot compile those. Therefore it's now alt code. The alt version will compile with clang and the main feature of the program will work but the program cannot generate every version of the program. The bugs.md and thanks-for-fixes.md have been updated along with the README.md. In the README.md there is a different heading level for the alt code sections to compare to another as we try and figure out what heading levels to use. I changed the delay to 0 in the compile.sh script but one can set it to another value if they like. This entry will have to be worked on more at another time. --- 1989/westley/Makefile | 4 ++-- 1989/westley/README.md | 43 +++++++++++++++++++++++++++++++------- 1989/westley/compile.sh | 8 +++---- 1989/westley/westley.alt.c | 25 ++++++++++++++++++++++ 1989/westley/westley.c | 5 ++--- bugs.md | 42 ++++++++++++++++++------------------- thanks-for-fixes.md | 5 ++++- 7 files changed, 92 insertions(+), 40 deletions(-) create mode 100644 1989/westley/westley.alt.c diff --git a/1989/westley/Makefile b/1989/westley/Makefile index b7f8fffa4..fe541f499 100644 --- a/1989/westley/Makefile +++ b/1989/westley/Makefile @@ -115,8 +115,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= ver0.o ver1.o ver2.o ver3.o -ALT_TARGET= ver0 ver1 ver2 ver3 +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/1989/westley/README.md b/1989/westley/README.md index 09107354b..444c18cbe 100644 --- a/1989/westley/README.md +++ b/1989/westley/README.md @@ -10,9 +10,17 @@ US\ make all ``` +### Bugs and (Mis)features + +This entry a listed in [bugs.md](/bugs.md) as: + +``` +STATUS: main() function args not allowed - please help us fix +STATUS: known bug - please help us fix +``` + +For more detailed information see [bugs.md](/bugs.md#1989westley-readmemd). -NOTE: this entry only partly works with clang and only some versions of clang, -due to defects in the compiler. See [bugs.md](/bugs.md) for more details. ## Try: @@ -51,20 +59,39 @@ Finally try: ```sh ./westley # input some lines of text, sending EOF (usually ctrl-d) to end + +echo IOCCC | ./westley +echo IOCCC | ./westley 1 +echo IOCCC | ./westley 1 2 +echo IOCCC | ./westley 1 2 3 + echo IOCCC | ./ver0 echo Version 1 | ./ver1 echo Version 2 | ./ver2 echo Version 3 | ./ver3 ``` +## Alternate code: -### INAFIAB - it's not a feature it's a bug :-( +The alternate code allows SOME of the features to work with clang but some of +the code it generates (see [compile.sh](compile.sh), which does not use this +version) is not compilable even in gcc let alone clang. Nevertheless the main +feature should work for clang. -There might have been a segfault that was fixed in the original code but as we -no longer know what condition or conditions caused this we cannot be sure. It -seems like, according to various files, that `ver1` and/or `ver2` also have this -problem but we also do not know about the status of this. See -[bugs.md](/bugs.md) for more information. +### To build: + +```sh +make alt +``` + +### Try: + +```sh +echo IOCCC | ./westley.alt +echo IOCCC | ./westley.alt 1 +echo IOCCC | ./westley.alt 1 2 +echo IOCCC | ./westley.alt 1 2 3 +``` diff --git a/1989/westley/compile.sh b/1989/westley/compile.sh index b4d497d72..1366968e9 100755 --- a/1989/westley/compile.sh +++ b/1989/westley/compile.sh @@ -13,9 +13,7 @@ # # 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: +# If you wish to slow down the script you can use the DELAY variable like: # # DELAY=2 ./compile.sh # @@ -36,11 +34,11 @@ if [[ -z "$CC" ]]; then fi # get sleep duration -# we cannot use the form '${DELAY:=5}' because at least in some versions of bash +# we cannot use the form '${DELAY:=0}' 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 + DELAY=0 fi # make clobber to make the directory clean and then compile westley which we diff --git a/1989/westley/westley.alt.c b/1989/westley/westley.alt.c new file mode 100644 index 000000000..92cff6cd2 --- /dev/null +++ b/1989/westley/westley.alt.c @@ -0,0 +1,25 @@ + +/**//*/};)/**/main(/*//**/tang ,gnat/**//*/,ABBA~,0-0(avnz;)0-0,tang,raeN +,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN)char +**gnat, **noon, **raeN;{int gn = gnat, ra = raeN, no = noon; (!tang&& +no!=-1&&(gn&2)&&((raeN&&( getchar(no+0)))||(1-ra&&(trgpune(no +)))))||tang&&znva(/*//**/tang ,tang,tang/**|**//*/((||)))0(enupgrt=raeN +(&&tang!(||)))0(rahcteg=raeN( &&1==tang((&&1-^)gnat=raeN(;;;)tang,gnat +,ABBA,0(avnz;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat +(&&)1-^gnat(&&)1& ABBA(!;)raeN,tang,gnat,ABBA(avnz&&0>ABBA{)raeN +,/**/);}znva(/*//**/tang,gnat,ABBA/**//*/(niam;}1-,78-,611-,321 +-,321-,001-,64-,43-,801-,001-,301-,321-,511-,53-,54,44,34,24 +,14,04,93,83,73,63,53,43,33,85,75,65,55,45,35,25,15,05,94,84 +,74,64,0,0,0,0,0,0,/**/){ABBA='N'==65;(ABBA&&(gnat=trgpune +(0)))||(!ABBA&&(gnat=getchar(0-0)));(--tang&1)&&(gnat='n'<= +gnat&&gnat<='z'||'a'<=gnat&&gnat<='m'||'N'<=gnat&&gnat<='Z' +||'A'<=gnat&&gnat<='M'?(((gnat&/*//**/31/**//*/,21,11,01,9,8 +,7,6,5,4,3,2,1,62,52,42,/**/)+12)%26)+(gnat&/*//**/32/**//*/, +22,12,02,91,81,71,61,51,41{=]652[kri};)/*pry*/)+65:gnat);main +(/*//**\**/tang^tang/**//*/,/* */,~/*//*-*/tang,gnat,ABBA- +0/**//*/(niam&&ABBA||))))tang( rahcteg&&1-1=]652%)191+gnat([kri=gnat diff --git a/bugs.md b/bugs.md index 60a70bf0c..f8c059b40 100644 --- a/bugs.md +++ b/bugs.md @@ -568,26 +568,22 @@ numbers with non-binary digits. ## [1989/westley](1989/westley/westley.c) ([README.md](1989/westley/README.md)) ### STATUS: main() function args not allowed - please help us fix -Although [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for -some of the versions that are generated (see below tip) it will not work for all -with the clang compiler (gcc works fine) and in some versions of clang it will -not work at all due to yet another defect (see below also). +This entry is a big problem for clang due to the way it is designed. Earlier a +change was made to let it compile with clang but although it appeared to work +with gcc, all generated versions (see the README.md for details), this was +either a mistake or it no longer does. + +Thus the original was copied and this does not work at all in clang. It is very +easy to get the first one or two to work with clang but the others result in +compilation failures even besides clang. + +The problems with clang is that it does not allow `int` for any arg in `main()` +except the first one, argc, and some versions of clang do not even allow a +fourth arg at all (0, 2 or 3 args only). Cody noted that trying to fix it in some cases causes a segfault and in other cases it fails to generate some of the files (others are okay) at all (empty -files). - -There is another change that was thought up on 08 July 2023 which allows for -another version to be compiled with clang but it causes some of the versions to -not be correctly generated (whereas the current way does generate all files but -is not compilable with clang) so for now this is not in. If it is put in it will -be an alternate version. - -Some versions of clang have an additional defect where in additional to forcing -the args of `main()` to be of type `int` (for first arg) and the rest to be -`char **` it also does not allow a fourth arg to main(). This in fact is part of -the change thought up on 08 July 2023: main() calls a function which has the old -types of variables. +files). These changes were never committed. Cody gives these tips on the problem: `main()`'s second, third and fourth args (but on fourth arg see above) are supposed to be a `char **`. This didn't use to @@ -597,10 +593,14 @@ to decrypt the function `znva` to be main in _generated files_ (see the [README.md](1989/westley/README.md) for details). Since that function does not have the correct types when converted to main() it -fails to compile. But as he said changing the type causes either a segfault or -files not generated at all. `ver1`, `ver2` and `ver3` are the problematic ones. -The segfault happens when running the main program. Cody fixed that but as noted -as for the generated files only `ver0` will compile with clang. +fails to compile. But as he said changing the type causes either a segfault, +files not generated at all or files ended up with syntax errors. `ver1`, `ver2` +and `ver3` are the problematic ones. + +The file [westley.alt.c](1989/westley/westley.alt.c) will compile with clang +but although it can perform some of its functions it will generate code that +does not work. + ### STATUS: known bug - please help us fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index f565fb465..b8e228244 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -643,7 +643,10 @@ not his only reason :-) ) Cody got some of the versions (the original and `ver0`) to work with some versions of `clang`. Unfortunately there are some defects in `clang` that break -this entry either in full or in part. +this entry either in full or in part. Also, some of the code generated by it +cannot be compiled by gcc either. Thus these changes are in the alt code. +Nevertheless the main features of the program does work in the alt version, it +just cannot generate every C file correctly. Cody provided the compile.sh script to generate the files and then try and compile them (which ones succeed depend on whether or not clang is the