diff --git a/1991/dds/dds.c b/1991/dds/dds.c index f9e5dce46..f05407a6e 100644 --- a/1991/dds/dds.c +++ b/1991/dds/dds.c @@ -11,8 +11,8 @@ aP1Q*aHb%FN1\nQm>::::aHC%VP3Q>bupj)hfut)c**aHb%JD12JON1!Qjg)a%LN1UP1D12JIQUa\ P1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.fssps!.Xop.sfu\ 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 -[1],"r"),*o=fopen(q-3,"w");for(p=s;;p++)switch(*p++){B'M':Q(k=fgetc(i))!=EOF -&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return system(q-69);}*r=0 -B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p--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':k= *p;G:p=s;while( -*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}} +[1],"r"),*o=fopen(q-3,"w");if(!i||!o)return 1;for(p=s;;p++)switch(*p++){B'M': +Q(k=fgetc(i))!=EOF&&k!=*p)*r++=k;if(k==EOF){fputs("}}\n",o);fclose(o);return +system(q-69);}*r=0 B'P':while(*p!='`')fputc(*p++,o)B'O':Q*r)fputc(*r++,o);p-- +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' +:k= *p;G:p=s;while(*p!='$'||p[1]!= k)p++;p++B'N':R[*p-'0'][0]++;}}} diff --git a/bugs.md b/bugs.md index 3300f0f8a..bc5ab5a68 100644 --- a/bugs.md +++ b/bugs.md @@ -652,23 +652,16 @@ If you want to try and fix this (mis)feature, you are welcome to try. ## 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) ### Information: [1991/dds/README.md](1991/dds/README.md) -If the BASIC file cannot be opened for reading or the output file cannot be -opened for writing the program will very likely crash or do something funny. -This is not a bug but a feature. Please do not fix this except for the -challenge to yourself. - -### STATUS: uses gets() - change to fgets() if possible - -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. +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 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 7be29ddfd..3234db882 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -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])) 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 -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 -was once `system(q-6);` but with clang this was not enough.. +and he also made it work for clang. He also added checks for NULL `FILE *`s. + +Clang (at least in some systems?) defaults 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 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 changed from `char*s` to `char s[]`):