diff --git a/2012/endoh2/README.md b/2012/endoh2/README.md index 5d9c91e0e..cb92caee0 100644 --- a/2012/endoh2/README.md +++ b/2012/endoh2/README.md @@ -27,7 +27,7 @@ gcc -o e e.c ### Try: ```sh -./everything.sh +./try.sh ``` @@ -50,7 +50,7 @@ program and [pi](https://en.wikipedia.org/wiki/Pi) or [e](https://en.wikipedia.org/wiki/E_(mathematical_constant))) computation. I know you're tired of them. -But have you ever seen **all-in-one**? +But have you ever seen them **all-in-one**? ### What it is @@ -72,7 +72,7 @@ rather than pi. ### Obfuscation This program itself is in the shape of a -[spigot](https://en.wikipedia.org/wiki/Tap_(valve)). This is derived from +[spigot](https://en.wikipedia.org/wiki/Tap_(valve)). This is derived as an analogy with [spigot algorithm](https://en.wikipedia.org/wiki/Spigot_algorithm) which infinitely computes the value of a mathematical constant such as [pi](https://en.wikipedia.org/wiki/Pi) or @@ -103,19 +103,24 @@ directives](https://en.wikipedia.org/wiki/C_preprocessor). In my program, These design requirements made my program well-obfuscated willy-nilly. + ### Portability I expect it to work in any major environment and C compiler. To build with no -warning, it requires two C99 features: string literal more than 509 characters -and not requiring a return in `main()` function. In fact, recent compilers with -`-std=c99 -Wall -W -Wextra -pedantic` would say nothing. +warning, it requires two C99 features: allow string literal to be more than 509 +characters and not requiring a return in `main()`. In fact, recent compilers +with `-std=c99 -Wall -W -Wextra -pedantic` would say nothing. - gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c - clang -std=c99 -Wall -W -Wextra -pedantic spigot.c + +```sh +gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c +clang -std=c99 -Wall -W -Wextra -pedantic spigot.c +``` I've tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) and gcc-4.5.3 and clang-3.1 on Cygwin. + ### Synopsis ```sh diff --git a/2012/endoh2/everything.sh b/2012/endoh2/everything.sh deleted file mode 100755 index 69ba30276..000000000 --- a/2012/endoh2/everything.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -make everything || exit 1 - -run() -{ - local program="$1" - echo "" 1>&2 - echo -n "$ ./${program}" 1>&2 - sleep 2 - "./${program}" | less -K -e -} -echo "running everything with $(type -P less): " 1>&2 -echo 1>&2 -run pi -run 314 -run 3141 -run 31415 -run 314159 -run 3141592 -run 31415926 -run 314159265 -run 3141592653 -run 31415926535 -run e 271 -run 2718 -run 27182 -run 271828 -run 2718281 -run 27182818 -run 271828182 -run 2718281828 -run 27182818284 diff --git a/2012/endoh2/try.sh b/2012/endoh2/try.sh new file mode 100755 index 000000000..8d02917ef --- /dev/null +++ b/2012/endoh2/try.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2000/tomx +# + +# 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" everything >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +run() +{ + local program="$1" + echo "" 1>&2 + read -r -n 1 -p "Press any key to run: ./${program} (space = next page, q = quit): " + "./${program}" | less -K -E -X +} +run pi +run 314 +run 3141 +run 31415 +run 314159 +run 3141592 +run 31415926 +run 314159265 +run 3141592653 +run 31415926535 +run e 271 +run 2718 +run 27182 +run 271828 +run 2718281 +run 27182818 +run 271828182 +run 2718281828 +run 27182818284 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 899b1fe8f..b85db13be 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3363,7 +3363,10 @@ de-obfuscated version. ## [2012/endoh2](2012/endoh2/endoh2.c) ([README.md](2012/endoh2/README.md)) -[Cody](#cody) fixed a typo in the ruby script +[Cody](#cody) added the [try.sh](2012/endoh2/try.sh) script that runs +everything, filtered through less. + +Cody also fixed a typo in the ruby script [find-font-table.rb](2012/endoh2/find-font-table.rb).