Adjusted alternate version to preserve formatting

The first alt version added some whitespaces that broke the outline, so
I simply filled those up.  I also expanded tabs to spaces since there is
no size limit restriction for the alternate version.

The second alt version attempted to force binary mode with _setmode()
and _fileno() calls, plus some additional headers.  Rather than doing it
this way, I hack in the binary mode adjustments via preprocessor.

Actually I did a similar trick for IOCCC 2011, but I guess I didn't
submit that version:
https://uguu.org/archive/ioccc2011/akari/source/binmode_main.h

The file above uses _setmode() and _fileno().  The leading underscore
indicates that they were nonstandard extensions.  For the binmode_main.h
in this change, I have opted for setmode() and STDIN_FILENO instead,
which are more widely available.
This commit is contained in:
omoikane committed 2025-05-15 17:51:12 -07:00
1 parent 376f51c489
commit aff78be8f9
5 files changed
+93 -117

No files matched your search

+14 -19
View File
@@ -5,9 +5,7 @@
```
There is an alternate version that will read from the compiled file itself, in
case you don't have a `/dev/urandom` file. There is also a version that should
theoretically work with Windows which distinguishes binary and text. See
[alternate code](#alternate-code) below.
case you don't have a `/dev/urandom` file.
## To use:
@@ -43,30 +41,19 @@ perl parts of the script.
The alternate version will, if no file is specified, read in the compiled binary
itself rather than trying to open `/dev/urandom`, which is the default for the
original entry. This is useful if your system does not have a `/dev/urandom`
file and you do not want to specify an extra file. The second alternate version
is like the first except it also should theoretically work with Windows, setting
binary mode on `stdin` and `stdout`.
file and you do not want to specify an extra file.
### Alternate build:
For the first version:
``` <!---sh-->
make alt
```
For the second version:
``` <!---sh-->
make alt2
```
### Alternate use:
Use `nyaruko.alt` or `nyaruko.alt2` as you would `nyaruko` above.
Use `nyaruko.alt` as you would `nyaruko` above.
### Alternate try:
@@ -77,8 +64,6 @@ For the first alternate version:
./try.alt.sh
```
We have no way to test the second version, sorry (tm Canada 🇨🇦 :-) )!
## Judges' remarks:
@@ -190,7 +175,17 @@ combinations:
* tcc 0.9.25 on JSLinux
Note that on MingW, `stdin` and `stdout` are not opened in binary mode by
default, this means `Nyaruko` may not faithfully encode files on MingW.
default, this means `Nyaruko` may not faithfully reproduce files on MingW.
As a workaround, a `binmode_main.h` is included, so it's possible to produce
an encoder that's binary-clean like this:
``` <!---sh-->
x86_64-w64-mingw32-gcc -include binmode_main.h nyaruko.c -o nyaruko.exe
```
The C code produced by the encoder will need to be compiled with the same
`-include binmode_main.h` hack if you want its output to faithfully reproduce
the original binary input.
### NOTICE to those who wish for a greater challenge: