Merge pull request #1907 from xexyl/thanks-typos
This commit is contained in:
9 files changed
+168
-251
No files matched your search
+12
-3
@@ -1,7 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# primes.sh - feed primes(1) IOCCC winner 1985/august
|
||||
#
|
||||
|
||||
# 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 everything || exit 1
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
PRIMES=$(type -P primes)
|
||||
|
||||
@@ -15,7 +24,7 @@ if [[ "$#" -ge 1 ]]; then
|
||||
fi
|
||||
|
||||
if [[ -n "$PRIMES" ]]; then
|
||||
while read -r n; do primes "$n" $((n + 1)); done < <((./august | head -n "$COUNT" |sed '/^$/d'))
|
||||
while read -r n; do primes "$n" $((n + 1)); done < <((./august | head -n "$COUNT" | sed '/^$/d'))
|
||||
else
|
||||
echo "primes not installed" 1>&2
|
||||
echo 1>&2
|
||||
@@ -23,6 +32,6 @@ else
|
||||
echo 1>&2
|
||||
echo " https://github.com/vattam/BSDGames" 1>&2
|
||||
echo 1>&2
|
||||
echo "and after installing try again."
|
||||
echo "and after installing it try running this again."
|
||||
exit 1
|
||||
fi
|
||||
@@ -5,9 +5,9 @@ make all
|
||||
```
|
||||
|
||||
|
||||
There is an alternate version that allows you to heat, giving you configurable
|
||||
amount of arrows at the start of the game. See [Alternate
|
||||
code](#alternate-code).
|
||||
There is an alternate version that allows you to cheat, giving you configurable
|
||||
amount of arrows at the start of the game. See the [Alternate
|
||||
code](#alternate-code) section below.
|
||||
|
||||
|
||||
### Bugs and (Mis)features:
|
||||
@@ -34,7 +34,7 @@ This version allows you to choose how many arrows to start with, instead of the
|
||||
default 0. If one tried specifying a value < 0 it will set it to 0.
|
||||
|
||||
Fun fact: this version helped uncover and fix a bug that prevented the entry
|
||||
from working on some cases.
|
||||
from working in some cases.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ make all
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./smr > smr.out ; diff -s smr.out smr.c
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1994/smr
|
||||
#
|
||||
|
||||
# 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 show smr.c: "
|
||||
echo 1>&2
|
||||
cat smr.c
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./smr: "
|
||||
echo 1>&2
|
||||
./smr
|
||||
echo 1>&2
|
||||
|
||||
rm -f smr.out
|
||||
read -r -n 1 -p "Press any key to run: ./smr > smr.out; diff -s smr.out smr.c: "
|
||||
echo 1>&2
|
||||
./smr > smr.out; diff -s smr.out smr.c
|
||||
echo 1>&2
|
||||
rm -f smr.out
|
||||
+11
-2
@@ -5,7 +5,7 @@ make all
|
||||
```
|
||||
|
||||
There is an alternate version that uses more memory. See [alternate
|
||||
code](#alternate-code) below.
|
||||
code](#alternate-code) below for more details.
|
||||
|
||||
|
||||
## To use:
|
||||
@@ -18,9 +18,18 @@ code](#alternate-code) below.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./weisberg | head -n 15
|
||||
./try.sh
|
||||
```
|
||||
|
||||
If you have `primes(1)` installed you might also wish to try:
|
||||
|
||||
```sh
|
||||
./primes.sh number
|
||||
```
|
||||
|
||||
where `number` is a positive number, defaulting to 15. The [try.sh](try.sh)
|
||||
script will also do this.
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# primes.sh - feed primes(1) IOCCC winner 1994/weisberg
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
PRIMES=$(type -P primes)
|
||||
|
||||
COUNT=15
|
||||
if [[ "$#" -ge 1 ]]; then
|
||||
COUNT="$1"
|
||||
if ! [[ $COUNT =~ ^[0-9]+$ ]]; then
|
||||
echo "not a number: $COUNT" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
REV="$(type -P rev)"
|
||||
if [[ -n "$PRIMES" && -n "$REV" ]]; then
|
||||
read -r -n 1 -p "Press any key to find primes in ./weisberg | head -n $COUNT, reversed: "
|
||||
echo 1>&2
|
||||
while read -r n; do primes "$n" $((n + 1)); done < <((./weisberg | head -n "$COUNT" | "$REV" ))
|
||||
else
|
||||
echo "primes not installed" 1>&2
|
||||
echo 1>&2
|
||||
echo "See the following GitHub repo:" 1>&2
|
||||
echo 1>&2
|
||||
echo " https://github.com/vattam/BSDGames" 1>&2
|
||||
echo 1>&2
|
||||
echo "and after installing it try running this again."
|
||||
exit 1
|
||||
fi
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1994/weisberg
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
REV="$(type -P rev)"
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./weisberg | head -n 15: "
|
||||
echo 1>&2
|
||||
./weisberg | head -n 15
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./weisberg | head -n 42 (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./weisberg | head -n 42 | less -rEXF
|
||||
echo 1>&2
|
||||
|
||||
if [[ -n "$REV" ]]; then
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to reverse ./weisberg | head -n 15: "
|
||||
echo 1>&2
|
||||
./weisberg | head -n 15 | "$REV"
|
||||
|
||||
read -r -n 1 -p "Press any key to reverse: ./weisberg | head -n 42 (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./weisberg | head -n 42 | "$REV" | less -rEXF
|
||||
echo 1>&2
|
||||
fi
|
||||
|
||||
# run primes.sh too
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to run: ./primes.sh: "
|
||||
echo 1>&2
|
||||
./primes.sh
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./primes.sh 25: "
|
||||
echo 1>&2
|
||||
./primes.sh 25
|
||||
echo 1>&2
|
||||
exit 0
|
||||
+14
-2
@@ -1870,7 +1870,7 @@ that already existed, how many you had and how many were stolen.
|
||||
## <a name="1994_horton"></a>[1994/horton](/1994/horton/horton.c) ([README.md](/1994/horton/README.md))
|
||||
|
||||
[Cody](#cody) fixed this to check that four args were specified. With the use of the C
|
||||
pre-processor macro and inclusion of stdlib.h in the Makefile the layout of the
|
||||
pre-processor macro and inclusion of `stdlib.h` in the Makefile the layout of the
|
||||
source is exactly the same column width and no additional lines were added. This
|
||||
was done during one of the times where this was changed to bug status, for
|
||||
better or worse.
|
||||
@@ -1886,7 +1886,7 @@ was that `srand()` returns void but it was used in a `||` expression. Thus the
|
||||
comma operator was needed.
|
||||
|
||||
Cody also fixed it for clang under Linux which objected to incompatible pointer
|
||||
type (because `time(/2)` takes a `time_t *` which in some systems is a `long *`
|
||||
type (because `time(2)` takes a `time_t *` which in some systems is a `long *`
|
||||
but what was being passed to it is an `int`).
|
||||
|
||||
Cody also changed the entry to use `fgets(3)` instead of `gets(3)`. This one has
|
||||
@@ -1932,6 +1932,11 @@ For an interesting problem that occurred here and what was done to solve it,
|
||||
check the [bugs.md](bugs.md) file.
|
||||
|
||||
|
||||
## <a name="1994_smr"></a>[1994/smr](/1994/smr/smr.c) ([README.md](/1994/smr/README.md]))
|
||||
|
||||
[Cody](#cody) added the [try.sh](/1994/smr/try.sh) script.
|
||||
|
||||
|
||||
## <a name="1994_tvr"></a>[1994/tvr](/1994/tvr/tvr.c) ([README.md](/1994/tvr/README.md]))
|
||||
|
||||
[Cody](#cody) made this use `fgets(3)` instead of `gets(3)`. In this case the newline had
|
||||
@@ -1948,6 +1953,13 @@ Note that the alt code does not use `fgets(3)` but rather `gets(3)`.
|
||||
use with other tools as well by making the program output not a space after each
|
||||
number but rather a newline.
|
||||
|
||||
Cody also added the scripts [try.sh](/1994/weisberg/try.sh) and
|
||||
[primes.sh](/1994/weisberg/primes.sh). The `primes.sh` script is used by
|
||||
`try.sh` and if both `primes(1)` and `rev(1)` are installed it will reverse the
|
||||
lines of the `weisberg`, feeding it to `primes(1)`, showing those that are
|
||||
primes. It only does the reversed output because the program actually prints
|
||||
primes.
|
||||
|
||||
|
||||
## <a name="1994_westley"></a>[1994/westley](/1994/westley/westley.c) ([README.md](/1994/westley/README.md]))
|
||||
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# ioccc_status.sh - quickly update status.json file
|
||||
#
|
||||
# Written by Cody Boone Ferguson in 2023:
|
||||
#
|
||||
# @xexyl
|
||||
# https://xexyl.net Cody Boone Ferguson
|
||||
# https://ioccc.xexyl.net
|
||||
#
|
||||
# If -s option is used, the status field is updated, providing that the status
|
||||
# arg is either "closed" or "open".
|
||||
#
|
||||
# If the -d or -n flags are used then it will update the status_date or
|
||||
# latest_news fields, respectively.
|
||||
#
|
||||
# If the -i status_ver option is used the IOCCC_status_version field will be
|
||||
# updated.
|
||||
#
|
||||
# The -N option is a dry-run: it will just show what would have been changed
|
||||
# without the option.
|
||||
#
|
||||
# The -S option lets one set the path to sed(1).
|
||||
#
|
||||
# The -G option lets one set the path to grep(1).
|
||||
#
|
||||
export IOCCC_STATUS_SCRIPT_VERSION="0.0.3-0 2024-01-15" # major.minor.release-patch YYYY-MM-DD
|
||||
|
||||
SED="$(type -P sed)"
|
||||
GREP="$(type -P grep)"
|
||||
|
||||
USAGE="usage: $(basename "$0") [-h] [-V] [-v level] [-s status] [-d] [-n] [-i status_ver] [-N] [-S] [-G] status.json
|
||||
|
||||
-h print help and exit
|
||||
-V print version and exit
|
||||
-v level set verbosity level
|
||||
-s status set contest status to open or closed
|
||||
|
||||
NOTE: status must be one of \"open\" or \"closed\"
|
||||
|
||||
-d update status_date
|
||||
-n update latest_news date
|
||||
-i status_ver update IOCCC_status_version
|
||||
|
||||
NOTE: version must match the regexp: ^[0-9]+\.[0-9]+ [0-9]{4}-[0-9]{2}-[0-9]{2}$
|
||||
|
||||
-N set dry-run mode: just show what would be changed (def: make changes)
|
||||
-S sed set path to sed(1) (def: $SED)
|
||||
-G grep set path to grep(1) (def: $GREP)
|
||||
|
||||
status.json the file to update
|
||||
|
||||
status version: $IOCCC_STATUS_SCRIPT_VERSION"
|
||||
|
||||
export UPDATE_DATE=""
|
||||
export UPDATE_NEWS=""
|
||||
export UPDATE_IOCCC_STATUS_VERSION=""
|
||||
export IOCCC_STATUS_VERSION=""
|
||||
export VERBOSITY=0
|
||||
export STATUS_JSON_FILE=""
|
||||
export STATUS_FLAG=""
|
||||
export STATUS="closed" # default closed
|
||||
export DRY_RUN_MODE=""
|
||||
export SED # already found default
|
||||
export GREP # already found default
|
||||
|
||||
# parse args
|
||||
#
|
||||
while getopts :hVv:s:dni:NS:G: flag; do
|
||||
case "$flag" in
|
||||
h) echo "$USAGE" 1>&2
|
||||
exit 2
|
||||
;;
|
||||
V) echo "$IOCCC_STATUS_SCRIPT_VERSION" 1>&2
|
||||
exit 2
|
||||
;;
|
||||
v) VERBOSITY="$OPTARG";
|
||||
;;
|
||||
s) STATUS_FLAG="-s"
|
||||
STATUS="$OPTARG";
|
||||
;;
|
||||
d) UPDATE_DATE="-d"
|
||||
;;
|
||||
n) UPDATE_NEWS="-n"
|
||||
;;
|
||||
i) UPDATE_IOCCC_STATUS_VERSION="-i"
|
||||
IOCCC_STATUS_VERSION="$OPTARG"
|
||||
;;
|
||||
N) DRY_RUN_MODE="-N"
|
||||
;;
|
||||
S) SED="$OPTARG"
|
||||
;;
|
||||
G) GREP="$OPTARG"
|
||||
;;
|
||||
:) echo "$0: ERROR: option -$OPTARG requires an argument" 1>&2
|
||||
echo 1>&2
|
||||
echo "$USAGE" 1>&2
|
||||
exit 3
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# remove the options
|
||||
#
|
||||
shift $(( OPTIND - 1 ));
|
||||
|
||||
# verify arg count
|
||||
#
|
||||
if [[ $# -gt 1 ]]; then
|
||||
echo "$0: ERROR: expected no more than 1 arg, found: $#" 1>&2
|
||||
echo "$USAGE" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# parse args
|
||||
#
|
||||
if [[ $# -gt 0 ]]; then
|
||||
export STATUS_JSON_FILE="$1"
|
||||
fi
|
||||
|
||||
# firewall STATUS_JSON_FILE must be a readable file
|
||||
#
|
||||
if [[ ! -e $STATUS_JSON_FILE ]]; then
|
||||
echo "$0: ERROR: status.json does not exist: $STATUS_JSON_FILE" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f $STATUS_JSON_FILE ]]; then
|
||||
echo "$0: ERROR: status.json not a file: $STATUS_JSON_FILE" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -r $STATUS_JSON_FILE ]]; then
|
||||
echo "$0: ERROR: status.json not a readable file: $STATUS_JSON_FILE" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check that $SED is an executable file
|
||||
if [[ ! -x "$SED" ]]; then
|
||||
echo "$0: sed not an executable file: $SED" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
# check that $GREP is an executable file
|
||||
if [[ ! -x "$GREP" ]]; then
|
||||
echo "$0: grep not an executable file: $GREP" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# check that if -s ($STATUS_FLAG) used that the status ($STATUS) is either 'open' or 'closed'
|
||||
#
|
||||
if [[ -n "$STATUS_FLAG" ]]; then
|
||||
if [[ "$STATUS" != "open" && "$STATUS" != "closed" ]]; then
|
||||
echo "$0: ERROR: status must be 'open' or 'closed'" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# check format of IOCCC_status_version if set (-i used, $UPDATE_IOCCC_STATUS_VERSION)
|
||||
#
|
||||
if [[ -n "$UPDATE_IOCCC_STATUS_VERSION" ]]; then
|
||||
echo "$IOCCC_STATUS_VERSION" | "$GREP" -qE '^[0-9]+\.[0-9]+ [0-9]{4}-[0-9]{2}-[0-9]{2}$'
|
||||
if [[ "${PIPESTATUS[1]}" -ne 0 ]]; then
|
||||
echo "$0: ERROR: IOCCC_status_version must match the regexp: '^[0-9]+\.[0-9]+ [0-9]{4}-[0-9]{2}-[0-9]{2}$'" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
# get date for options that update the date
|
||||
DATE="$(date)"
|
||||
# if verbosity is >= 1 or dry-run specified show what would/will be updated
|
||||
if [[ "$VERBOSITY" -ge 1 ]]; then
|
||||
echo "$0: status.json file: $STATUS_JSON_FILE" 1>&2
|
||||
if [[ -n "$STATUS_FLAG" ]]; then
|
||||
echo "$0: will update contest status to: \"$STATUS\"" 1>&2
|
||||
fi
|
||||
if [[ -n "$UPDATE_DATE" ]]; then
|
||||
echo "$0: will update status_date to: \"$DATE\"" 1>&2
|
||||
fi
|
||||
if [[ -n "$UPDATE_NEWS" ]]; then
|
||||
echo "$0: will update latest_news to: \"$DATE\"" 1>&2
|
||||
fi
|
||||
if [[ -n "$UPDATE_IOCCC_STATUS_VERSION" ]]; then
|
||||
echo "$0: will update IOCCC_status_version to: \"$IOCCC_STATUS_VERSION\"" 1>&2
|
||||
fi
|
||||
elif [[ -n "$DRY_RUN_MODE" ]]; then
|
||||
echo "$0: status.json file: $STATUS_JSON_FILE" 1>&2
|
||||
if [[ -n "$STATUS_FLAG" ]]; then
|
||||
echo "$0: would update contest status to: \"$STATUS\"" 1>&2
|
||||
fi
|
||||
if [[ -n "$UPDATE_DATE" ]]; then
|
||||
echo "$0: would update status_date to: \"$DATE\"" 1>&2
|
||||
fi
|
||||
if [[ -n "$UPDATE_NEWS" ]]; then
|
||||
echo "$0: would update latest_news to: \"$DATE\"" 1>&2
|
||||
fi
|
||||
if [[ -n "$UPDATE_IOCCC_STATUS_VERSION" ]]; then
|
||||
echo "$0: would update IOCCC_status_version to: \"$IOCCC_STATUS_VERSION\"" 1>&2
|
||||
fi
|
||||
|
||||
# nothing to do, exit success
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# first status_date if requested and not dry-run
|
||||
if [[ -n "$UPDATE_DATE" ]]; then
|
||||
"$SED" -i'' "s|\"status_date\" : \".*[^\"]\"|\"status_date\" : \"$DATE\"|g" "$STATUS_JSON_FILE"
|
||||
|
||||
if [[ "$VERBOSITY" -gt 1 ]]; then
|
||||
echo "$0: updated status_date to: \"$DATE\"" 1>&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# then update latest_news date if requested
|
||||
if [[ -n "$UPDATE_NEWS" ]]; then
|
||||
"$SED" -i'' "s|\"latest_news\" : \".*[^\"]\"|\"latest_news\" : \"$DATE\"|g" "$STATUS_JSON_FILE"
|
||||
|
||||
if [[ "$VERBOSITY" -gt 1 ]]; then
|
||||
echo "$0: updated latest_news to: \"$DATE\"" 1>&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# then update IOCCC_STATUS_VERSION if requested
|
||||
if [[ -n "$UPDATE_IOCCC_STATUS_VERSION" ]]; then
|
||||
"$SED" -i'' "s|\"IOCCC_status_version\" : \".*[^\"]\"|\"IOCCC_status_version\" : \"$IOCCC_STATUS_VERSION\"|g" "$STATUS_JSON_FILE"
|
||||
|
||||
if [[ "$VERBOSITY" -gt 1 ]]; then
|
||||
echo "$0: updated IOCCC_status_version to: \"$IOCCC_STATUS_VERSION\"" 1>&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# finally if we need to change the status of the contest do so
|
||||
if [[ -n "$STATUS_FLAG" ]]; then
|
||||
"$SED" -i'' "s|\"contest\" : \".*[^\"]\"|\"contest\" : \"$STATUS\"|g" "$STATUS_JSON_FILE"
|
||||
|
||||
if [[ "$VERBOSITY" -gt 1 ]]; then
|
||||
echo "$0: updated contest status to: \"$STATUS\"" 1>&2
|
||||
fi
|
||||
fi
|
||||
Reference in new issue
Block a user