1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
--- luna.c.orig 1992-05-25 01:01:32.000000000 +0200
+++ luna.c 2011-12-20 19:57:51.404175556 +0100
@@ -25,27 +25,43 @@
#include "luna.h"
-void
+int
main(argc, argv)
int argc;
char **argv;
{
- int aotmoon, i;
- struct tm *localtmp, *algotmp;
- char *chp;
+ int aotmoon, tzhere,
+ i;
+ struct tm *localtmp, algotm;
+ char *chp, *envp, *tzname;
- getoptions(argc, argv, &localtmp, &algotmp);
+ getoptions(argc, argv, &localtmp);
+ envp = getenv("TZ");
+ if ((envp = getenv("TZ")) == NULL ||
+ (chp = strchr(envp, '-')) == NULL && (chp = strchr(envp, '+')) == NULL
+ ) {
+ tzhere = TZ_DFL;
+ } else {
+ tzhere = atoi(chp);
+ }
+ tzconv(&algotm, localtmp, tzhere - TZ_ALGO);
+/*printf("%d %d:%d\n", algotm.tm_mday, algotm.tm_hour, algotm.tm_min);*/
+
for (i = 0; i < bdate; i++) {
if (extluna) {
aotmoon = getext(localtmp -> tm_year, localtmp -> tm_mon,
localtmp -> tm_mday);
} else {
- aotmoon = getmoon(algotmp -> tm_year, algotmp -> tm_yday);
+ aotmoon = getmoon(algotm.tm_year, algotm.tm_yday);
}
+
+ if ((tzname = getenv("TZ")) == NULL) {
+ tzname = TZNAME_DFL;
+ }
chp = Asctime(localtmp);
chp[LASCTIME - 2] = 0;
- printf("%s", chp);
+ printf("%s %3.3s", chp, tzname);
if (numonly) {
printf(" ");
@@ -62,10 +78,11 @@
today = FALSE;
tomorrow(localtmp);
- tomorrow(algotmp);
+ tomorrow(&algotm);
}
exit(0);
+/* NEVERREACHED */
}
@@ -177,18 +194,15 @@
void
-getoptions(argc, argv, localtmpp, algotmpp)
+getoptions(argc, argv, localtmpp)
int argc;
char **argv;
struct tm **localtmpp;
- struct tm **algotmpp;
{
- int argnum[3], argnumcnt,
- tzhere;
- char *chp, *envp;
+ int argnum[3], argnumcnt;
+ char *chp;
register int j, i;
BOOLEAN namedmon, followname;
- static struct tm algotm;
struct tm *localtmp;
argnumcnt = 0;
@@ -375,20 +389,7 @@
localtmp -> tm_yday
= ymd2yday(localtmp -> tm_year, localtmp -> tm_mon,
localtmp -> tm_mday);
-
- envp = getenv("TZ");
- if ((envp = getenv("TZ")) == NULL ||
- (chp = strchr(envp, '-')) == NULL && (chp = strchr(envp, '+')) == NULL
- ) {
- tzhere = TZ_DFL;
- } else {
- tzhere = atoi(chp);
- }
- tzconv(&algotm, localtmp, tzhere - TZ_ALGO);
-printf("%d %d:%d\n", algotm.tm_mday, algotm.tm_hour, algotm.tm_min);
-
*localtmpp = localtmp;
- *algotmpp = &algotm;
return;
}
|