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
|
Description: Fix GCC compiler warnings found in lunar.c
Revise lunar.c to remove GCC compiler warnings such as:
.
* implicit declaration of function ‘CmpDate’
* implicit declaration of function ‘exit’
* incompatible implicit declaration of built-in function ‘exit’
* unused variable ‘d’
* suggest parentheses around ‘&&’ within ‘||’
* variable ‘nYear’ set but not used
.
First applied since 2.2-1; revised in 2.2-3 and 2.2-4.
.
In July 2015, Xie Xun found a bug where lunar 2.2-4 always outputs
Solar Year 1900 no matter what the date of lunar-to-solar conversion is,
and traced to a bug that I (Anthony) introduced in 2.2-4: When I removed
the unused ‘nYear’ variable, I had mistakenly removed the necessary call
to make_yday(). Xie Xun’s report and patch in Bug #792472 fixes the bug.
Author: Anthony Fok <foka@debian.org>, Xie Xun <xiexun162534@gmail.com>
Origin: vendor, https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=10;bug=792472
Bug-Debian: https://bugs.debian.org/792472
Forwarded: not-needed
Last-Update: 2015-09-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/lunar.c
+++ b/lunar.c
@@ -64,6 +64,7 @@ References:
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
/* "Bitmap" constants */
@@ -150,7 +151,7 @@ long Solar2Day(), Solar2Day1(), Lunar
void Day2Lunar(), Day2Solar();
int make_yday(), make_mday(), GZcycle();
void CalGZ();
-int JieDate(), JieDate();
+int CmpDate(), JieDate();
void readBM(), display3();
void Report(), ReportE(), ReportBM(), ReportGB();
void usage(), Error();
@@ -243,9 +244,7 @@ void usage()
void Solar2Lunar()
{
-
long offset;
- Date *d;
offset = Solar2Day(&solar);
solar.weekday = (offset + SolarFirstDate.weekday) % 7;
@@ -269,7 +268,6 @@ void Lunar2Solar()
{
long offset;
int adj;
- Date *d;
/* A solar day begins at 12 a.m. */
adj = (lunar.hour == 23)? -1 : 0;
@@ -286,7 +284,7 @@ void Lunar2Solar()
}
-#define LeapYear(y) (((y)%4==0) && ((y)%100!=0) || ((y)%400==0))
+#define LeapYear(y) ((((y)%4==0) && ((y)%100!=0)) || ((y)%400==0))
#define BYEAR 1201
/* BYEAR % 4 == 1 and BYEAR % 400 == 1 for easy calculation of leap years */
/* assert(BYEAR <= SolarFirstDate.year) */
@@ -328,9 +326,9 @@ long Lunar2Day(d)
Date *d;
{
long offset = 0;
- int year, i, m, nYear, leapMonth;
+ int year, i, m, leapMonth;
- nYear = make_yday();
+ make_yday();
year = d->year - LunarFirstDate.year;
for (i=0; i<year; i++)
offset += yday[i];
@@ -357,7 +354,6 @@ Date *d;
void Day2Lunar(offset, d)
long offset;
Date *d;
-
{
int i, m, nYear, leapMonth;
|