Fix 1996/westley
It always segfaulted (though with the correct input it still showed the right results) and when argc == 1 it showed an environmental variable. The body of the for loop can now be empty (or so it appears). I put the original in westley.alt.c because it has some interesting techniques in which he wrote about (which I preserved in the README.md file). I also put in the original code because I'm not entirely sure if the for loop really can be empty in all cases. Certainly it can be in the scripts provided but I don't know if there is a valid invocation that would need it (but in any case it would always segfault with that loop body). Updated 1996/westley/.gitignore (added westley.alt) and the Makefile so that make alt will build westley.alt. Formatting fixes in README.md.
This commit is contained in:
1 parent
674a05e15e
commit
cf2ec74b17
5 files changed
+31
-8
No files matched your search
@@ -1 +1,2 @@
|
||||
westley
|
||||
westley.alt
|
||||
@@ -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
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+26
-5
@@ -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
|
||||
|
||||
@@ -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]);}
|
||||
@@ -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]);}}
|
||||
Reference in new issue
Block a user