Reinstate NULL FILE * checks in 1991/dds

This commit is contained in:
Cody Boone Ferguson committed 2023-10-30 06:50:02 -07:00
1 parent 30062a189a
commit 92cb3c43db
3 files changed
+18 -23

No files matched your search

+5 -5
View File
@@ -11,8 +11,8 @@ aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\
P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!.Xop.fssps!.Xop.sfu\ P1HL%IQ*m>aN2!N2\nP2Q<fmtf!m,,aHC%MN1!N2>P2Q>aN2\nP2Hbdd!.Xop.fssps!.Xop.sfu\
vso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d";int k;char R[4][99] vso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!b/d";int k;char R[4][99]
;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v ;main(c,v)char**v;{char*p,*r,*q;for(q=s;*q;q++)*q>' '&&(*q)--;{FILE*i=fopen(v
[1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF [1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p++)switch(*p++){B'M':
&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-69);}*r=0 Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return
B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--B'C':k=0;Q k<*p-'0' system(q-69);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--
)(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G':k= *p;G:p=s;while( B'C':k=0;Q k<*p-'0')(*r++=fgetc(i),k++);*r=0 B'I':k= *p;if(**R==k)goto G B'G'
*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}} :k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}}
+7 -14
View File
@@ -652,23 +652,16 @@ If you want to try and fix this (mis)feature, you are welcome to try.
## 1991 dds ## 1991 dds
### STATUS: INABIAF - please **DO NOT** fix ### STATUS: uses gets() - change to fgets() if possible
### Source code: [1991/dds/dds.c](1991/dds/dds.c) ### Source code: [1991/dds/dds.c](1991/dds/dds.c)
### Information: [1991/dds/README.md](1991/dds/README.md) ### Information: [1991/dds/README.md](1991/dds/README.md)
If the BASIC file cannot be opened for reading or the output file cannot be The compiled code uses `gets()` not `fgets()`. Can you fix this? It's quite
opened for writing the program will very likely crash or do something funny. complicated to do: the `s` array is certainly relevant and you can see a bit of
This is not a bug but a feature. Please do not fix this except for the the magic in the [thanks](/thanks-for-fixes.md) and the README.md file for how
challenge to yourself. it works. It's easy enough to get the code to refer to `fgets()` and call it
correctly but it might take more work to get the generated code sorted. This
### STATUS: uses gets() - change to fgets() if possible will be looked at later.
That being said the compiled code uses `gets()` not `fgets()`. Can you fix this?
It's quite complicated to do: the `s` array is certainly relevant and you can
see a bit of the magic in the [thanks](/thanks-for-fixes.md) and the README.md
file for how it works. It's easy enough to get the code to refer to `fgets()`
and call it correctly but it might take more work to get the generated code
sorted. This will be looked at later.
## 1991 westley ## 1991 westley
+6 -4
View File
@@ -1032,10 +1032,12 @@ slightly more like the original, even though it's unused.
## [1991/dds](1991/dds/dds.c) ([README.md](1991/dds/README.md])) ## [1991/dds](1991/dds/dds.c) ([README.md](1991/dds/README.md]))
Cody fixed a segfault that prevented this entry from working in any condition Cody fixed a segfault that prevented this entry from working in any condition
and he also made it work for clang. Clang (at least in some systems?) defaults and he also made it work for clang. He also added checks for NULL `FILE *`s.
to having `-Werror` and the code that the entry generates had some warnings
that were causing compilation to fail as it just ran `cc a.c`. It ran it by what Clang (at least in some systems?) defaults to having `-Werror` and the code that
was once `system(q-6);` but with clang this was not enough.. the entry generates had some warnings that were causing compilation to fail as
it just ran `cc a.c`. It ran it by what was once `system(q-6);` but with clang
this was not enough.
The following had to be added to the string `s` (which to fix the segfault was The following had to be added to the string `s` (which to fix the segfault was
changed from `char*s` to `char s[]`): changed from `char*s` to `char s[]`):