Merge pull request #2185 from xexyl/boutines05-try

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-02-06 13:35:24 -08:00
commit 9e4ba9a0a0
18 files changed
+121 -81

No files matched your search

+4 -8
View File
@@ -23,16 +23,12 @@ fi
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it # 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 # this way allows us to have the user specify a different compiler in an easy
# way. # way.
if [[ -z "$CC" ]]; then [[ -z "$CC" ]] && CC="cc"
CC="cc"
fi
# try getting the columns the simple way first: tput cols # try getting the columns the simple way first: tput cols
COLUMNS="$(tput cols)" if ! COLUMNS="$(tput cols)"; then
# if tput failed for any reason try stty(1) with cut(1).
if [[ "$?" -ne 0 ]]; then COLUMNS="$(stty size|cut -f2 -d' ')"
# if tput failed for any reason try stty(1) with awk(1):
COLUMNS="$(stty size|awkf '{print $NF}')"
fi fi
if [[ "$COLUMNS" -lt 80 ]]; then if [[ "$COLUMNS" -lt 80 ]]; then
+4 -7
View File
@@ -23,15 +23,12 @@ fi
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it # 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 # this way allows us to have the user specify a different compiler in an easy
# way. # way.
if [[ -z "$CC" ]]; then [[ -z "$CC" ]] && CC="cc"
CC="cc"
fi
# try getting the columns the simple way first: tput cols # try getting the columns the simple way first: tput cols
COLUMNS="$(tput cols)" if ! COLUMNS="$(tput cols)"; then
if [[ "$?" -ne 0 ]]; then # if tput failed for any reason try stty(1) with cut(1).
# if tput failed for any reason try stty(1) with awk(1): COLUMNS="$(stty size|cut -f2 -d' ')"
COLUMNS="$(stty size|awkf '{print $NF}')"
fi fi
if [[ "$COLUMNS" -lt 80 ]]; then if [[ "$COLUMNS" -lt 80 ]]; then
+6 -11
View File
@@ -19,17 +19,12 @@ clear
# be determined: we just use a default value. # be determined: we just use a default value.
# #
# try getting the columns the simple way first: tput cols # try getting the columns the simple way first: tput cols
if ! COLUMNS="$(tput cols)"; then if COLUMNS="$(tput cols)"; then
# if tput failed for any reason try stty(1) with awk(1). # if tput failed for any reason try stty(1) with cut(1).
# COLUMNS="$(stty size|cut -f2 -d' ')"
# Disable this warning of shellcheck as it's wrong: awk needs single quotes.
# # if however either stty size or cut fails, set to 150.
# SC2016 (info): Expressions don't expand in single quotes, use double quotes for that. if [[ "${PIPESTATUS[0]}" -ne 0 || "${PIPESTATUS[1]}" -ne 0 ]]; then
# https://www.shellcheck.net/wiki/SC2016
# shellcheck disable=SC2016
COLUMNS="$(stty size|awk '{print $NF}')"
if [[ "$?" -ne 0 ]]; then
COLUMNS=150 COLUMNS=150
fi fi
fi fi
+1 -12
View File
@@ -14,19 +14,8 @@ make
## Try: ## Try:
If you have access to `/dev/audio` or `/dev/sound/dsp`:
```sh ```sh
./coupard > /dev/audio ./try.sh
./coupard > /dev/sound/dsp
```
If you do not, first install [sox](https://en.wikipedia.org/wiki/SoX). If you
use macOS you might install it from [MacPorts](https://www.macports.org) or
[Homebrew](https://brew.sh). Then you can try:
```sh
./coupard | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
``` ```
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2001/coupard
#
# 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.
[[ -z "$CC" ]] && CC="cc"
# in this case we won't fail if we can't compile the code because we can still
# run the supplementary program.
make CC="$CC" everything >/dev/null
# clear screen after compilation so that only the entry is shown
clear
# hopefully sox(1) is installed but we check for it just in case that it's not
SOX="$(type -P sox)"
AUDIO="/dev/audio"
DSP="/dev/sound/dsp"
if [[ -n "$SOX" ]]; then
echo "$ ./coupard | $SOX -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./coupard | "$SOX" -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
echo 1>&2
elif [[ -S "$AUDIO" ]]; then
./coupard > "$AUDIO"
elif [[ -S "$DSP" ]]; then
./coupard > "$DSP"
else
echo "SoX not installed. Please install it and try again." 1>&2
echo "Tip: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#sox." 1>&2
fi
+1
View File
@@ -2,6 +2,7 @@
# sort with: ../../bin/sgi # sort with: ../../bin/sgi
*.dSYM *.dSYM
ctk ctk
ctk.alt
ctk.orig ctk.orig
indent indent
indent.c indent.c
-7
View File
@@ -55,13 +55,6 @@ It's a very simple thing to do. Read the author's remarks for clues.
This game crashes if it loses. This game crashes if it loses.
This is supposed to happen. As is written in the
[The Jargon File](http://catb.org/jargon/html/F/feature.html):
```
That's not a bug, that's a feature.
```
## Judges' remarks: ## Judges' remarks:
+5 -5
View File
@@ -19,25 +19,25 @@ clear
read -r -n 1 -p "Press any key to run: ./ollinger 1000 | cut -c -200 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./ollinger 1000 | cut -c -200 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./ollinger 1000 | cut -c -200 | less -rEXF ./ollinger 1000 | cut -c -200 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./ollinger 1000 | cut -c -100 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./ollinger 1000 | cut -c -100 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./ollinger 1000 | cut -c -100 | less -rEXF ./ollinger 1000 | cut -c -100 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./ollinger 42 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./ollinger 42 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./ollinger 42 | less -rEXF ./ollinger 42 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./ollinger 42 | cut -c -100 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./ollinger 42 | cut -c -100 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./ollinger 42 | cut -c -100 | less -rEXF ./ollinger 42 | cut -c -100 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./ollinger 42 | cut -c -200 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./ollinger 42 | cut -c -200 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./ollinger 42 | cut -c -200 | less -rEXF ./ollinger 42 | cut -c -200 | less -rEXFK
echo 1>&2 echo 1>&2
+8 -8
View File
@@ -18,43 +18,43 @@ clear
read -r -n 1 -p "Press any key to run: ./hoyle 10 0.5 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 10 0.5 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 10 0.5 ./hoyle 10 0.5 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 1 1 1 1 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 1 1 1 1 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 1 1 1 1 ./hoyle 1 1 1 1 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 2 0 1 0 -0.001 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 2 0 1 0 -0.001 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 2 0 1 0 -0.001 ./hoyle 2 0 1 0 -0.001 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 1 2 3 42 -0.42 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 1 2 3 42 -0.42 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 1 2 3 42 -0.42 ./hoyle 1 2 3 42 -0.42 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 42 42 42 42 42 42 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 42 42 42 42 42 42 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 42 42 42 42 42 42 ./hoyle 42 42 42 42 42 42 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 42 42 42 42 42 (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 42 42 42 42 42 (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 42 42 42 42 42 ./hoyle 42 42 42 42 42 | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 0 0 1 | tee hoyle1.txt (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 0 0 1 | tee hoyle1.txt (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 0 0 1 | tee hoyle1.txt | less -rEXF ./hoyle 0 0 1 | tee hoyle1.txt | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./hoyle 0 0 2 | tee hoyle2.txt (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./hoyle 0 0 2 | tee hoyle2.txt (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./hoyle 0 0 2 | tee hoyle2.txt | less -rEXF ./hoyle 0 0 2 | tee hoyle2.txt | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: diff -s hoyle1.txt hoyle2.txt: " read -r -n 1 -p "Press any key to run: diff -s hoyle1.txt hoyle2.txt: "
+2 -2
View File
@@ -17,7 +17,7 @@ clear
read -r -n 1 -p "Press any key to run: ./newbern newbern.dat \"IOCCC 2004\" (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./newbern newbern.dat \"IOCCC 2004\" (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./newbern newbern.dat "IOCCC 2004" | less -rEXF ./newbern newbern.dat "IOCCC 2004" | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: echo SOS | ./newbern: " read -r -n 1 -p "Press any key to run: echo SOS | ./newbern: "
@@ -27,5 +27,5 @@ echo 1>&2
read -r -n 1 -p "Press any key to run: ./newbern newbern.dat IOCCC x (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./newbern newbern.dat IOCCC x (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./newbern newbern.dat IOCCC x | less -rEXF ./newbern newbern.dat IOCCC x | less -rEXFK
echo 1>&2 echo 1>&2
+14
View File
@@ -1,5 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2004/omoikane
#
# 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 run: ./omoikane omoikane.info omoikane.info omoikane.output: " read -r -n 1 -p "Press any key to run: ./omoikane omoikane.info omoikane.info omoikane.output: "
echo 1>&2 echo 1>&2
+7 -7
View File
@@ -17,12 +17,12 @@ clear
read -r -n 1 -p "Press any key to show sds.c (space = next page, q = quit): " read -r -n 1 -p "Press any key to show sds.c (space = next page, q = quit): "
echo 1>&2 echo 1>&2
less -rEXF sds.c less -rEXFK sds.c
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: ./sds < sds.c | tee encoder.c (space = next page, q = quit): " read -r -n 1 -p "Press any key to run: ./sds < sds.c | tee encoder.c (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./sds < sds.c | tee encoder.c | less -rEXF ./sds < sds.c | tee encoder.c | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: make encoder 2>/dev/null: " read -r -n 1 -p "Press any key to run: make encoder 2>/dev/null: "
@@ -33,7 +33,7 @@ echo 1>&2
echo "$ ./encoder README.md <sds.c | tee sds_msg.c" 1>&2 echo "$ ./encoder README.md <sds.c | tee sds_msg.c" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./encoder README.md <sds.c | tee sds_msg.c | less -rEXF ./encoder README.md <sds.c | tee sds_msg.c | less -rEXFK
read -r -n 1 -p "Press any key to run: make sds_msg 2>/dev/null: " read -r -n 1 -p "Press any key to run: make sds_msg 2>/dev/null: "
echo 1>&2 echo 1>&2
@@ -43,7 +43,7 @@ echo 1>&2
echo "$ ./sds_msg < sds.c | tee sds2_msg.c | less -rEXF" 1>&2 echo "$ ./sds_msg < sds.c | tee sds2_msg.c | less -rEXF" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./sds_msg < sds.c | tee sds2_msg.c | less -rEXF ./sds_msg < sds.c | tee sds2_msg.c | less -rEXFK
read -r -n 1 -p "Press any key to run: diff -s sds2_msg.c encoder.c: " read -r -n 1 -p "Press any key to run: diff -s sds2_msg.c encoder.c: "
echo 1>&2 echo 1>&2
@@ -58,12 +58,12 @@ echo 1>&2
echo "$ ./encoder message < README.md | tee remarks.md" 1>&2 echo "$ ./encoder message < README.md | tee remarks.md" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2 echo 1>&2
./encoder message < README.md | tee remarks.md | less -rEXF ./encoder message < README.md | tee remarks.md | less -rEXFK
echo 1>&2 echo 1>&2
read -r -n 1 -p "Press any key to run: diff remarks.md README.md: " read -r -n 1 -p "Press any key to run: diff remarks.md README.md (space = next page, q = quit): "
echo 1>&2 echo 1>&2
diff remarks.md README.md # notice how similar they are diff remarks.md README.md | less -rEXFK
echo "Did you notice how similar they are?" 1>&2 echo "Did you notice how similar they are?" 1>&2
echo 1>&2 echo 1>&2
+4 -4
View File
@@ -132,11 +132,11 @@ all: data ${TARGET}
${PROG}: ${PROG}.c ${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
test: test-su.perl test: ${PROG} test-su.perl
${PERL} $< ${PERL} test-su.perl
test-n0: test-su.perl test-n0: ${PROG} test-su.perl
${PERL} $< -n 0 ${PERL} test-su.perl -n 0
# alternative executable # alternative executable
# #
+2
View File
@@ -9,6 +9,8 @@ make
You will need an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) viewer or You will need an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) viewer or
a converter like [ImageMagick](https://imagemagick.org/index.php)'s `convert`. a converter like [ImageMagick](https://imagemagick.org/index.php)'s `convert`.
See [FAQ 3.17 - How do I compile and install ImageMagick for entries that
require it?](/faq.md#imagemagick).
Look here to find some [SVG Viewer Look here to find some [SVG Viewer
Implementations](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations). Implementations](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations).
+1 -1
View File
@@ -43,7 +43,6 @@ if [[ ! -f result.svg && ! -f test.svg ]]; then
fi fi
if [[ -n "$CONVERT" ]]; then if [[ -n "$CONVERT" ]]; then
read -r -n 1 -p "Press any key to run: convert test.svg test.png: " read -r -n 1 -p "Press any key to run: convert test.svg test.png: "
echo 1>&2 echo 1>&2
if ! convert test.svg test.png; then if ! convert test.svg test.png; then
@@ -66,4 +65,5 @@ else
echo 1>&2 echo 1>&2
echo "convert not found (ImageMagick not installed?)" 1>&2 echo "convert not found (ImageMagick not installed?)" 1>&2
echo "Try viewing *.svg with a graphics viewer that can view SVG files." 1>&2 echo "Try viewing *.svg with a graphics viewer that can view SVG files." 1>&2
echo "Tip: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#imagemagick." 1>&2
fi fi
+1
View File
@@ -76,6 +76,7 @@ endoh3()
echo 1>&2 echo 1>&2
else else
echo "Please install either SoX, ruby or padsp (from PulseAudio)." 1>&2 echo "Please install either SoX, ruby or padsp (from PulseAudio)." 1>&2
echo "Tip: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#sox." 1>&2
exit 1 exit 1
fi fi
fi fi
+9 -4
View File
@@ -2808,14 +2808,19 @@ void e(n,h){
``` ```
This was not really worth a thanks per se but it was originally done by adding and for some reason it was being reported as an error. This was not really worth
`int`. The better solution is to disable the warning which is what was done a thanks per se but it was originally done by adding `int`. The better solution
later on to make it more like the original. is to disable the warning which is what was done later on to make it more like
the original.
Yusuke provided a proper command line for macOS (to do with sound; see his [Yusuke](#yusuke) provided a proper command line for those without `/dev/audio`
or `/dev/sound/dsp` (which is most everyone nowadays, it seems, and especially
those with macOS) (to do with sound; see his
[/2013/endoh3/README.md](/2013/endoh3/README.md) entry where he also refers to [/2013/endoh3/README.md](/2013/endoh3/README.md) entry where he also refers to
sound devices in macOS). sound devices in macOS).
Cody added the [try.sh](/2001/coupard/try.sh).
## <a name="2001_ctk"></a>[2001/ctk](/2001/ctk/ctk.c) ([README.md](/2001/ctk/README.md])) ## <a name="2001_ctk"></a>[2001/ctk](/2001/ctk/ctk.c) ([README.md](/2001/ctk/README.md]))
+16 -5
View File
@@ -81,7 +81,7 @@ fi
# first determine if git is executable # first determine if git is executable
if [[ -z "$GIT" || ! -f "$GIT" || ! -x "$GIT" ]]; then if [[ -z "$GIT" || ! -f "$GIT" || ! -x "$GIT" ]]; then
echo "$0: ERROR: git not an executable file: $GIT" 1>&2 echo "$0: ERROR: git not a regular executable file: $GIT" 1>&2
exit 3 exit 3
fi fi
@@ -106,22 +106,33 @@ if ! cd "$TOPDIR"; then
fi fi
# I have found problems using git rev-parse to verify that we're in a git repo # I have found problems using git rev-parse to verify that we're in a git repo
# so use git status instead. Plus we need the user to see git status anyway. # plus we need the user to see git status anyway so use git status instead.
"$GIT" status 1>&2 if ! "$GIT" status 1>&2; then
status="$?"
if [[ "$status" -ne 0 ]]; then
echo "$USAGE" 1>&2 echo "$USAGE" 1>&2
echo 1>&2 echo 1>&2
echo "$(basename "$0"): ERROR: ${PWD} is not a git repository" 1>&2 echo "$(basename "$0"): ERROR: ${PWD} is not a git repository" 1>&2
exit 3 exit 3
fi fi
echo 1>&2
echo "NOTE: manifest.numbers and manifest.csv may be modified here but nothing else" 1>&2
echo "may be and no new files may be staged for commit either:" 1>&2
read -r -p "Do you have a clean state from git status (Y/N)? " read -r -p "Do you have a clean state from git status (Y/N)? "
if [[ "$REPLY" != "Y" && "$REPLY" != "y" ]]; then if [[ "$REPLY" != "Y" && "$REPLY" != "y" ]]; then
echo "$0: exiting 4 due to user telling us there's a problem." 1>&2 echo "$0: exiting 4 due to user telling us there's a problem." 1>&2
exit 4 exit 4
fi fi
# ask user if they're on the correct branch
#
echo "Showing branches: " 1>&2
"$GIT" branch 1>&2
read -r -p "Are you on the right branch (Y/N)? "
if [[ "$REPLY" != "Y" && "$REPLY" != "y" ]]; then
echo "$0: exiting 4 due to user telling us there's a problem." 1>&2
exit 4
fi
# now cd to the tmp directory # now cd to the tmp directory
# #
if ! cd tmp; then if ! cd tmp; then