Format/typo check 1989/westley/README.md
This one might not yet be done but there were some formatting and some typo fixes.
This commit is contained in:
1 parent
f12f2a78d0
commit
5193b261df
1 file changed
+15
-15
+15
-15
@@ -78,18 +78,18 @@ There is a secret way to get ONE of the versions to print out
|
|||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
This is a filter. If it is run with no arguments, it copies
|
This is a filter. If it is run with no arguments, it copies
|
||||||
stdin to stdout. With one argument, it ROT13's stdin to
|
`stdin` to `stdout`. With one argument, it ROT13's `stdin` to
|
||||||
stdout. With two arguments, it reverses stdin to stdout. With
|
`stdout`. With two arguments, it reverses `stdin` to `stdout`. With
|
||||||
three arguments, it does both. It requires the ASCII character
|
three arguments, it does both. It requires the ASCII character
|
||||||
set, with all characters being in 0..255, and EOF must be -1.
|
set, with all characters being in `0..255`, and `EOF` must be `-1`.
|
||||||
Also requires two's complement (I think).
|
Also requires two's complement (I think).
|
||||||
|
|
||||||
The source code will run if ROT13'ed and/or reversed, using a
|
The source code will run if ROT13'ed and/or reversed, using a
|
||||||
different algorithm for each version (hereafter referred to as
|
different algorithm for each version (hereafter referred to as
|
||||||
`ver0` (original), `ver1` (ROT13), `ver2` (reversed), and `ver3`\
|
`ver0` (original), `ver1` (ROT13), `ver2` (reversed), and `ver3`
|
||||||
(ROT13 and reversed)).
|
(ROT13 and reversed)).
|
||||||
|
|
||||||
When compiling these versions, one needs to define 'trgpune'
|
When compiling these versions, one needs to define `trgpune`
|
||||||
in the compile line (which the Makefile now has). Example:
|
in the compile line (which the Makefile now has). Example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -106,13 +106,13 @@ definition will supersede the library function. Hence, the
|
|||||||
compiler option gives me `putchar()`, and allows me to use
|
compiler option gives me `putchar()`, and allows me to use
|
||||||
`getchar()`. I pass a dummy argument to `getchar()` to eliminate
|
`getchar()`. I pass a dummy argument to `getchar()` to eliminate
|
||||||
"variable number of args" from lint (unless it checks against
|
"variable number of args" from lint (unless it checks against
|
||||||
the library). Otherwise, all versions lint reasonably (main
|
the library). Otherwise, all versions of lint complain that `main()`
|
||||||
returns random value & constant in conditional context [when I
|
returns random value & constant in conditional context (when I
|
||||||
check for ROT13 version] is all it complains about).
|
check for ROT13 version).
|
||||||
|
|
||||||
`ver0` and `ver1` use a range check and a calculation to do ROT13,
|
`ver0` and `ver1` use a range check and a calculation to do ROT13,
|
||||||
while `ver2` and `ver3` use table lookup. All versions contain
|
while `ver2` and `ver3` use table lookup. All versions contain
|
||||||
`main()` and its ROT13 function, `znva()`. `ver0`/`ver1` [`ver2`/`ver3`] are
|
`main()` and its ROT13 function, `znva()`. `ver0`/`ver1` (`ver2`/`ver3`) are
|
||||||
(of course) syntactically identical, since the syntax is in the
|
(of course) syntactically identical, since the syntax is in the
|
||||||
non-alphabetic characters. However, since one program starts
|
non-alphabetic characters. However, since one program starts
|
||||||
at `main()` while it's ROT13 counterpart starts at `znva()`, `znva()`
|
at `main()` while it's ROT13 counterpart starts at `znva()`, `znva()`
|
||||||
@@ -121,14 +121,14 @@ calls main (`znva()` is also used for output).
|
|||||||
All versions use recursion to work. If the program is NOT
|
All versions use recursion to work. If the program is NOT
|
||||||
reversing it's output, it prints out the (possibly ROT13'd)
|
reversing it's output, it prints out the (possibly ROT13'd)
|
||||||
character before recursing, otherwise it prints it out
|
character before recursing, otherwise it prints it out
|
||||||
afterward (or doesn't recurse at all when EOF is reached).
|
afterward (or doesn't recurse at all when `EOF` is reached).
|
||||||
Since most of this code is identical, it is put into `znva()` and
|
Since most of this code is identical, it is put into `znva()` and
|
||||||
called with a first parameter of 0 as a flag (as `main()`, it's
|
called with a first parameter of 0 as a flag (as `main()`, it's
|
||||||
first argument (argc) must be at least one).
|
first argument (argc) must be at least one).
|
||||||
|
|
||||||
I can't use any flow control. If I used if(), I would have a
|
I can't use any flow control. If I used `if()`, I would have a
|
||||||
function vs() to define in the ROT13 version. But a function
|
function `vs()` to define in the ROT13 version. But a function
|
||||||
called vs() turns into a function called if() in the original,
|
called `vs()` turns into a function called `if()` in the original,
|
||||||
so it can't be done. Therefore, I do:
|
so it can't be done. Therefore, I do:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
@@ -184,9 +184,9 @@ The code can therefore be interlaced. There are eight
|
|||||||
such palindromic bits. You can find them within the
|
such palindromic bits. You can find them within the
|
||||||
`/*//**/ /**//*/` pairs.
|
`/*//**/ /**//*/` pairs.
|
||||||
|
|
||||||
The body of the code of `ver0` and `ver1` is a large lumpy 'K' (for
|
The body of the code of `ver0` and `ver1` is a large lumpy `K` (for
|
||||||
Kernighan); the code of `ver2` and `ver3` is a flat-topped and
|
Kernighan); the code of `ver2` and `ver3` is a flat-topped and
|
||||||
lumpier 'R' (for Ritchie). Judicious use of spaces and tabs
|
lumpier `R` (for Ritchie). Judicious use of spaces and tabs
|
||||||
helped here. It barely fits on an 80x24 screen. Squint. Note
|
helped here. It barely fits on an 80x24 screen. Squint. Note
|
||||||
that the code must start with a blank line, or the reversed version
|
that the code must start with a blank line, or the reversed version
|
||||||
will lack a terminating newline.
|
will lack a terminating newline.
|
||||||
|
|||||||
Reference in new issue
Block a user