svn commit: r205580 - user/edwin/calendar

Edwin Groothuis edwin at FreeBSD.org
Wed Mar 24 07:03:11 UTC 2010


Author: edwin
Date: Wed Mar 24 07:03:11 2010
New Revision: 205580
URL: http://svn.freebsd.org/changeset/base/205580

Log:
  Make the code WARNS=7 errors free.
  Well, except for something in io.c, therefore it won't be enabled
  in the Makefile.

Modified:
  user/edwin/calendar/calendar.c
  user/edwin/calendar/calendar.h
  user/edwin/calendar/dates.c
  user/edwin/calendar/day.c
  user/edwin/calendar/locale.c
  user/edwin/calendar/parsedata.c
  user/edwin/calendar/pom.c
  user/edwin/calendar/sunpos.c

Modified: user/edwin/calendar/calendar.c
==============================================================================
--- user/edwin/calendar/calendar.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/calendar.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -65,20 +65,21 @@ struct passwd	*pw;
 int		doall = 0;
 int		debug = 0;
 char		*DEBUG = NULL;
-double		UTCoffset = UTCOFFSET_NOTSET;
-int		eastlongitude = LONGITUDE_NOTSET;
 time_t		f_time = 0;
-
-int	f_dayAfter = 0;		/* days after current date */
-int	f_dayBefore = 0;	/* days before current date */
-int	Friday = 5;		/* day before weekend */
+double		UTCOffset = UTCOFFSET_NOTSET;
+int		EastLongitude = LONGITUDE_NOTSET;
 
 static void	usage(void) __dead2;
 
 int
 main(int argc, char *argv[])
 {
+	int	f_dayAfter = 0;		/* days after current date */
+	int	f_dayBefore = 0;	/* days before current date */
+	int	Friday = 5;		/* day before weekend */
+
 	int ch;
+	struct tm tp1, tp2;
 
 	(void)setlocale(LC_ALL, "");
 
@@ -113,10 +114,10 @@ main(int argc, char *argv[])
 			Friday = atoi(optarg);
 			break;
 		case 'l': /* Change longitudal position */
-			eastlongitude = strtol(optarg, NULL, 10);
+			EastLongitude = strtol(optarg, NULL, 10);
 			break;
 		case 'U': /* Change UTC offset */
-			UTCoffset = strtod(optarg, NULL);
+			UTCOffset = strtod(optarg, NULL);
 			break;
 
 		case 'd':
@@ -146,8 +147,8 @@ main(int argc, char *argv[])
 
 	/* if not set, determine where I could be */
 	{
-		if (UTCoffset == UTCOFFSET_NOTSET &&
-		    eastlongitude == LONGITUDE_NOTSET) {
+		if (UTCOffset == UTCOFFSET_NOTSET &&
+		    EastLongitude == LONGITUDE_NOTSET) {
 			/* Calculate on difference between here and UTC */
 			time_t t;
 			struct tm tm;
@@ -169,18 +170,18 @@ main(int argc, char *argv[])
 			uo /=  60.0 / 100.0;
 			uo = hh + uo / 100;
 
-			UTCoffset = uo;
-			eastlongitude = UTCoffset * 15;
-		} else if (UTCoffset == UTCOFFSET_NOTSET) {
+			UTCOffset = uo;
+			EastLongitude = UTCOffset * 15;
+		} else if (UTCOffset == UTCOFFSET_NOTSET) {
 			/* Base on information given */
-			UTCoffset = eastlongitude / 15;
-		} else if (eastlongitude == LONGITUDE_NOTSET) {
+			UTCOffset = EastLongitude / 15;
+		} else if (EastLongitude == LONGITUDE_NOTSET) {
 			/* Base on information given */
-			eastlongitude = UTCoffset * 15;
+			EastLongitude = UTCOffset * 15;
 		}
 	}
 
-	settimes(f_time, f_dayBefore, f_dayAfter, &tp1, &tp2);
+	settimes(f_time, f_dayBefore, f_dayAfter, Friday, &tp1, &tp2);
 	generatedates(&tp1, &tp2);
 
 	/*

Modified: user/edwin/calendar/calendar.h
==============================================================================
--- user/edwin/calendar/calendar.h	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/calendar.h	Wed Mar 24 07:03:11 2010	(r205580)
@@ -55,14 +55,13 @@
 extern struct passwd *pw;
 extern int doall;
 extern struct iovec header[];
-extern struct tm tp1, tp2;
 extern time_t t1, t2;
 extern const char *calendarFile;
 extern int yrdays;
 extern struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon;
 extern struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice;
-extern double UTCoffset;
-extern int eastlongitude;
+extern double UTCOffset;
+extern int EastLongitude;
 
 #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
 
@@ -113,9 +112,6 @@ extern int eastlongitude;
 #define UTCOFFSET_CNY		8.0		
 
 extern int	debug;		/* show parsing of the input */
-extern int	f_dayAfter;	/* days after current date */
-extern int	f_dayBefore;	/* days before current date */
-extern int	Friday;		/* day before weekend */
 extern int	year1, year2;
 
 /* events.c */
@@ -143,7 +139,7 @@ struct event {
 
 struct fixs {
 	char	*name;
-	int	len;
+	size_t	len;
 };
 
 extern const char *days[];
@@ -162,7 +158,7 @@ void	setnsequences(char *);
 
 /* day.c */
 extern const struct tm tm0;
-void	settimes(time_t,int, int, struct tm *tp1, struct tm *tp2);
+void	settimes(time_t,int before, int after, int friday, struct tm *tp1, struct tm *tp2);
 time_t	Mktime(char *);
 
 /* parsedata.c */

Modified: user/edwin/calendar/dates.c
==============================================================================
--- user/edwin/calendar/dates.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/dates.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -171,7 +171,6 @@ generatedates(struct tm *tp1, struct tm 
 	int y1, m1, d1;
 	int y2, m2, d2;
 	int y, m, d;
-	int *mondays;
 
 	y1 = tp1->tm_year;
 	m1 = tp1->tm_mon + 1;

Modified: user/edwin/calendar/day.c
==============================================================================
--- user/edwin/calendar/day.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/day.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
 
 #include "calendar.h"
 
-struct tm		tp1, tp2;
+//struct tm		tp1, tp2;
 time_t			time1, time2;
 const struct tm		tm0;
 char			dayname[10];
@@ -51,7 +51,7 @@ int			year1, year2;
 
 
 void
-settimes(time_t now, int before, int after, struct tm *tp1, struct tm *tp2)
+settimes(time_t now, int before, int after, int friday, struct tm *tp1, struct tm *tp2)
 {
 	char *oldl, *lbufp;
 	struct tm tp;
@@ -59,13 +59,13 @@ settimes(time_t now, int before, int aft
 	localtime_r(&now, &tp);
 
 	/* Friday displays Monday's events */
-	if (f_dayAfter == 0 && f_dayBefore == 0 && Friday != -1)
-		f_dayAfter = tp.tm_wday == Friday ? 3 : 1;
+	if (after == 0 && before == 0 && friday != -1)
+		after = tp.tm_wday == friday ? 3 : 1;
 
-	time1 = now - SECSPERDAY * f_dayBefore;
+	time1 = now - SECSPERDAY * before;
 	localtime_r(&time1, tp1);
 	year1 = 1900 + tp1->tm_year;
-	time2 = now + SECSPERDAY * f_dayAfter;
+	time2 = now + SECSPERDAY * after;
 	localtime_r(&time2, tp2);
 	year2 = 1900 + tp2->tm_year;
 
@@ -121,49 +121,3 @@ Mktime(char *dp)
 #endif
 	return (mktime(&tm));
 }
-
-
-
-/* return offset for variable weekdays
- * -1 -> last weekday in month
- * +1 -> first weekday in month
- * ... etc ...
- */
-int
-getdayvar(char *s)
-{
-	int offs;
-
-	offs = strlen(s);
-
-	/* Sun+1 or Wednesday-2
-	 *    ^              ^   */
-
-	/* fprintf(stderr, "x: %s %s %d\n", s, s + offs - 2, offs); */
-	switch (*(s + offs - 2)) {
-	case '-':
-		return (-(atoi(s + offs - 1)));
-	case '+':
-		return (atoi(s + offs - 1));
-	}
-
-	/*
-	 * some aliases: last, first, second, third, fourth
-	 */
-
-	/* last */
-	if      (offs > 4 && !strcasecmp(s + offs - 4, "last"))
-		return (-1);
-	else if (offs > 5 && !strcasecmp(s + offs - 5, "first"))
-		return (+1);
-	else if (offs > 6 && !strcasecmp(s + offs - 6, "second"))
-		return (+2);
-	else if (offs > 5 && !strcasecmp(s + offs - 5, "third"))
-		return (+3);
-	else if (offs > 6 && !strcasecmp(s + offs - 6, "fourth"))
-		return (+4);
-
-	/* no offset detected */
-	return (0);
-}
-

Modified: user/edwin/calendar/locale.c
==============================================================================
--- user/edwin/calendar/locale.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/locale.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -147,7 +147,7 @@ setnsequences(char *seq)
 		if ((p = strchr(p, ' ')) == NULL) {
 			for (i = 0; i < 5; i++) {
 				nsequences[i].name = NULL;
-				nsequences[i].len = -1;
+				nsequences[i].len = 0;
 				return;
 			}
 			

Modified: user/edwin/calendar/parsedata.c
==============================================================================
--- user/edwin/calendar/parsedata.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/parsedata.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -37,12 +37,11 @@ __FBSDID("$FreeBSD$");
 #include "calendar.h"
 
 static char *showflags(int flags);
-static int isonlydigits(char *s, int star);
-static char *getmonthname(int i);
-static int checkmonth(char *s, int *len, int *offset, char **month);
-static char *getdayofweekname(int i);
-static int checkdayofweek(char *s, int *len, int *offset, char **dow);
 static int isonlydigits(char *s, int nostar);
+static const char *getmonthname(int i);
+static int checkmonth(char *s, int *len, int *offset, const char **month);
+static const char *getdayofweekname(int i);
+static int checkdayofweek(char *s, int *len, int *offset, const char **dow);
 static int indextooffset(char *s);
 static int parseoffset(char *s);
 static char *floattoday(int year, double f);
@@ -89,9 +88,10 @@ determinestyle(char *date, int *flags,
     char *dayofweek, int *idayofweek, char *modifieroffset,
     char *modifierindex, char *specialday)
 {
-	char *p, *dow, *pmonth, *p1, *p2;
+	char *p, *p1, *p2;
+	const char *dow, *pmonth;
 	char pold;
-	int len, offset;
+	size_t len, offset;
 
 	*flags = F_NONE;
 	*month = '\0';
@@ -298,25 +298,25 @@ allfine:
 }
 
 static void
-remember(int *index, int *y, int *m, int *d, char **ed, int yy, int mm, int dd,
-    char *extra)
+remember(int *rememberindex, int *y, int *m, int *d, char **ed, int yy, int mm,
+    int dd, char *extra)
 {
 	static int warned = 0;
 
-	if (*index >= MAXCOUNT - 1) {
+	if (*rememberindex >= MAXCOUNT - 1) {
 		if (warned == 0)
 			warnx("Index > %d, ignored", MAXCOUNT);
 		warned++;
 		return;
 	}
-	y[*index] = yy;
-	m[*index] = mm;
-	d[*index] = dd;
+	y[*rememberindex] = yy;
+	m[*rememberindex] = mm;
+	d[*rememberindex] = dd;
 	if (extra != NULL)
-		strcpy(ed[*index], extra);
+		strcpy(ed[*rememberindex], extra);
 	else
-		ed[*index][0] = '\0';
-	*index += 1;
+		ed[*rememberindex][0] = '\0';
+	*rememberindex += 1;
 }
 
 static void
@@ -371,7 +371,7 @@ parsedaymonth(char *date, int *yearp, in
 {
 	char month[100], dayofmonth[100], dayofweek[100], modifieroffset[100];
 	char modifierindex[100], specialday[100];
-	int idayofweek, imonth, idayofmonth, year, index;
+	int idayofweek = -1, imonth = -1, idayofmonth = -1, year, remindex;
 	int d, m, dow, rm, rd, offset;
 	char *ed;
 	int retvalsign = 1;
@@ -407,7 +407,7 @@ parsedaymonth(char *date, int *yearp, in
 		    dayofmonth, idayofmonth, dayofweek, idayofweek,
 		    modifieroffset, modifierindex, specialday);
 
-	index = 0;
+	remindex = 0;
 	for (year = year1; year <= year2; year++) {
 		/* Get important dates for this year */
 		yearinfo = years;
@@ -427,11 +427,11 @@ parsedaymonth(char *date, int *yearp, in
 
 			yearinfo->mondays = mondaytab[isleap(year)];
 			yearinfo->ieaster = easter(year);
-			fpom(year, UTCoffset, yearinfo->ffullmoon,
+			fpom(year, UTCOffset, yearinfo->ffullmoon,
 			    yearinfo->fnewmoon);
 			fpom(year, UTCOFFSET_CNY, yearinfo->ffullmooncny,
 			    yearinfo->fnewmooncny);
-			fequinoxsolstice(year, UTCoffset,
+			fequinoxsolstice(year, UTCOffset,
 			    yearinfo->equinoxdays, yearinfo->solsticedays);
 
 			/*
@@ -454,7 +454,7 @@ parsedaymonth(char *date, int *yearp, in
 		if (*flags == (F_MONTH | F_DAYOFMONTH)) {
 			if (!remember_ymd(year, imonth, idayofmonth))
 				continue;
-			remember(&index, yearp, monthp, dayp, edp,
+			remember(&remindex, yearp, monthp, dayp, edp,
 			    year, imonth, idayofmonth, NULL);
 			continue;
 		}
@@ -463,7 +463,7 @@ parsedaymonth(char *date, int *yearp, in
 		if (*flags == (F_MONTH | F_DAYOFMONTH | F_VARIABLE)) {
 			if (!remember_ymd(year, imonth, idayofmonth))
 				continue;
-			remember(&index, yearp, monthp, dayp, edp,
+			remember(&remindex, yearp, monthp, dayp, edp,
 			    year, imonth, idayofmonth, NULL);
 			continue;
 		}
@@ -473,7 +473,7 @@ parsedaymonth(char *date, int *yearp, in
 			for (m = 1; m <= 12; m++) {
 				if (!remember_ymd(year, m, idayofmonth))
 					continue;
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, m, idayofmonth, NULL);
 			}
 			continue;
@@ -484,7 +484,7 @@ parsedaymonth(char *date, int *yearp, in
 			for (d = 1; d <= yearinfo->mondays[imonth]; d++) {
 				if (!remember_ymd(year, imonth, d))
 					continue;
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, imonth, d, NULL);
 			}
 			continue;
@@ -495,7 +495,7 @@ parsedaymonth(char *date, int *yearp, in
 			for (m = 1; m <= 12; m++) {
 				if (!remember_ymd(year, m, idayofmonth))
 					continue;
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, m, idayofmonth, NULL);
 			}
 			continue;
@@ -507,7 +507,7 @@ parsedaymonth(char *date, int *yearp, in
 			d = (idayofweek - dow + 8) % 7;
 			while (d <= 366) {
 				if (remember_yd(year, d, &rm, &rd))
-					remember(&index,
+					remember(&remindex,
 					    yearp, monthp, dayp, edp,
 					    year, rm, rd, NULL);
 				d += 7;
@@ -526,7 +526,7 @@ parsedaymonth(char *date, int *yearp, in
 				while (d <= yearinfo->mondays[imonth]) {
 					if (--offset == 0
 					 && remember_ymd(year, imonth, d)) {
-						remember(&index,
+						remember(&remindex,
 						    yearp, monthp, dayp, edp,
 						    year, imonth, d, NULL);
 						continue;
@@ -543,7 +543,7 @@ parsedaymonth(char *date, int *yearp, in
 					d -= 7;
 				}
 				if (remember_ymd(year, imonth, d))
-					remember(&index,
+					remember(&remindex,
 					    yearp, monthp, dayp, edp,
 					    year, imonth, d, NULL);
 				continue;
@@ -557,7 +557,7 @@ parsedaymonth(char *date, int *yearp, in
 			d = (idayofweek - dow + 8) % 7;
 			while (d <= yearinfo->mondays[imonth]) {
 				if (remember_ymd(year, imonth, d))
-					remember(&index,
+					remember(&remindex,
 					    yearp, monthp, dayp, edp,
 					    year, imonth, d, NULL);
 				d += 7;
@@ -573,7 +573,7 @@ parsedaymonth(char *date, int *yearp, in
 				offset = parseoffset(modifieroffset);
 			if (remember_yd(year, yearinfo->ieaster + offset,
 			    &rm, &rd))
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, NULL);
 			continue;
 		}
@@ -586,7 +586,7 @@ parsedaymonth(char *date, int *yearp, in
 				offset = parseoffset(modifieroffset);
 			if (remember_yd(year, yearinfo->ipaskha + offset,
 			    &rm, &rd))
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, NULL);
 			continue;
 		}
@@ -599,7 +599,7 @@ parsedaymonth(char *date, int *yearp, in
 				offset = parseoffset(modifieroffset);
 			if (remember_yd(year, yearinfo->firstcnyday + offset,
 			    &rm, &rd))
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, NULL);
 			continue;
 		}
@@ -618,7 +618,7 @@ parsedaymonth(char *date, int *yearp, in
 					&rm, &rd)) {
 					ed = floattotime(
 					    yearinfo->ffullmoon[i]);
-					remember(&index,
+					remember(&remindex,
 					    yearp, monthp, dayp, edp,
 					    year, rm, rd, ed);
 				}
@@ -639,7 +639,7 @@ parsedaymonth(char *date, int *yearp, in
 				    floor(yearinfo->fnewmoon[i]) + offset,
 				    &rm, &rd)) {
 					ed = floattotime(yearinfo->fnewmoon[i]);
-					remember(&index,
+					remember(&remindex,
 					    yearp, monthp, dayp, edp,
 					    year, rm, rd, ed);
 				}
@@ -656,7 +656,7 @@ parsedaymonth(char *date, int *yearp, in
 			if (remember_yd(year, yearinfo->equinoxdays[0] + offset,
 			    &rm, &rd)) {
 				ed = floattotime(yearinfo->equinoxdays[0]);
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, ed);
 			}
 			continue;
@@ -669,7 +669,7 @@ parsedaymonth(char *date, int *yearp, in
 			if (remember_yd(year, yearinfo->equinoxdays[1] + offset,
 			    &rm, &rd)) {
 				ed = floattotime(yearinfo->equinoxdays[1]);
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, ed);
 			}
 			continue;
@@ -684,7 +684,7 @@ parsedaymonth(char *date, int *yearp, in
 			if (remember_yd(year,
 			    yearinfo->solsticedays[0] + offset, &rm, &rd)) {
 				ed = floattotime(yearinfo->solsticedays[0]);
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, ed);
 			}
 			continue;
@@ -697,7 +697,7 @@ parsedaymonth(char *date, int *yearp, in
 			if (remember_yd(year,
 			    yearinfo->solsticedays[1] + offset, &rm, &rd)) {
 				ed = floattotime(yearinfo->solsticedays[1]);
-				remember(&index, yearp, monthp, dayp, edp,
+				remember(&remindex, yearp, monthp, dayp, edp,
 				    year, rm, rd, ed);
 			}
 			continue;
@@ -711,9 +711,9 @@ parsedaymonth(char *date, int *yearp, in
 	}
 
 	if (retvalsign == -1)
-		return (-index - 1);
+		return (-remindex - 1);
 	else
-		return (index);
+		return (remindex);
 }
 
 static char *
@@ -762,16 +762,16 @@ showflags(int flags)
 	return s;
 }
 
-static char *
+static const char *
 getmonthname(int i)
 {
 	if (nmonths[i - 1].len != 0 && nmonths[i - 1].name != NULL)
 		return (nmonths[i - 1].name);
-	return ((char *)months[i - 1]);
+	return (months[i - 1]);
 }
 
 static int
-checkmonth(char *s, int *len, int *offset, char **month)
+checkmonth(char *s, int *len, int *offset, const char **month)
 {
 	struct fixs *n;
 	int i;
@@ -797,7 +797,7 @@ checkmonth(char *s, int *len, int *offse
 	for (i = 0; fmonths[i] != NULL; i++) {
 		*len = strlen(fmonths[i]);
 		if (strncasecmp(s, fmonths[i], *len) == 0) {
-			*month = (char *)fmonths[i];
+			*month = fmonths[i];
 			*offset = i + 1;
 			return (1);
 		}
@@ -805,7 +805,7 @@ checkmonth(char *s, int *len, int *offse
 	for (i = 0; months[i] != NULL; i++) {
 		if (strncasecmp(s, months[i], 3) == 0) {
 			*len = 3;
-			*month = (char *)months[i];
+			*month = months[i];
 			*offset = i + 1;
 			return (1);
 		}
@@ -813,16 +813,16 @@ checkmonth(char *s, int *len, int *offse
 	return (0);
 }
 
-static char *
+static const char *
 getdayofweekname(int i)
 {
 	if (ndays[i].len != 0 && ndays[i].name != NULL)
 		return (ndays[i].name);
-	return ((char *)days[i]);
+	return (days[i]);
 }
 
 static int
-checkdayofweek(char *s, int *len, int *offset, char **dow)
+checkdayofweek(char *s, int *len, int *offset, const char **dow)
 {
 	struct fixs *n;
 	int i;
@@ -848,7 +848,7 @@ checkdayofweek(char *s, int *len, int *o
 	for (i = 0; fdays[i] != NULL; i++) {
 		*len = strlen(fdays[i]);
 		if (strncasecmp(s, fdays[i], *len) == 0) {
-			*dow = (char *)fdays[i];
+			*dow = fdays[i];
 			*offset = i;
 			return (1);
 		}
@@ -856,7 +856,7 @@ checkdayofweek(char *s, int *len, int *o
 	for (i = 0; days[i] != NULL; i++) {
 		if (strncasecmp(s, days[i], 3) == 0) {
 			*len = 3;
-			*dow = (char *)days[i];
+			*dow = days[i];
 			*offset = i;
 			return (1);
 		}
@@ -892,7 +892,7 @@ indextooffset(char *s)
 	}
 	for (i = 0; i < 6; i++) {
 		n = nsequences + i;
-		if (n->len == -1)
+		if (n->len == 0)
 			continue;
 		if (strncasecmp(s, n->name, n->len) == 0) {
 			if (i == 5)
@@ -953,37 +953,20 @@ floattoday(int year, double f)
 	return (buf);
 }
 
-char *
-inttoday(int year, int f)
-{
-	static char buf[100];
-	int i, m, d;
-	int *cumdays = cumdaytab[isleap(year)];
-
-	for (i = 0; 1 + cumdays[i] < f; i++)
-		;;
-	m = --i;
-	d = floor(f - 1 - cumdays[i]);
-	f -= floor(f);
-
-	sprintf(buf, "%02d-%02d", m, d);
-	return (buf);
-}
-
 void
 dodebug(char *what)
 {
 	int year;
 
-	printf("UTCOffset: %g\n", UTCoffset);
-	printf("eastlongitude: %d\n", eastlongitude);
+	printf("UTCOffset: %g\n", UTCOffset);
+	printf("eastlongitude: %d\n", EastLongitude);
 
 	if (strcmp(what, "moon") == 0) {
 		double ffullmoon[MAXMOONS], fnewmoon[MAXMOONS];
 		int i;
 
 		for (year = year1; year <= year2; year++) {
-			fpom(year, UTCoffset, ffullmoon, fnewmoon);
+			fpom(year, UTCOffset, ffullmoon, fnewmoon);
 			printf("Full moon %d:\t", year);
 			for (i = 0; ffullmoon[i] >= 0; i++) {
 				printf("%g (%s) ", ffullmoon[i],
@@ -1005,7 +988,7 @@ dodebug(char *what)
 		double equinoxdays[2], solsticedays[2];
 		for (year = year1; year <= year2; year++) {
 			printf("Sun in %d:\n", year);
-			fequinoxsolstice(year, UTCoffset, equinoxdays,
+			fequinoxsolstice(year, UTCOffset, equinoxdays,
 			    solsticedays);
 			printf("e[0] - %g (%s)\n",
 			    equinoxdays[0],

Modified: user/edwin/calendar/pom.c
==============================================================================
--- user/edwin/calendar/pom.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/pom.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -81,8 +81,8 @@ __FBSDID("$FreeBSD$");
 
 static void	adj360(double *);
 static double	dtor(double);
-static double	potm(double);
-static double	potm_minute(double days, int olddir);
+static double	potm(double onday);
+static double	potm_minute(double onday, int olddir);
 
 void
 pom(int year, double utcoffset, int *fms, int *nms)
@@ -93,6 +93,7 @@ pom(int year, double utcoffset, int *fms
 
 	fpom(year, utcoffset, ffms, fnms);
 
+	j = 0;
 	for (i = 0; ffms[i] != 0; i++)
 		fms[j++] = round(ffms[i]);
 	fms[i] = -1;
@@ -183,7 +184,7 @@ fpom(int year, double utcoffset, double 
 }
 
 static double
-potm_minute(double days, int olddir) {
+potm_minute(double onday, int olddir) {
 	double period = FSECSPERDAY / 2.0;
 	double p1, p2;
 	double before, after;
@@ -191,7 +192,7 @@ potm_minute(double days, int olddir) {
 
 //	printf("---> days:%g olddir:%d\n", days, olddir);
 
-	p1 = days + (period / SECSPERDAY);
+	p1 = onday + (period / SECSPERDAY);
 	period /= 2;
 
 	while (period > 30) {	/* half a minute */
@@ -219,23 +220,23 @@ potm_minute(double days, int olddir) {
  *	return phase of the moon, as a percentage [0 ... 100]
  */
 static double
-potm(double days)
+potm(double onday)
 {
 	double N, Msol, Ec, LambdaSol, l, Mm, Ev, Ac, A3, Mmprime;
 	double A4, lprime, V, ldprime, D, Nm;
 
-	N = 360 * days / 365.2422;				/* sec 42 #3 */
+	N = 360 * onday / 365.2422;				/* sec 42 #3 */
 	adj360(&N);
 	Msol = N + EPSILONg - RHOg;				/* sec 42 #4 */
 	adj360(&Msol);
 	Ec = 360 / PI * ECCEN * sin(dtor(Msol));		/* sec 42 #5 */
 	LambdaSol = N + Ec + EPSILONg;				/* sec 42 #6 */
 	adj360(&LambdaSol);
-	l = 13.1763966 * days + lzero;				/* sec 61 #4 */
+	l = 13.1763966 * onday + lzero;				/* sec 61 #4 */
 	adj360(&l);
-	Mm = l - (0.1114041 * days) - Pzero;			/* sec 61 #5 */
+	Mm = l - (0.1114041 * onday) - Pzero;			/* sec 61 #5 */
 	adj360(&Mm);
-	Nm = Nzero - (0.0529539 * days);			/* sec 61 #6 */
+	Nm = Nzero - (0.0529539 * onday);			/* sec 61 #6 */
 	adj360(&Nm);
 	Ev = 1.2739 * sin(dtor(2*(l - LambdaSol) - Mm));	/* sec 61 #7 */
 	Ac = 0.1858 * sin(dtor(Msol));				/* sec 61 #8 */

Modified: user/edwin/calendar/sunpos.c
==============================================================================
--- user/edwin/calendar/sunpos.c	Wed Mar 24 06:23:04 2010	(r205579)
+++ user/edwin/calendar/sunpos.c	Wed Mar 24 07:03:11 2010	(r205580)
@@ -366,12 +366,13 @@ calculatesunlongitude30(int year, int de
 	double dec;
 	double curL, prevL;
 	int *pichinesemonths, *monthdays, *cumdays, i;
-	int firstmonth330;
+	int firstmonth330 = -1;
 
 	cumdays = cumdaytab[isleap(year)];
 	monthdays = mondaytab[isleap(year)];
 	pichinesemonths = ichinesemonths;
 
+	h = 0;
 	sunpos(year - 1, 12, 31,
 	    -24 * (degreeGMToffset / 360.0),
 	    HOUR(h), MIN(h), SEC(h), 0.0, 0.0, &prevL, &dec);


More information about the svn-src-user mailing list