Get 1986/holloway to compile with clang

As I described in the README.md the problem was that clang is more
strict about the second (also third but this is not used) arg type being
char **. However changing its type to char ** and updating *s to be **s
resulted in a core dump (segfault); and not doing that caused other
problems. The fix was to do a char *t = s; and then update in the code
the references to s to be t (including passing it to main()). This makes
it compile and run successfully with both clang and gcc.
This commit is contained in:
Cody Boone Ferguson committed 2023-03-14 07:35:19 -07:00
1 parent bc454ddb18
commit 9941402291
2 files changed
+10 -7

No files matched your search

+6 -4
View File
@@ -10,10 +10,12 @@ USA
make all
NOTE: we could not compile this entry under modern macOS but it will work
fine under linux. It likely fails to compile under macOS because its gcc is
actually just clang which is more strict about the type of the second
argument of main(). If you have gcc under macOS it might work just as well.
NOTE: Cody Boone Ferguson fixed this to compile with clang (it worked with gcc).
The problem was that clang is more strict about the type of second arg to
main(). However simply changing it to a `char **` and updating the `*s` to `**s`
caused a segfault. By adding a new variable, `char *t`, initialising it to `s`
and then using `t` instead of `s` it compiles and runs successfully under clang
and gcc. Thank you Cody for your assistance!
## Judges' comments:
+4 -3
View File
@@ -11,7 +11,8 @@
long tab1[]={ 989L,5L,26L,0L,88319L,123L,0L,9367L };
int tab2[]={ 4,6,10,14,22,26,34,38,46,58,62,74,82,86 };
main(m1,s) char *s; {
main(m1,s) char **s; {
char *t = s;
int a,b,c,d,o[k],n=(int)s;
if(m1==1){ char b[2*j+f-g]; main(l(h+e)+h+e,b); printf(b); }
else switch(m1-=h){
@@ -27,7 +28,7 @@ main(m1,s) char *s; {
if((b=n)>=e)for(b=g<<g;b<n;++b)o[b]=o[b-h]+o[b-g]+c;
return(o[b-g]%n+k-h);
default:
if(m1-=e) main(m1-g+e+h,s+g); else *(s+g)=f;
for(*s=a=f;a<e;) *s=(*s<<e)|main(h+a++,(char *)m1);
if(m1-=e) main(m1-g+e+h,t+g); else *(t+g)=f;
for(*t=a=f;a<e;) *t=(*t<<e)|main(h+a++,(char *)m1);
}
}