Add try.sh and try.alt.sh to 1996/westley
These scripts simplify running the three other scripts (that the author provided, renamed to have the extension '.sh') to show the three styles of clocks with both the fixed (for modern systems) version and the original version (the alt code). The README.md file has been format and typo checked. This should complete 1996/westley.
This commit is contained in:
1 parent
aee071cdf8
commit
c2b720f874
8 files changed
+65
-32
No files matched your search
@@ -39,7 +39,8 @@ include ../../var.mk
|
|||||||
# Common C compiler warnings to silence
|
# Common C compiler warnings to silence
|
||||||
#
|
#
|
||||||
CSILENCE= -Wno-char-subscripts -Wno-error -Wno-implicit-function-declaration \
|
CSILENCE= -Wno-char-subscripts -Wno-error -Wno-implicit-function-declaration \
|
||||||
-Wno-int-to-pointer-cast -Wno-empty-body -Wno-deprecated-non-prototype
|
-Wno-int-to-pointer-cast -Wno-empty-body -Wno-deprecated-non-prototype\
|
||||||
|
-Wno-implicit-int
|
||||||
|
|
||||||
# Common C compiler warning flags
|
# Common C compiler warning flags
|
||||||
#
|
#
|
||||||
@@ -109,7 +110,7 @@ ENTRY= westley
|
|||||||
PROG= ${ENTRY}
|
PROG= ${ENTRY}
|
||||||
#
|
#
|
||||||
OBJ= ${PROG}.o
|
OBJ= ${PROG}.o
|
||||||
DATA= clock1 clock2 clock3
|
DATA= clock1.sh clock2.sh clock3.sh
|
||||||
TARGET= ${PROG}
|
TARGET= ${PROG}
|
||||||
#
|
#
|
||||||
ALT_OBJ= westley.alt.o
|
ALT_OBJ= westley.alt.o
|
||||||
|
|||||||
+27
-30
@@ -4,51 +4,46 @@
|
|||||||
make all
|
make all
|
||||||
```
|
```
|
||||||
|
|
||||||
|
There is another version which is the original entry. See [alternate
|
||||||
|
version](#alternate-code) for details as to how to use and why it was made the
|
||||||
|
alt version.
|
||||||
|
|
||||||
|
|
||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sh ./clock1
|
./clock1.sh
|
||||||
|
./clock2.sh
|
||||||
|
./clock3.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
NOTE: the original version had a display problem in modern systems which
|
|
||||||
somewhat affected the usability of the program. See the Alternate code section
|
|
||||||
for details on the original version.
|
|
||||||
|
|
||||||
|
|
||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sh ./clock2
|
./try.sh
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
And for a good time, try:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sh ./clock3
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Alternate code:
|
## Alternate code:
|
||||||
|
|
||||||
An alternate version of this entry, [westley.alt.c](westley.alt.c), is provided.
|
The original version had a display problem in modern systems which somewhat
|
||||||
This version is the original code and does not contain the above mentioned
|
affected the usability of the program. This alternate code, the original, is
|
||||||
fixes.
|
provided, to show the differences.
|
||||||
|
|
||||||
|
### Alternate build:
|
||||||
|
|
||||||
To compile this alternate version:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
```
|
```
|
||||||
|
|
||||||
To use it with the scripts try:
|
|
||||||
|
### Alternate try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
WESTLEY=./westley.alt ./clock1
|
./try.alt.sh
|
||||||
WESTLEY=./westley.alt ./clock2
|
|
||||||
WESTLEY=./westley.alt ./clock3
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -66,7 +61,8 @@ This 1-line program allows various analog ASCII clocks to print out the time;
|
|||||||
the ASCII clock is built from the command line arguments, so many different
|
the ASCII clock is built from the command line arguments, so many different
|
||||||
types of clocks can be generated. Three different scripts are supplied to print
|
types of clocks can be generated. Three different scripts are supplied to print
|
||||||
out a grandfather clock, a mantle clock that runs backwards, and a linear-style
|
out a grandfather clock, a mantle clock that runs backwards, and a linear-style
|
||||||
clock. (they are `clock1`, `clock2`, and `clock3`)
|
clock. (they are [clock1.sh](clock1.sh), [clock2.sh](clock2.sh), and
|
||||||
|
[clock3.sh](clock3.sh))
|
||||||
|
|
||||||
The program makes the following (possibly non-portable) assumptions:
|
The program makes the following (possibly non-portable) assumptions:
|
||||||
|
|
||||||
@@ -74,8 +70,8 @@ The program makes the following (possibly non-portable) assumptions:
|
|||||||
|
|
||||||
2. `argv[0]` can be written to as if it were a `long *`.
|
2. `argv[0]` can be written to as if it were a `long *`.
|
||||||
|
|
||||||
3. The first three elements of the struct * returned by localtime() are seconds,
|
3. The first three elements of the `struct *` returned by `localtime(3)` are
|
||||||
minutes, hours, and all are ints.
|
seconds, minutes, hours, and all are `int`s.
|
||||||
|
|
||||||
4. My sample scripts assume ASCII, though this is not inherent in the code, just
|
4. My sample scripts assume ASCII, though this is not inherent in the code, just
|
||||||
my sample scripts.
|
my sample scripts.
|
||||||
@@ -83,6 +79,7 @@ my sample scripts.
|
|||||||
These assumptions are pretty reasonable. 2) can be eliminated but makes the code
|
These assumptions are pretty reasonable. 2) can be eliminated but makes the code
|
||||||
larger.
|
larger.
|
||||||
|
|
||||||
|
|
||||||
The code is simple; the arguments passed are:
|
The code is simple; the arguments passed are:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -94,14 +91,14 @@ values, looks up the offsets in `minute_map` and `hour_map`
|
|||||||
and writes the `hand_symbol` for each into the `clock_image`
|
and writes the `hand_symbol` for each into the `clock_image`
|
||||||
string. This string is then printed.
|
string. This string is then printed.
|
||||||
|
|
||||||
The for() loop starts by calling `time()` with `argv[0]`, so
|
The `for()` loop starts by calling `time()` with `argv[0]`, so
|
||||||
the time value (a long) is written into the program name.
|
the time value (a `long`) is written into the program name.
|
||||||
The for() control value is `argc`, which starts at `5`, but
|
The `for()` control value is `argc`, which starts at `5`, but
|
||||||
the `/=2` statement is executed before the test, so the for()
|
the `/=2` statement is executed before the test, so the `for()`
|
||||||
loop is executed twice, with `h=2`, then `h=1` (for hour & minute).
|
loop is executed twice, with `h=2`, then `h=1` (for hour & minute).
|
||||||
|
|
||||||
The statement of the for() loop takes the hour or minute
|
The statement of the `for()` loop takes the hour or minute
|
||||||
field of the struct returned by `localtime()` by casting it
|
field of the struct returned by `localtime(3)` by casting it
|
||||||
to an `int *` and dereferencing element `[h]`. It is slightly
|
to an `int *` and dereferencing element `[h]`. It is slightly
|
||||||
smaller to use the trick `h[(int*)localtime(*m)]` instead of
|
smaller to use the trick `h[(int*)localtime(*m)]` instead of
|
||||||
`((int*)localtime(*m))[h]`.
|
`((int*)localtime(*m))[h]`.
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
make everything 1>/dev/null || exit 1
|
||||||
|
|
||||||
|
echo "Showing alt grandfather clock:" 1>&2
|
||||||
|
WESTLEY=./westley.alt ./clock1.sh
|
||||||
|
read -r -n 1 -p "Press any key to continue: " 1>&2
|
||||||
|
|
||||||
|
echo "Showing alt mantle clock that runs backwards:" 1>&2
|
||||||
|
WESTLEY=./westley.alt ./clock2.sh
|
||||||
|
read -r -n 1 -p "Press any key to continue: " 1>&2
|
||||||
|
|
||||||
|
echo "Showing alt linear style clock:" 1>&2
|
||||||
|
WESTLEY=./westley.alt ./clock3.sh
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
make everything 1>/dev/null || exit 1
|
||||||
|
|
||||||
|
echo "Showing grandfather clock:" 1>&2
|
||||||
|
WESTLEY=./westley ./clock1.sh
|
||||||
|
read -r -n 1 -p "Press any key to continue: " 1>&2
|
||||||
|
|
||||||
|
echo "Showing mantle clock that runs backwards:" 1>&2
|
||||||
|
WESTLEY=./westley ./clock2.sh
|
||||||
|
read -r -n 1 -p "Press any key to continue: " 1>&2
|
||||||
|
|
||||||
|
echo "Showing linear style clock:" 1>&2
|
||||||
|
WESTLEY=./westley ./clock3.sh
|
||||||
@@ -1980,6 +1980,13 @@ Note that you should check the [westley.alt.c](1996/westley/westley.alt.c) file
|
|||||||
when reading the author's comments. To see how to use the original, see the
|
when reading the author's comments. To see how to use the original, see the
|
||||||
README.md file.
|
README.md file.
|
||||||
|
|
||||||
|
Cody also added the two scripts, [try.sh](1996/westley/try.sh) and
|
||||||
|
[try.alt.sh](1996/westley/try.alt.sh) to show automate showing the different
|
||||||
|
clocks, both with the fixed version and the original (alt) version.
|
||||||
|
|
||||||
|
Also, to fix any potential problem with displaying in GitHub the scripts
|
||||||
|
provided by the author, Cody added '.sh'.
|
||||||
|
|
||||||
|
|
||||||
## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md]))
|
## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md]))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user