diff --git a/2012/deckmyn/.gitignore b/2012/deckmyn/.gitignore index b51f80632..7398d355b 100644 --- a/2012/deckmyn/.gitignore +++ b/2012/deckmyn/.gitignore @@ -1,3 +1,5 @@ +beethoven.pbm +blank.pbm deckmyn example_greensleeves greensleeves.pbm diff --git a/2012/deckmyn/README.md b/2012/deckmyn/README.md index b97be6a62..30d26f9fb 100644 --- a/2012/deckmyn/README.md +++ b/2012/deckmyn/README.md @@ -5,19 +5,28 @@ make ``` +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [2012 deckmyn in bugs.md](/bugs.md#2012-deckmyn). + + ## To use: -A shell interpreter with proper backtick interpolation is required. - ```sh -./deckmyn "`cat deckmyn.c`" "`cat musicfile.txt`" > sheetmusic.pbm +./deckmyn "$(cat deckmyn.c)" "$(cat musicfile.txt)" > sheetmusic.pbm ``` ### Try: ```sh -./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm +./try.sh ``` @@ -26,15 +35,21 @@ A shell interpreter with proper backtick interpolation is required. The C of this entry is definitely sharp. The program cleverly uses its own source at runtime to define the notes, time signature and accidental bitmaps. -In addition to sheet music, this program is also able, given the right input, -to generate an image of a 10-pin [DIP +In addition to sheet music, this program is also able to, given the right input, +generate an image of a 10-pin [DIP chip](https://en.wikipedia.org/wiki/Dual_in-line_package) (a sound processor?). -Ironically, the way this entry is called from the command line is an abuse of [C -Shell](https://en.wikipedia.org/wiki/C_shell). + +### Historical remarks: + +We previously wrote that ironically, the way this entry is called from the +command line is an abuse of [C Shell](https://en.wikipedia.org/wiki/C_shell). Please use [Bourne-family shells](https://en.wikipedia.org/wiki/Bourne_shell) to run this entry. +... but in 2023 we changed the backticks to be the bash `$(..)` construct. This +is not done in the author's remarks, however. + ## Author's remarks: @@ -42,18 +57,36 @@ run this entry. You need the source code and example input (either one of the example files, or manual input as below) ready and a program capable of showing [.pbm bitmap -format](https://en.wikipedia.org/wiki/Netpbm). +format](https://en.wikipedia.org/wiki/Netpbm) images. ```sh ./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm +``` + +If you have macOS you can open the image like: + +```sh open greensleeves.pbm ``` +... otherwise, you'll have to open it in your viewer of choice how you would +normally open an image. + + ```sh ./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 : a4 a4 g2 :; " > short_bass.pbm +``` + +If you have macOS you can open the image like: + +```sh open short_bass.pbm ``` +... otherwise, you'll have to open it in your viewer of choice how you would +normally open an image. + + ### Description Every major C competition should have an entry capable of producing C major. @@ -70,7 +103,7 @@ The program expects *two command line arguments*. The first is a (very long) string that contains the complete music font. Note that it should *not* be given as a file name! The default music font is encoded in the (whitespace of the) source code [deckmyn.c](deckmyn.c) itself. Therefore, the first argument should -be `"cat deckmyn.c"`. +be `"`` ` ``cat deckmyn.c`` ` ``"`. The second command line argument is the music itself. This is, again, a string, not a file name. All music signs are entered as tokens of exactly 3 characters. @@ -78,21 +111,23 @@ The code is very sensitive to bad spacing! So for instance, if you use a file to write the music (e.g. [example\_greensleeves](example_greensleeves)), you should keep in mind that newline is also a character! + ### Internals To minimise the memory footprint, this program has *no variable declarations at all*, except for the arguments to `main()`. The only available memory space is from the command line arguments and count (`argv` and `argc`). Parts of `argv` -are cast as integer when values under 0 or beyond 127 are expected. +are cast as `int` when values under 0 or beyond 127 are expected. The "music font" is defined by the source code itself. The first few lines are -not part of the font definition, as this memory space will modified by the +not part of the font definition, as this memory space will be modified by the program. (So as required by the rules, it is only a (memory) copy of the source code that is modified.) -As there is no memory available, output is directly to stdout, byte by byte, +As there is no memory available, output is directly to `stdout`, byte by byte, from the top left to the bottom right pixel. + ### LIMITATIONS The memory locations of `argv` are used for various purposes. Therefore, the @@ -107,17 +142,18 @@ only error checking available. Any input that is not according to the rules in the [manual](deckmyn.md), may cause errors. The program has no special hardware limitations or requirements, other than 8bit -char (signed or unsigned) and two's complement negatives. +`char` (`signed` or `unsigned`) and two's complement negatives. -The limitations of using char as counters for e.g. the number of music staves +The limitations of using `char` as counters for e.g. the number of music staves are minor. 127 staves to a page is rather a lot. + ### Obfuscations The code has no declared variables other than the command line variables. Not even pointers (we all know how messy code can get with too many pointers!). As more than one variable needs values beyond 127, parts of the command line memory -are cast as integer using a macro. +are cast to `int` using a macro. - The formatting of the code is in fact necessary, as this is the definition of the music font. It is therefore not an obfuscation. @@ -133,7 +169,7 @@ by replacing some numbers by a character representation. On average, therefore, it is not an obfuscation. - Randomly changing the way the elements of `argv` are addressed is a matter of maintaining a diversified code base. It is therefore not... Oh all right. -- The actual output of the music is done by one print command including a 800+ +- The actual output of the music is done by one `printf(3)` call including a 800+ character nested conditional expression. - `printf()` is also used for its return value. diff --git a/2012/deckmyn/deckmyn.md b/2012/deckmyn/deckmyn.md index 825818567..f644252f1 100644 --- a/2012/deckmyn/deckmyn.md +++ b/2012/deckmyn/deckmyn.md @@ -1,5 +1,6 @@ # USER MANUAL + ## Calling the program ```sh @@ -31,14 +32,14 @@ Therefore, when preparing music in a file, care should be taken that the last musical element of a line is only 2 characters! 1. Basic notes: - A single note is input by a letter `[A-Ga-g]` followed by a duration - [1,2,4,8] and possibly a dot [`.`]. The notes cover 2 octaves, from `C` - (lowest) to `b` (highest). The possible durations are 1 (whole note), 2 - (half note), 4 (quaver), 8 (semi-quaver). So a dotted quaver `A` followed by - a semi quaver `G` is input as `"A4.G8 "`. + A single note is input by a letter (in the range `[A-Ga-g]`) followed by a + duration (1, 2, 4 or 8) and possibly a dot (`.`). The notes cover 2 octaves, + from `C` (lowest) to `b` (highest). The possible durations are 1 (whole + note), 2 (half note), 4 (quaver), 8 (semi-quaver). So a dotted quaver `A` + followed by a semi quaver `G` is input as `"A4.G8 "`. 2. Rests: - A rest is given by the letter [`r`] followed by a duration [1,2,4,8]. + A rest is given by the letter `r` followed by a duration (1, 2, 4 or 8). 3. Bar lines: There are three possible bar line types: single (`": "`), double (`":: "`) @@ -54,7 +55,7 @@ musical element of a line is only 2 characters! 5. Space (formatting): To manually change the spacing of the music, you can add space between - different musical elements. This is given by a `[s]` followed by the amount + different musical elements. This is given by an `s` followed by the amount of space. `"s3 "` is the space taken by one note. This length is given in 1 character. However, to get a value larger than 9, you can just continue along the ASCII table. So `"sz "` gives you quite a lot of space on a staff. @@ -79,6 +80,7 @@ musical element of a line is only 2 characters! input. If the music starts with `"KF "`, the music will be written in a bass clef. `"K"` followed by any other letter will just default to a standard G clef. + ## Examples Blank music paper (with G clef): diff --git a/2012/deckmyn/try.sh b/2012/deckmyn/try.sh new file mode 100755 index 000000000..ef62403dc --- /dev/null +++ b/2012/deckmyn/try.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2012/deckmyn +# + +# 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 + +read -r -n 1 -p "Press any key to run deckmyn.c through less (space = next page, q = quit): " +echo 1>&2 +less deckmyn.c +echo 1>&2 +echo "$ ./deckmyn "\$\(cat deckmyn.c\)" "\$\(cat example_greensleeves\)" 2>/dev/null > greensleeves.pbm" 1>&2 +./deckmyn "$(cat deckmyn.c)" "$(cat example_greensleeves)" 2>/dev/null > greensleeves.pbm +echo 1>&2 +echo "Now open greensleeves.pbm in your image viewer of choice." 1>&2 +echo 1>&2 + +echo "$ ./deckmyn "\$\(cat deckmyn.c\)" "\$\(cat example_beethoven\)" 2>/dev/null > beethoven.pbm" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +./deckmyn "$(cat deckmyn.c)" "$(cat example_beethoven)" 2>/dev/null > beethoven.pbm +echo "Now open beethoven.pbm in your image viewer of choice." 1>&2 +echo 1>&2 + +echo "$ ./deckmyn "\$\(cat deckmyn.c\)" \"sz sa x s1 x s1 x s1 x s1 x s1 \" 2>/dev/null > blank.pbm" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +./deckmyn "$(cat deckmyn.c)" "sz sa x s1 x s1 x s1 x s1 x s1 " 2>/dev/null > blank.pbm +echo "Now open blank.pbm in your image viewer of choice." 1>&2 + diff --git a/2012/hamano/README.md b/2012/hamano/README.md index 9d2b1cffc..b5417be80 100644 --- a/2012/hamano/README.md +++ b/2012/hamano/README.md @@ -15,23 +15,21 @@ make ### Try: ```sh -./hamano < README.md > hint.pdf +./try.sh ``` -You can read `hint.pdf` with a PDF reader like `acroread hint.pdf` or `evince -hint.pdf`. With macOS you can do `open hint.pdf` which by default will open -`Preview.app`. You may of course use your pdf view to open the file directly -instead. +The script will generate a number of PDF files and it will suggest you look at +them as well. You can read `hint.pdf` with a PDF reader like `acroread hint.pdf` +or `evince hint.pdf`. With macOS you can do `open hint.pdf` which by default +will open `Preview.app`. You may of course use your pdf viewer to open the file +directly instead. +One of the PDF files generated is this README.md file as a PDF, obfuscated, and +the PDF file will then be compiled as C (itself!) and executed so that it shows +README.md! -To deobfuscate: - -```sh -cc -xc hint.pdf -o hint -./hint -``` - -Of course, You can also obfuscate C code: +Another PDF file generated is obfuscated C code. Once this is done it will +compile the PDF as if it was C and then run it like: ```sh echo 'int main(){puts("Hello World!");}' | ./hamano > hello.pdf @@ -53,7 +51,8 @@ is the font?), and the submitted entry created PDF files that left Ghostscript confused. The results can be viewed with Acrobat Reader, -[evince](http://en.wikipedia.org/wiki/Evince) and Apple's Preview. +[evince](http://en.wikipedia.org/wiki/Evince) and Apple's +[Preview](https://en.wikipedia.org/wiki/Preview_(macOS)). The updated version can also be viewed using Ghostscript. @@ -63,7 +62,9 @@ you might draw is too elementary. :-) So what do those flags really mean? -The [Dancing men algorithm][1] might be useful. +The [Dancing men +algorithm](http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men) might +be useful. Don't forget to take a look at the generated PDF. Perhaps you might even want to compile the output with a C compiler. When you run it, what does it diff --git a/2012/hamano/try.sh b/2012/hamano/try.sh new file mode 100755 index 000000000..2f949d0e4 --- /dev/null +++ b/2012/hamano/try.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2012/hamano +# + +# 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 + +read -r -n 1 -p "Press any key to obfuscate README.md, writing to hint.pdf: " +echo 1>&2 +echo "$ ./hamano < README.md > hint.pdf" 1>&2 +./hamano < README.md > hint.pdf + +echo "Now try opening it in a pdf viewer before proceeding." 1>&2 +read -r -n 1 -p "Press any key to continue: " + +echo 1>&2 +echo "$ ${CC} -xc hint.pdf -o hint" 1>&2 +${CC} -xc hint.pdf -o hint +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./hint | less (space = next page, q = quit): " +./hint | less + +echo 1>&2 + +echo "Will obfuscate the following code: " 1>&2 +echo 1>&2 +echo " int main(){puts("Hello World!");}" +echo 1>&2 +echo "writing to hello.pdf" 1>&2 +echo 'int main(){puts("Hello World!");}' | ./hamano > hello.pdf +echo 1>&2 +echo "Now open hello.pdf in a pdf viewer before continuing." 1>&2 +echo 1>&2 +read -r -n 1 -p "Press any key to continue to deobfuscate and compile hello.pdf: " +echo 1>&2 +echo "$ ${CC} -Wno-implicit-function-declaration -xc hello.pdf -o hello2" 1>&2 +${CC} -Wno-implicit-function-declaration -xc hello.pdf -o hello2 +echo "$ ./hello2 | ${CC} -Wno-implicit-function-declaration -xc - -o ./hello3" 1>&2 +./hello2 | ${CC} -Wno-implicit-function-declaration -xc - -o ./hello3 +echo "$ ./hello3" 1>&2 +./hello3 diff --git a/2012/tromp/README.md b/2012/tromp/README.md index cdc78d1c9..713377405 100644 --- a/2012/tromp/README.md +++ b/2012/tromp/README.md @@ -7,6 +7,18 @@ make tromp32 # On a 32-bit machine ``` +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [2012 tromp in bugs.md](/bugs.md#2012-tromp). + + + ## To use: ```sh @@ -27,9 +39,7 @@ cat binary-prog.Blc data | ./tromp ### Try: ```sh -(cat hilbert.Blc; echo -n 1234) | ./tromp -(cat oddindices.Blc; echo; cat primes.blc | ./tromp -b) | ./tromp -cat primes.blc | ./tromp -b | ./primes.pl +./try.sh ``` @@ -73,11 +83,11 @@ with [De Bruijn notation](https://en.wikipedia.org/wiki/De_Bruijn_notation) `\ \ In the closely related [BLC8](https://tromp.github.io/cl/Binary_lambda_calculus.html#BLC8:_byte_sized_I.2FO) -language, IO is byte oriented, translating between a stream of bytes and a list +language, I/O is byte oriented, translating between a stream of bytes and a list of length-8 lists of [booleans](https://en.wikipedia.org/wiki/Boolean_algebra). The submission implements the universal machine in the most concise manner conceivable. -It lacks `#defines` and `#includes`, and compiles to a (stripped) executable of +It lacks `#define`s and `#include`s, and compiles to a (stripped) executable of under 6K in size. Without arguments, it runs in byte mode, using standard input and output. @@ -95,13 +105,14 @@ The program uses the following exit codes: The size of the term space is fixed at compile time with `-DA`. + ### A half byte `cat` The shortest (closed) lambda calculus term is `\x x (\ 1` in [De Bruijn notation](https://en.wikipedia.org/wiki/De_Bruijn_notation)) which is the identity function. When its encoding `0010` is fed into the universal machine, -it will simply copy the input to the output. (well, not that simply, since each -byte is smashed to bits and rebuilt from scratch) Voila: a half byte cat: +it will simply copy the input to the output (well, not that simply, since each +byte is smashed to bits and rebuilt from scratch). Voila: a half byte cat: ```sh $ echo " Hello, world" | ./tromp @@ -118,7 +129,6 @@ Hello, world ``` - ### Bad programs If the input doesn't start with a valid program, that is, @@ -129,14 +139,13 @@ it will crash in some way. E.g. the following might dump core: echo -n "U" | ./tromp ``` -Furthermore, the interpreter requires the initial encoded lambda term to be closed, -that is, variable `n` can only appear within at least `n` enclosing lambdas. -For instance the term `\ 5` is not closed, causing the interpreter to crash when -looking into a null-pointer environment: +Furthermore, the interpreter requires the initial encoded lambda term to be +closed, that is, variable `n` can only appear within at least `n` enclosing +lambdas. For instance, here the term `\ 5` is not closed, causing the +interpreter to crash when looking into a null-pointer environment: ```sh echo ">Hello, world" | ./tromp - ``` will likely dump core. @@ -199,7 +208,8 @@ Ni hao ### A prime number sieve -Even shorter than the self-interpreter is this prime number sieve in 167 bits (under 21 bytes): +Even shorter than the self-interpreter is this prime number sieve in 167 bits +(under 21 bytes): ``` 000100011001100101000110100 @@ -329,11 +339,13 @@ Hello World! Curiously, the interpreter `bf.Blc` is the exact same size as `hw.bf`. + ### A BLC assembler Writing BLC programs can be made slightly less painful with this parser that translates single-letter-variable lambda calculus into BLC: + ```sh $ echo "\f\x f (f (f x))" > three $ cat parse.Blc three | ./tromp @@ -356,7 +368,7 @@ cat parse.Blc reverse | ./tromp > reverse.blc and change it to BLC8 with -``` +```sh $ cat deflate.Blc reverse.blc | ./tromp > rev.Blc $ wc rev.Blc 0 1 9 rev.Blc @@ -438,6 +450,7 @@ out all multiples of the first prime, 2. Since my computer reaches swap hell before line 40, we can't see the next bit arriving, at least not in this symbolic reduction. + ### Performance Performance is quite decent, and amazingly good for such a tiny implementation, @@ -476,9 +489,10 @@ How does the program reach exit code 0? And how do any of those BLC programs work? + ### Portability -The program freely (without casting) converts between int and `int *`, causing +The program freely (without casting) converts between `int` and `int *`, causing many warnings; ``` @@ -496,22 +510,27 @@ many warnings; Avoiding these would make the program substantially longer, and detract from its single minded focus on conciseness. -It implicitly declares functions `read()`, `write()`, `exit()` and `calloc()`, the latter two incompatibly. -32 bit and 64 bit executables are separate [Makefile](Makefile) targets, involving a change -from `int` to `long` and from a hardcoded sizeof of 4 to 8. +It implicitly declares functions `read(2)`, `write(2)`, `exit(3)` and +`calloc(3)`, the latter two incompatibly. 32 bit and 64 bit executables are +separate [Makefile](Makefile) targets, involving a change from `int` to `long` +and from a hardcoded sizeof of 4 to 8. + +The program has been tested to work correctly on Linux/Solaris/MacOSX both in 32 +and 64 bits. -The program has been tested to work correctly on Linux/Solaris/MacOSX both in 32 and 64 bits. ### How the program works See the file [how.md](how.md). + ### Acknowledgements Christopher Hendrie, Bertram Felgenhauer, Alex Stangl, Seong-hoon Kang, and [Yusuke Endoh](/winners.html#Yusuke_Endoh) have contributed ideas and suggestions for improvement. + ### References Binary Lambda Calculus - diff --git a/2012/tromp/how.md b/2012/tromp/how.md index ead070e9b..5ab2bc82a 100644 --- a/2012/tromp/how.md +++ b/2012/tromp/how.md @@ -10,7 +10,7 @@ continuations (see the 3rd reference for details). The term space holds [lambda calculus](https://en.wikipedia.org/wiki/Lambda_calculus) terms in the following -format. 0 denotes some form of IO; the only four occurrences are at: +format. 0 denotes some form of I/O; the only four occurrences are at: ``` C=13: recognizes end of a byte @@ -19,10 +19,10 @@ format. 0 denotes some form of IO; the only four occurrences are at: C=end: input list, expanded lazily ``` -`1` denotes a variable, with next entry its de [Bruijn +`1` denotes a variable, with the next entry its [de Bruijn index](https://en.wikipedia.org/wiki/De_Bruijn_index). -`2` denotes application with next entry the size of the term being applied. +`2` denotes application with the next entry the size of the term being applied. `3` denotes lambda abstraction. @@ -31,11 +31,11 @@ A closure consists of the following items: 0. pointer to the next closure (as part of an environment), or next record on free list. -1. reference count -2. pointer to environment -3. lambda term (index in term space) +1. reference count. +2. pointer to environment. +3. lambda term (index in term space). -Here's what each variable do: +Here's what each variable does: ``` L Lambda term space diff --git a/2012/tromp/try.sh b/2012/tromp/try.sh new file mode 100755 index 000000000..1b404686b --- /dev/null +++ b/2012/tromp/try.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2012/tromp +# + +# 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 + +# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? +# shellcheck disable=SC2140 +echo "$ (cat hilbert.Blc; echo -n "1") | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +(cat hilbert.Blc; echo -n "1") | ./tromp +echo 1>&2 + +# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? +# shellcheck disable=SC2140 +echo "$ (cat hilbert.Blc; echo -n "12") | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +(cat hilbert.Blc; echo -n "12") | ./tromp +echo 1>&2 + +# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? +# shellcheck disable=SC2140 +echo "$ (cat hilbert.Blc; echo -n "123") | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 + +# There's no such thing as a useless cat so we silence: +# +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# +# shellcheck disable=SC2002 +(cat hilbert.Blc; echo -n "123") | ./tromp +echo 1>&2 + +echo "$ (cat hilbert.Blc; echo -n 1234) | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +# There's no such thing as a useless cat so we silence: +# +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# +# shellcheck disable=SC2002 + +(cat hilbert.Blc; echo -n 1234) | ./tromp +echo 1>&2 + +echo "$ echo " Hello, world" | ./tromp" +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +echo " Hello, world" | ./tromp +echo 1>&2 + +echo "$ echo "*Hello, world" | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +echo "*Hello, world" | ./tromp +echo 1>&2 + +echo "$ (cat uni8.Blc; echo " Ni hao") | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +# There's no such thing as a useless cat so we silence: +# +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# +# shellcheck disable=SC2002 +(cat uni8.Blc; echo " Ni hao") | ./tromp +echo 1>&2 + +echo "$ cat primes.blc | ./tromp -b | head -c 70" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +# There's no such thing as a useless cat so we silence: +# +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# +# shellcheck disable=SC2002 +cat primes.blc | ./tromp -b | head -c 70 +echo 1>&2 + +echo "$ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70" 1>&2 +echo 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +# There's no such thing as a useless cat so we silence: +# +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# +# shellcheck disable=SC2002 +(cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70 +echo 1>&2 + +echo "$ cat hw.bf" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +cat hw.bf +echo 1>&2 +echo "$ cat bf.Blc hw.bf | ./tromp" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +# There's no such thing as a useless cat so we silence: +# +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# +# shellcheck disable=SC2002 +cat bf.Blc hw.bf | ./tromp + +echo 1>&2 +echo "We also recommend that you check the author's remarks for more examples." 1>&2 diff --git a/bugs.md b/bugs.md index c81f9eba3..b9fb5e81c 100644 --- a/bugs.md +++ b/bugs.md @@ -2728,6 +2728,74 @@ fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-) # 2012 +## 2012 deckmyn + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2012/deckmyn/deckmyn.c](2012/deckmyn/deckmyn.c) +### Information: [2012/deckmyn/README.md](2012/deckmyn/README.md) + +The author stated: + +``` +The memory locations of `argv` are used for various purposes. Therefore, the +program name (default `deckmyn`) must be *at least 4 characters long*, including +possibly the path. This, along with the ending `'\0'`, gives a minimum 5 bytes of +useful memory space. Otherwise, the program may attempt to write outside the +string. + +The code is quite sensitive. Errors in the input can lead to strange results. +The code does not read beyond the end of the music input, but that is about the +only error checking available. Any input that is not according to the rules in +the deckmyn.md, may cause errors. + +The program has no special hardware limitations or requirements, other than 8bit +`char` (`signed` or `unsigned`) and two's complement negatives. + +The limitations of using `char` as counters for e.g. the number of music staves +are minor. 127 staves to a page is rather a lot. + +The file layout must be exactly the same as deckmyn.c though, only the locations +of space (`" "`) may differ. + +Every element in the music is given by a string of *exactly* 3 characters. Any +violation of this will result in the rest of the music being interpreted in some +randomly wrong way. Notice that in a file, the newline is also a character! +Therefore, when preparing music in a file, care should be taken that the last +musical element of a line is only 2 characters! +``` + + + +The manual referred to is [here](2012/deckmyn/deckmyn.md). + + +## 2012 tromp + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2012/tromp/tromp.c](2012/tromp/tromp.c) +### Information: [2012/tromp/README.md](2012/tromp/README.md) + +The author stated: + +``` +If the input doesn't start with a valid program, that is, +if the interpreter reaches end-of-file during program parsing, +it will crash in some way. E.g. the following might dump core: + + echo -n "U" | ./tromp + +Furthermore, the interpreter requires the initial encoded lambda term to be closed, +that is, variable n can only appear within at least 'n' enclosing lambdas. +For instance, here the term '\ 5' is not closed, causing the interpreter to crash when +looking into a null-pointer environment: + + echo ">Hello, world" | ./tromp + +will likely dump core. + +``` + + ## 2012 vik ### STATUS: INABIAF - please **DO NOT** fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 4be66e285..298226ba3 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3327,6 +3327,11 @@ Cody added explicit linking of libm (`-lm`) as not all systems do this implicitly (linux doesn't seem to but macOS does). +## [2012/deckmyn](2012/deckmyn/deckmyn.c) ([README.md](2012/deckmyn/README.md])) + +Cody added the [try.sh](2012/deckmyn/try.sh) script. + + ## [2012/endoh1](2012/endoh1/endoh1.c) ([README.md](2012/endoh1/README.md)) Cody added explicit linking of libm (`-lm`) as not all systems do this @@ -3344,6 +3349,11 @@ Cody fixed a typo in the ruby script Cody restored the original code from the archive. +## [2012/hamano](2012/hamano/hamano.c) ([README.md](2012/hamano/README.md])) + +Cody added the [try.sh](2012/hamano/try.sh) script. + + ## [2012/hou](2012/hou/hou.c) ([README.md](2012/hou/README.md])) Cody added the [try.sh](2012/hou/try.sh) script and restored the original [hint @@ -3386,6 +3396,11 @@ show different languages and numbers. Cody added the [try.sh](2012/konno/try.sh) script. +## [2012/tromp](2012/tromp/tromp.c) ([README.md](2012/tromp/README.md)) + +Cody added the [try.sh](2012/tromp/try.sh) script. + + ## [2012/vik](2012/vik/vik.c) ([README.md](2012/vik/README.md])) Based on the author's description it should be able to get this entry to work