diff --git a/1996/westley/.gitignore b/1996/westley/.gitignore index 2a0c890f9..0c08f64e6 100644 --- a/1996/westley/.gitignore +++ b/1996/westley/.gitignore @@ -1 +1,2 @@ westley +westley.alt diff --git a/1996/westley/Makefile b/1996/westley/Makefile index 92a7192ed..f73463f0a 100644 --- a/1996/westley/Makefile +++ b/1996/westley/Makefile @@ -167,8 +167,8 @@ OBJ= ${PROG}.o DATA= clock1 clock2 clock3 TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= westley.alt.o +ALT_TARGET= westley.alt ################# diff --git a/1996/westley/README.md b/1996/westley/README.md index 3c14411c6..775a0779d 100644 --- a/1996/westley/README.md +++ b/1996/westley/README.md @@ -11,26 +11,47 @@ make all -### To run + +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed a segfault in +this entry as well as it displaying environmental variables if argc == 1. +Although the scripts showed correct output these also segfaulted but with the +fix they no longer do. Now if argc < 5 (argv[4] is referenced) it will not do +anything and it will not segfault either (this was caused by the body of the +for() loop which is now empty (it doesn't appear to be needed at all). Note that +this does make some of the author's explanations / portability notes no longer +valid but we have kept them there for the interested. The original is in +[westley.alt.c](westley.alt.c). Thank you Cody for your assistance! + + +## To run: sh ./clock1 -## Judges' comments + +## Try: + + + sh ./clock2 Also try: + + + sh ./clock2 - sh ./clock2 And for a good time, try: - sh ./clock3 + + sh ./clock3 + +## Judges' comments: Time and time again, Brian Westley seems to come up with a winner! We are amazed at how much is being done with only one relatively short line. We think you will as well if you take the time to understand it. -## Author's comments +## Author's comments: This 1-line program allows various analog ASCII clocks to print out the time; the ASCII clock is built from diff --git a/1996/westley/westley.alt.c b/1996/westley/westley.alt.c new file mode 100644 index 000000000..00f7ec364 --- /dev/null +++ b/1996/westley/westley.alt.c @@ -0,0 +1 @@ +main(h,m)char**m;{for(time(*m);h/=2;)m[4][m[h][h[(int*)localtime(*m)]]]=m[3][h];puts(m[4]);} diff --git a/1996/westley/westley.c b/1996/westley/westley.c index 00f7ec364..46d2475b5 100644 --- a/1996/westley/westley.c +++ b/1996/westley/westley.c @@ -1 +1 @@ -main(h,m)char**m;{for(time(*m);h/=2;)m[4][m[h][h[(int*)localtime(*m)]]]=m[3][h];puts(m[4]);} +main(h,m)int h;char**m;{if(h>4){for(time(*m);h/=2;);puts(m[4]);}}