diff --git a/1991/dds/dds.c b/1991/dds/dds.c index 2670a5a85..3165c02ef 100644 --- a/1991/dds/dds.c +++ b/1991/dds/dds.c @@ -1,19 +1,19 @@ #include #define Q r=R[*p++-'0'];while( #define B ;break;case -char s[]="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[QaP2QaP4HC%T\ -Qs\\q,,^>m,2aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\ -R%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\ -\\(aP3Q(^*m>g\\(aP3Q(^::::aHC%VP3Q>bupj)ghfut)c-::-tuejo**aHb%JD12JON1!Qjg)a%LN1U\ -P1D12JIQUaP1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.fssp\ -s!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!.Xop.jnqmjdju.jou!.jod\ -mvef!tuejp/i!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");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-104);}*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]++;}}} +char s[]="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[QaP2QaP4\ +HC%TQs\\q,,^>m,2aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQU\ +aP1HR%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\\(aP3Q(^*m>g\\(aP3Q(^::::aHC%VP3Q>bupj)ghfut)c-::-tuejo**aHb%JD12JON1!Qjg)a%\ +LN1UP1D12JIQUaP1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.\ +fssps!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!.Xop.jnqmjdju.jou!.jodmvef!tuejp/i!\ +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");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-87);}*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/thanks-for-fixes.md b/thanks-for-fixes.md index 43390e23a..735428f57 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1212,8 +1212,10 @@ the entry generates had some warnings that were causing compilation to fail if `cc` is clang as it just ran `cc a.c`. It ran it by what was once `system(q-6);` but if `cc` is clang like in macOS this is not enough. -(Cody stupidly did the below manually until he thought to write a simple program -to do the conversions which he used for `gets()` to `fgets()`.) +(Cody said he stupidly did the below manually until he thought to write a simple +program to do the conversions which he used for `gets()` to `fgets()` and for +making the generated code return a value from `main()` rather than just +`return;`). The following had to be added to the string `s` (which to fix the segfault was changed from `char*s` to `char s[]`): @@ -1286,25 +1288,30 @@ which is the end of the warning disabled for clang as described above. But now the `system(q-69);` had to be changed to `system(q-86);`. Then, later on, Cody discovered that in some systems, clang triggers even more -warnings so this had to be corrected too. Thus the string had to be changed to, -in full: +warnings so this had to be corrected too so the string was updated again and +the `system(q-86)` had to be changed to `system(q-104)`. + +But then to prevent the need for disabling a warning and to be more correct +code, the generated code was changed to `return 1;` rather than just `return;`. +Thus in full the string became: ```c -char s[]="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[QaP2QaP4HC%T\ -Qs\\q,,^>m,2aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQUaP1H\ -R%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\ -\\(aP3Q(^*m>g\\(aP3Q(^::::aHC%VP3Q>bupj)ghfut)c-::-tuejo**aHb%JD12JON1!Qjg)a%LN1U\ -P1D12JIQUaP1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.fssp\ -s!.Xop.sfuvso.uzqf!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!.Xop.jnqmjdju.jou!.jod\ -mvef!tuejp/i!b/d"; +char s[]="Qjou!s\\311^-g\\311^-n\\311^-c\\::^-q-ma%mO1JBHm%BQ-aP1J[O1HB%[QaP2QaP4\ +HC%TQs\\q,,^>m,2aP4HC%SD12N1\nJNQm>s\\..q^aHC%NHb%GN1!D32P3%RN1UP1D12JPQU\ +aP1HR%PN4\nQaP2Q,2aP4Hb%OD12D12N2!N3\nJVP3Q,,n\\(aP3Q(^*m>g\\(aP3Q(^::::aHC%VP3Q>bupj)ghfut)c-::-tuejo**aHb%JD12JON1!Qjg)a%\ +LN1UP1D12JIQUaP1HL%IQ*m>aN2!N2\nP2QP2Q>aN2\nP2Hbdd!.Xop.\ +fssps!.Xop.jnqmjdju.gvodujpo.efdmbsbujpo!.Xop.jnqmjdju.jou!.jodmvef!tuejp/i!\ +b/d"; ``` -and then the `system(q-86)` had to be changed to `system(q-104)`. It is hoped -that this is the last time the string has to be updated to work with all -versions of clang but if not the above is how it works. +and it now is `system(q-87);`. + +It is hoped that this is the last time the string has to be updated to work with +all versions of clang but if not the above is how it works. With these changes in place it will compile and work with both gcc and clang and the C code generated will use `fgets()`, not `gets()`, therefore removing the