Merge pull request #1722 from xexyl/yang2019-try

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-12-17 12:05:51 -08:00
commit 1c0e5140ff
9 files changed
+320 -53

No files matched your search

+38 -9
View File
@@ -139,8 +139,16 @@ all: data ${TARGET}
clean clobber install love haste waste maker easter_egg \
sandwich supernova deep_magic magic charon pluto
# Variable to decide if the emulator should save state (default no)
#
SAVE=0
MAP=MAP_PRIVATE
ifneq ($((SAVE)),0)
MAP=MAP_SHARED
endif
${PROG}: ${PROG}.c rk05.bsd.fs
${CC} ${CFLAGS} -DI='"rk05.bsd.fs"' -DA=4096 -DS=0173030 -DW=MAP_PRIVATE -DT= -DX=5 -DY=128 \
${CC} ${CFLAGS} -DI='"rk05.bsd.fs"' -DA=4096 -DS=0173030 -DW=${MAP} -DT= -DX=5 -DY=128 \
-DV=270 -DP='"89!>@@89T=@@89\"89DQ@K89$$89Q1@H0@@@P@1@@"' ${PROG}.c -o $@ ${LDFLAGS}
rk05.bsd.fs: empty.fs.bz2 builddisk.bsd bsd.img.bz2
@@ -148,6 +156,10 @@ rk05.bsd.fs: empty.fs.bz2 builddisk.bsd bsd.img.bz2
${BZIP2} -dc empty.fs.bz2 > rk05.bsd.fs
${BZIP2} -dc bsd.img.bz2 | ./builddisk.bsd
# NOTE: we don't set -DW=${MAP} here because it's already set to MAP_SHARED and
# we don't want to break anything here. The default for the program itself is
# MAP_PRIVATE but it's possible that if MAP is set to MAP_PRIVATE then having W
# set to MAP_PRIVATE here could be a problem as it's meant to be MAP_SHARED.
builddisk.bsd: ${PROG}.c
${CC} ${CFLAGS} -DI='"rk05.bsd.fs"' -DA=4096 -DS=0 -DW=MAP_SHARED -DT= -DX=0 -DY=0 -DV=270 \
-DP='"Q@ 89D?A E@#?@$$D@H?<@E@$$8CA1@H8CJ4EH8CA1@L8CJ4FH)@!F@H%@$$1@H?@%89\"?<@89T89!Q@\"89$$89Q1@[%@#1@D<@ @EHO??@X@@@@@@@1@@"' \
@@ -158,6 +170,10 @@ rk05.v6.fs: empty.fs.bz2 builddisk.v6 v6.img.bz2
${BZIP2} -dc empty.fs.bz2 > rk05.v6.fs
${BZIP2} -dc v6.img.bz2 | ./builddisk.v6
# NOTE: we don't set -DW=${MAP} here because it's already set to MAP_SHARED and
# we don't want to break anything here. The default for the program itself is
# MAP_PRIVATE but it's possible that if MAP is set to MAP_PRIVATE then having W
# set to MAP_PRIVATE here could be a problem as it's meant to be MAP_SHARED.
builddisk.v6: ${PROG}.c
${CC} ${CFLAGS} -DI='"rk05.v6.fs"' -DA=4096 -DS=0 -DW=MAP_SHARED -DT= -DX=0 -DY=0 -DV=270 \
-DP='"Q@ 89D?A E@#?@$$D@H?<@E@$$8CA1@H8CJ4EH8CA1@L8CJ4FH)@!F@H%@$$1@H?@%89\"?<@89T89!Q@\"89$$89Q1@[%@#1@D<@ @EHO??@X@@@@@@@1@@"' \
@@ -170,24 +186,37 @@ empty.fs.bz2: boot.dat
${BZIP2} empty.fs
v0: ${PROG}.c Makefile v0.image.fs
@echo "This IOCCC25 Makefile preserves the state of v0.image.fs at the time it won."
@echo "If you want to look for v0.image.fs updates, try: ${CURL} ${IMAGE_FS_URL} -o v0.image.fs"
@echo "Warning: any updates from ${IMAGE_FS_URL} are unofficial and are not part of the IOCCC."
${CC} ${CFLAGS} -DI='"v0.image.fs"' -DA=4096 -DS=0 -DW=MAP_PRIVATE \
${CC} ${CFLAGS} -DI='"v0.image.fs"' -DA=4096 -DS=0 -DW=${MAP} \
-DT="INLCR|ICRNL,0,0,ECHO" -DX=5 -DY=128 -DV=200 \
-DP='"89!?@@89T=@@89\"Q@M89DQ@L89$$89Q1@I0A@@P@X@@1@@"' ${PROG}.c -o $@
@echo ""
@echo "This IOCCC25 Makefile preserves the state of v0.image.fs at the time it won."
@echo "If you want to look for v0.image.fs updates, try:"
@echo ""
@echo " ${CURL} ${IMAGE_FS_URL} -o v0.image.fs"
@echo ""
@echo "Warning: any updates from ${IMAGE_FS_URL}"
@echo "are unofficial and are not part of this IOCCC entry."
@echo ""
v6: empty.fs.bz2 builddisk.v6 v6.img.bz2 rk05.v6.fs
${CC} ${CFLAGS} -DI='"rk05.v6.fs"' -DA=4096 -DS=0173030 -DW=MAP_PRIVATE -DT= -DX=5 -DY=128 \
${CC} ${CFLAGS} -DI='"rk05.v6.fs"' -DA=4096 -DS=0173030 -DW=${MAP} -DT= -DX=5 -DY=128 \
-DV=270 -DP='"89!>@@89T=@@89\"89DQ@K89$$89Q1@H0@@@P@1@@"' ${PROG}.c -o $@ ${LDFLAGS}
v6.img.bz2: v6.tape.gz
@echo "This IOCCC25 Makefile preserves the state of v6.tape.gz at the time it won."
@echo "If you want to look for v6.tape.gz updates, try: ${CURL} ${V6_TAPE_URL} -o v6.tape.gz"
@echo "Warning: any updates from ${V6_TAPE_URL} are unofficial and are not part of the IOCCC."
${RM} -f v6.tape
${GZIP_PROG} -c -d v6.tape.gz | ${DD} of=v6.img count=4000 skip=100
${BZIP2} v6.img
@echo ""
@echo "This IOCCC25 Makefile preserves the state of v6.tape.gz at the time it won."
@echo "If you want to look for v6.tape.gz updates, try:"
@echo ""
@echo " ${CURL} ${V6_TAPE_URL} -o v6.tape.gz"
@echo ""
@echo "Warning: any updates from ${V6_TAPE_URL}"
@echo "are unofficial and are not part of this IOCCC entry."
@echo ""
# alternative executable
#
+13
View File
@@ -4,12 +4,25 @@
make
```
If you wish to save state so that you can run the program and keep files changed
(for instance you don't want to compile `mullender.c` again) you can compile it
like:
```sh
make clobber SAVE=1 all
```
Make sure that if you do add a file (including by compiling code) that before
you exit (ctrl-e) you type in `sync`! Otherwise the file might not exist or it
will be corrupt if it does.
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: known bug - please help us fix
STATUS: INABIAF - please **DO NOT** fix
```
+9
View File
@@ -9,6 +9,15 @@ e
indent
indent.c
indent.o
input.txt
original.txt
output.txt
output1.txt
output2.txt
prog
prog.orig
scrambled.txt
scrambled1.txt
scrambled2.txt
scrambled3.txt
unscrambled.txt
+32 -40
View File
@@ -5,6 +5,17 @@ make
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2019 yang in bugs.md](/bugs.md#2019-yang).
## To use:
```sh
@@ -25,28 +36,7 @@ cat a b c d | ./prog
### Try:
```sh
./prog prog.c a b c d e
cat a
cat b
cat c
cat d
cat e
cat a b c d e | ./prog
cat a b c d e | ./prog | diff - prog.c
./prog prog.c | ruby prog.c
./prog violet.c | ruby prog.c
./prog violet.c | ruby violet.c
./try.sh
```
@@ -108,13 +98,13 @@ can simply use `cat` to unscramble the output text.
cat output.txt
```
It might seem like nothing was scrambled, but you can try passing the
output through `strings(1)` and see that most of the original strings
are gone. What happened is that the original text has been shuffled
with ANSI cursor positioning codes inserted such that characters are
printed in random order. This effect is more visible if there is a
delay after each character is printed. For convenience, a utility is
included in the source to output characters slowly:
It might seem like nothing was scrambled, but you can try passing the output
through `strings(1)` and see that most of the original strings are gone. What
happened is that the original text has been shuffled with ANSI cursor
positioning codes inserted in such a way that characters are printed in random
order. This effect is more visible if there is a delay after each character is
printed. For convenience, a utility is included in the source to output
characters slowly:
```sh
./prog input.txt | ruby prog.c
@@ -146,14 +136,14 @@ For files that are larger than your terminal window, `cat` will not be
sufficient for unscrambling because any scrolling causes the character
positions to be misaligned. But fear not, this utility also includes
unscrambling functionality. If no argument is specified, input will
be read through stdin and unscrambled to stdout:
be read through `stdin` and unscrambled to `stdout`:
```sh
./prog < scrambled.txt > unscrambled.txt
```
Where this is useful is that if you scramble the input to multiple
files and unscramble each output files individually, those output
files and unscramble each output file individually, those output
files can be printed on transparencies and distributed separately.
```sh
@@ -181,8 +171,8 @@ A simple text scrambling utility might not have required a screenful
of code, but this particular one natively supports UTF-8.
Specifically: individual UTF-8 byte sequences will not be split into
broken ones, and the utility is aware of full-width versus half-width
differences such that cursor is positioned correctly for most CJK
input. `sample_input.txt` demonstrates this feature with a mix of
differences such that the cursor is positioned correctly for most CJK
input. [sample_input.txt](sample_input.txt) demonstrates this feature with a mix of
Basic Latin and Japanese characters.
Output cursor positions will most definitely be wrong for inputs
@@ -191,17 +181,19 @@ be possible to unscramble those text back to the original using this
same utility, since the utility is self-consistent in how cursor
positions are handled.
### Error handling
If any file can not be opened for reading or writing, an error is
printed to stderr, and the utility will exit with nonzero status.
printed to `stderr`, and the utility will exit with nonzero status.
If there isn't enough memory, the utility will likely crash.
If input contains CR-LF end of line sequences, those CRs are silently
If input contains CR-LF end of line sequences, those `CR`s are silently
dropped. In fact, most control codes are silently ignored except line
feeds (preserved) and tabs (expanded to 8 spaces).
### Compatibility
Verified to work and compiles without warnings on these environments:
@@ -212,13 +204,13 @@ Verified to work and compiles without warnings on these environments:
* clang 5.0.1 on Cygwin
* gcc 4.8.4 on Linux
### Full version
I tried really hard to make `prog.c` fit in a 80x25 terminal without
wrapping. If I were not constrained by space, I would have made an
ASCII art out of it. `violet.c` is that program, and also comes with
the minor benefit of supporting lines longer than a million columns
depending on `sizeof(int)`.
I tried really hard to make `prog.c` fit in a 80x25 terminal without wrapping.
If I were not constrained by space, I would have made an ASCII art out of it.
[violet.c](violet.c) is that program, and also comes with the minor benefit of
supporting lines longer than a million columns depending on `sizeof(int)`.
Violet is named after [Violet
Evergarden](https://en.wikipedia.org/wiki/Violet_Evergarden) in the story with
+4
View File
@@ -0,0 +1,4 @@
IOCCC 2019 Most
in need of
transparency
by Don Yang!
-2
View File
@@ -11,5 +11,3 @@
あぁ おおo ぉオオ しい シシシシシシ CCCCc cCc
ぁあ おぉおぉお しぃしぃしっ シシシシ CCCCccCCC
(*゚ー゚)
+168
View File
@@ -0,0 +1,168 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2019/yang
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
read -r -n 1 -p "Press any key to scramble ioccc.txt into five files: "
echo 1>&2
echo "$ ./prog ioccc.txt a b c d e" 1>&2
./prog ioccc.txt a b c d e
read -r -n 1 -p "Press any key to unscramble part a with cat: "
clear
cat a
read -r -n 1 -p "Press any key to unscramble part b with cat: "
clear
cat b
read -r -n 1 -p "Press any key to unscramble part c with cat: "
clear
cat c
read -r -n 1 -p "Press any key to unscramble part d with cat: "
clear
cat d
read -r -n 1 -p "Press any key to unscramble part e with cat: "
clear
cat e
echo "$ cat a b c d e | ./prog" 1>&2
read -r -n 1 -p "Press any key to unscramble all parts: "
echo 1>&2
cat a b c d e | ./prog
echo 1>&2
echo "$ cat a b c d e | ./prog | diff - ioccc.txt" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
cat a b c d e | ./prog | diff -s - ioccc.txt
LINES="$(tput lines)"
COLS="$(tput cols)"
if [[ "$COLS" -lt 75 || "$LINES" -lt 13 ]]; then
# if screen size < 75 x 13 then exit
exit 0
fi
read -r -n 1 -p "Press any key to scramble sample_input.txt into five files: "
echo 1>&2
echo "$ ./prog sample_input.txt a b c d e" 1>&2
./prog sample_input.txt a b c d e
read -r -n 1 -p "Press any key to unscramble part a with cat: "
clear
cat a
read -r -n 1 -p "Press any key to unscramble part b with cat: "
clear
cat b
read -r -n 1 -p "Press any key to unscramble part c with cat: "
clear
cat c
read -r -n 1 -p "Press any key to unscramble part d with cat: "
clear
cat d
read -r -n 1 -p "Press any key to unscramble part e with cat: "
clear
cat e
echo "$ cat a b c d e | ./prog" 1>&2
read -r -n 1 -p "Press any key to unscramble all parts: "
echo 1>&2
cat a b c d e | ./prog
echo 1>&2
echo "$ cat a b c d e | ./prog | diff - sample_input.txt" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
cat a b c d e | ./prog | diff -s - sample_input.txt
if [[ "$COLS" -lt 80 || "$LINES" -lt 25 ]]; then
# if screen size < 80 x 25 then exit
exit 0
fi
read -r -n 1 -p "Press any key to run: cat prog.c: "
echo 1>&2
cat prog.c
echo 1>&2
read -r -n 1 -p "Press any key to scramble prog.c into five files: "
echo 1>&2
echo "$ ./prog prog.c a b c d e" 1>&2
./prog prog.c a b c d e
read -r -n 1 -p "Press any key to unscramble part a with cat: "
clear
cat a
read -r -n 1 -p "Press any key to unscramble part b with cat: "
clear
cat b
read -r -n 1 -p "Press any key to unscramble part c with cat: "
clear
cat c
read -r -n 1 -p "Press any key to unscramble part d with cat: "
clear
cat d
read -r -n 1 -p "Press any key to unscramble part e with cat: "
clear
cat e
echo "$ cat a b c d e | ./prog" 1>&2
read -r -n 1 -p "Press any key to unscramble all parts: "
echo 1>&2
cat a b c d e | ./prog
echo 1>&2
echo "$ cat a b c d e | ./prog | diff - prog.c" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
cat a b c d e | ./prog | diff -s - prog.c
# For the next three we have to see if ruby is installed
RUBY="$(type -P ruby)"
if [[ -n "$RUBY" ]]; then
read -r -p "Do you want to see the slow scrambling: ./prog prog.c | ruby prog.c (Y/N)? "
if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then
echo "This may take a while, hit ctrl-c to exit script." 1>&2
echo 1>&2
./prog prog.c | ruby prog.c
fi
read -r -p "Do you want to see the slow scrambling: ./prog violet.c | ruby prog.c (Y/N)? "
if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then
echo "This may take a while, hit ctrl-c to exit script." 1>&2
echo 1>&2
./prog violet.c | ruby prog.c
fi
read -r -p "Do you want to see the slow scrambling: ./prog violet.c | ruby violet.c (Y/N)? "
if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then
echo "This may take a while, hit ctrl-c to exit script." 1>&2
echo 1>&2
./prog violet.c | ruby violet.c
fi
fi
+36 -2
View File
@@ -3185,10 +3185,25 @@ but this is expected and the file `ioccc.html` will be generated properly.
## 2018 mills
### STATUS: INABIAF - please **DO NOT** fix
### STATUS: known bug - please help us fix
### Source code: [2018/mills/prog.c](2018/mills/prog.c)
### Information: [2018/mills/README.md](2018/mills/README.md)
After exiting the program (with ctrl-e) if you try running it again you will
likely see:
```
>bootT5pw
]h_ 8D3[]
```
where `[]` is the cursor. When this happens if you hit enter (this is necessary
or else it'll happen again) and then exit again (ctrl-e) and run `prog` again
it'll be okay.
### STATUS: INABIAF - please **DO NOT** fix
The author stated that if you make a typo it can happen that the boot loader can
crash and halt. If this is the case type ctrl-e to quit the emulator and try
again.
@@ -3198,7 +3213,11 @@ do this you should type `make clobber all` and try again.
Cody caused a funny problem where it showed `ERROR` after each command. The
solution was to hit ctrl-e and start again. He does not know if this is what was
referred to by the author though he doesn't think he made a typo either.
referred to by the author but there was likely no typo involved.
Cody notes that if you are using the saved mode you must type `sync` prior to
exiting the program or else the next time you run it the file will not exist (or
in the case of compiled code it won't be executable).
## 2018 vokes
@@ -3382,6 +3401,21 @@ This program will not validate input so it might fail or get stuck if invoked
erroneously.
## 2019 yang
### STATUS: INABIAF - please **DO NOT** fix
### Source code: [2019/yang/prog.c](2019/yang/prog.c)
### Information: [2019/yang/README.md](2019/yang/README.md)
The author noted that if the program runs out of memory it is likely to crash.
The author also stated that 'if input contains CR-LF end of line sequences,
those `CR`s are silently dropped. In fact, most control codes are silently
ignored except line feeds (preserved) and tabs (expanded to 8 spaces).'
# 2020
+20
View File
@@ -4066,6 +4066,18 @@ that's probably true: let's just say that for the IOCCC I'm (Cody) a weasel! :-)
Cody also added the [try.sh](/2018/hou/try.sh) script.
## <a name="2018_mills"></a>[2018/mills](/2018/mills/prog.c) ([README.md](/2018/mills/README.md))
[Cody](#cody), based on the author's remarks, made it possible to save state
between runs of the program so that one can resume where they left off. It
should be noted that there is a bug in the entry (irrespective of save state
option) where running `./prog` twice in a row involves having to hit (the second
run) enter and then exit and then start the program again. Also if you do add a
file you should run `sync` prior to exiting or else the file might not exist or
it might be corrupt. See [2018/mills in bugs.md](/bugs.md#2018-mills) for more
details on the bug.
## <a name="2018_poikola"></a>[2018/poikola](/2018/poikola/prog.c) ([README.md[(/2018/poikola/README.md))
[Cody](#cody) added the missing `docs` rule to the Makefile that forms a PDF
@@ -4200,6 +4212,14 @@ He also added the script [try.sh](/2019/karns/try.sh) to showcase the entry a
bit more easily.
## <a name="2019_yang"></a>[2019/yang](/2019/yang/prog.c) ([README.md](/2019/yang/README.md]))
[Cody](#cody) added the [try.sh](/2019/yang/try.sh) script which also involved
slightly updating the [sample_input.txt](/2019/yang/sample_input.txt) file
(removed trailing newlines as it resulted in `diff` showing differences when it
shouldn't) and adding the [ioccc.txt](/2019/yang/ioccc.txt) file.
# <a name="2020"></a>2020