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