Fixes for 2013/misaka and add demo.sh

A link in the judges' remarks was dead and was replaced by a link in the
Internet Wayback Machine.

Format fix the README.md file.

As there are a lot of commands to try I added them in demo.sh, sleeping
approximately 1 second between each command (though I thought of
prompting instead).

And... since the author appears to love cats I'll throw out the word of
us cat lovers: ailurophile(s). And to those who are afraid of cats
(though I don't know why :-) ), the phobia is: ailurophobia.

If you're an ailurophile see https://rationalwiki.org/wiki/Fun:Cat. Even
if you're not you might find it amusing.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-15 09:14:47 -07:00
1 parent 6f54faeb4b
commit 3f78718eda
3 files changed
+126 -72

No files matched your search

+84 -72
View File
@@ -1,8 +1,8 @@
# Most catty # Most catty
Don Yang Don Yang<br>
<omoikane@uguu.org> <omoikane@uguu.org><br>
<http://uguu.org/> <http://uguu.org/>
## To build: ## To build:
@@ -10,7 +10,8 @@
make make
``` ```
This will build a bunch of versions of the code. See the author's details for information on all of these builds. This will build a bunch of versions of the code. See the author's details for
information on all of these builds.
## To run: ## To run:
@@ -42,6 +43,12 @@ seq 1 12 | ./horizontal_cat - - -
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c
``` ```
Alternately you can just try:
```sh
./demo.sh
```
NOTE: Use - for standard input. For example: NOTE: Use - for standard input. For example:
```sh ```sh
@@ -50,31 +57,32 @@ NOTE: Use - for standard input. For example:
## Judges' remarks: ## Judges' remarks:
There is more to cat than [mere cats](http://cheezburger.com/1680494336). There is more to cat than [mere cats](http://cheezburger.com/1680494336). Be
Be they tall, fat, long or squat, this source code is sure to amuse. they tall, fat, long or squat, this source code is sure to amuse.
#### Slight diversion #### Slight diversion
While one of the judges was reviewing this entry on the stern of the While one of the judges was reviewing this entry on the stern of the
[Island Sky](http://www.noble-caledonia.co.uk/information/detail.asp?id=2&spid=76) [Island Sky](http://www.noble-caledonia.co.uk/information/detail.asp?id=2&spid=76)
in the middle of the Atlantic Ocean waiting the in the middle of the Atlantic Ocean waiting for the
[total solar eclipse of 2013](http://en.wikipedia.org/wiki/Solar_eclipse_of_November_3,_2013) [total solar eclipse of 2013](http://en.wikipedia.org/wiki/Solar_eclipse_of_November_3,_2013)
the judge was stuck by a the judge was struck by a
[flying fish](http://en.wikipedia.org/wiki/Flying_fish). [flying fish](http://en.wikipedia.org/wiki/Flying_fish).
While result the impact was that the While the result of the impact was that the
[Port](http://en.wikipedia.org/wiki/Port_wine) from Portugal was lost, the [Port](http://en.wikipedia.org/wiki/Port_wine) from Portugal was lost, but the
[Grog](http://www.travelforpassion.com/grog-factory-cape-verde-santo-antao-cape-verde-1602-photo) from Cape Verde [Grog](https://web.archive.org/web/20130702003043/http://www.travelforpassion.com/grog-factory-cape-verde-santo-antao-cape-verde-1602-photo)
and the laptop containing this entry was saved. from Cape Verde and the laptop containing this entry was saved.
While I'm sure most cats would have preferred otherwise, While I'm sure most [cats](https://rationalwiki.org/wiki/Fun:Cat) would have
the flying fish was returned to *em*swim with the fishes*em*. :-) preferred otherwise, the flying fish was returned to *swim with the fishes*. :-)
No cats were harmed in the process of judging this entry. No [cats](https://rationalwiki.org/wiki/Fun:Cat) were harmed in the process of
judging this entry.
## Author's remarks: ## Author's remarks:
### Overview ### Overview
Misaka is a file concatenation utility, with at least two modes of `Misaka` is a file concatenation utility, with at least two modes of
operation: operation:
```sh ```sh
@@ -86,16 +94,17 @@ cc misaka2.c -o vertical_cat
./vertical_cat [files...] > [output] ./vertical_cat [files...] > [output]
``` ```
Where [files...] are a list of text file names. Use "-" to read from stdin. Where `[files...]` are a list of text file names. Use `-` to read from stdin.
### Details ### Details
### Horizontal cat ### Horizontal cat
One of my favorite unix utilities is *cat*. The best thing about it was One of my favorite unix utilities is `cat`. The best thing about it was that it
that it was named "cat". That, and it's useful for quickly showing contents was named "[cat](https://rationalwiki.org/wiki/Fun:Cat)". That, and it's useful
of a file. Though it was primary meant for concatenating files, that for quickly showing contents of a file. Though it was primary meant for
function only seem to work if I wanted to concatenate files vertically. concatenating files, that function only seem to work if I wanted to concatenate
files vertically.
I thought the lack of horizontal concatenation must have been an oversight, I thought the lack of horizontal concatenation must have been an oversight,
so I implemented this utility: so I implemented this utility:
@@ -105,15 +114,15 @@ cc misaka.c -o horizontal_cat
./horizontal_cat files... ./horizontal_cat files...
``` ```
*horizontal_cat* concatenates files horizontally and write the output to `horizontal_cat` concatenates files horizontally and write the output to
stdout. Each input file is padded with spaces on the right so that the `stdout`. Each input file is padded with spaces on the right so that the
original text alignments are preserved. original text alignments are preserved.
If "-" is specified as a file name, *horizontal_cat* will read from stdin. If `-` is specified as a file name, `horizontal_cat` will read from `stdin`.
Unlike *cat*, *horizontal_cat* loads all input to memory first. Thus you Unlike `cat`, `horizontal_cat` loads all input to memory first. Thus you
can specify "-" multiple times to get stdin multiplied horizontally. For can specify `-` multiple times to get stdin multiplied horizontally. For
example, if you have seq(1) in your shell, you can add line numbers to both example, if you have `seq(1)` in your shell, you can add line numbers to both
sides of misaka.c like this: sides of [misaka.c](misaka.c) like this:
```sh ```sh
seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c - seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
@@ -121,12 +130,12 @@ seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
### Vertical cat ### Vertical cat
Because *horizontal_cat* must know the maximum width of all files before Because `horizontal_cat` must know the maximum width of all files before
writing any output, all files must be processed at least twice. To support writing any output, all files must be processed at least twice. To support
stdin, file must be buffered to memory. This lead to the feature that `stdin`, file must be buffered to memory. This lead to the feature that
*horizontal_cat* can be used to duplicate stdin. `horizontal_cat` can be used to duplicate `stdin`.
Seems like the stdin doubling feature might be useful even for concatenating Seems like the `stdin` doubling feature might be useful even for concatenating
files vertically, so I included a vertical mode. But supporting vertical files vertically, so I included a vertical mode. But supporting vertical
mode with command line options would be no fun. Instead, vertical mode is mode with command line options would be no fun. Instead, vertical mode is
enabled by concatenating the source code horizontally: enabled by concatenating the source code horizontally:
@@ -137,8 +146,8 @@ gcc misaka2.c -o vertical_cat
./vertical_cat files... ./vertical_cat files...
``` ```
*vertical_cat* works more or less like *cat*, except you can use `vertical_cat` works more or less like `cat`, except you can use
*vertical_cat* to duplicate stdin: `vertical_cat` to duplicate `stdin`:
```sh ```sh
./vertical_cat - - ./vertical_cat - -
@@ -146,9 +155,10 @@ gcc misaka2.c -o vertical_cat
### Long cat ### Long cat
After *horizontal_cat* and *vertical_cat*, I thought, maybe all I really After `horizontal_cat` and `vertical_cat`, I thought, maybe all I really wanted
wanted was just more cats. So I implemented one more mode, this one is was just more [cats](https://rationalwiki.org/wiki/Fun:Cat). So I implemented
enabled by concatenating misaka.c vertically: one more mode, this one is enabled by concatenating [misaka.c](misaka.c)
vertically:
```sh ```sh
./vertical_cat misaka.c misaka.c > misaka3.c ./vertical_cat misaka.c misaka.c > misaka3.c
@@ -156,9 +166,9 @@ gcc misaka3.c -o long_cat
./long_cat ./long_cat
``` ```
*long_cat* outputs ASCII art of a cat to stdout. You can make this cat `long_cat` outputs ASCII art of a cat to `stdout`. You can make this cat
exponentially longer by concatenating more files vertically (up to 31 levels exponentially longer by concatenating more files vertically (up to 31 levels
high, depending on sizeof(int) for your compiler): high, depending on `sizeof(int)` for your compiler):
```sh ```sh
./vertical_cat misaka.c misaka.c misaka.c > misaka4.c ./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
@@ -190,9 +200,10 @@ triangle like the following will not have horizontally expanded output:
gcc misaka9.c -o same_as_long_cat gcc misaka9.c -o same_as_long_cat
``` ```
Finally, if you lost track of how many misaka.c you have stacked together, Finally, if you lost track of how many [misaka.c](misaka.c) you have stacked
you can feed the source to a brainfuck interpreter to get a overview of how together, you can feed the source to a
the programs are stacked. Example: [brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter to get an
overview of how the programs are stacked. Example:
```sh ```sh
perl bf.pl misaka9.c perl bf.pl misaka9.c
@@ -200,43 +211,44 @@ perl bf.pl misaka9.c
This outputs: This outputs:
MISAKA ```
MISAKA MISAKA MISAKA
MISAKA MISAKA
```
### Return value ### Return value
*horizontal_cat* and *vertical_cat* will exit with zero status on success. `horizontal_cat` and `vertical_cat` will exit with zero status on success.
If any input file fails to open, *horizontal_cat* and *vertical_cat* will If any input file fails to open, `horizontal_cat` and `vertical_cat` will
report the offending file name to stdout, and exit with nonzero status. report the offending file name to `stdout`, and exit with nonzero status.
If *horizontal_cat* and *vertical_cat* ran out of memory, they will exit If `horizontal_cat` and `vertical_cat` ran out of memory, they will exit
with nonzero status without outputting anything. with nonzero status without outputting anything.
### Compatibility ### Compatibility
*horizontal_cat* makes the following assumptions about input files: `horizontal_cat` makes the following assumptions about input files:
* ASCII with LF end of line sequences. If CR-LF sequences are used, CR * ASCII with LF end of line sequences. If CR-LF sequences are used, CR
characters will appear in the middle of output lines. characters will appear in the middle of output lines.
* All characters are of equal width, even tab characters. * All characters are of equal width, even tab characters.
Misaka has been verified to work on these following compiler+OS `Misaka` has been verified to work on these following compiler+OS combinations:
combinations:
* gcc 4.6.3 on Linux 3.5.0-41 * gcc 4.6.3 on Linux 3.5.0-41
* gcc 4.4.5 on Linux 2.6.32-5 * gcc 4.4.5 on Linux 2.6.32-5
* gcc 4.3.5 on JS/Linux 2.6.20 * gcc 4.3.5 on JS/Linux 2.6.20
* gcc 4.8.1 on Windows (Cygwin and MingW) * gcc 4.8.1 on Windows (Cygwin and MingW)
Misaka requires a C99 compiler due to the use of single line comments. `Misaka` requires a C99 compiler due to the use of single line comments.
Misaka does not depend on any other C99 features. `Misaka` does not depend on any other C99 features.
### Obfuscation ### Obfuscation
Main obfuscation is in having a C program that compiles when tiled Main obfuscation is in having a C program that compiles when tiled
horizontally and vertically, while using single line comments in less than horizontally and vertically, while using single line comments in less than
half of the lines. *And* maintaining a meaningful layout while doing that. half of the lines *and* maintaining a meaningful layout while doing that.
There are other challenges too, of course, like getting a Brainfuck program There are other challenges too, of course, like getting a Brainfuck program
to tile horizontally and vertically. Really, tiling code of any sort to tile horizontally and vertically. Really, tiling code of any sort
@@ -245,12 +257,12 @@ once.
Other features to look for: Other features to look for:
* Peculiar bits that switches horizontal cat to vertical cat. * Peculiar bits that switches horizontal cat to vertical cat.
* Run-length encoded long cat. * Run-length encoded long cat.
* Symmetric and recycled variable names. * Symmetric and recycled variable names.
* CRC of the source code in the source code. * CRC of the source code in the source code.
"gcc -Wall" should provide a hint to where the mode switch happens, it `gcc -Wall` should provide a hint to where the mode switch happens, it
does not output any irrelevant other warnings (verified on 4.6.3). does not output any irrelevant other warnings (verified on 4.6.3).
### Extra files ### Extra files
@@ -258,16 +270,16 @@ does not output any irrelevant other warnings (verified on 4.6.3).
Extra files included in my submission are informational only, they are not Extra files included in my submission are informational only, they are not
needed for the program to work. needed for the program to work.
* bf.pl = a brainfuck interpreter, in case if you don't have one handy. * [bf.pl](bf.pl) - a brainfuck interpreter, in case you don't have one handy.
* spoiler.html = making of this program. * [spoiler.html](spoiler.html) - making of this program.
### About Misaka ### About `Misaka`
The name, layout, and functionality of Misaka is inspired by a particular The name, layout, and functionality of `Misaka` is inspired by a particular
stackable figure: stackable figure:
* [Google images](http://google.co.jp/search?q=%E3%83%9F%E3%82%B5%E3%82%AB%E7%9B%9B%E3%82%8A&tbm=isch) * [Google images](http://google.co.jp/search?q=%E3%83%9F%E3%82%B5%E3%82%AB%E7%9B%9B%E3%82%8A&tbm=isch)
* [Kotobukiya](http://main.kotobukiya.co.jp/figure/tsubucole_tmi_misakamori/) * [Kotobukiya](http://main.kotobukiya.co.jp/figure/tsubucole_tmi_misakamori/)
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License:
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# make sure code compiled
make all || exit 1
echo "$ seq 1 12 | ./horizontal_cat - - -"
seq 1 12 | ./horizontal_cat - - -
sleep 1
echo "$ ./long_cat"
./long_cat
sleep 1
echo "$ ./long_faat_cat"
./long_faat_cat
sleep 1
echo "$ ./long_fat_cat"
./long_fat_cat
sleep 1
echo "$ ./loong_cat"
./loong_cat
sleep 1
echo "$ ./loooong_cat"
./loooong_cat
sleep 1
echo "$ ./loooooooong_cat"
./loooooooong_cat
sleep 1
echo "$ seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c"
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c
+7
View File
@@ -1779,6 +1779,13 @@ Further, after the file 2013/hou/doc/example.markdown was moved to
this broke `make` which Cody also fixed. this broke `make` which Cody also fixed.
## [2013/misaka](2013/misaka/misaka.c) ([README.md)[2013/misaka/README.md))
As there are a lot of commands to try, Cody added the
[demo.sh](2013/misaka/demo.sh) script to do this, sleeping for approximately 1
second between commands.
## [2013/morgan1](2013/morgan1/morgan1.c) ([README.md](2013/morgan1/README.md)) ## [2013/morgan1](2013/morgan1/morgan1.c) ([README.md](2013/morgan1/README.md))
Cody added explicit linking of libm (`-lm`) as not all systems do this Cody added explicit linking of libm (`-lm`) as not all systems do this