$OpenBSD: patch-luna_c,v 1.2 2007/12/18 09:43:36 ajacoutot Exp $
--- luna.c.orig	Tue Dec 18 09:36:17 2007
+++ luna.c	Tue Dec 18 09:36:17 2007
@@ -25,27 +25,41 @@
 #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);
+
 	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 = asctime(localtmp);
 		chp[LASCTIME - 2] = 0;
-		printf("%s", chp);
+		printf("%s %3.3s", chp, tzname);
 
 		if (numonly) {
 			printf("  ");
@@ -62,7 +76,7 @@ main(argc, argv)
 
 		today = FALSE;
 		tomorrow(localtmp);
-		tomorrow(algotmp);
+		tomorrow(&algotm);
 	}
 
 	exit(0);
@@ -177,18 +191,16 @@ usage()
 
 
 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;
@@ -203,7 +215,7 @@ getoptions(argc, argv, localtmpp, algotmpp)
 		strlwr(argv[i]);
 #else
 		for (j = 0; j < strlen(argv[i]); j++) {
-			*(argv[i] + j) = Tolower(*(argv[i] + j));
+			*(argv[i] + j) = tolower(*(argv[i] + j));
 		}
 #endif	/* MSDOS or not */
 
@@ -376,19 +388,7 @@ getoptions(argc, argv, localtmpp, algotmpp)
 		= 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;
 }
