Fixes in 1992/westley
The whereami.c file should not have been left in as the scripts added take care of the problem. The Makefile now links whereami to westley and whereami.alt to westley.alt. Running make clobber will remove the links. The index.html had some mistakes from the time where the C file was useful. There might still be some mistakes but that will have to be checked another time. The manifest has been updated locally but the .entry.json file and the index.html file have not yet been corrected. This will happen soon after the rest of the changes of 1992 are committed.
This commit is contained in:
1 parent
90511b95b4
commit
c5dde38b81
5 files changed
+62
-116
No files matched your search
@@ -8,3 +8,5 @@ prog.orig
|
||||
westley
|
||||
westley.alt
|
||||
westley.orig
|
||||
whereami
|
||||
whereami.alt
|
||||
@@ -134,6 +134,7 @@ all: data ${TARGET}
|
||||
|
||||
${PROG}: ${PROG}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
${LN} -sf ${PROG} whereami
|
||||
@echo "NOTE: your terminal must be at least 80 columns wide for this to work right"
|
||||
|
||||
# alternative executable
|
||||
@@ -143,6 +144,7 @@ alt: data ${ALT_TARGET}
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
${LN} -sf ${PROG}.alt whereami.alt
|
||||
@echo "NOTE: your terminal must be at least 80 columns wide for this to work right"
|
||||
|
||||
|
||||
|
||||
+31
-18
@@ -29,9 +29,9 @@ If lost:
|
||||
Where `lat` and `long` correspond to your latitude and longitude.
|
||||
|
||||
NOTE: you **MUST** have a terminal that is at least 80 columns for this to show
|
||||
properly. The `whereami` and `whereami.alt` code checks this but it is not
|
||||
prohibitive if it cannot be compiled and linked (it uses curses); instead one
|
||||
should just use the `westley` and `westley.alt` programs directly.
|
||||
properly. The `whereami.sh` and `whereami.alt.sh` scripts check this but if you
|
||||
do not have such a terminal you can run the `whereami` (or for the alternate code
|
||||
described below, `whereami.alt`) directly.
|
||||
|
||||
|
||||
## Try:
|
||||
@@ -59,13 +59,14 @@ The author provided a version for the US which we added. To build:
|
||||
./whereami.alt.sh lat long
|
||||
```
|
||||
|
||||
NOTE: this alternative version also needs a terminal with at least 80 columns.
|
||||
NOTE: this alternative version also needs a terminal with at least 80 columns
|
||||
but if you do not have such a terminal you can run `whereami.alt` directly.
|
||||
|
||||
|
||||
### Alternate try:
|
||||
|
||||
The [try.sh](%%REPO_URL%%/1992/westley/try.sh) script uses both the original entry and the alternate code
|
||||
so one can try the same script for both:
|
||||
The [try.sh](%%REPO_URL%%/1992/westley/try.sh) script uses both the original
|
||||
entry and the alternate code so one can try the same script for both:
|
||||
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
@@ -77,10 +78,22 @@ so one can try the same script for both:
|
||||
To find the approximate place where this entry was judged, type:
|
||||
|
||||
``` <!---sh-->
|
||||
./whereami 37 -122 # NOTE: - means west of meridian
|
||||
./whereami.sh 37 -122 # NOTE: - means west of meridian
|
||||
|
||||
# or if you don't have curses installed:
|
||||
./westley 37 -122 # NOTE: - means west of meridian
|
||||
# or if you don't have at least 80 columns and want to see what it
|
||||
# looks like anyway:
|
||||
./whereami 37 -122 # NOTE: - means west of meridian
|
||||
```
|
||||
|
||||
If you wish to see this on the US map:
|
||||
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
./whereami.alt.sh 37 -122 # NOTE: - means west of meridian
|
||||
|
||||
# or if you don't have at least 80 columns and want to see what it
|
||||
# looks like anyway:
|
||||
./whereami.alt.sh 37 -122 # NOTE: - means west of meridian
|
||||
```
|
||||
|
||||
|
||||
@@ -151,16 +164,16 @@ is reasonably accurate.
|
||||
### Here are some cities you might like to try:
|
||||
|
||||
```
|
||||
New York 41 -74
|
||||
London 52 0
|
||||
Moscow 56 38
|
||||
New Delhi 29 77
|
||||
Sydney -34 151
|
||||
Los Angeles 34 -118
|
||||
Paris 45 2
|
||||
New York 41 -74
|
||||
London 52 0
|
||||
Moscow 56 38
|
||||
New Delhi 29 77
|
||||
Sydney -34 151
|
||||
Los Angeles 34 -118
|
||||
Paris 45 2
|
||||
Rio de Janeiro -23 -43
|
||||
Beijing 40 116
|
||||
Tokyo 36 140
|
||||
Beijing 40 116
|
||||
Tokyo 36 140
|
||||
```
|
||||
|
||||
|
||||
|
||||
+27
-18
@@ -413,9 +413,9 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<pre><code> ./whereami.sh lat long</code></pre>
|
||||
<p>Where <code>lat</code> and <code>long</code> correspond to your latitude and longitude.</p>
|
||||
<p>NOTE: you <strong>MUST</strong> have a terminal that is at least 80 columns for this to show
|
||||
properly. The <code>whereami</code> and <code>whereami.alt</code> code checks this but it is not
|
||||
prohibitive if it cannot be compiled and linked (it uses curses); instead one
|
||||
should just use the <code>westley</code> and <code>westley.alt</code> programs directly.</p>
|
||||
properly. The <code>whereami.sh</code> and <code>whereami.alt.sh</code> scripts check this but if you
|
||||
do not have such a terminal you can run the <code>whereami</code> (or for the alternate code
|
||||
described below, <code>whereami.alt</code>) directly.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
@@ -424,17 +424,26 @@ should just use the <code>westley</code> and <code>westley.alt</code> programs d
|
||||
<pre><code> make alt</code></pre>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<pre><code> ./whereami.alt.sh lat long</code></pre>
|
||||
<p>NOTE: this alternative version also needs a terminal with at least 80 columns.</p>
|
||||
<p>NOTE: this alternative version also needs a terminal with at least 80 columns
|
||||
but if you do not have such a terminal you can run <code>whereami.alt</code> directly.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/try.sh">try.sh</a> script uses both the original entry and the alternate code
|
||||
so one can try the same script for both:</p>
|
||||
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/westley/try.sh">try.sh</a> script uses both the original
|
||||
entry and the alternate code so one can try the same script for both:</p>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>To find the approximate place where this entry was judged, type:</p>
|
||||
<pre><code> ./whereami 37 -122 # NOTE: - means west of meridian
|
||||
<pre><code> ./whereami.sh 37 -122 # NOTE: - means west of meridian
|
||||
|
||||
# or if you don't have curses installed:
|
||||
./westley 37 -122 # NOTE: - means west of meridian</code></pre>
|
||||
# or if you don't have at least 80 columns and want to see what it
|
||||
# looks like anyway:
|
||||
./whereami 37 -122 # NOTE: - means west of meridian</code></pre>
|
||||
<p>If you wish to see this on the US map:</p>
|
||||
<pre><code> make alt
|
||||
./whereami.alt.sh 37 -122 # NOTE: - means west of meridian
|
||||
|
||||
# or if you don't have at least 80 columns and want to see what it
|
||||
# looks like anyway:
|
||||
./whereami.alt.sh 37 -122 # NOTE: - means west of meridian</code></pre>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>Run the program with your latitude & longitude as integer
|
||||
arguments; it will produce a map made up of <code>'!'</code> with the given
|
||||
@@ -487,16 +496,16 @@ blank line. It’s just for show, really.</p>
|
||||
be just off the map; this is an unavoidable artifact. The map
|
||||
is reasonably accurate.</p>
|
||||
<h3 id="here-are-some-cities-you-might-like-to-try">Here are some cities you might like to try:</h3>
|
||||
<pre><code> New York 41 -74
|
||||
London 52 0
|
||||
Moscow 56 38
|
||||
New Delhi 29 77
|
||||
Sydney -34 151
|
||||
Los Angeles 34 -118
|
||||
Paris 45 2
|
||||
<pre><code> New York 41 -74
|
||||
London 52 0
|
||||
Moscow 56 38
|
||||
New Delhi 29 77
|
||||
Sydney -34 151
|
||||
Los Angeles 34 -118
|
||||
Paris 45 2
|
||||
Rio de Janeiro -23 -43
|
||||
Beijing 40 116
|
||||
Tokyo 36 140</code></pre>
|
||||
Beijing 40 116
|
||||
Tokyo 36 140</code></pre>
|
||||
<p>For a domestic (US) version with higher resolution, try:</p>
|
||||
<pre><code> main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043;
|
||||
n="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* whereami.c: wrapper program to westley.c that checks first the
|
||||
* columns of the terminal, exiting if < 80 and otherwise try compiling
|
||||
* westley.c (with make) and then if is already compiled or ends up being
|
||||
* compiled it will be run with the specified args to this program.
|
||||
*
|
||||
* It is an error to not specify two args but it is not an error to specify args
|
||||
* that are not numbers. The atoi(3) function typically returns 0 in that case
|
||||
* which westley.c uses.
|
||||
*
|
||||
* The reason to use this wrapper is because westley.c needs at least 80 columns
|
||||
* to show the output right. Previously it required 80 column wrapping but in
|
||||
* 2023 this limitation was removed, allowing it to work as long as there are at
|
||||
* least 80 columns.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <curses.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int cols;
|
||||
char *cc = NULL; /* for if the user passes in CC=foo */
|
||||
char *buf = NULL;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
fprintf(stderr, "usage: %s <lat> <long>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* try and get compiler to use */
|
||||
cc = getenv("CC");
|
||||
if (!cc)
|
||||
cc = "cc";
|
||||
|
||||
buf = calloc(1, strlen(cc) + strlen("CC=") + 1);
|
||||
if (buf != NULL)
|
||||
sprintf(buf, "CC=%s", cc);
|
||||
else
|
||||
buf = "CC=cc";
|
||||
|
||||
|
||||
/* init curses so we can get the number of columns */
|
||||
initscr();
|
||||
/* save columns */
|
||||
cols = COLS;
|
||||
/*
|
||||
* end curses so that we can either report an error or compile and run
|
||||
* westley
|
||||
*/
|
||||
endwin();
|
||||
|
||||
if (cols < 80)
|
||||
{
|
||||
fprintf(stderr, "your terminal must be at\nleast 80 columns wide\nbut is only %d, sorry.\n", COLS);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/*
|
||||
* compile westley.c and run if successful
|
||||
*/
|
||||
buf = calloc(1, strlen("make CC=") + strlen(cc) + strlen("westley") + strlen(">/dev/null") + 1);
|
||||
if (buf)
|
||||
sprintf(buf, "make CC=%s westley >/dev/null", cc);
|
||||
else
|
||||
buf = "make westley >/dev/null";
|
||||
|
||||
/* compile source file */
|
||||
if (system(buf))
|
||||
{
|
||||
fprintf(stderr, "couldn't compile westley.c, sorry.\n");
|
||||
exit(4);
|
||||
}
|
||||
/* if we get here we compiled the code or it was already compiled so run it */
|
||||
execl("./westley", "./westley", argv[1], argv[2], NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user