Fix segfault in 1984/laman without an arg

This commit is contained in:
Cody Boone Ferguson committed 2023-03-26 11:13:20 -07:00
1 parent 0e2a09de93
commit 860cffbdad
3 files changed
+6 -7

No files matched your search

-2
View File
@@ -159,8 +159,6 @@ all: data ${TARGET}
supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
@echo "NOTE: this entry will likely dump core without an arg and it will not work without"
@echo "a positive number."
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# alternative executable
+5 -4
View File
@@ -10,9 +10,13 @@ Mike Laman
./laman <positive number>
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this entry to not
segfault if no arg is specified. Instead it'll print nothing. Thank you Cody for
your assistance!
## Try:
The program accepts ONE positive argument. Seeing is believing, so try things
The program accepts ONE POSITIVE argument. Seeing is believing, so try things
like:
./laman 4
@@ -21,9 +25,6 @@ like:
This code should run you in circles.
NOTE: this program will likely segfault if you do not provide an argument and it
will not print anything if the number is not positive or not a number.
## Judges' comments:
Some new compilers dislike lines 6 and 10 of the source, so we changed
+1 -1
View File
@@ -1,5 +1,5 @@
a[900]; b;c;d=1 ;e=1;f; g;h;O; main(k,
l)char* *l;{g= atoi(* ++l); for(k=
l)char* *l;{g= l[1]? atoi(*++l) :0;for(k=
0;k*k< g;b=k ++>>1) ;for(h= 0;h*h<=
g;++h); --h;c=( (h+=g>h *(h+1)) -1)>>1;
while(d <=g){ ++O;for (f=0;f< O&&d<=g