diff --git a/1992/westley/.gitignore b/1992/westley/.gitignore index 6aaf6c97a..b2b7df607 100644 --- a/1992/westley/.gitignore +++ b/1992/westley/.gitignore @@ -8,3 +8,5 @@ prog.orig westley westley.alt westley.orig +whereami +whereami.alt diff --git a/1992/westley/Makefile b/1992/westley/Makefile index 6a0398f48..ef3196f10 100644 --- a/1992/westley/Makefile +++ b/1992/westley/Makefile @@ -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" diff --git a/1992/westley/README.md b/1992/westley/README.md index 93e5220d1..75f601fea 100644 --- a/1992/westley/README.md +++ b/1992/westley/README.md @@ -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: ``` ./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: ``` - ./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: + +``` + 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 ``` diff --git a/1992/westley/index.html b/1992/westley/index.html index bb8a725fe..aff2f349e 100644 --- a/1992/westley/index.html +++ b/1992/westley/index.html @@ -413,9 +413,9 @@ Location: US - United States of America
    ./whereami.sh lat long

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:

    ./try.sh

Alternate code:

@@ -424,17 +424,26 @@ should just use the westley and westley.alt programs d
    make alt

Alternate use:

    ./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 script uses both the original entry and the alternate code -so one can try the same script for both:

+

The try.sh script uses both the original +entry and the alternate code so one can try the same script for both:

    ./try.sh

Judges’ remarks:

To find the approximate place where this entry was judged, type:

-
    ./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:

+
        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

Author’s remarks:

Run the program with your latitude & longitude as integer arguments; it will produce a map made up of '!' with the given @@ -487,16 +496,16 @@ blank line. It’s just for show, really.

be just off the map; this is an unavoidable artifact. The map 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

For a domestic (US) version with higher resolution, try:

    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"
diff --git a/1992/westley/whereami.c b/1992/westley/whereami.c
deleted file mode 100644
index d5eb87117..000000000
--- a/1992/westley/whereami.c
+++ /dev/null
@@ -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 
-#include 
-#include 
-#include 
-
-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  \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;
-}