From e2a8f813dcbf194188bf3c78a6a84f12388e488a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:52:52 -0700 Subject: [PATCH] Fix both original and alt code for 1992/westley For both check args. For alt move main()'s code to new function as some versions of clang do not allow four args. Instead main() has two args now, the traditional argc and argv, and the other two are passed 0. --- 1992/westley/westley.alt.c | 3 ++- 1992/westley/westley.c | 6 +++--- bugs.md | 13 ------------- thanks-for-fixes.md | 15 +++++++++------ 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/1992/westley/westley.alt.c b/1992/westley/westley.alt.c index f188c7e1c..315dac7f0 100644 --- a/1992/westley/westley.alt.c +++ b/1992/westley/westley.alt.c @@ -1,4 +1,5 @@ -main(l,a,n,d)char**a,**n,**d;{int N=n,D=d;for(D=atoi(a[1])/2*80-atoi(a[2])-2043; +pain(l,a,n,d)char**a,**n,**d;{int N=n,D=d;for(D=atoi(a[1])/2*80-atoi(a[2])-2043; N="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd" [l++-3];)for(;N-->64;)putchar(!D+++33^l&1);} +main(l,a)char**a;{pain(l,a,0,0);} diff --git a/1992/westley/westley.c b/1992/westley/westley.c index d9a352b4c..f669a8457 100644 --- a/1992/westley/westley.c +++ b/1992/westley/westley.c @@ -1,7 +1,7 @@ main(l - ,a)char**a;{int n;int - d;for(d=atoi(a[1])/10*80- - atoi(a[2])/5-596;n="@NKA\ + ,a)char**a;{int n;int d; +if (l>2)for(d=atoi(a[1])/10 +*80-atoi(a[2])/5-596;n="@NKA\ CLCCGZAAQBEAADAFaISADJABBA^\ SNLGAQABDAXIMBAACTBATAHDBAN\ ZcEMMCCCCAAhEIJFAEAAABAfHJE\ diff --git a/bugs.md b/bugs.md index 4d3aae201..9fa12f326 100644 --- a/bugs.md +++ b/bugs.md @@ -788,19 +788,6 @@ As you might see the part under the `warning:` line is different. Can you help us? -## 1992 westley - -### STATUS: INABIAF - please **DO NOT** fix -### Source code: [1992/westley/westley.c](1992/westley/westley.c) -### Information: [1992/westley/README.md](1992/westley/README.md) - -This program and the alternate version will very likely crash or -[nuke](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire -world](https://en.wikipedia.org/wiki/Earth) or just the -[USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough -args. And not that we need any help with this or anything :-) but we do -encourage you to test it. This should not be fixed. - # 1993 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 258969431..d34d71cb5 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1209,15 +1209,18 @@ Cody fixed this to work for clang by changing the third and fourth arg of **` and some versions do not even allow a fourth arg. He also added the alternate version that the author gave in the remarks that is -specifically for the USA rather than the world. +specifically for the USA rather than the world. This had to be fixed for clang +as well to make the args of `main()` be the correct type and by moving the body +of main() to another function, `pain()`, which does the work since not all +versions of clang support four args to `main()`. -NOTE: as noted in the README.md file and the [bugs.md](/bugs.md), this program and the -[alternate version](1992/westley/westley.alt.c) will very likely crash or -[nuke](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire +Cody also added an arg check because the program and the +[alternate version](1992/westley/westley.alt.c) might have crashed or +[nuked](https://en.wikipedia.org/wiki/Nuclear_weapon) the [entire world](https://en.wikipedia.org/wiki/Earth) or just the [USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough -args (2). And not that we need the help or anything for this :-) but we do -encourage you to test this :-) This should NOT be fixed. +args (2). And not that we need the help or anything for this :-) but we +encourage you to try the original :-) ## [1993/jonth](1993/jonth/jonth.c) ([README.md](1993/jonth/README.md]))