From cdc2cffdd0955264fb3f604303e3e7b4b409df6f Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:36:44 -0700 Subject: [PATCH] Undo no arg check in 1990/theorem As part of the redefinition of INABIAF one of the segfault fixes has been undone. The others were necessary as part of making the entry work in modern systems but this one should not have been done. Instead the Makefile and README.md warn about it. I did however discover another bug with this entry that makes one of the generated programs not work. I documented that in bugs.md and I'll look at it another time. --- 1990/theorem/Makefile | 1 + 1990/theorem/README.md | 28 ++++++++++++++-------------- 1990/theorem/theorem.c | 1 - 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/1990/theorem/Makefile b/1990/theorem/Makefile index 758bf8cac..cf9710a31 100644 --- a/1990/theorem/Makefile +++ b/1990/theorem/Makefile @@ -133,6 +133,7 @@ all: data ${TARGET} supernova deep_magic magic charon pluto ${PROG}: ${PROG}.c + @echo "NOTE: this entry will segfault on no arg specified." ${CC} ${CFLAGS} $< -o $@ ${LIBS} sorter.c: ${PROG} ${PROG}.c diff --git a/1990/theorem/README.md b/1990/theorem/README.md index 2aeba6a60..d85a4675f 100644 --- a/1990/theorem/README.md +++ b/1990/theorem/README.md @@ -1,10 +1,10 @@ # Best of Show - Adrian Mariano - University of Washington - 2729 72nd Ave SE - Mercer Island, WA 98040 - USA +Adrian Mariano +University of Washington +2729 72nd Ave SE +Mercer Island, WA 98040 +USA ## To build: @@ -12,13 +12,12 @@ make all [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed some segfaults -under modern (and in some cases earlier) systems with this entry. He also fixed -a segfault if not enough args are used. Originally we noted that the 4 trailing -args '0 0 0 0' were required on systems that dump core when NULL is dereferenced -but this problem showed itself in modern systems even with the 4 '0 0 0 0'. To -make this easier for users Cody also kindly fixed this problem. Finally he -changed this program to use `fgets()` not `gets()` to make it safer. Thank you -Cody for your assistance! +under modern (and in some cases earlier) systems with this entry. Originally we +noted that the 4 trailing args '0 0 0 0' were required on systems that dump core +when NULL is dereferenced but this problem showed itself in modern systems even +with the 4 '0 0 0 0'. Finally he changed this program to use `fgets()` not +`gets()` to make it safer and to prevent a warning about `gets()` at linking or +runtime. Thank you Cody for your assistance! [Yusuke Endoh](/winners.html#Yusuke_Endoh) pointed out that `atof` nowadays needs `#include ` which was used in order to get this to work @@ -37,6 +36,7 @@ where: h - step size y1 - initial value (y(x1) == y1) +NOTE: this entry will segfault on no arg specified. ## Try: @@ -76,7 +76,7 @@ reversing filter! Try: Still not impressed? The author throws in for free, a sort program! Try: - cc sorter.c -o sorter + make sorter ls | ./sorter This program is safe for home use as well. The author has @@ -89,7 +89,7 @@ And finally, as a special offer to users of this entry, the author provides a Fibonacci sequence generator! Try: ./sorter 0 0 0 0 < theorem.c > fibonacci.c - cc fibonacci.c -o fibonacci + make fibonacci ./fibonacci 1 1 ./fibonacci 2 1 diff --git a/1990/theorem/theorem.c b/1990/theorem/theorem.c index cd2c619aa..db1d0de8b 100644 --- a/1990/theorem/theorem.c +++ b/1990/theorem/theorem.c @@ -24,7 +24,6 @@ w(g,R,u)float*g,u;char R; /**/{int b,f;A=atoi(++a);b=atoi(++a);while((f=A+b)<15000){printf("%d\n",f);A=b;b=f;}} main(A,a)int A;char*a[]; o o -if (a[1]==NULL||a[2]==NULL||a[3]==NULL||a[4]==NULL||a[5]==NULL) return 1; if(!strcmp(*++a,"-r"))S(); D=atof(*++a); T=atof(*++a);