Fixes in 1998/df

A pointer to int was being used for fopen(3) and this has been changed
to a FILE * as using the wrong type has been observed in some cases to
cause programs to fail.

Make the code more like the original by using the old style main() arg
so that it could read 'int main(i,love_unix)' and also changing the
typedef for 'int' from 'lint' to be '_int' (see the code for why it no
longer can be 'int' and ask yourself why it can be 'int' in other cases).

Format/typo check README.md file.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-13 08:02:39 -08:00
1 parent 10b5b47466
commit 504813918d
4 files changed
+24 -14

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ include ../../var.mk
# #
CSILENCE= -Wno-bitwise-op-parentheses -Wno-char-subscripts -Wno-pointer-to-int-cast \ CSILENCE= -Wno-bitwise-op-parentheses -Wno-char-subscripts -Wno-pointer-to-int-cast \
-Wno-return-type -Wno-unused-parameter -Wno-unused-variable \ -Wno-return-type -Wno-unused-parameter -Wno-unused-variable \
-Wno-typedef-redefinition -Wno-deprecated-non-prototype -Wno-typedef-redefinition -Wno-deprecated-non-prototype -Wno-implicit-int
# Common C compiler warning flags # Common C compiler warning flags
# #
+9 -10
View File
@@ -23,7 +23,7 @@ the program are used.
Curiously, the program only works if its source is in the directory Curiously, the program only works if its source is in the directory
it's run in. More curiously, the program would fail if the program's it's run in. More curiously, the program would fail if the program's
name's second letter wasn't `r` (the source has been changed for your name's second letter wasn't `r` (the source has been changed for your
convenience and this restriction does no longer exist). convenience and this restriction no longer exist).
Modern design has come a long way since the unreadable, tightly-coupled Modern design has come a long way since the unreadable, tightly-coupled
systems we used to have. systems we used to have.
@@ -44,7 +44,7 @@ itself. You can guess a letter simply by typing it in. If your C
implementation requires it, you may have to hit Return before it implementation requires it, you may have to hit Return before it
is recognized. In this case, you can also type multiple guesses is recognized. In this case, you can also type multiple guesses
on the same line (completely solve it by entering on the same line (completely solve it by entering
"abcdefghijklmnopqrstuvwxyz"). Execution stops when all underscores `abcdefghijklmnopqrstuvwxyz`). Execution stops when all underscores
have been replaced. have been replaced.
The program offers a number of different words to guess, `time()` is The program offers a number of different words to guess, `time()` is
@@ -76,7 +76,7 @@ to `#define`. I have also included comments in the code, and vital
code in the comments. And of course there is code that doesn't do code in the comments. And of course there is code that doesn't do
anything but will crash the program if it is removed (just like anything but will crash the program if it is removed (just like
those comments I mentioned above). Additionally, since you said those comments I mentioned above). Additionally, since you said
you'd be preprocessing entries ignoring includes I figured I should you'd be preprocessing entries ignoring `#include`s I figured I should
use some more of them instead of other obfuscation methods. Did use some more of them instead of other obfuscation methods. Did
I mention that preprocessed or beautified sources will crash or I mention that preprocessed or beautified sources will crash or
hang your system? The program will also crash on non-ASCII machines. hang your system? The program will also crash on non-ASCII machines.
@@ -99,7 +99,7 @@ These restrictions have been removed for your convenience.
The following lines describe how this program works; if you don't The following lines describe how this program works; if you don't
want to know it at this time, please skip them. If this entry would want to know it at this time, please skip them. If this entry would
by some mistake win the contest, please do not rot13 this - I hate by some mistake win the contest, please do not rot13 this - I hate
rot13'd spoilers since it is somewhat complicated on a Mac to rot13 spoilers since it is somewhat complicated on a Mac to
reverse them. Anyone out there should have enough discipline and reverse them. Anyone out there should have enough discipline and
rot13 shouldn't be required, really. After all, we are not children rot13 shouldn't be required, really. After all, we are not children
anymore :-) anymore :-)
@@ -123,7 +123,7 @@ spread over six lines in the source; decoding starts on a line
after a tab and a whitespace have been found, and stops on a newline. after a tab and a whitespace have been found, and stops on a newline.
The grin after the "Demonic Smiley" actually is one encoded letter The grin after the "Demonic Smiley" actually is one encoded letter
while the string is completely ignored; and the `cut` in "cut here" while the string is completely ignored; and the `cut` in "cut here"
is required while "here" is not. is required while `here` is not.
"For extra credit", explain why the words are sorted alphabetically "For extra credit", explain why the words are sorted alphabetically
(because I extracted them from a dictionary :-) ) (because I extracted them from a dictionary :-) )
@@ -131,17 +131,16 @@ is required while "here" is not.
The file name had to fulfill the restrictions mentioned above The file name had to fulfill the restrictions mentioned above
because `__FILE__+1` was used as a second parameter to `fopen()`. (It because `__FILE__+1` was used as a second parameter to `fopen()`. (It
essentially was `fopen(__FILE__,__FILE__+1)` ). This was an extra joke essentially was `fopen(__FILE__,__FILE__+1)` ). This was an extra joke
that does no longer exist in the released version. that doesn't exist in the released version.
You probably discovered that the `while(FILE)` in main is not a while loop You probably discovered that the `while(FILE)` in `main()` is not a while loop
but the statement that opens the file and initializes the dictionary. but the statement that opens the file and initializes the dictionary.
Similarly, int and signed have been redefined (to save space, of Similarly, `int` and `signed` have been redefined (to save space, of course).
course).
The main function (the guessing part) is between the last `#else..#endif`, The main function (the guessing part) is between the last `#else..#endif`,
but still is declared before `main()`. The `5[O]()` in `main()` calls but still is declared before `main()`. The `5[O]()` in `main()` calls
this function. Similarly, most indexing operations have been this function. Similarly, most indexing operations have been
changed to this form; and I tried to write each such operation changed to this form and I tried to write each such operation
different. different.
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef int #ifndef int
typedef int lint; typedef int _int;
#ifdef while #ifdef while
char s[234],d[56],*p=s,m='m'; char s[234],d[56],*p=s,m='m';
#define int typedef (*define)();\ #define int typedef (*define)();\
@@ -10,14 +10,14 @@ signed short n(short bz){
char o=1,i=1,l,pc=i,b=r+o/2,_f=6,m=7,s=8,g,q,od=o*rs+4^s,js=_f/*3-m*'c',bs='g'; char o=1,i=1,l,pc=i,b=r+o/2,_f=6,m=7,s=8,g,q,od=o*rs+4^s,js=_f/*3-m*'c',bs='g';
return 1; } return 1; }
#y FILE c[a]+s,p[c],r[m]+u[i+4*o|f]-r[wob][wad]+s*f-!w|o,L+x | cut #y FILE c[a]+s,p[c],r[m]+u[i+4*o|f]-r[wob][wad]+s*f-!w|o,L+x | cut
;}int main(lint i,char**love_unix){*/;}int main(lint i,char**love_unix){/*;}int main(lint i,char**love_unix){*\;}| here */ ;}int main(i,love_unix)_int i;char**love_unix;{*/;}int main(i,love_unix)_int i;char**love_unix;{/*;}int main(i,love_unix)_int i;char**love_unix;{*\;}| here */
while(FILE)for(;9-(i=0[O](f));); while(FILE)for(;9-(i=0[O](f)););
for(;32-(i=0[O](f));0&& 3[O]("-->%s<--", "gxdgbtgxsxpcctvpixktedhiedcte")); for(;32-(i=0[O](f));0&& 3[O]("-->%s<--", "gxdgbtgxsxpcctvpixktedhiedcte"));
for(;'\n'-(i=O[0](f));)(i>='a'&&i<'z')?* for(;'\n'-(i=O[0](f));)(i>='a'&&i<'z')?*
#include __FILE__ #include __FILE__
"Demonic Smiley" );} /* <g> */ "Demonic Smiley" );} /* <g> */
#else #else
#define while(int) short c=0;int*f=fopen(__##int##__,"r");for(i=0;i<25;i _)i[d]='A'+(13+i)%26;main: #define while(int) short c=0;FILE*f=fopen(__##int##__,"r");for(i=0;i<25;i _)i[d]='A'+(13+i)%26;main:
#define y define #define y define
#define _ ++ #define _ ++
#include <stdio.h> #include <stdio.h>
+11
View File
@@ -2048,6 +2048,17 @@ Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when
exiting the program. exiting the program.
## [1998/df](1998/df/df.c) ([README.md](1998/df/README.md]))
Cody changed a `int *` used for `fopen(3)` to be a `FILE *` to be more correct
and prevent any possible problems in some systems (which has happened).
Cody also made the fixed version look more like the original version by using
the old style of `main()` args so that it read `i,love_unix` more naturally, and
by changing the typedef `lint` (to `int` - see the code for why this has to be
done in modern systems) to be `_int`.
## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) ## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md]))
Cody added the scripts [try.sh](1998/dlowe/try.sh), Cody added the scripts [try.sh](1998/dlowe/try.sh),