Make alt code for gets() / fgets() changes
As both Landon and I have been wondering if changing entries to use
fgets() is bordering on tampering with entries I decided to make the
original (sometimes bug fixed) versions (using gets()) alt code. I had
originally started to make the fgets() version of each entry the alt but
since the fgets() versions can handle input better and since some also
fixed bugs (see below) I decided to make the original version the alt
code (this also is how it is for other entries).
There were some exceptions here. If the change also fixed some crashes
or other bugs outside of the gets() to fgets() conversion I did not
bother to make an alt version. An example is 1992/dds. In some cases the
alt code does have bug fixes in which case they were added.
Updated the Makefiles and .gitignore files as well for the alt target
and the new files (compiled and in the case of 1992/adrian additional
source files in the Makefile alt rule).
This should solve the problem observed by Landon and me. It wouldn't be
a problem to change it so the alt version is the one that uses fgets()
but I think that might be the wrong choice.
In some entries I altogether avoided changing to fgets() say if the
author notes it uses gets() (in one case even providing a version that
uses fgets()). In some cases using fgets() introduces a bug so those are
also not changed.
As for 1990/tbr there's a strong reason for not having the fgets()
version being the alt. In macOS in particular (in linux - or maybe gcc,
not sure - it shows a warning at linker time) it will mess up the first
line of output in a potentially confusing way. For instance:
$ ./tbr.alt
$ warning: this program uses gets(), which is unsafe.
# nothing here, what to do?
And that touches on another issue of making the alt version the one that
uses gets(): the warnings that can be alarming during compilation,
linking and (in the case of macOS) runtime.
Not all entries should be or can be changed to fgets() but some can and
it's warranted for these reasons. More will possibly happen in the
future.
This commit is contained in:
1 parent
843ce60b47
commit
06a5665f5d
31 files changed
+672
-86
No files matched your search
+26
-7
@@ -8,7 +8,9 @@ USA
|
||||
|
||||
## To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make all
|
||||
```
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this so it would
|
||||
compile and work with modern compilers. The problem was that `srand()` returns
|
||||
@@ -21,21 +23,38 @@ a line is greater than 231 in length if the program chooses that line it might
|
||||
print the first 231 characters or it might print (up to) the next 231 characters
|
||||
and so on. Thank you Cody for your assistance!
|
||||
|
||||
For the original fixed version [ldb.alt.c](ldb.alt.c) see below.
|
||||
|
||||
|
||||
## To run:
|
||||
|
||||
./ldb < file
|
||||
```sh
|
||||
./ldb < file
|
||||
|
||||
some_command | ./ldb
|
||||
some_command | ./ldb
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
./ldb < /etc/passwd
|
||||
```sh
|
||||
./ldb < /etc/passwd
|
||||
|
||||
printf "The International Obfuscated C Code Contest\n
|
||||
Best One-liner\n
|
||||
by Laurion Burchall" | ./ldb
|
||||
printf "The International Obfuscated C Code Contest\n
|
||||
Best One-liner\n
|
||||
by Laurion Burchall" | ./ldb
|
||||
```
|
||||
|
||||
### Alternate code:
|
||||
|
||||
For the original version fixed so that it will compile with modern compiles,
|
||||
try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `ldb.alt` as you would `ldb`.
|
||||
|
||||
## Judges' comments:
|
||||
|
||||
|
||||
Reference in new issue
Block a user