From 45a7c8ca5f1fad80fec531c972f267d8d1bec3a3 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 3 Dec 2023 09:50:59 -0800 Subject: [PATCH] Add 2013/cable2/try.sh + update bugs + formatting The try.sh script is as usual but it integrates some of the comments in the previous set of commands in the 'try' section (in particular about different typesets). The bugs.md was updated with features, not bugs. Typo/format check README.md file. --- 2013/cable2/README.md | 66 ++++++++++++++++--------------------------- 2013/cable2/try.sh | 55 ++++++++++++++++++++++++++++++++++++ bugs.md | 34 ++++++++++++++++++++++ thanks-for-fixes.md | 5 ++++ 4 files changed, 119 insertions(+), 41 deletions(-) create mode 100755 2013/cable2/try.sh diff --git a/2013/cable2/README.md b/2013/cable2/README.md index 9a02aefa4..2b81946a9 100644 --- a/2013/cable2/README.md +++ b/2013/cable2/README.md @@ -5,6 +5,19 @@ make ``` +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [2013 cable2 in bugs.md](/bugs.md#2013-cable2). + + + + ## To use: ```sh @@ -14,44 +27,10 @@ make ### Try: -Here is an OCR example that shows all 94 supported ASCII characters: +For different OCR examples: ```sh -./cable2 ascii.bmp -``` - -Here is an example of colored ASCII: - -```sh -./cable2 multi_color.bmp color -``` - -Here is an example using different character sizes and different -positions in the same file: - -```sh -./cable2 mixed_sizes.bmp -``` - -How about about hand-written C code: - -```sh -./cable2 hello_world.bmp | gcc -xc -o hello - -./hello -``` - -Sometimes typeset text will work, if the typeset has characters that -are enough to the supported handwritten shapes. For example -Menlo, 160 pt: - -```sh -./cable2 typeset.bmp -``` - -And as an added IOCCC bonus: :-) - -```sh -./cable2 bonus.bmp +./try.sh ``` @@ -73,6 +52,7 @@ Magic! BMP files created by most paint programs should work. The author recommends Paint.NET. + ### Features - Every printable ASCII character is recognized (94 characters plus space), plus @@ -91,6 +71,7 @@ colors for different text characters. - If "color" is specified as the second command line parameter, the program's output will also be in color, on ANSI/VTxxx terminals. + ### Why is this entry obfuscated/interesting? - The source is presented as a beautiful moonlit scene, in which a quick brown @@ -117,6 +98,7 @@ sequences? Clue: the weird macro `P` does the interesting part of it, but how? do this? Clue: the string to print is defined in the macro `$`, but how can a string defined in that way ever get printed? + ### Other notes - The novel character recognition algorithm used has not been previously @@ -125,10 +107,10 @@ this entry win the IOCCC, it will be the first time (to the author's knowledge) that the IOCCC has been used for peer review/publication of original research. - OCR in general is a hard problem. Here, we only recognise one possible form for each character. You can see what the supported character shapes look like by -looking at the examples in ascii.bmp. If you copy the shape of the character -forms you find in there, recognition accuracy should be very good (95%+). A more -"useful" version would extend the character stroke table to support multiple -different commonly-used forms for each character. +looking at the examples in [ascii.bmp](ascii.bmp). If you copy the shape of the +character forms you find in there, recognition accuracy should be very good +(95%+). A more "useful" version would extend the character stroke table to +support multiple different commonly-used forms for each character. - Despite being the largest possible IOCCC entry at 4096 bytes, it is also probably the smallest general-purpose OCR program ever written (including the character stroke data), maybe by several orders of magnitude. @@ -137,6 +119,7 @@ McCaughan - thank you!) to squeeze the character stroke table (containing around 2000 strokes for the whole ASCII character set) into a string constant of just 472 characters. + ### Bugs/features - The width of input images must be a multiple of 4. @@ -146,11 +129,12 @@ feature, do not use a greyscale input file! - Normal Windows BMP files are stored "upside-down", i.e. the bottom line in the image is written first. Some (old) graphics programs actually write BMP files "top-to-bottom" and the program does not support such files. -- Using antialiased brush strokes to draw your letters is fine; however, +- Using anti-aliased brush strokes to draw your letters is fine; however, antialiasing interferes with color detection in "color" mode. - Only runs on little endian machines (since the BMP format is little endian, and endianness conversion would make the source too large for IOCCC rule 2). + ### Compiler warnings `clang` warns about unused expression results, missing type specifiers, and diff --git a/2013/cable2/try.sh b/2013/cable2/try.sh new file mode 100755 index 000000000..a03c6dbec --- /dev/null +++ b/2013/cable2/try.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2013/cable2 +# + +# 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 for OCR example that shows all 94 ASCII chars: " +echo 1>&2 +echo "$ ./cable2 ascii.bmp" 1>&2 +./cable2 ascii.bmp +echo 1>&2 + +read -r -n 1 -p "Press any key for OCR example with ASCII colours: " +echo 1>&2 +echo "$ ./cable2 multi_color.bmp color" 1>&2 +./cable2 multi_color.bmp color +echo 1>&2 + +read -r -n 1 -p "Press any key for OCR example of different character size/positions: " +echo 1>&2 +echo "$ ./cable2 mixed_sizes.bmp" 1>&2 +./cable2 mixed_sizes.bmp +echo 1>&2 + +read -r -n 1 -p "Press any key to extract and compile C code by OCR: " +echo 1>&2 +echo "$ ./cable2 hello_world.bmp | gcc -xc -o hello -" 1>&2 +./cable2 hello_world.bmp | gcc -xc -o hello - +echo "$ ./hello" 1>&2 +./hello +echo 1>&2 + +echo "Sometimes typeset text will work if the typeset has characters that are" 1>&2 +echo "enough to support the handwritten shapes." 1>&2 +read -r -n 1 -p "Press any key to try Menlo 160pt text: " +echo 1>&2 +echo "$ ./cable2 typeset.bmp" 1>&2 +./cable2 typeset.bmp +echo 1>&2 + +read -r -n 1 -p "Press any key for an added IOCCC bonus: " +echo 1>&2 +echo "$ ./cable2 bonus.bmp" 1>&2 +./cable2 bonus.bmp diff --git a/bugs.md b/bugs.md index 5ab0e0dc4..f71ae6830 100644 --- a/bugs.md +++ b/bugs.md @@ -2840,6 +2840,26 @@ fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-) # 2013 +## 2013 cable2 + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2013/cable2/cable2.c](2013/cable2/cable2.c) +### Information: [2013/cable2/README.md](2013/cable2/README.md) + +The author stated: + +- The width of input images must be a multiple of 4. +- Input images can be 8-bit greyscale, 24-bit color or 32-bit color only. 8-bit +color and 16-bit color are not supported. If you use the "color" command-line +feature, do not use a greyscale input file! +- Normal Windows BMP files are stored "upside-down", i.e. the bottom line in the +image is written first. Some (old) graphics programs actually write BMP files +"top-to-bottom" and the program does not support such files. +- Using anti-aliased brush strokes to draw your letters is fine; however, +antialiasing interferes with color detection in "color" mode. +- Only runs on little endian machines (since the BMP format is little endian, +and endianness conversion would make the source too large for IOCCC rule 2). + ## 2013 cable3 @@ -2882,6 +2902,20 @@ This program will not terminate on its own; you must kill `hou` (but not Qiming Hou :-) ) yourself. This should not be fixed. +## 2013 mills + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2013/mills/mills.c](2013/mills/mills.c) +### Information: [2013/mills/README.md](2013/mills/README.md) + +The author reminds us that if you kill the program you will have to wait a short +bit of time before you can start it again if you want it to be able to bind to +the socket (which obviously you do). The source is out the scope of this +document but the author does mention the well known (at least to those of us who +have experience with socket programming :-) ) fix. However as the author pointed +it out as a known limitation it is not a bug but a feature. + + # 2014 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 6f3426539..627feb0a4 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3495,6 +3495,11 @@ Cody also added the [try.sh](2013/birken/try.sh) script for the entry and the joke Easter egg in it based on the judges' remarks. +## [2013/cable2](2013/cable2/cable2.c) ([README.md](2013/cable2/README.md])) + +[Cody](#cody) added the [try.sh](2013/cable2/try.sh) script. + + ## [2013/cable3](2013/cable3/cable3.c) ([README.md](2013/cable3/README.md])) [Cody](#cody) fixed this to compile with modern systems. The problems were that