Path: blob/main/astro/luna/files/patch-luna.c
16461 views
--- luna.c.orig 2016-07-26 13:07:24 UTC1+++ luna.c2@@ -25,27 +25,43 @@3#include "luna.h"456-void7+int8main(argc, argv)9int argc;10char **argv;11{12- int aotmoon, i;13- struct tm *localtmp, *algotmp;14- char *chp;15+ int aotmoon, tzhere,16+ i;17+ struct tm *localtmp, algotm;18+ char *chp, *envp, *tzname;1920- getoptions(argc, argv, &localtmp, &algotmp);21+ getoptions(argc, argv, &localtmp);22+ envp = getenv("TZ");23+ if ((envp = getenv("TZ")) == NULL ||24+ (chp = strchr(envp, '-')) == NULL && (chp = strchr(envp, '+')) == NULL25+ ) {26+ tzhere = TZ_DFL;27+ } else {28+ tzhere = atoi(chp);29+ }30+ tzconv(&algotm, localtmp, tzhere - TZ_ALGO);31+/*printf("%d %d:%d\n", algotm.tm_mday, algotm.tm_hour, algotm.tm_min);*/32+33for (i = 0; i < bdate; i++) {34if (extluna) {35aotmoon = getext(localtmp -> tm_year, localtmp -> tm_mon,36localtmp -> tm_mday);37} else {38- aotmoon = getmoon(algotmp -> tm_year, algotmp -> tm_yday);39+ aotmoon = getmoon(algotm.tm_year, algotm.tm_yday);40}4142+43+ if ((tzname = getenv("TZ")) == NULL) {44+ tzname = TZNAME_DFL;45+ }46chp = Asctime(localtmp);47chp[LASCTIME - 2] = 0;48- printf("%s", chp);49+ printf("%s %3.3s", chp, tzname);5051if (numonly) {52printf(" ");53@@ -62,10 +78,11 @@ main(argc, argv)5455today = FALSE;56tomorrow(localtmp);57- tomorrow(algotmp);58+ tomorrow(&algotm);59}6061exit(0);62+/* NEVERREACHED */63}646566@@ -177,18 +194,15 @@ usage()676869void70-getoptions(argc, argv, localtmpp, algotmpp)71+getoptions(argc, argv, localtmpp)72int argc;73char **argv;74struct tm **localtmpp;75- struct tm **algotmpp;76{77- int argnum[3], argnumcnt,78- tzhere;79- char *chp, *envp;80+ int argnum[3], argnumcnt;81+ char *chp;82register int j, i;83BOOLEAN namedmon, followname;84- static struct tm algotm;85struct tm *localtmp;8687argnumcnt = 0;88@@ -375,20 +389,7 @@ getoptions(argc, argv, localtmpp, algotm89localtmp -> tm_yday90= ymd2yday(localtmp -> tm_year, localtmp -> tm_mon,91localtmp -> tm_mday);92-93- envp = getenv("TZ");94- if ((envp = getenv("TZ")) == NULL ||95- (chp = strchr(envp, '-')) == NULL && (chp = strchr(envp, '+')) == NULL96- ) {97- tzhere = TZ_DFL;98- } else {99- tzhere = atoi(chp);100- }101- tzconv(&algotm, localtmp, tzhere - TZ_ALGO);102-printf("%d %d:%d\n", algotm.tm_mday, algotm.tm_hour, algotm.tm_min);103-104*localtmpp = localtmp;105- *algotmpp = &algotm;106107return;108}109110111