From be04376fa6b294f4d9aa396edaba989af4417193 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 03:54:49 -0800 Subject: [PATCH 01/12] Minor fixes and clarifications in FAQ This includes typos, inconsistencies as well as updates to referring to an entry to show how clang can complicate matters (sometimes greatly) but making your entries work with clang will make your entry better. --- faq.md | 61 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/faq.md b/faq.md index 816313563..31d8a5f19 100644 --- a/faq.md +++ b/faq.md @@ -863,7 +863,7 @@ make clobber all 'CWARN+= -Weverything' ``` though it should be noted that if one tries `-Weverything` with compilers that -are not `clang` they might see something like: +are not `clang` they _might_ see something like: ```sh echo 'int main(void) {}' > foo.c ; cc -Weverything foo.c -o foo @@ -871,44 +871,68 @@ cc: error: unrecognized command-line option '-Weverything' ``` which means that it can't even be compiled. Thus the proper way to do it is the -first one. +first way, `make clobber all CC=clang`. -IOCCC authors who have access to a `clang` compiler might wish to try they their +IOCCC authors who have access to `clang` might wish to try their hand at compiling with `-Weverything` while using a minimum of `-Wno-foo` statements. Sometimes there is a technical or pedantic issue that -`-Weverything` warns about that would merit a change to your C code. Of course +`-Weverything` warns about that would merit a change to your C code; often, +however, it is not even possible to fix let alone is it worth it. Of course if you're running out of bytes due to rule 2[ab] one might not have much choice. -Thus is something that obfuscators simply sometimes have to deal with! +This is something that obfuscators simply sometimes have to deal with! -If you to try to use minimize the number of `-Wno-foo` options needed with +If you try to minimize the number of `-Wno-foo` options needed with `-Weverything`, please mention this in your remarks about the entry, as the judges note you attempt to honor it (see also below). In some cases your obfuscated code will issue warnings with `-Weverything` no matter what: the `-Wno-poison-system-directories` is a common example of this but there are -others as well. +others as well, sometimes depending on the version of `clang`. -If you do try for a warning clean `-Weverything`, keep on mind that while _your_ +If you do try for a compile with `clang -Weverything`, keep on mind that while _your_ compile environment might be warning free, a different clang version or a different build environment might still have warnings. For instance the warning -set is different in macOS (which by default is `clang` even when run as `gcc`!) -than linux! Given that your entry *MUST* work as documented, you may be safer to +set is different in macOS (which by default is `clang`: even when run as `gcc`!) +than linux (due to versions and possibly other things)! + +Given that your entry **MUST** work as documented, you may be safer to say that your entry keeps the number of warnings and `-Wno-foo` options while -compiling with `clang -Weverything` at a minimum. Because if you claim zero +compiling with `clang -Weverything` at a minimum. You might want to say the +version number and platform too as an extra safety net. Because if you claim zero warnings, and we find a warning situation, this may diminish the value of your entry as it is not as documented. Thus it might be wise to point this out and -also if you can test it in multiple platforms (or versions of `clang`, see +if you can test it in multiple platforms (or versions of `clang`, see below note) this would be advisable. NOTE: different versions of `clang` have other differences as well. For instance -a defect of `clang` that required numerous entries to be fixed is that it +a defect of `clang` that required numerous entries to be fixed for clang is that it requires that `main()`'s arguments to be of a specific type. However some versions of `clang` are more strict in the number of args allowed. These reasons are part of why numerous entries had to be modified so that `main()` calls -another function instead of doing it all in `main()`. Another reason was that +another function instead of doing it all in `main()` (another reason was that some entries that recursively called `main()` caused a crash or otherwise broke -the entry in modern systems. Some entries do not work in `clang` (or at least do +the entry in modern systems). Some entries do not work in `clang` (or at least do not work completely) due to these defects, for instance -[1989/westley](1989/westley/README.md). +[1989/westley](1989/westley/README.md); [Cody Boone +Ferguson](https://www.ioccc.org/winners.html#Cody_Boone_Ferguson) was able to +get much of it to work and looking at that entry might be of value to your +submissions, at least if you can figure the code out :-). To see the +differences, try from `1989/westley`: + +```sh +make diff_orig_prog +``` + +If you have `colordiff` try: + +```sh +make DIFF=colordiff diff_orig_prog +``` + +Alternatively you can try: + +```sh +git diff d2a42f42e8f477f29e9d5ed09ce2bb349eaf7397..eb9e69fde657acc8c85a618a8a99af4c2f93b21d westley.c +``` As you can see, using `clang` has some additional problems to work out but if you can get your entry to work well in `clang` it might very well be considered @@ -918,7 +942,7 @@ better than other entries. ## Section 4: Changes made to IOCCC winners -### FAQ 4.0: Why are some winning author remarks incongruent with the winning IOCCC code? +### FAQ 4.0: Why are some winning entry remarks incongruent with the winning IOCCC code? It is very likely in this case that the code was fixed to work for modern systems as part of the reworking of the website. If you have this problem in @@ -926,7 +950,8 @@ some entries you should look at the original code as in `winner.orig.c` or `prog.orig.c`. `winner` is the directory name. For instance, one of Landon's favourite entries of all time is [1984/mullender](1984/mullender/README.md) and the winner there would be `mullender`. Sometimes the original is in an alt -version like `winner.alt.c` or `prog.alt.c`. +version like `winner.alt.c` or `prog.alt.c`. In fact it is advisable to look at +the original code when reading the author's (and sometimes authors') remarks. ### FAQ 4.1: Why were some calls to the libc function gets changed to use fgets? From f91e883def90d0649f4e0440c395edbfbfc7aa52 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:07:46 -0800 Subject: [PATCH 02/12] Test change in format of FAQ table of contents Only the first two sections have had a change so that we can see it side by side to see what looks better. --- faq.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/faq.md b/faq.md index 31d8a5f19..f9a9596a7 100644 --- a/faq.md +++ b/faq.md @@ -1,20 +1,17 @@ # FAQ Table of Contents ## Section 0 - [History of the IOCCC](#faq0) - -### FAQ 0.0 - [How did the IOCCC get started?](#faq0_0) -### FAQ 0.1 - [Why are some years missing IOCCC winners?](#faq0_1) -### FAQ 0.2 - [Why do some IOCCC winners receive the Grand Prize or Best of Show award?](#faq0_2) + - [0.0 - How did the IOCCC get started?](#faq0_0) + - [0.1 - Why are some years missing IOCCC winners?](#faq0_1) + - [0.2 - Why do some IOCCC winners receive the Grand Prize or Best of Show award?](#faq0_2) ## Section 1 - [Submitting entries to a new IOCCC](#faq1) - -### FAQ 1.0 - [What types of entries have been over-submitted to the IOCCC?](#faq1_0) -### FAQ 1.1 - [What should I put in my entry's Makefile?](#faq1_1) -### FAQ 1.2 - [May I use a different source or compiled filename than prog.c or prog?](#faq1_2) -### FAQ 1.3 - [What platform should I assume for my entry?](#faq1_3) + - [1.0 - What types of entries have been over-submitted to the IOCCC?](#faq1_0) + - [1.1 - What should I put in my entry's Makefile?](#faq1_1) + - [1.2 - May I use a different source or compiled filename than prog.c or prog?](#faq1_2) + - [1.3 - What platform should I assume for my entry?](#faq1_3) ## Section 2 - [IOCCC Judging process](#faq2) - ### FAQ 2.0 - [How many entries do the judges receive for a given IOCCC?](#faq2_0) ### FAQ 2.1 - [What should I put in the remarks.md file of my entry?](#faq2_1) ### FAQ 2.2 - [Why don't you publish non-winners?](#faq2_2) From a3b7e5128936d5e6034d1c127cfcfe6bbb6497fd Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:10:24 -0800 Subject: [PATCH 03/12] Try fixing links in FAQ format test --- faq.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/faq.md b/faq.md index f9a9596a7..e8b7aa2a3 100644 --- a/faq.md +++ b/faq.md @@ -1,15 +1,15 @@ # FAQ Table of Contents ## Section 0 - [History of the IOCCC](#faq0) - - [0.0 - How did the IOCCC get started?](#faq0_0) - - [0.1 - Why are some years missing IOCCC winners?](#faq0_1) - - [0.2 - Why do some IOCCC winners receive the Grand Prize or Best of Show award?](#faq0_2) +- [0.0 - How did the IOCCC get started?](#faq0_0) +- [0.1 - Why are some years missing IOCCC winners?](#faq0_1) +- [0.2 - Why do some IOCCC winners receive the Grand Prize or Best of Show award?](#faq0_2) ## Section 1 - [Submitting entries to a new IOCCC](#faq1) - - [1.0 - What types of entries have been over-submitted to the IOCCC?](#faq1_0) - - [1.1 - What should I put in my entry's Makefile?](#faq1_1) - - [1.2 - May I use a different source or compiled filename than prog.c or prog?](#faq1_2) - - [1.3 - What platform should I assume for my entry?](#faq1_3) +- [1.0 - What types of entries have been over-submitted to the IOCCC?](#faq1_0) +- [1.1 - What should I put in my entry's Makefile?](#faq1_1) +- [1.2 - May I use a different source or compiled filename than prog.c or prog?](#faq1_2) +- [1.3 - What platform should I assume for my entry?](#faq1_3) ## Section 2 - [IOCCC Judging process](#faq2) ### FAQ 2.0 - [How many entries do the judges receive for a given IOCCC?](#faq2_0) From 7352698d27f434575d89373f16df97f819f6216c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:23:03 -0800 Subject: [PATCH 04/12] Improve the way the FAQ table of contents looks --- faq.md | 74 +++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/faq.md b/faq.md index e8b7aa2a3..6486a7139 100644 --- a/faq.md +++ b/faq.md @@ -1,57 +1,53 @@ # FAQ Table of Contents ## Section 0 - [History of the IOCCC](#faq0) -- [0.0 - How did the IOCCC get started?](#faq0_0) -- [0.1 - Why are some years missing IOCCC winners?](#faq0_1) -- [0.2 - Why do some IOCCC winners receive the Grand Prize or Best of Show award?](#faq0_2) +- [0.0 - How did the IOCCC get started?](#faq0_0) +- [0.1 - Why are some years missing IOCCC winners?](#faq0_1) +- [0.2 - Why do some IOCCC winners receive the Grand Prize or Best of Show award?](#faq0_2) ## Section 1 - [Submitting entries to a new IOCCC](#faq1) -- [1.0 - What types of entries have been over-submitted to the IOCCC?](#faq1_0) -- [1.1 - What should I put in my entry's Makefile?](#faq1_1) -- [1.2 - May I use a different source or compiled filename than prog.c or prog?](#faq1_2) -- [1.3 - What platform should I assume for my entry?](#faq1_3) +- [1.0 - What types of entries have been over-submitted to the IOCCC?](#faq1_0) +- [1.1 - What should I put in my entry's Makefile?](#faq1_1) +- [1.2 - May I use a different source or compiled filename than prog.c or prog?](#faq1_2) +- [1.3 - What platform should I assume for my entry?](#faq1_3) ## Section 2 - [IOCCC Judging process](#faq2) -### FAQ 2.0 - [How many entries do the judges receive for a given IOCCC?](#faq2_0) -### FAQ 2.1 - [What should I put in the remarks.md file of my entry?](#faq2_1) -### FAQ 2.2 - [Why don't you publish non-winners?](#faq2_2) -### FAQ 2.3 - [How much time does it take to judge the contest?](#faq2_3) -### FAQ 2.4 - [How many judging rounds do you have?](#faq2_4) +- [2.0 - How many entries do the judges receive for a given IOCCC?](#faq2_0) +- [2.1 - What should I put in the remarks.md file of my entry?](#faq2_1) +- [2.2 - Why don't you publish non-winners?](#faq2_2) +- [2.3 - How much time does it take to judge the contest?](#faq2_3) +- [2.4 - How many judging rounds do you have?](#faq2_4) ## Section 3 - [Compiling and running IOCCC winners](#faq3) - -### FAQ 3.0 - [What Makefile are available to build or clean up IOCCC winners?](#faq3_0) -### FAQ 3.1 - [Why doesn't this IOCCC winner compile?](#faq3_1) -### FAQ 3.2 - [Why does a IOCCC winner fail on my 64-bit system?](#faq3_2) -### FAQ 3.3 - [Why do some IOCCC winners fail to compile under macOS?](#faq3_3) -### FAQ 3.4 - [Why does clang or gcc fail to compile an IOCCC winner?](#faq3_4) -### FAQ 3.5 - [What is this cb tool that is mentioned in the IOCCC?](#faq3_5) -### FAQ 3.6 - [An IOCCC winner missed by my terminal application, how do I fix this?](#faq3_6) -### FAQ 3.7 - [How do I compile and use on macOS, an IOCCC winner that requires X11?](#faq3_7) -### FAQ 3.8 - [How do I compile an IOCCC winner that requires SDL1 or SDL2?](#faq3_8) -### FAQ 3.9 - [How do I compile and use on macOS, an IOCCC winner that requires sound?](#faq3_9) -### FAQ 3.10 - [Why do Makefiles use -Weverything with clang?](#faq3_10) +- [3.0 - What Makefile are available to build or clean up IOCCC winners?](#faq3_0) +- [3.1 - Why doesn't this IOCCC winner compile?](#faq3_1) +- [3.2 - Why does a IOCCC winner fail on my 64-bit system?](#faq3_2) +- [3.3 - Why do some IOCCC winners fail to compile under macOS?](#faq3_3) +- [3.4 - Why does clang or gcc fail to compile an IOCCC winner?](#faq3_4) +- [3.5 - What is this cb tool that is mentioned in the IOCCC?](#faq3_5) +- [3.6 - An IOCCC winner missed by my terminal application, how do I fix this?](#faq3_6) +- [3.7 - How do I compile and use on macOS, an IOCCC winner that requires X11?](#faq3_7) +- [3.8 - How do I compile an IOCCC winner that requires SDL1 or SDL2?](#faq3_8) +- [3.9 - How do I compile and use on macOS, an IOCCC winner that requires sound?](#faq3_9) +- [3.10 - Why do Makefiles use -Weverything with clang?](#faq3_10) ## Section 4 - [Changes made to IOCCC winners](#faq4) - -### FAQ 4.0 - [Why are some winning author remarks incongruent with the winning IOCCC code?](#faq4_0) -### FAQ 4.1 - [Why were some calls to the libc function gets changed to use fgets?](#faq4_1) -### FAQ 4.2 - [What was changed in an IOCCC winner source code?](#faq4_2) -### FAQ 4.3 - [Why do author remarks sometimes not match the source?](#faq4_3) -### FAQ 4.4 - [What is the meaning of the file ending in .orig.c in IOCCC winners?](#faq4_4) +- [4.0 - Why are some winning author remarks incongruent with the winning IOCCC code?](#faq4_0) +- [4.1 - Why were some calls to the libc function gets changed to use fgets?](#faq4_1) +- [4.2 - What was changed in an IOCCC winner source code?](#faq4_2) +- [4.3 - Why do author remarks sometimes not match the source?](#faq4_3) +- [4.4 - What is the meaning of the file ending in .orig.c in IOCCC winners?](#faq4_4) ## Section 5 - [Updating or correcting IOCCC web site content](#faq5) - -### FAQ 5.0 - [Why does an IOCCC winner fail to compile or or fail run?](#faq5_0) -### FAQ 5.1 - [How do I report a bug in an IOCCC winner?](#faq5_1) +- [5.0 - Why does an IOCCC winner fail to compile or or fail run?](#faq5_0) +- [5.1 - How do I report a bug in an IOCCC winner?](#faq5_1) ## Section 6 - [Miscellaneous IOCCC](#faq6) - -### FAQ 6.0 - [How did an entry breaks the size rule 2, win the IOCCC?](#faq6_0) -### FAQ 6.1 - [Is there a list of known bugs and misfeatures of IOCCC winners?](#faq6_1) -### FAQ 6.2 - [May I mirror the IOCCC web site?](#faq6_2) -### FAQ 6.3 - [May I use parts of the IOCCC in an article, book, newsletter, or instructional material?](#faq6_3) -### FAQ 6.4 - [Why do you sometimes use the first person plural?](#faq6_4) +- [6.0 - How did an entry breaks the size rule 2, win the IOCCC?](#faq6_0) +- [6.1 - Is there a list of known bugs and (mis)features of IOCCC winners?](#faq6_1) +- [6.2 - May I mirror the IOCCC web site?](#faq6_2) +- [6.3 - May I use parts of the IOCCC in an article, book, newsletter, or instructional material?](#faq6_3) +- [6.4 - Why do you sometimes use the first person plural?](#faq6_4) # The IOCCC FAQ From 2621ab4deb79eb15e90ed026f1a6a3dd7bbe9862 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:28:27 -0800 Subject: [PATCH 05/12] Format fix 1998/dloweneil/README.md An annoying problem with markdown is that in single backtick code blocks if the line is wrapped and the line begins with '-' (even in a code block) the line becomes a list item and breaks the code. --- 1998/dloweneil/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1998/dloweneil/README.md b/1998/dloweneil/README.md index 1cd8dd502..78c4d20d3 100644 --- a/1998/dloweneil/README.md +++ b/1998/dloweneil/README.md @@ -145,8 +145,8 @@ than one way simultaneously. - Several different coordinate systems are used. There's the "real" X by Y system used for curses, the "inside the box" X by Y system used for moving things around and finding instances of `POOT` inside the box, and the position -of the current letter, which is a single value from 0 to `2 * xsize + 2 * ysize -- 1`. +of the current letter, which is a single value from `0` to +`2 * xsize + 2 * ysize - 1`. - The fact that `x%3` is a perfect hash function for `x` values `P`, `O` and `T` is used. From 95b5938a4e8f39c2b1a759033d275f55d1e43703 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:31:47 -0800 Subject: [PATCH 06/12] Fix alternate use of 1998/dloweneil One can specify the size of the board too but I missed the feature of the original entry. --- 1998/dloweneil/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1998/dloweneil/README.md b/1998/dloweneil/README.md index 78c4d20d3..107015f89 100644 --- a/1998/dloweneil/README.md +++ b/1998/dloweneil/README.md @@ -53,7 +53,7 @@ make alt ### Alternate use: ```sh -./pootris.alt +./pootris.alt [X size of board] [Y size of board] ``` From 10b5b47466e8b00cced40913c442e57c46e1dde8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 06:08:26 -0800 Subject: [PATCH 07/12] Update 1998/dlowe - add scripts + formatting The following scripts were added: - try.sh: a fun use of the program. - pootify.sh: a local pootifier that downloads a web page (or use a local file) and either changes it to text or writes html which can be viewed in a local browser. - pootify.cgi.sh: a CGI version that the judges added but made to use bash(1) and pass shellcheck(1). There is an issue that is known with this and the 'Historical remarks' discusses this in more detail as well as how to use the pootify.sh and pootify.cgi.sh scripts. The README.md file has been formatted as well. --- 1998/dlowe/.gitignore | 1 + 1998/dlowe/README.md | 44 ++++++++++++++++++++++++++++---- 1998/dlowe/pootify.cgi.sh | 25 ++++++++++++++++++ 1998/dlowe/pootify.sh | 53 +++++++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 11 ++++++++ 5 files changed, 129 insertions(+), 5 deletions(-) create mode 100755 1998/dlowe/pootify.cgi.sh create mode 100755 1998/dlowe/pootify.sh diff --git a/1998/dlowe/.gitignore b/1998/dlowe/.gitignore index 929663f8b..5855a6a26 100644 --- a/1998/dlowe/.gitignore +++ b/1998/dlowe/.gitignore @@ -3,3 +3,4 @@ dlowe.alt README.poot.md dlowe.orig prog.orig +make.1 diff --git a/1998/dlowe/README.md b/1998/dlowe/README.md index a385f3d48..d77e5c351 100644 --- a/1998/dlowe/README.md +++ b/1998/dlowe/README.md @@ -33,6 +33,12 @@ For more detailed information see [1998 dlowe in bugs.md](/bugs.md#1998-dlowe). Why is there different output? +Also try: + +```sh +./try.sh +``` + ## Alternate code: @@ -58,8 +64,10 @@ a CGI program: ms.html +``` + +where the first one would show the text as rendered but without links, images +etc. and the second one would write the html to ms.html so that you could open +it in a browser. + +If one does use it as a CGI script you'll want to check out +[pootify.cgi.sh](pootify.cgi.sh) which forbids `file://` based URLs and which +uses `lynx(1)` with the option referred to above. + +For an old example of it working as a CGI script see: ```sh https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org @@ -96,8 +130,8 @@ https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/ ## Author's remarks: -This program is a text filter, it reads stdin and outputs the -"corrected" text to stdout. +This program is a text filter, it reads `stdin` and outputs the +"corrected" text to `stdout`. It is obfuscated in that the code is painful to look at and its purpose and mode of operation are not terribly obvious. diff --git a/1998/dlowe/pootify.cgi.sh b/1998/dlowe/pootify.cgi.sh new file mode 100755 index 000000000..e7649aa70 --- /dev/null +++ b/1998/dlowe/pootify.cgi.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# pootify.cgi.sh - a sample CGI pootifier +# +POOT="./dlowe" +LYNX="lynx" +ECHO="echo" +EXPR="expr" + +${ECHO} "Content-type: text/html" +${ECHO} + +QUERY_STRING="$1" +if [[ -z "${QUERY_STRING}" ]]; then + ${ECHO} "QUERY_STRING not found" +else + URL="$(${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)')" + if [[ -z "${URL}" ]]; then + ${ECHO} "No URL given in QUERY_STRING" + elif [[ X"$(${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:')" != X0 ]]; then + ${ECHO} "file: based URLs are not allowed" + else + ${LYNX} -restrictions=all -source "${URL}" | ${POOT} + fi +fi diff --git a/1998/dlowe/pootify.sh b/1998/dlowe/pootify.sh new file mode 100755 index 000000000..e9b8204a2 --- /dev/null +++ b/1998/dlowe/pootify.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# +# Script to download a page and pootify it. You can pipe it through less(1) to +# see the output or you can redirect it to a file and open it in your local +# browser (use the -r option for that). +# +# Note from 2023: this used to be a CGI script that used lynx(1) which has +# security features but lynx does not work with redirects, it would appear, and +# unfortunately links(1) does not have such restrictions. If you wanted to use +# it anyway you could change the -dump to -source and see how it goes. It might +# also be that if it was used as a CGI script it would work well but this has +# not been tested. +# +# Example uses: +# +# ./pootify.sh URL=https://microsoft.com | less +# +# ./pootify.sh -r URL=https://microsoft.com > ms.html +# +# and then open ms.html in your local browser. Neither are as nice as a rendered +# html page as a script from another page and certainly it's less convenient but +# you can at least enjoy the output somewhat, the latter one more so, perhaps. +# +POOT="./dlowe" +LINKS="links" +ECHO="echo" +EXPR="expr" +RAW="" +${ECHO} "Content-type: text/html" +${ECHO} +if [[ "$#" -eq 2 ]]; then + if [[ "$1" = "-r" ]]; then + RAW="-r" + fi + shift 1 +fi + +QUERY_STRING="$1" +if [[ -z "${QUERY_STRING}" ]]; then + ${ECHO} "QUERY_STRING not found" +else + URL="$(${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)')" + if [[ -z "${URL}" ]]; then + ${ECHO} "No URL given in QUERY_STRING" + # if used as a CGI script uncomment the below: + #elif [[ X"$(${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:')" != X0 ]]; then + # ${ECHO} "file: based URLs are not allowed" + elif [[ -n "$RAW" ]]; then + ${LINKS} -source "${URL}" | ${POOT} + else + ${LINKS} -dump "${URL}" | ${POOT} + fi +fi diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 055f0e328..46271cc2a 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2048,6 +2048,17 @@ Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when exiting the program. +## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) + +Cody added the scripts [try.sh](1998/dlowe/try.sh), +[pootify.sh](1998/dlowe/pootify.sh) and +[pootify.cgi.sh](1998/dlowe/pootify.cgi.sh) for a fun example use of the +program, a local pootifier of web pages and a CGI pootifier. It should be noted +that the CGI version might have an issue with modern systems; see [historical +remarks](1998/dlowe/README.md#historical-remarks) for more details on the +pootify scripts. + + ## [1998/dloweneil](1998/dloweneil/dloweneil.c) ([README.md](1998/dloweneil/README.md])) Cody added [alt code](1998/dloweneil/dloweneil.alt.c) which has vi(m) movement From 504813918d633a06b5370af0ab8de5fadf4dadb4 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:02:39 -0800 Subject: [PATCH 08/12] Fixes in 1998/df A pointer to int was being used for fopen(3) and this has been changed to a FILE * as using the wrong type has been observed in some cases to cause programs to fail. Make the code more like the original by using the old style main() arg so that it could read 'int main(i,love_unix)' and also changing the typedef for 'int' from 'lint' to be '_int' (see the code for why it no longer can be 'int' and ask yourself why it can be 'int' in other cases). Format/typo check README.md file. --- 1998/df/Makefile | 2 +- 1998/df/README.md | 19 +++++++++---------- 1998/df/df.c | 6 +++--- thanks-for-fixes.md | 11 +++++++++++ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/1998/df/Makefile b/1998/df/Makefile index f0571a925..66f486b31 100644 --- a/1998/df/Makefile +++ b/1998/df/Makefile @@ -40,7 +40,7 @@ include ../../var.mk # CSILENCE= -Wno-bitwise-op-parentheses -Wno-char-subscripts -Wno-pointer-to-int-cast \ -Wno-return-type -Wno-unused-parameter -Wno-unused-variable \ - -Wno-typedef-redefinition -Wno-deprecated-non-prototype + -Wno-typedef-redefinition -Wno-deprecated-non-prototype -Wno-implicit-int # Common C compiler warning flags # diff --git a/1998/df/README.md b/1998/df/README.md index c49e3d16d..db17ebda2 100644 --- a/1998/df/README.md +++ b/1998/df/README.md @@ -23,7 +23,7 @@ the program are used. Curiously, the program only works if its source is in the directory it's run in. More curiously, the program would fail if the program's name's second letter wasn't `r` (the source has been changed for your -convenience and this restriction does no longer exist). +convenience and this restriction no longer exist). Modern design has come a long way since the unreadable, tightly-coupled systems we used to have. @@ -44,7 +44,7 @@ itself. You can guess a letter simply by typing it in. If your C implementation requires it, you may have to hit Return before it is recognized. In this case, you can also type multiple guesses on the same line (completely solve it by entering -"abcdefghijklmnopqrstuvwxyz"). Execution stops when all underscores +`abcdefghijklmnopqrstuvwxyz`). Execution stops when all underscores have been replaced. The program offers a number of different words to guess, `time()` is @@ -76,7 +76,7 @@ to `#define`. I have also included comments in the code, and vital code in the comments. And of course there is code that doesn't do anything but will crash the program if it is removed (just like those comments I mentioned above). Additionally, since you said -you'd be preprocessing entries ignoring includes I figured I should +you'd be preprocessing entries ignoring `#include`s I figured I should use some more of them instead of other obfuscation methods. Did I mention that preprocessed or beautified sources will crash or hang your system? The program will also crash on non-ASCII machines. @@ -99,7 +99,7 @@ These restrictions have been removed for your convenience. The following lines describe how this program works; if you don't want to know it at this time, please skip them. If this entry would by some mistake win the contest, please do not rot13 this - I hate -rot13'd spoilers since it is somewhat complicated on a Mac to +rot13 spoilers since it is somewhat complicated on a Mac to reverse them. Anyone out there should have enough discipline and rot13 shouldn't be required, really. After all, we are not children anymore :-) @@ -123,7 +123,7 @@ spread over six lines in the source; decoding starts on a line after a tab and a whitespace have been found, and stops on a newline. The grin after the "Demonic Smiley" actually is one encoded letter while the string is completely ignored; and the `cut` in "cut here" -is required while "here" is not. +is required while `here` is not. "For extra credit", explain why the words are sorted alphabetically (because I extracted them from a dictionary :-) ) @@ -131,17 +131,16 @@ is required while "here" is not. The file name had to fulfill the restrictions mentioned above because `__FILE__+1` was used as a second parameter to `fopen()`. (It essentially was `fopen(__FILE__,__FILE__+1)` ). This was an extra joke -that does no longer exist in the released version. +that doesn't exist in the released version. -You probably discovered that the `while(FILE)` in main is not a while loop +You probably discovered that the `while(FILE)` in `main()` is not a while loop but the statement that opens the file and initializes the dictionary. -Similarly, int and signed have been redefined (to save space, of -course). +Similarly, `int` and `signed` have been redefined (to save space, of course). The main function (the guessing part) is between the last `#else..#endif`, but still is declared before `main()`. The `5[O]()` in `main()` calls this function. Similarly, most indexing operations have been -changed to this form; and I tried to write each such operation +changed to this form and I tried to write each such operation different. diff --git a/1998/df/df.c b/1998/df/df.c index 75262423b..4ba6d91d9 100644 --- a/1998/df/df.c +++ b/1998/df/df.c @@ -1,5 +1,5 @@ #ifndef int -typedef int lint; +typedef int _int; #ifdef while char s[234],d[56],*p=s,m='m'; #define int typedef (*define)();\ @@ -10,14 +10,14 @@ signed short n(short bz){ char o=1,i=1,l,pc=i,b=r+o/2,_f=6,m=7,s=8,g,q,od=o*rs+4^s,js=_f/*3-m*'c',bs='g'; return 1; } #y FILE c[a]+s,p[c],r[m]+u[i+4*o|f]-r[wob][wad]+s*f-!w|o,L+x | cut -;}int main(lint i,char**love_unix){*/;}int main(lint i,char**love_unix){/*;}int main(lint i,char**love_unix){*\;}| here */ +;}int main(i,love_unix)_int i;char**love_unix;{*/;}int main(i,love_unix)_int i;char**love_unix;{/*;}int main(i,love_unix)_int i;char**love_unix;{*\;}| here */ while(FILE)for(;9-(i=0[O](f));); for(;32-(i=0[O](f));0&& 3[O]("-->%s<--", "gxdgbtgxsxpcctvpixktedhiedcte")); for(;'\n'-(i=O[0](f));)(i>='a'&&i<'z')?* #include __FILE__ "Demonic Smiley" );} /* */ #else -#define while(int) short c=0;int*f=fopen(__##int##__,"r");for(i=0;i<25;i _)i[d]='A'+(13+i)%26;main: +#define while(int) short c=0;FILE*f=fopen(__##int##__,"r");for(i=0;i<25;i _)i[d]='A'+(13+i)%26;main: #define y define #define _ ++ #include diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 46271cc2a..f2dc9a636 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2048,6 +2048,17 @@ Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when exiting the program. +## [1998/df](1998/df/df.c) ([README.md](1998/df/README.md])) + +Cody changed a `int *` used for `fopen(3)` to be a `FILE *` to be more correct +and prevent any possible problems in some systems (which has happened). + +Cody also made the fixed version look more like the original version by using +the old style of `main()` args so that it read `i,love_unix` more naturally, and +by changing the typedef `lint` (to `int` - see the code for why this has to be +done in modern systems) to be `_int`. + + ## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) Cody added the scripts [try.sh](1998/dlowe/try.sh), From f9f057daf1261f44d9331566f67f36acdd39c14d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:10:09 -0800 Subject: [PATCH 09/12] Format/typo check 1998/chaos/README.md --- 1998/chaos/README.md | 8 ++++---- thanks-for-fixes.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/1998/chaos/README.md b/1998/chaos/README.md index 03a4c7edf..d4f1f1521 100644 --- a/1998/chaos/README.md +++ b/1998/chaos/README.md @@ -29,7 +29,7 @@ a nice example of a compact collection of obfuscations. Can you figure out why, in some cases, it wants to read itself? -## Selected Author's Comments: +## Author's remarks: ### Usage @@ -48,13 +48,13 @@ interrupted by user input. ### Features (aka Bugs): -Memory malloced is never freed. This shouldn't be a big deal, +Memory `malloc(3)`ed is never freed. This shouldn't be a big deal, since only one block is ever allocated, and the OS should recover it. My local flavor of lint doesn't seem to like the fact that I never -`return` from main. Feh, what does it know? Otherwise, ignoring +`return` from `main()`. Feh, what does it know? Otherwise, ignoring lint's over protectiveness ("Of course I'm not using all of the -functions defined in curses.h!"), it's lint clean. +functions defined in `curses.h`!"), it's lint clean. If the compiler happens to generate the byte sequence "AlWuzEre" in the executable by chance, the program may be unable to locate diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index f2dc9a636..1b4438249 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2045,7 +2045,7 @@ have them like with Macs. ## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md])) Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when -exiting the program. +exiting the program (in both versions). ## [1998/df](1998/df/df.c) ([README.md](1998/df/README.md])) From aa1427f18e9b1b183e5e08512ad3a4f338ed00c5 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:13:59 -0800 Subject: [PATCH 10/12] Minor fixes in 1998/dlowe The program (both main and alt versions) had main()'s return type as void. To make it more portable, like another entry (that I was asked to make this same change), I changed it to int. --- 1998/dlowe/dlowe.alt.c | 4 ++-- 1998/dlowe/dlowe.c | 4 ++-- thanks-for-fixes.md | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/1998/dlowe/dlowe.alt.c b/1998/dlowe/dlowe.alt.c index efe783ab2..06d351cb0 100644 --- a/1998/dlowe/dlowe.alt.c +++ b/1998/dlowe/dlowe.alt.c @@ -2,7 +2,7 @@ #define PO(o,t)\ (((o>64)&&(o<91))?(((t>96)&&(t<123))?(t-32):(t)):(((t>64)&&(t<91))?(t+32):(t))) - void main() { char *poo="poot", + int main() { char *poo="poot", *Poo="pootpoot" ,O[9],o;int t, T;(t=0)|| (*O='\0');while( (o= getc( stdin ))!=( EOF))if (((o> 64)&& (o< 91)) ||(( o>96 )&&(o <123 ))) ( @@ -14,5 +14,5 @@ ("%c", PO(*(O +T),*( poo+T) -) ); printf( "%c", o ) ; } else printf("%s%c", O, o); ( t =0) || (*O='\0'); } } +) ); printf( "%c", o ) ; } else printf("%s%c", O, o); ( t =0) || (*O='\0'); } return 0;} diff --git a/1998/dlowe/dlowe.c b/1998/dlowe/dlowe.c index 5466711fb..9e9d29108 100644 --- a/1998/dlowe/dlowe.c +++ b/1998/dlowe/dlowe.c @@ -2,7 +2,7 @@ #define PO(o,t)\ (((o>64)&&(o<91))?(((t>96)&&(t<123))?(t-32):(t)):(((t>64)&&(t<91))?(t+32):(t))) - void main() { char *poo= "poot", + int main() { char *poo= "poot", *Poo="pootpoot" ,O[9];int o,t,T,p;(t=p =0)||(*O='\0');while ((o= getc( stdin ))!=( EOF))if ((p== 0)&& (((o>64 )&& ( o<91 )) || ((o> 96 ) &&(o< 123) ))) ( @@ -15,4 +15,4 @@ +T),*( poo+T) ) ) ; printf( "%c" , o ) ; } else printf ( "%s%c" , O , o ) ; ( t = 0 ) || ( -* O = '\0' ) ; ( o == 60 ) && ( ++p ) ; ( o == 62 ) && (p!=0) && ( --p ) ; } } +* O = '\0' ) ; ( o == 60 ) && ( ++p ) ; ( o == 62 ) && (p!=0) && ( --p ) ; } return 0;} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 1b4438249..d48f0025b 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2061,6 +2061,9 @@ done in modern systems) to be `_int`. ## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) +Cody made the program more portable by changing the void return type of `main()` +to be `int` (in both versions). + Cody added the scripts [try.sh](1998/dlowe/try.sh), [pootify.sh](1998/dlowe/pootify.sh) and [pootify.cgi.sh](1998/dlowe/pootify.cgi.sh) for a fun example use of the From d742eb23e788564876482a577d932eef22fa3184 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:31:47 -0800 Subject: [PATCH 11/12] Add 1998/bas2/try.sh + format/typo check README.md The try.sh allows one to pass in args: if a readable regular file it will be fed to the program and otherwise it'll act as if it's a string. It also has some additional commands that I thought might be fun to show the entry. Format/typo check README.md file. --- 1998/bas2/README.md | 18 +++++++++++++++--- 1998/bas2/try.sh | 38 ++++++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 7 +++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100755 1998/bas2/try.sh diff --git a/1998/bas2/README.md b/1998/bas2/README.md index 91f0ccf0b..f960fca5a 100644 --- a/1998/bas2/README.md +++ b/1998/bas2/README.md @@ -8,12 +8,23 @@ make all ## To use: ```sh -./bas2 < bas2.c +./bas2 < file +echo text | ./bas2 +``` + + +## Try: + +```sh +./try.sh + +./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md ``` ## Judges' remarks: + ### Questions to ponder: Can you determine the relationship between the input and the resulting numeric @@ -22,6 +33,7 @@ output? The program was not designed to process files with a certain octet value, what value is that? + ### Hint and Extra Credit: This entry points out a minor flaw in the IOCCC rules that has @@ -40,10 +52,10 @@ done by matching the bit patterns. Minor obfuscations are: - Useless variable names. -- Recursive main() instead of 2 loops (over input characters and over bits in +- Recursive `main()` instead of 2 loops (over input characters and over bits in the character). -- `?` and `||` instead of if statements. +- `?:` and `||` instead of if statements. ## Copyright and CC BY-SA 4.0 License: diff --git a/1998/bas2/try.sh b/1998/bas2/try.sh new file mode 100755 index 000000000..08a76ae35 --- /dev/null +++ b/1998/bas2/try.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate 1998/bas2 +# +# If any args are specified it checks if it's a readable file and if it is it +# feeds it to the program. If not it assumes it's a string and feeds that to the +# program. +# + +make all || exit 1 + +echo "$ ./bas2 < bas2.c" 1>&2 +./bas2 < bas2.c + +echo "$ ./bas2 < README.md" 1>&2 +./bas2 < README.md + +echo "$ ./bas2 < Makefile" 1>&2 +./bas2 < Makefile + +echo "$ echo foo bar baz | ./bas2" 1>&2 +echo foo bar baz | ./bas2 + +echo "$ cat README.md Makefile bas2.c | ./bas2" 1>&2 +cat README.md Makefile bas2.c | ./bas2 + +# while we have an arg check if it's a file. If it is a regular file that is +# readable feed it to the program; otherwise act as if it's a string. +while [[ "$#" -gt 0 ]]; do + if [[ -f "$1" && -r "$1" ]]; then + echo "$ ./bas2 < $1" 1>&2 + ./bas2 < "$1" + else + echo "$ echo $1 | ./bas2" 1>&2 + echo "$1" | ./bas2 + fi + shift 1 +done diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index d48f0025b..ca6e039e4 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2042,6 +2042,12 @@ they do have page up and page down but this gives a default for those who don't have them like with Macs. +## [1998/bas2](1998/bas2/bas2.c) ([README.md](1998/bas2/README.md])) + +Cody added the [try.sh](1998/bas2/try.sh) script which runs some default actions +as well as allowing one to pass in different file names or strings. + + ## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md])) Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when @@ -2059,6 +2065,7 @@ by changing the typedef `lint` (to `int` - see the code for why this has to be done in modern systems) to be `_int`. +## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) ## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) Cody made the program more portable by changing the void return type of `main()` From a979195d7bee8a1353f8372f3896b7dfa9568e50 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:40:56 -0800 Subject: [PATCH 12/12] Format/typo check 1998/bas1 The Makefile now has -Wno-implicit-int. Running 'make all' will copy 'bas1' to 'bemazing' (what the author calls the program). The README.md file has been format/typo checked. --- 1998/bas1/.gitignore | 1 + 1998/bas1/Makefile | 8 ++++++-- 1998/bas1/README.md | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/1998/bas1/.gitignore b/1998/bas1/.gitignore index f0c8d3ee5..ce02bca67 100644 --- a/1998/bas1/.gitignore +++ b/1998/bas1/.gitignore @@ -1,3 +1,4 @@ bas1 bas1.orig +bemazing prog.orig diff --git a/1998/bas1/Makefile b/1998/bas1/Makefile index 3a72d116f..d1765ed1e 100644 --- a/1998/bas1/Makefile +++ b/1998/bas1/Makefile @@ -40,7 +40,7 @@ include ../../var.mk # CSILENCE= -Wno-bitwise-conditional-parentheses -Wno-bitwise-op-parentheses \ -Wno-empty-body -Wno-invalid-source-encoding -Wno-main -Wno-parentheses \ - -Wno-shift-op-parentheses -Wno-deprecated-non-prototype + -Wno-shift-op-parentheses -Wno-deprecated-non-prototype -Wno-implicit-int # Common C compiler warning flags # @@ -114,7 +114,7 @@ PROG= ${ENTRY} # OBJ= ${PROG}.o DATA= -TARGET= ${PROG} +TARGET= ${PROG} bemazing # ALT_OBJ= ALT_TARGET= @@ -135,6 +135,10 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} +bemazing: ${PROG} + ${RM} -f $@ + ${CP} $< $@ + # alternative executable # alt: data ${ALT_TARGET} diff --git a/1998/bas1/README.md b/1998/bas1/README.md index afd9ae665..a5593639c 100644 --- a/1998/bas1/README.md +++ b/1998/bas1/README.md @@ -10,19 +10,19 @@ make all If `lpr` on your system can print PostScript: ```sh -./bas1 | gunzip | lpr +./bemazing | gunzip | lpr ``` else, while in X Window System, ```sh -./bas1 | gunzip | gv - +./bemazing | gunzip | gv - ``` or: ```sh -./bas1 | gunzip | gs -sDEVICE=pgmraw -sOutputFile='|xv -' - +./bemazing | gunzip | gs -sDEVICE=pgmraw -sOutputFile='|xv -' - ``` @@ -47,19 +47,21 @@ creates a 3D maze of beams. Try to go from the entrance (the unfinished beam in one corner) to the exit (the unfinished beam in the opposite corner) or vice versa. -For maximum portability, `Bemazing` is not tied to any window system, -but creates postscript. The picture it makes will fit on either A4 or -letter size paper. +For maximum portability, `Bemazing` is not tied to any window system, but +creates postscript output. The picture it makes will fit on either A4 or letter +size paper. In addition, because postscript is rather verbose, `Bemazing` creates -the postscript in gzip format, in order to save precious bits on your -hard disk for the latest version of GNU Emacs (after all, you wouldn't +the postscript in `gzip(1)` format, in order to save precious bits on your +hard disk for the latest version of [GNU +Emacs](https://www.gnu.org/software/emacs/) (after all, you wouldn't want to use an editor without a psychoanalyze-pinhead function, now would you). Again for maximum portability, `Bemazing` will take special care that the binary output will not contain any newline or return characters that may get weird treatment on systems that do not use the One True Line Separator. + ### NOTES Be sure to view the source with something that can display characters