diff --git a/1992/adrian/.gitignore b/1992/adrian/.gitignore index d62e915cf..b4e2580d6 100644 --- a/1992/adrian/.gitignore +++ b/1992/adrian/.gitignore @@ -13,8 +13,10 @@ adsleep adsleep.c adwc adwc.c +adwc.adwc.txt *.dSYM indent indent.c indent.o prog.orig +wc.adwc.txt diff --git a/1992/adrian/README.md b/1992/adrian/README.md index ff12916b2..338ba8a1d 100644 --- a/1992/adrian/README.md +++ b/1992/adrian/README.md @@ -20,7 +20,7 @@ For more detailed information see [1992 adrian in bugs.md](/bugs.md#1992-adrian) ### Try: ```sh -./adrian adrian.grep.try < README.md +./try.sh ``` For the slow minded, try: @@ -29,9 +29,6 @@ For the slow minded, try: ./adsleep 32767 ``` -NOTE: if you do not specify an arg some of the programs such as `adsleep` it -will very likely segfault do something funny. This is supposed to happen. - ## Judges' remarks: @@ -160,11 +157,11 @@ Running: will perform a function similar to that of the unix `from` command. -If no filename is specified on the command line, then `__FILE__` is used -as the specification for the automaton. (Originally `"adgrep.c"` the file was renamed -to `adrian.c` by the judges but for more portability the arg was changed to -`__FILE__`.) In this case, the program will search for -matches to the regular expression: +If no filename is specified on the command line, then `__FILE__` is used as the +specification for the automaton. (Originally this was `"adgrep.c"` but the file +was renamed to `adrian.c` by the judges and for more portability the arg was +changed to `__FILE__`.) In this case, the program will search for matches to +the regular expression: ``` ^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$ @@ -219,7 +216,7 @@ you can search for matches to By some freak happenstance, lines of `adrian.c` which match this regular expression form a unix `head(1)` command. It prints the first ten lines of -the file specified on the command line or adrian.c if no file is +the file specified on the command line or `adrian.c` if no file is specified (again this was changed to `__FILE__`). By setting the first line to diff --git a/1992/adrian/try.sh b/1992/adrian/try.sh new file mode 100755 index 000000000..59b715692 --- /dev/null +++ b/1992/adrian/try.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1992/adrian +# + +# 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 + +# don't redirect output to /dev/null so that they can see how it's done, +# assuming it's not already built +make CC="$CC" everything || exit 1 +# DON'T clear the screen so they can see how the files are generated! + +echo 1>&2 +read -r -n 1 -p "Press any key to show: adrian.grep.try: " +echo 1>&2 +cat adrian.grep.try +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./adrian adrian.grep.try < README.md: " +echo 1>&2 +./adrian adrian.grep.try < README.md +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./adhead try.sh: " +echo 1>&2 +./adhead try.sh +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./adecho 1992 IOCCC adrian: " +echo 1>&2 +./adecho 1992 IOCCC adrian +echo 1>&2 + +rm -f wc.adwc.txt adwc.adwc.txt +echo "$ wc adwc.c | sed -e 's/^[[:space:]]//g' | tr -s '[:space:]' | cut -d' ' -f1-3 | tee wc.adwc.txt" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +wc adwc.c | sed -e 's/^[[:space:]]//g' | tr -s '[:space:]' | cut -d' ' -f1-3 | tee wc.adwc.txt +echo 1>&2 + +echo "$ ./adwc adwc.c|tr -s ' '|sed -e 's/^[[:space:]]//g' | tee adwc.adwc.txt" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +./adwc adwc.c|tr -s ' '|sed -e 's/^[[:space:]]//g' | tee adwc.adwc.txt +echo 1>&2 + +read -r -n 1 -p "Press any key to show diff between wc.adwc.txt and adwc.adwc.txt: " +echo 1>&2 +diff -s wc.adwc.txt adwc.adwc.txt +echo 1>&2 +rm -f wc.adwc.txt adwc.adwc.txt + +echo "$ ./adsleep 10" 1>&2 +read -r -n 1 -p "Press any key to take a 10 second nap: " +echo 1>&2 +./adsleep 10 diff --git a/thanks-for-help.md b/thanks-for-help.md index fc0e91b99..96abb5d9f 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -1427,7 +1427,7 @@ from (`__FILE__`), not `adgrep.c`, as the latter does not exist: `adgrep` is simply a link to `adrian` as `adgrep` is what the program was submitted as but the winner is `adrian.c`. -Not fixing the above problem would have also cause the program to crash if no +Not fixing the above problem would have also caused the program to crash if no arg was specified as the file doesn't exist. In making the above fix, at first the change to check for a `NULL` file was added. Then it was noticed that the problem is that `adgrep.c` was an incorrect reference that never existed and it @@ -1489,6 +1489,11 @@ one must keep the `Y[strlen(Y)-1]='\0';` part and keep it there. These fixes are complex changes due to the way the program and Makefile generate the additional tools. +Cody finally added the [try.sh](/1992/adrian/try.sh) script that shows the entry +and some of the tools this entry generates. Unlike other scripts, it does not +clear the screen after compilation so that one can see how the other files are +generated. + ## [1992/albert](/1992/albert/albert.c) ([README.md](/1992/albert/README.md]))