[Chinese-commits] [lunar] 05/05: Imported Debian patch 2.2-4

Anthony Fok foka at debian.org
Sat Sep 19 19:35:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

foka pushed a commit to branch master
in repository lunar.

commit cf7a8c00806245a2536c6f5f61f0c0c3819feb5b
Author: Anthony Fok <foka at debian.org>
Date:   Wed Nov 20 02:07:41 2013 +0800

    Imported Debian patch 2.2-4
---
 Makefile                                           |   2 +-
 debian/changelog                                   |  36 +++
 debian/compat                                      |   2 +-
 debian/control                                     |   7 +-
 debian/copyright                                   |  86 +++---
 debian/patches/01_strip_trailing_whitespace.diff   | 192 +++++++++++++
 debian/patches/02_fix_compiler_warnings.diff       |  81 ++++++
 .../patches/03_add_full_path_to_lunar_bitmap.diff  |  24 ++
 debian/patches/04_add_big5_and_utf8_output.diff    | 299 +++++++++++++++++++++
 debian/patches/05_fix_output_on_year_2033.diff     |  37 +++
 debian/patches/06_use_locale_and_current_date.diff | 147 ++++++++++
 ...fix_segfault_aggressive-loop-optimizations.diff |  36 +++
 debian/patches/10_complete_the_makefile.diff       |  39 +++
 debian/patches/20_update_man_page.diff             | 182 +++++++++++++
 debian/patches/series                              |   9 +
 debian/rules                                       |  66 +----
 debian/source/format                               |   1 +
 debian/watch                                       |   5 +
 lunar.1                                            |  10 +-
 lunar.c                                            | 152 +----------
 tables.h                                           |   2 +-
 21 files changed, 1165 insertions(+), 250 deletions(-)

diff --git a/Makefile b/Makefile
index e4aecd4..6ced2e3 100644
--- a/Makefile
+++ b/Makefile
@@ -24,5 +24,5 @@ lunar:	lunar.o
 	cc -o lunar lunar.o
 
 clean:
-	rm *.o lunar
+	rm *.o
 
diff --git a/debian/changelog b/debian/changelog
index bc7a4ea..875c874 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,39 @@
+lunar (2.2-4) unstable; urgency=low
+
+  * Acknowledge NMU on 2.2-3.1.  Thanks to CHENG Yuk-Pong for noticing
+    the wrong output on year 2033 and providing an initial patch,
+    and to LI Daobing for providing a corrected patch and NMU.
+  * Use current locale and system time for display by default.
+    Most parameters thus become optional. Saves a lot of typing!  :-)
+  * lunar.bitmap contained a line that was too long, and with the new
+    aggressive loop optimizations in GCC 4.8, "lunar -b" would not stop
+    looping when parsing lunar.bitmap, and would eventually result in a
+    segmentation fault.  Fixed lunar.bitmap and lunar.c accordingly.
+  * Bump Standards-Version to 3.9.4
+  * Switch to dpkg-source 3.0 (quilt) format, and split up the patches
+    as follows:
+     - 01_strip_trailing_whitespace.diff
+     - 02_fix_compiler_warnings.diff
+     - 03_add_full_path_to_lunar_bitmap.diff
+     - 04_add_big5_and_utf8_output.diff
+     - 05_fix_output_on_year_2033.diff
+     - 06_use_locale_and_current_date.diff
+     - 07_fix_segfault_aggressive-loop-optimizations.diff
+     - 10_complete_the_makefile.diff
+     - 20_update_man_page.diff
+  * Convert debian/copyright to machine-readable format
+  * Move to dh9-style minimal rules file
+  * Remove explicit compilation target from Makefile
+    (Lintian: W: lunar: hardening-no-relro usr/bin/lunar)
+  * Add "Depends: ${misc:Depends}
+    (Lintian: W: lunar source: debhelper-but-no-misc-depends lunar)
+  * Update upstream URL to the archived copy found on http://web.archive.org/
+  * Add debian/watch (Lintian: I: lunar source: debian-watch-file-is-missing)
+  * Update man page to reflect the new options added to this Debian version
+    of Lunar.  Thanks to Jidanni for the suggestion!  (Closes: #514069)
+
+ -- Anthony Fok <foka at debian.org>  Wed, 20 Nov 2013 02:07:41 +0800
+
 lunar (2.2-3.1) unstable; urgency=low
 
   * Non-maintainer upload.
diff --git a/debian/compat b/debian/compat
index b8626c4..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-4
+9
diff --git a/debian/control b/debian/control
index 4300f0f..5b90cf4 100644
--- a/debian/control
+++ b/debian/control
@@ -2,12 +2,13 @@ Source: lunar
 Section: utils
 Priority: optional
 Maintainer: Anthony Fok <foka at debian.org>
-Build-Depends: debhelper (>> 3.0.0)
-Standards-Version: 3.6.2
+Build-Depends: debhelper (>> 9)
+Standards-Version: 3.9.4
+Homepage: http://web.archive.org/web/20051027042122/http://umunhum.stanford.edu/~lee/chicomp/chicomp.html
 
 Package: lunar
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: Chinese Lunar Calendar conversion utility
  The program performs date conversion between the Gregorian Solar Calendar
  (SC) and the Chinese Lunar Calendar (LC).  Given a date in either calendar,
diff --git a/debian/copyright b/debian/copyright
index 46a93dd..6df8162 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,35 +1,53 @@
-This package was debianized by Anthony Fok <foka at debian.org> on
-Sat, 21 Sep 2002 11:54:26 +0800.
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: Lunar
+Upstream-Contact: Fung F. Lee <lee at umunhum.stanford.edu>
+Source: http://web.archive.org/web/20051027042122/http://umunhum.stanford.edu/~lee/chicomp/chicomp.html
+
+Files: *
+Copyright: 1988,1989,1991,1992,2001 Fung F. Lee <lee at umunhum.stanford.edu>
+                                    and Ricky Yeung <cryeung at hotmail.com>
+License: GPL-2+
+
+Files: debian/*
+Copyright: 2002, 2006, 2013 Anthony Fok <foka at debian.org>
+License: GPL-2+
+
+Files: lunar.c lunar.1 Makefile
+Copyright: 1988,1989,1991,1992,2001 Fung F. Lee <lee at umunhum.stanford.edu>
+                                    and Ricky Yeung <cryeung at hotmail.com>
+           2002, 2006, 2013 Anthony Fok <foka at debian.org>
+License: GPL-2+
+
+Files: tables.h
+Copyright: 1988,1989,1991,1992,2001 Fung F. Lee <lee at umunhum.stanford.edu>
+                                    and Ricky Yeung <cryeung at hotmail.com>
+           1992 Hwei Chen Ti <chetihc at nus.edu.sg>
+License: GPL-2+
+
+Files: lunar.bitmap
+Copyright: 1991? Weimin Liu <weimin at alpha.ece.jhu.edu>
+License: GPL-2+
+
+License: GPL-2+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or any
+ later version.
+ .
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ .
+ The last version of this program was released on July 23, 1992 as
+ version 2.1a.  This program was first released under the terms of GNU
+ GPL on October 28, 2001 as version 2.2.  Both versions are identical
+ except for the license text.
+ .
+ The complete text of the GNU General Public License can be found
+ in "/usr/share/common-licenses/GPL" on your Debian system.
 
-It was downloaded from
-    http://umunhum.stanford.edu/~lee/chicomp/lunar-2.2.tar.gz
-
-Upstream Authors:
-    Fung F. Lee <lee at umunhum.stanford.edu> and
-    Ricky Yeung <cryeung at hotmail.com>
-
-Copyright:
-
-    Copyright (C) 1988, 1989, 1991, 1992, 2001 Fung F. Lee and Ricky Yeung
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or any
-    later version.
-
-    This program is distributed in the hope that it will be useful, but
-    WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
-
-    The last version of this program was released on July 23, 1992 as
-    version 2.1a.  This program was first released under the terms of GNU
-    GPL on October 28, 2001 as version 2.2.  Both versions are identical
-    except for the license text.
-
-The complete text of the GNU General Public License can be found
-in `/usr/share/common-licenses/GPL' on your Debian system.
diff --git a/debian/patches/01_strip_trailing_whitespace.diff b/debian/patches/01_strip_trailing_whitespace.diff
new file mode 100644
index 0000000..6b49c28
--- /dev/null
+++ b/debian/patches/01_strip_trailing_whitespace.diff
@@ -0,0 +1,192 @@
+Description: Strip trailing whitespace from lunar.c
+ First applied in 2.2-4.
+Author: Anthony Fok <foka at debian.org>
+Origin: vendor
+Last-Update: 2013-10-04
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lunar.c
++++ b/lunar.c
+@@ -12,25 +12,25 @@ char version[] = "Lunar Version 2.2 (Oct
+ 
+ # Copyright (C) 1988,1989,1991,1992,2001 Fung F. Lee and Ricky Yeung
+ #
+-# 
++#
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License
+ # as published by the Free Software Foundation; either version 2
+ # of the License, or any later version.
+-# 
++#
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+-# 
++#
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software Foundation,
+ # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+-# 
++#
+ #
+ # Revision History:
+ # The last version of this program was released on July 23, 1992 as
+-# version 2.1a.  This program was first released under the terms of 
++# version 2.1a.  This program was first released under the terms of
+ # GNU GPL on October 28, 2001 as version 2.2. Both versions are identical
+ # except for the license text.
+ #
+@@ -38,19 +38,19 @@ char version[] = "Lunar Version 2.2 (Oct
+ # Please send your comments and suggestions to the authors:
+ # Fung F. Lee	lee at umunhum.stanford.edu
+ # Ricky Yeung	cryeung at hotmail.com
+-#	
++#
+ # The special "bitmap" file "lunar.bitmap" was contributed
+ # by Weimin Liu (weimin at alpha.ece.jhu.edu).
+ #
+ # Special thanks to Hwei Chen Ti (chetihc at nuscc.nus.sg or
+-# chetihc at nusvm.bitnet) who extended the tables from 2001 to 2049. 
++# chetihc at nusvm.bitnet) who extended the tables from 2001 to 2049.
+ #
+ ----------------------------------------------------------------------------*/
+ 
+ /*
+ This document contains Highest-bit-set GuoBiao (HGB) code, as adopted by
+ CCDOS on IBM PC compatibles, ChineseTalk 6.0 (GB version) on Macintosh,
+-and cxterm on UNIX and X window.  Hence, one may need to transfer this 
++and cxterm on UNIX and X window.  Hence, one may need to transfer this
+ document as a **binary** file.
+ 
+ References:
+@@ -60,7 +60,7 @@ References:
+    �����������ƽ���ԡ�����
+ 3. Da1zhong4 wan4nian2li4.
+    ��������������
+-*/ 
++*/
+ 
+ 

+ #include <stdio.h>
+@@ -162,7 +162,7 @@ char *argv[];
+ {
+     int year, month, day, hour, i, k, option, inverse=0, leap=0;
+     int dateInfo[4];
+-    
++
+     progname = "lunar";
+     printf("%s\n\n", version);
+ 
+@@ -223,7 +223,7 @@ char *argv[];
+     Report();
+     exit(0);
+ }
+- 
++
+ void usage()
+ {
+     printf("Usage:\n\n");
+@@ -249,7 +249,7 @@ void Solar2Lunar()
+ 
+     offset = Solar2Day(&solar);
+     solar.weekday = (offset + SolarFirstDate.weekday) % 7;
+-    
++
+     /* A lunar day begins at 11 p.m. */
+     if (solar.hour == 23)
+ 	offset++;
+@@ -343,7 +343,7 @@ Date *d;
+     }
+     for (m=1; m<d->month; m++)
+ 	offset += mday[m];
+-    if (leapMonth && 
++    if (leapMonth &&
+ 	((d->month>leapMonth) || (d->leap && (d->month==leapMonth))))
+ 	offset += mday[m++];
+     offset += d->day - 1;
+@@ -360,7 +360,7 @@ Date *d;
+ 
+ {
+     int i, m, nYear, leapMonth;
+-    
++
+     nYear = make_yday();
+     for (i=0; i<nYear && offset > 0; i++)
+ 	offset -= yday[i];
+@@ -403,7 +403,7 @@ Date *d;
+     /* offset is now the number of days from SolarFirstDate.year.1.1 */
+ 
+     for (i=SolarFirstDate.year;
+-         (i<SolarFirstDate.year+Nyear) && (offset > 0);	 i++) 
++         (i<SolarFirstDate.year+Nyear) && (offset > 0);	 i++)
+ 	offset -= 365 + LeapYear(i);
+     if (offset<0)
+     {
+@@ -412,7 +412,7 @@ Date *d;
+     }
+     if (i==(SolarFirstDate.year + Nyear)) Error("Year out of range.");
+     d->year = i;
+-    
++
+     /* assert(offset<(365+LeapYear(i))); */
+     for (m=1; m<=12; m++)
+     {
+@@ -439,14 +439,14 @@ int g, z;
+     if (gz >= 60) printf("internal error\n");
+     return gz+1;
+ }
+-	     
++
+ 
+ void CalGZ(offset, d, g, z)
+ long offset;
+ Date *d, *g, *z;
+ {
+     int	year, month;
+-        
++
+     year = d->year - LunarFirstDate.year;
+     month = year * 12 + d->month - 1;   /* leap months do not count */
+ 
+@@ -520,7 +520,7 @@ int make_yday()
+ {
+     int year, i, leap;
+     long code;
+-    
++
+     for (year = 0; year < Nyear; year++)
+     {
+ 	code = yearInfo[year];
+@@ -550,7 +550,7 @@ int year;
+ {
+     int i, leapMonth;
+     long code;
+-    
++
+     code = yearInfo[year];
+     leapMonth = code & 0xf;
+     /* leapMonth == 0 means no leap month */
+@@ -566,7 +566,7 @@ int year;
+     }
+     else
+     {
+-	/* 
++	/*
+ 	  There is a leap month (run4 yue4) L in this year.
+ 	  mday[1] contains the number of days in the 1-st month;
+ 	  mday[L] contains the number of days in the L-th month;
+@@ -604,10 +604,10 @@ void ReportGB()
+     printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "��������",
+ 	   solar.year, "��", solar.month, "��", solar.day,
+ 	   "��", solar.hour, "ʱ��",
+-	   "����", weekdayGB[solar.weekday]); 
++	   "����", weekdayGB[solar.weekday]);
+     printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "��������",
+ 	   lunar.year, "��", (lunar.leap? "��":""),
+-	   lunar.month, "��", lunar.day, "��", 
++	   lunar.month, "��", lunar.day, "��",
+ 	   ZhiGB[zhi.hour], "ʱ��",
+ 	   "����", ShengXiaoGB[zhi.year]);
+     printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "��֧����",
diff --git a/debian/patches/02_fix_compiler_warnings.diff b/debian/patches/02_fix_compiler_warnings.diff
new file mode 100644
index 0000000..6b0b59a
--- /dev/null
+++ b/debian/patches/02_fix_compiler_warnings.diff
@@ -0,0 +1,81 @@
+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.
+Author: Anthony Fok <foka at debian.org>
+Origin: vendor
+Last-Update: 2013-10-04
+---
+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,8 @@ long Lunar2Day(d)
+ Date *d;
+ {
+     long offset = 0;
+-    int year, i, m, nYear, leapMonth;
++    int year, i, m, leapMonth;
+ 
+-    nYear = 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;
+ 
diff --git a/debian/patches/03_add_full_path_to_lunar_bitmap.diff b/debian/patches/03_add_full_path_to_lunar_bitmap.diff
new file mode 100644
index 0000000..ac6339a
--- /dev/null
+++ b/debian/patches/03_add_full_path_to_lunar_bitmap.diff
@@ -0,0 +1,24 @@
+Description: Add full path of lunar.bitmap to lunar.c
+ Prepend "/usr/share/lunar/" to "lunar.bitmap" to make "lunar -b"
+ actually works.  Thanks to Jeronimo Pellegrini for finding the bug
+ and submitted a bug report, with patch, to Debian on 2002-09-27.
+ .
+ First applied in 2.2-2.
+Author: Jeronimo Pellegrini <pellegrini at mpcnet.com.br>
+Origin: other, http://bugs.debian.org/162634
+Bug-Debian: http://bugs.debian.org/162634
+Reviewed-by: Anthony Fok <foka at debian.org>
+Last-Update: 2013-10-04
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lunar.c
++++ b/lunar.c
+@@ -142,7 +142,7 @@ int jieAlert;		/* if there is uncertaint
+ 
+ int	showHZ = 0;			/* output in hanzi */
+ int	showBM = 0;			/* output in bitmap */
+-char	BMfile[] = "lunar.bitmap";	/* bit map file */
++char	BMfile[] = "/usr/share/lunar/lunar.bitmap";	/* bit map file */
+ char	GZBM[NBM][BMRow][BMCol];	/* the bitmap array */
+ char	*progname;
+ 
diff --git a/debian/patches/04_add_big5_and_utf8_output.diff b/debian/patches/04_add_big5_and_utf8_output.diff
new file mode 100644
index 0000000..56da989
--- /dev/null
+++ b/debian/patches/04_add_big5_and_utf8_output.diff
@@ -0,0 +1,299 @@
+Description: Add Big5 and UTF-8 output options for lunar.c
+ Big5 support was added to 2.2-1 in 2002.
+ .
+ UTF-8 support was added to 2.2-3 at the request of LI Daobing in 2006,
+ see Debian Bug#288170.  However, it could only print simplified Chinese
+ in UTF-8 mode back then.
+ .
+ In 2013, two new options, -s and -t, were added to 2.2-4 so that the
+ end-user may choose either simplified or traditional Chinese in UTF-8 mode.
+Author: Anthony Fok <foka at debian.org>
+Origin: vendor
+Bug-Debian: http://bugs.debian.org/288170
+Last-Update: 2013-10-04
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lunar.c
++++ b/lunar.c
+@@ -112,6 +112,31 @@ static char *weekday[] = {
+     "Thursday", "Friday", "Saturday"
+ };
+ 
++static	char	*GanUTF8[] = {
++    "甲", "乙", "丙", "丁", "戊",
++    "己", "庚", "辛", "壬", "癸"
++};
++
++static	char	*ZhiUTF8[] = {
++    "子", "丑", "寅", "卯", "辰", "巳",
++    "午", "未", "申", "酉", "戌", "亥"
++};
++
++static	char   *ShengXiaoUTF8_hant[] = {
++    "鼠", "牛", "虎", "兔", "龍", "蛇",
++    "馬", "羊", "猴", "雞", "狗", "豬"
++};
++
++static	char   *ShengXiaoUTF8_hans[] = {
++    "鼠", "牛", "虎", "兔", "龙", "蛇",
++    "马", "羊", "猴", "鸡", "狗", "猪"
++};
++
++static char *weekdayUTF8[] = {
++    "日", "一", "二", "三",
++    "四", "五", "六"
++};
++
+ static	char	*GanGB[] = {
+     "��", "��", "��", "��", "��",
+     "��", "��", "��", "��", "��"
+@@ -132,6 +157,26 @@ static char *weekdayGB[] = {
+     "��", "��", "��"
+ };
+ 
++static	char	*GanB5[] = {
++    "��", "�A", "��", "�B", "��",
++    "�v", "��", "��", "��", "��"
++};
++
++static	char	*ZhiB5[] = {
++    "�l", "��", "�G", "�f", "��", "�x",
++    "��", "��", "��", "��", "��", "��"
++};
++
++static	char   *ShengXiaoB5[] = {
++    "��", "��", "��", "��", "�s", "�D",
++    "��", "��", "�U", "��", "��", "��"
++};
++
++static char *weekdayB5[] = {
++    "��", "�@", "�G", "�T",
++    "�|", "��", "��"
++};
++
+ 
+ Date solar, lunar, gan, zhi, gan2, zhi2, lunar2;
+ 
+@@ -140,8 +185,11 @@ int yday[Nyear];	/* number of lunar days
+ int mday[Nmonth+1];	/* number of days in the months of the lunar year */
+ int jieAlert;		/* if there is uncertainty in JieQi calculation */
+ 
+-int	showHZ = 0;			/* output in hanzi */
++int	showHZ_GB = 0;			/* output in GB-encoded hanzi */
+ int	showBM = 0;			/* output in bitmap */
++int	showHZ_UTF8 = 0;		/* output in UTF-8-encoded hanzi */
++int	showHZ_B5 = 0;			/* output in Big5-encoded hanzi */
++int	simplified = 0;			/* output in simplified Chinese */
+ char	BMfile[] = "/usr/share/lunar/lunar.bitmap";	/* bit map file */
+ char	GZBM[NBM][BMRow][BMCol];	/* the bitmap array */
+ char	*progname;
+@@ -153,7 +201,8 @@ int     make_yday(), make_mday(), GZcycl
+ void	CalGZ();
+ int	CmpDate(), JieDate();
+ void    readBM(), display3();
+-void	Report(), ReportE(), ReportBM(), ReportGB();
++void	Report(), ReportE(), ReportBM(), ReportGB(), ReportB5();
++void	ReportUTF8_hant(), ReportUTF8_hans();
+ void	usage(), Error();
+ 
+ 
+@@ -174,8 +223,45 @@ char *argv[];
+ 	{
+ 	    case 'i': inverse = 1; break;
+ 	    case 'l': if (inverse) leap=1; else usage(); break;
+-	    case 'h': showHZ = 1; break;
+-	    case 'b': showBM = 1; break;
++	    case 'g':
++	    case 'h': showHZ_GB = 1;
++		      showHZ_UTF8 = showHZ_B5 = 0;
++		      break;
++	    case 'b': showBM = 1;
++		      showHZ_UTF8 = showHZ_GB = showHZ_B5 = 0;
++		      break;
++	    case 'u': showHZ_UTF8 = 1;
++		      showHZ_B5 = showHZ_GB = 0;
++		      break;
++	    case '5': showHZ_B5 = 1;
++		      showHZ_UTF8 = showHZ_GB = 0;
++		      break;
++	    case 's': simplified = 1; break;
++	    case 't': simplified = 0; break;
++	    case '-':
++		if (!strcmp(argv[k], "--utf8"))
++		{
++		    showHZ_UTF8 = 1;
++		    showHZ_B5 = 0;
++		    showHZ_GB = 0;
++		}
++		else if (!strcmp(argv[k], "--big5"))
++		{
++		    showHZ_B5 = 1;
++		    showHZ_UTF8 = 0;
++		    showHZ_GB = 0;
++		}
++		else if (!strcmp(argv[k], "--gb"))
++		{
++		    showHZ_GB = 1;
++		    showHZ_UTF8 = 0;
++		    showHZ_B5 = 0;
++		}
++		else if (!strcmp(argv[k], "--help"))
++		    usage();
++		else
++		    usage();
++		break;
+ 	    default:  usage(); break;
+ 	}
+     }
+@@ -230,12 +316,16 @@ void usage()
+     printf("Usage:\n\n");
+     printf("Solar->Lunar:\t%s [-h] [-b] year month day [hour]\n", progname);
+     printf("\t\t(in Solar Calendar, 24 hour clock)\n\n");
+-    printf("Lunar->Solar:\t%s [-h] [-b] -i [-l] year month day [hour]\n",
++    printf("Lunar->Solar:\t%s [-u] [-h] [-b] -i [-l] year month day [hour]\n",
+ 	   progname);
+     printf("\t\t(in Lunar Calendar, 24 hour clock)\n");
+-    printf("\t\t-l means the month is a leap month (\"run4 yue4\")\n\n");
+-    printf("\t\t-h means output in hanzi (GB)\n");
+-    printf("\t\t-b means output in \"bitmap\"\n\n");
++    printf("\t\t-l  means the month is a leap month (\"run4 yue4\")\n\n");
++    printf("\t\t-u, --utf8  means output in hanzi (UTF-8)\n");
++    printf("\t\t        -s  selects simplified Chinese for UTF-8\n");
++    printf("\t\t        -t  selects traditional Chinese for UTF-8\n");
++    printf("\t\t-h, --gb    means output in hanzi (GB)\n");
++    printf("\t\t-5, --big5  means output in hanzi (Big5)\n\n");
++    printf("\t\t-b          means output in \"bitmap\"\n");
+     printf("Date range: about %d years from the Solar Date %d.%d.%d\n", Nyear,
+ 	   SolarFirstDate.year, SolarFirstDate.month, SolarFirstDate.day);
+     exit(1);
+@@ -586,7 +676,16 @@ int year;
+ 
+ void Report()
+ {
+-    if (showHZ)
++    if (showHZ_UTF8)
++    {
++	if (simplified)
++	    ReportUTF8_hans();
++	else
++	    ReportUTF8_hant();
++    }
++    else if (showHZ_B5)
++	ReportB5();
++    else if (showHZ_GB)
+ 	ReportGB();
+     else if (showBM)
+ 	ReportBM();
+@@ -595,6 +694,72 @@ void Report()
+ }
+ 
+ 
++void ReportUTF8_hant()
++{
++    printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "陽曆: ",
++	   solar.year, "年", solar.month, "月", solar.day,
++	   "日", solar.hour, "時 ",
++	   "星期", weekdayUTF8[solar.weekday]);
++    printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "陰曆: ",
++	   lunar.year, "年", (lunar.leap? "閏":""),
++	   lunar.month, "月", lunar.day, "日",
++	   ZhiUTF8[zhi.hour], "時 ",
++	   "生肖屬", ShengXiaoUTF8_hant[zhi.year]);
++    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "干支: ",
++	   GanUTF8[gan.year], ZhiUTF8[zhi.year], "年 ",
++	   GanUTF8[gan.month], ZhiUTF8[zhi.month], "月 ",
++	   GanUTF8[gan.day], ZhiUTF8[zhi.day], "日 ",
++	   GanUTF8[gan.hour], ZhiUTF8[zhi.hour], "時 ");
++    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
++	   "用四柱神算推算之時辰八字: ",
++	   GanUTF8[gan2.year], ZhiUTF8[zhi2.year], "年 ",
++	   GanUTF8[gan2.month], ZhiUTF8[zhi2.month], "月 ",
++	   GanUTF8[gan2.day], ZhiUTF8[zhi2.day], "日 ",
++	   GanUTF8[gan2.hour], ZhiUTF8[zhi2.hour], "時 ");
++    if (jieAlert)
++    {
++	printf("* %s, %s\n", "是日為節",
++	       "月柱可能要修改");
++	if (lunar2.month==1)
++	    printf("* %s\n", "年柱亦可能要修改");
++	printf("* %s\n", "請查有節氣時間之萬年曆");
++    }
++}
++
++
++void ReportUTF8_hans()
++{
++    printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "阳历: ",
++	   solar.year, "年", solar.month, "月", solar.day,
++	   "日", solar.hour, "时 ",
++	   "星期", weekdayUTF8[solar.weekday]);
++    printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "阴历: ",
++	   lunar.year, "年", (lunar.leap? "闰":""),
++	   lunar.month, "月", lunar.day, "日",
++	   ZhiUTF8[zhi.hour], "时 ",
++	   "生肖属", ShengXiaoUTF8_hans[zhi.year]);
++    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "干支: ",
++	   GanUTF8[gan.year], ZhiUTF8[zhi.year], "年 ",
++	   GanUTF8[gan.month], ZhiUTF8[zhi.month], "月 ",
++	   GanUTF8[gan.day], ZhiUTF8[zhi.day], "日 ",
++	   GanUTF8[gan.hour], ZhiUTF8[zhi.hour], "时 ");
++    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
++	   "用四柱神算推算之时辰八字: ",
++	   GanUTF8[gan2.year], ZhiUTF8[zhi2.year], "年 ",
++	   GanUTF8[gan2.month], ZhiUTF8[zhi2.month], "月 ",
++	   GanUTF8[gan2.day], ZhiUTF8[zhi2.day], "日 ",
++	   GanUTF8[gan2.hour], ZhiUTF8[zhi2.hour], "时 ");
++    if (jieAlert)
++    {
++	printf("* %s, %s\n", "是日为节",
++	       "月柱可能要修改");
++	if (lunar2.month==1)
++	    printf("* %s\n", "年柱亦可能要修改");
++	printf("* %s\n", "请查有节气时间之万年历");
++    }
++}
++
++
+ void ReportGB()
+ {
+     printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "��������",
+@@ -627,6 +792,39 @@ void ReportGB()
+     }
+ }
+ 
++
++void ReportB5()
++{
++    printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "����G�@",
++	   solar.year, "�~", solar.month, "��", solar.day,
++	   "��", solar.hour, "�ɡ@",
++	   "�P��", weekdayB5[solar.weekday]);
++    printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "����G�@",
++	   lunar.year, "�~", (lunar.leap? "�|":""),
++	   lunar.month, "��", lunar.day, "��",
++	   ZhiB5[zhi.hour], "�ɡ@",
++	   "�ͨv��", ShengXiaoB5[zhi.year]);
++    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "�z��G�@",
++	   GanB5[gan.year], ZhiB5[zhi.year], "�~�@",
++	   GanB5[gan.month], ZhiB5[zhi.month], "��@",
++	   GanB5[gan.day], ZhiB5[zhi.day], "��@",
++	   GanB5[gan.hour], ZhiB5[zhi.hour], "�ɡ@");
++    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
++	   "�Υ|�W������⤧�ɨ��K�r�G�@",
++	   GanB5[gan2.year], ZhiB5[zhi2.year], "�~�@",
++	   GanB5[gan2.month], ZhiB5[zhi2.month], "��@",
++	   GanB5[gan2.day], ZhiB5[zhi2.day], "��@",
++	   GanB5[gan2.hour], ZhiB5[zhi2.hour], "�ɡ@");
++    if (jieAlert)
++    {
++	printf("* %s, %s\n", "�O�鬰�`",
++	       "��W�i��n�ק�");
++	if (lunar2.month==1)
++	    printf("* %s\n", "�~�W��i��n�ק�");
++	printf("* %s\n", "�Ьd���`��ɶ����U�~��");
++    }
++}
++
+ 
+ void ReportE()
+ {
diff --git a/debian/patches/05_fix_output_on_year_2033.diff b/debian/patches/05_fix_output_on_year_2033.diff
new file mode 100644
index 0000000..327ba36
--- /dev/null
+++ b/debian/patches/05_fix_output_on_year_2033.diff
@@ -0,0 +1,37 @@
+Description: Fix lunar-2.2 output on year 2033
+ On 2006-05-26, CHENG Yuk-Pong reported:
+ .
+   I have found a bug in the lunar-2.2, on the leap months in year 2033.
+   The year 2033 is a special case in modern Chinese Lunar Calendar,
+   as the 冬至 must be on 11th month.
+ .
+ and provided a patch on the Debian BTS.
+ .
+ LI Daobing reviewed the patch in October 2008, and noted:
+ .
+   the patch provided by bug reporter still have a bug, the 10th month of
+   2003 in chinese calendar should have 30 days (a big month). so the
+   correct value should be 0x04afb.
+ .
+ Daobing then corrected the patch, prepared a NMU of lunar-2.2-3.1,
+ which was uploaded by Alexander Reichle-Schmehl on 2008-10-08.
+Author: CHENG Yuk-Pong <scim at sdiz.net>
+Author: LI Daobing <lidaobing at gmail.com>
+Origin: vendor, http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=12;filename=lunar-2.2-3.1-nmu.diff;att=1;bug=366918
+Bug-Debian: http://bugs.debian.org/366918
+Reviewed-By: LI Daobing <lidaobing at gmail.com>
+Reviewed-By: Alexander Reichle-Schmehl <tolimar at debian.org>
+Last-Update: 2013-10-03
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/tables.h
++++ b/tables.h
+@@ -86,7 +86,7 @@ static long yearInfo[Nyear] = {
+     0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954,	/* 2020 */
+     0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6,	/* 2025 */
+     0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, 0x05aa0,	/* 2030 */
+-    0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0,	/* 2035 */
++    0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0,	/* 2035 */
+     0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0,	/* 2040 */
+     0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0,	/* 2045 */
+     0x0aa50, 0x1b255, 0x06d20, 0x0ada0			/* 2049 */
diff --git a/debian/patches/06_use_locale_and_current_date.diff b/debian/patches/06_use_locale_and_current_date.diff
new file mode 100644
index 0000000..d43a507
--- /dev/null
+++ b/debian/patches/06_use_locale_and_current_date.diff
@@ -0,0 +1,147 @@
+Description: Use current locale and system time for display by default
+ I was getting too lazy to type out the long string of parameters
+ to manually set the output character set and the full date every time
+ I wanted to check the current date in Lunar calendar, hence this patch.
+ It was also a good little exercise to brush up my C programming skill.  :-)
+ .
+ First applied in 2.2-4.
+Author: Anthony Fok <foka at debian.org>
+Origin: vendor
+Last-Update: 2013-11-15
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lunar.c
++++ b/lunar.c
+@@ -1,6 +1,6 @@
+ /* $Id: lunar.c,v 1.6 2001/10/29 05:55:39 fflee Exp $ */
+ 
+-char version[] = "Lunar Version 2.2 (October 28, 2001)";
++char version[] = "Lunar Version 2.2-4 (Debian) (October 4, 2013)";
+ 
+ /*----------------------------------------------------------------------------
+ 
+@@ -66,6 +66,7 @@ References:
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <time.h>
+ 
+ /* "Bitmap" constants */
+ #define	BMRow	7	/* number of rows for each bitmap */
+@@ -212,10 +213,56 @@ char *argv[];
+ {
+     int year, month, day, hour, i, k, option, inverse=0, leap=0;
+     int dateInfo[4];
++    time_t cur_time;
++    struct tm *now;
++    char *locale, *s;
++    char *language, *territory, *codeset;
+ 
+     progname = "lunar";
+     printf("%s\n\n", version);
+ 
++    locale = getenv("LC_ALL");
++    if (locale == NULL)
++	locale = getenv("LANG");
++    if (locale)
++    {
++	/* Form: language[_territory][.codeset][@modifier] */
++	s = strdup(locale);
++	language = strsep(&s, "_.@");
++	s = strdup(locale);
++	strsep(&s, "_");
++	territory = strsep(&s, "_.@");
++	s = strdup(locale);
++	strsep(&s, ".");
++	codeset = strsep(&s, ".@");
++#if 0
++	s = strdup(locale);
++	strsep(&s, "@");
++	char *modifier = strsep(&s, "@");
++
++	printf("%s_%s.%s@%s\n", language, territory, codeset, modifier);
++#endif
++	if (codeset)
++	{
++	    if (!strcasecmp(codeset, "UTF-8") || !strcasecmp(codeset, "utf8"))
++	    {
++		if (!strcmp(language, "zh") ||
++		    !strcmp(language, "ja") ||
++		    !strcmp(language, "ko"))
++		    showHZ_UTF8 = 1;
++		if (territory &&
++		    (!strcmp(territory, "CN") || !strcmp(territory, "SG")))
++		    simplified = 1;
++	    }
++	    else if (!strcasecmp(codeset, "GB2312") ||
++		     !strcasecmp(codeset, "GBK") ||
++		     !strcasecmp(codeset, "GB18030"))
++		showHZ_GB = 1;
++	    else if (!strncasecmp(codeset, "Big5", 4))
++		showHZ_B5 = 1;
++	}
++    }
++
+     for (k=1; k<argc && argv[k][0]=='-'; k++)
+     {
+ 	option = argv[k][1];
+@@ -265,18 +312,42 @@ char *argv[];
+ 	    default:  usage(); break;
+ 	}
+     }
++
+     if (showBM) readBM();
+-    if (!((argc - k >= 3) && (argc - k <= 4))) usage();
+-    dateInfo[3] = 0;
+-    for (i=0; k<argc && i<4; k++, i++)
++
++    switch(argc - k)
+     {
+-	if (sscanf(argv[k], "%d", &dateInfo[i]) != 1)
++	case 0:
++	    if (inverse)
++		usage();
++	    else
++	    {
++		setenv("TZ", "UTC-8", 1);
++		cur_time = time(NULL);
++		now = localtime(&cur_time);
++		year  = now->tm_year + 1900;
++		month = now->tm_mon + 1;
++		day   = now->tm_mday;
++		hour  = now->tm_hour;
++	    }
++	    break;
++	case 3:
++	case 4:
++	    dateInfo[3] = 0;
++	    for (i=0; k<argc && i<4; k++, i++)
++	    {
++		if (sscanf(argv[k], "%d", &dateInfo[i]) != 1)
++		    usage();
++	    }
++	    year  = dateInfo[0];
++	    month = dateInfo[1];
++	    day   = dateInfo[2];
++	    hour  = dateInfo[3];
++	    break;
++	default:
+ 	    usage();
+     }
+-    year = dateInfo[0];
+-    month = dateInfo[1];
+-    day = dateInfo[2];
+-    hour = dateInfo[3];
++
+     if (!(year>=Cyear && year<Cyear+Nyear))
+ 	Error("Year out of range.");
+     if (!(month>=1 && month<=12))
+@@ -314,7 +385,7 @@ char *argv[];
+ void usage()
+ {
+     printf("Usage:\n\n");
+-    printf("Solar->Lunar:\t%s [-h] [-b] year month day [hour]\n", progname);
++    printf("Solar->Lunar:\t%s [-u] [-h] [-b] [year month day [hour]]\n", progname);
+     printf("\t\t(in Solar Calendar, 24 hour clock)\n\n");
+     printf("Lunar->Solar:\t%s [-u] [-h] [-b] -i [-l] year month day [hour]\n",
+ 	   progname);
diff --git a/debian/patches/07_fix_segfault_aggressive-loop-optimizations.diff b/debian/patches/07_fix_segfault_aggressive-loop-optimizations.diff
new file mode 100644
index 0000000..3c8c81e
--- /dev/null
+++ b/debian/patches/07_fix_segfault_aggressive-loop-optimizations.diff
@@ -0,0 +1,36 @@
+Description: Fix "lunar -b" segfault when compiled with -O2 in gcc-4.8
+ lunar.bitmap contained a line that was too long with extraneous
+ trailing spaces, causing an overflow the array in readBM(), but did not
+ ause any visible error previously.
+ .
+ When compiled with GCC 4.8, however, this bug results in segmentation fault,
+ probably due to the new aggressive loop optimizations used in -O2 and -O3.
+ .
+ See http://blog.regehr.org/archives/918 for a different but related issue.
+Origin: vendor
+Author: Anthony Fok <foka at debian.org>
+Last-Update: 2013-11-20
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lunar.bitmap
++++ b/lunar.bitmap
+@@ -21,7 +21,7 @@ _|___|____
+   |_____|
+        |
+ |-|  --|--
+-|_| ---`---     
++|_| ---`---
+ | | ____|__
+ |-|  \  |
+         |
+--- a/lunar.c
++++ b/lunar.c
+@@ -978,7 +978,7 @@ void readBM()
+ 	  {
+ 	      c = getc(fp);
+ 	      if ((c==EOF) || (c=='\n')) break;
+-	      GZBM[i][j][k++] = c;
++	      if (k<BMCol) GZBM[i][j][k++] = c;
+ 	  }
+ 	  for (m=k; m<BMCol; m++) GZBM[i][j][m] = ' ';
+       }
diff --git a/debian/patches/10_complete_the_makefile.diff b/debian/patches/10_complete_the_makefile.diff
new file mode 100644
index 0000000..12c5fa1
--- /dev/null
+++ b/debian/patches/10_complete_the_makefile.diff
@@ -0,0 +1,39 @@
+Description: Complete the Makefile so debian/rules can truly be minimal
+ The special provisions in previous debian/rules are now moved into
+ the upstream Makefile.
+ .
+ Also, the explicit compilation rules in Makefile are removed
+ so that compiler flags set by dpkg-buildflags may get through.
+Origin: vendor
+Author: Anthony Fok <foka at debian.org>
+Last-Update: 2013-10-04
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/Makefile
++++ b/Makefile
+@@ -20,9 +20,22 @@
+ 
+ # CFLAGS= -O
+ 
+-lunar:	lunar.o
+-	cc -o lunar lunar.o
++all: lunar
+ 
+ clean:
+-	rm *.o
++	rm -f *.o lunar
+ 
++PREFIX = /usr
++BINDIR  = $(PREFIX)/bin
++DATADIR = $(PREFIX)/share
++MANDIR  = $(PREFIX)/share/man
++
++install: lunar lunar.1
++	install -m755 -d $(DESTDIR)$(BINDIR)
++	install -m755 -p lunar $(DESTDIR)$(BINDIR)/
++	install -m755 -d $(DESTDIR)$(DATADIR)/lunar
++	install -m644 -p lunar.bitmap $(DESTDIR)$(DATADIR)/lunar/
++	install -m755 -d $(DESTDIR)$(MANDIR)/man1
++	install -m644 -p lunar.1 $(DESTDIR)$(MANDIR)/man1/
++
++.PHONY: install clean
diff --git a/debian/patches/20_update_man_page.diff b/debian/patches/20_update_man_page.diff
new file mode 100644
index 0000000..c9d1384
--- /dev/null
+++ b/debian/patches/20_update_man_page.diff
@@ -0,0 +1,182 @@
+Description: Update lunar.1 man page with added options
+ Jidanni reported in 2009:
+ .
+   There are options, e.g., --utf8, on --help that are not documented on
+   the man page. Indeed, also mention --help itself.
+ .
+ In October 2013, I finally worked on the man page to document the new
+ options and changes as found in the Debian version of lunar 2.2-4.
+Origin: vendor
+Author: Anthony Fok <foka at debian.org>
+Bug-Debian: http://bugs.debian.org/514069
+Last-Update: 2013-10-04
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/lunar.1
++++ b/lunar.1
+@@ -1,29 +1,41 @@
+-.TH lunar 1 "28 October 2001"
++.TH LUNAR 1 "4 October 2013" "Lunar version 2.2-4 (Debian)"
++.
+ .SH NAME
+-lunar (version 2.2) \- a calendar conversion utility
+-.SH SYNTAX
+-.B lunar
+-[
+-.B\-h
+-] [
+-.B\-b
+-] [
+-.B\-i
+-] [
+-.B\-l
+-]
+-.I year month day
+-[
+-.I hour
+-]
++lunar \- a calendar conversion utility
++.
++.SH SYNOPSIS
++.
++.SY lunar
++.OP \-usthg5b
++.
++.SY lunar
++.OP \-usthg5b
++.I year
++.I month
++.I day
++.RI [ hour ]
++.
++.SY lunar
++.OP \-usthg5b
++.B \-i
++.OP \-l
++.I year
++.I month
++.I day
++.RI [ hour ]
++.
++.SY lunar
++.B \-\-help
++.YS
++.
+ .SH DESCRIPTION
+ The
+-.PN lunar
++.I lunar
+ program performs date conversion between the Gregorian Solar Calendar (SC)
+ and the Chinese Lunar Calendar (LC).
+ Given a date in either calendar, the program also
+-outputs the corresponding "shengxiao" (animal of the year)
+-and "ganzhi" characters.
++outputs the corresponding "\fIsheng\%xiao\fR" (animal of the year)
++and "\fIganzhi\fR" characters.
+ The date range currently covered is from about 1900 A.D. to 2049 A.D.
+ .PP
+ For the sake of convenience, we choose the convention such that the solar 
+@@ -39,7 +51,7 @@ and SC 1991.2.16.1 is LC 1991.1.2.1.
+ The standard time of the Lunar Calendar is
+ Beijing (Hong Kong) Standard Time, not GMT.
+ Be sure to adjust appropriately for other time zones
+-and "Day-light Saving Time".
++and "Daylight Saving Time".
+ .PP
+ In the Lunar Calendar,
+ a normal year has 12 months, and a leap year (run-nian) has 13 months,
+@@ -49,23 +61,63 @@ is called the 6-th leap month.
+ A (leap) month is either a short or long one, which has 29 or 30 days
+ respectively.
+ .PP
+-There are 10 gan's and 12 zhi's.
+-The ganzhi labeling of the year, month, day and hour of a date
++There are 10 \fIgan\fR's and 12 \fIzhi\fR's.
++The \fIganzhi\fR labeling of the year, month, day and hour of a date
+ is a member of the Cartesian product GxGxGxG, where G = {1,2,...,60}.
+-For example, "jia-zi" is 1, "yi-chou" is 2, and so on.
+-The ganzhi of the j-th leap month is the same as that of the j-th month.
+-
++For example, "\fIjia-zi\fR" is 1, "\fIyi-chou\fR" is 2, and so on.
++The \fIganzhi\fR of the j-th leap month is the same as that of the j-th month.
++.
++.SH OPTIONS
++.P
++Since
++.I lunar
++was first packaged for Debian in 2002, the Debian package maintainer
++has made minor additions such as Big5 and UTF-8 support.
++More recently,
++.I lunar
++gained the ability to detect system locale and choose the correct
++character set.
++.P
++.I Lunar
++now also detects and displays the current China Standard Time by default,
++so that the
++.I year
++.I month
++.I day
++.RI [ hour ]
++parameters are now optional for solar-to-lunar calendar conversion.
++.P
+ The possible options are
+-.IP b
+-output ganzhi in special "bitmap" characters.
+-.IP h
+-output hanzi or Chinese characters encoded in (highest-bit-set) GB code.
+-.IP i
++.TP
++.B \-b
++output \fIganzhi\fR in special "bitmap" characters.
++.TP
++\fB\-u\fR, \fB\-\-utf8\fR
++output \fIhanzi\fR or Chinese characters encoded in UTF-8.
++.TP
++.B \-s
++output simplified Chinese (for UTF-8 only).
++.TP
++.B \-t
++output traditional Chinese (for UTF-8 only).
++.TP
++\fB\-g\fR, \fB\-h\fR, \fB\-\-gb\fR
++output \fIhanzi\fR or Chinese characters encoded in (highest-bit-set) GB code.
++.TP
++\fB\-5\fR, \fB\-\-big5\fR
++output \fIhanzi\fR or Chinese characters encoded in Big5.
++.TP
++.B \-i
+ convert a lunar date to solar date.
+ The default is to convert a solar date to a lunar date.
+-.IP l
++.TP
++.B \-l
+ indicate the month is a lunar leap month.
+-This option is meaningful only when the "-i" option is used.
++This option is meaningful only when the "\-i" option is used.
++.TP
++.B \-\-help
++Print a help message.
++.
+ .SH COPYRIGHT
+ Copyright (C) 1988, 1989, 1991, 1992, 2001 Fung F. Lee and Ricky Yeung 
+ .sp
+@@ -88,15 +140,17 @@ version 2.1a.  This program was first re
+ GNU GPL on October 28, 2001 as version 2.2. Both versions are identical
+ except for the license text.
+ 
+-
+ .SH AUTHORS
+ Fung F. Lee and Ricky Yeung
++.
+ .SH ACKNOWLEDGEMENT
+ The special "bitmap" file "lunar.bitmap" was contributed by Weimin Liu.
+ 
+ Special thanks to Hwei Chen Ti who extended the tables from 2001 to 2049.
++.
+ .SH BUGS
+ Bug reports and comments should be sent to lee at umunhum.stanford.edu.
++.
+ .SH DISCLAIMER
+ This software has no connection with our employers.
+ 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..a7676bc
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,9 @@
+01_strip_trailing_whitespace.diff
+02_fix_compiler_warnings.diff
+03_add_full_path_to_lunar_bitmap.diff
+04_add_big5_and_utf8_output.diff
+05_fix_output_on_year_2033.diff
+06_use_locale_and_current_date.diff
+07_fix_segfault_aggressive-loop-optimizations.diff
+10_complete_the_makefile.diff
+20_update_man_page.diff
diff --git a/debian/rules b/debian/rules
index bf289c9..cbe925d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,65 +1,3 @@
 #!/usr/bin/make -f
-# debian/rules file for lunar-2.2
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
-	CFLAGS += -g
-endif
-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
-	INSTALL_PROGRAM += -s
-endif
-
-build: build-stamp
-build-stamp:
-	dh_testdir
-
-	# Add here commands to compile the package.
-	$(MAKE) CFLAGS="-O2 -Wall"
-
-	touch build-stamp
-
-clean:
-	dh_testdir
-	dh_testroot
-	rm -f build-stamp configure-stamp
-
-	# Add here commands to clean up after the build process.
-	-$(MAKE) clean
-
-	dh_clean
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_clean -k
-	dh_installdirs usr/bin usr/share/lunar
-
-	# Add here commands to install the package into debian/lunar.
-	install -m755 -p lunar debian/lunar/usr/bin/
-	install -m644 -p lunar.bitmap debian/lunar/usr/share/lunar/
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-	dh_installdocs
-	dh_installman lunar.1
-	dh_installchangelogs 
-	dh_link
-	dh_strip
-	dh_compress
-	dh_fixperms
-	dh_installdeb
-	dh_shlibdeps
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+%:
+	dh $@
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/watch b/debian/watch
new file mode 100644
index 0000000..33d2fff
--- /dev/null
+++ b/debian/watch
@@ -0,0 +1,5 @@
+version=3
+# http://umunhum.stanford.edu/~lee/chicomp/chicomp.html \
+#   (?:.*/)?lunar-(\d[\d\.]*)\.tar\.(?:gz|bz2|xz)
+http://web.archive.org/web/20051027042122/http://umunhum.stanford.edu/~lee/chicomp/chicomp.html \
+  (?:.*/)?lunar-(\d[\d\.]*)\.tar\.(?:gz|bz2|xz)
diff --git a/lunar.1 b/lunar.1
index 17c053f..56b1da5 100644
--- a/lunar.1
+++ b/lunar.1
@@ -4,13 +4,13 @@ lunar (version 2.2) \- a calendar conversion utility
 .SH SYNTAX
 .B lunar
 [
-.B \-h
+.B\-h
 ] [
-.B \-b
+.B\-b
 ] [
-.B \-i
+.B\-i
 ] [
-.B \-l
+.B\-l
 ]
 .I year month day
 [
@@ -39,7 +39,7 @@ and SC 1991.2.16.1 is LC 1991.1.2.1.
 The standard time of the Lunar Calendar is
 Beijing (Hong Kong) Standard Time, not GMT.
 Be sure to adjust appropriately for other time zones
-and "Daylight Saving Time".
+and "Day-light Saving Time".
 .PP
 In the Lunar Calendar,
 a normal year has 12 months, and a leap year (run-nian) has 13 months,
diff --git a/lunar.c b/lunar.c
index d2241c3..38e5f03 100644
--- a/lunar.c
+++ b/lunar.c
@@ -64,7 +64,6 @@ References:
 
 

 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 /* "Bitmap" constants */
@@ -112,26 +111,6 @@ static char *weekday[] = {
     "Thursday", "Friday", "Saturday"
 };
 
-static	char	*GanUTF8[] = {
-    "甲", "乙", "丙", "丁", "戊",
-    "己", "庚", "辛", "壬", "癸"
-};
-
-static	char	*ZhiUTF8[] = {
-    "子", "丑", "寅", "卯", "辰", "巳",
-    "午", "未", "申", "酉", "戌", "亥"
-};
-
-static	char   *ShengXiaoUTF8[] = {
-    "鼠", "牛", "虎", "兔", "龙", "蛇",
-    "马", "羊", "猴", "鸡", "狗", "猪"
-};
-
-static char *weekdayUTF8[] = {
-    "日", "一", "二", "三",
-    "四", "五", "六"
-};
-
 static	char	*GanGB[] = {
     "��", "��", "��", "��", "��",
     "��", "��", "��", "��", "��"
@@ -152,26 +131,6 @@ static char *weekdayGB[] = {
     "��", "��", "��"
 };
 
-static	char	*GanB5[] = {
-    "��", "�A", "��", "�B", "��",
-    "�v", "��", "��", "��", "��"
-};
-
-static	char	*ZhiB5[] = {
-    "�l", "��", "�G", "�f", "��", "�x",
-    "��", "��", "��", "��", "��", "��"
-};
-
-static	char   *ShengXiaoB5[] = {
-    "��", "��", "��", "��", "�s", "�D",
-    "��", "��", "�U", "��", "��", "��"
-};
-
-static char *weekdayB5[] = {
-    "��", "�@", "�G", "�T",
-    "�|", "��", "��"
-};
-
 
 Date solar, lunar, gan, zhi, gan2, zhi2, lunar2;
 
@@ -182,10 +141,7 @@ int jieAlert;		/* if there is uncertainty in JieQi calculation */
 
 int	showHZ = 0;			/* output in hanzi */
 int	showBM = 0;			/* output in bitmap */
-int	showHZ_UTF8 = 0;		/* output in UTF-8-encoded hanzi */
-int	showHZ_GB = 0;			/* output in GB-encoded hanzi */
-int	showHZ_B5 = 0;			/* output in Big5-encoded hanzi */
-char	BMfile[] = "/usr/share/lunar/lunar.bitmap";	/* bit map file */
+char	BMfile[] = "lunar.bitmap";	/* bit map file */
 char	GZBM[NBM][BMRow][BMCol];	/* the bitmap array */
 char	*progname;
 
@@ -194,9 +150,9 @@ long    Solar2Day(), Solar2Day1(), Lunar2Day();
 void	Day2Lunar(), Day2Solar();
 int     make_yday(), make_mday(), GZcycle();
 void	CalGZ();
-int	CmpDate(), JieDate();
+int	JieDate(), JieDate();
 void    readBM(), display3();
-void	Report(), ReportE(), ReportBM(), ReportUTF8(), ReportGB(), ReportB5();
+void	Report(), ReportE(), ReportBM(), ReportGB();
 void	usage(), Error();
 
 
@@ -219,22 +175,6 @@ char *argv[];
 	    case 'l': if (inverse) leap=1; else usage(); break;
 	    case 'h': showHZ = 1; break;
 	    case 'b': showBM = 1; break;
-	    case '-':
-		if (strncmp(argv[k], "--utf8", 7) == 0) {
-		    showHZ = showHZ_UTF8 = 1;
-		    showHZ_B5 = 0;
-		    showHZ_GB = 0;
-		} else if (strncmp(argv[k], "--big5", 7) == 0) {
-		    showHZ = showHZ_B5 = 1;
-		    showHZ_UTF8 = 0;
-		    showHZ_GB = 0;
-		} else if (strncmp(argv[k], "--gb", 5) == 0) {
-		    showHZ = showHZ_GB = 1;
-		    showHZ_UTF8 = 0;
-		    showHZ_B5 = 0;
-		} else
-		    usage();
-		break;
 	    default:  usage(); break;
 	}
     }
@@ -294,10 +234,7 @@ void usage()
     printf("\t\t(in Lunar Calendar, 24 hour clock)\n");
     printf("\t\t-l means the month is a leap month (\"run4 yue4\")\n\n");
     printf("\t\t-h means output in hanzi (GB)\n");
-    printf("\t\t-b means output in \"bitmap\"\n");
-    printf("\t\t--utf8 means output in hanzi (UTF-8)\n");
-    printf("\t\t--gb   means output in hanzi (GB)\n");
-    printf("\t\t--big5 means output in hanzi (Big5)\n\n");
+    printf("\t\t-b means output in \"bitmap\"\n\n");
     printf("Date range: about %d years from the Solar Date %d.%d.%d\n", Nyear,
 	   SolarFirstDate.year, SolarFirstDate.month, SolarFirstDate.day);
     exit(1);
@@ -306,7 +243,9 @@ void usage()
 
 void Solar2Lunar()
 {
+
     long offset;
+    Date *d;
 
     offset = Solar2Day(&solar);
     solar.weekday = (offset + SolarFirstDate.weekday) % 7;
@@ -330,6 +269,7 @@ void Lunar2Solar()
 {
     long offset;
     int adj;
+    Date *d;
 
     /* A solar day begins at 12 a.m. */
     adj = (lunar.hour == 23)? -1 : 0;
@@ -346,7 +286,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) */
@@ -417,6 +357,7 @@ Date *d;
 void Day2Lunar(offset, d)
 long offset;
 Date *d;
+
 {
     int i, m, nYear, leapMonth;
     
@@ -545,7 +486,7 @@ int month1, day1, month2, day2;
 int JieDate(ds, dl)
 Date *ds, *dl;
 {
-    int m, flag = 0;
+    int m, flag;
 
     if (ds->month==1)
     {
@@ -650,12 +591,7 @@ int year;
 void Report()
 {
     if (showHZ)
-	if (showHZ_UTF8)
-	    ReportUTF8();
-	else if (showHZ_B5)
-	    ReportB5();
-	else 
-	    ReportGB();
+	ReportGB();
     else if (showBM)
 	ReportBM();
     else
@@ -663,39 +599,6 @@ void Report()
 }
 
 
-void ReportUTF8()
-{
-    printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "阳历: ",
-	   solar.year, "年", solar.month, "月", solar.day,
-	   "日", solar.hour, "时 ",
-	   "星期", weekdayUTF8[solar.weekday]); 
-    printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "阴历: ",
-	   lunar.year, "年", (lunar.leap? "闰":""),
-	   lunar.month, "月", lunar.day, "日", 
-	   ZhiUTF8[zhi.hour], "时 ",
-	   "生肖属", ShengXiaoUTF8[zhi.year]);
-    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "干支: ",
-	   GanUTF8[gan.year], ZhiUTF8[zhi.year], "年 ",
-	   GanUTF8[gan.month], ZhiUTF8[zhi.month], "月 ",
-	   GanUTF8[gan.day], ZhiUTF8[zhi.day], "日 ",
-	   GanUTF8[gan.hour], ZhiUTF8[zhi.hour], "时 ");
-    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
-	   "用四柱神算推算之时辰八字: ",
-	   GanUTF8[gan2.year], ZhiUTF8[zhi2.year], "年 ",
-	   GanUTF8[gan2.month], ZhiUTF8[zhi2.month], "月 ",
-	   GanUTF8[gan2.day], ZhiUTF8[zhi2.day], "日 ",
-	   GanUTF8[gan2.hour], ZhiUTF8[zhi2.hour], "时 ");
-    if (jieAlert)
-    {
-	printf("* %s, %s\n", "是日为节",
-	       "月柱可能要修改");
-	if (lunar2.month==1)
-	    printf("* %s\n", "年柱亦可能要修改");
-	printf("* %s\n", "请查有节气时间之万年历");
-    }
-}
-
-
 void ReportGB()
 {
     printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "��������",
@@ -729,39 +632,6 @@ void ReportGB()
 }
 
 
-void ReportB5()
-{
-    printf("%s%d%s%2d%s%2d%s%2d%s%s%s\n", "����G�@",
-	   solar.year, "�~", solar.month, "��", solar.day,
-	   "��", solar.hour, "�ɡ@",
-	   "�P��", weekdayB5[solar.weekday]); 
-    printf("%s%d%s%s%2d%s%2d%s%s%s%s%s\n", "����G�@",
-	   lunar.year, "�~", (lunar.leap? "�|":""),
-	   lunar.month, "��", lunar.day, "��", 
-	   ZhiB5[zhi.hour], "�ɡ@",
-	   "�ͨv��", ShengXiaoB5[zhi.year]);
-    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n", "�z��G�@",
-	   GanB5[gan.year], ZhiB5[zhi.year], "�~�@",
-	   GanB5[gan.month], ZhiB5[zhi.month], "��@",
-	   GanB5[gan.day], ZhiB5[zhi.day], "��@",
-	   GanB5[gan.hour], ZhiB5[zhi.hour], "�ɡ@");
-    printf("%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
-	   "�Υ|�W������⤧�ɨ��K�r�G�@",
-	   GanB5[gan2.year], ZhiB5[zhi2.year], "�~�@",
-	   GanB5[gan2.month], ZhiB5[zhi2.month], "��@",
-	   GanB5[gan2.day], ZhiB5[zhi2.day], "��@",
-	   GanB5[gan2.hour], ZhiB5[zhi2.hour], "�ɡ@");
-    if (jieAlert)
-    {
-	printf("* %s, %s\n", "�O�鬰�`",
-	       "��W�i��n�ק�");
-	if (lunar2.month==1)
-	    printf("* %s\n", "�~�W��i��n�ק�");
-	printf("* %s\n", "�Ьd���`��ɶ����U�~��");
-    }
-}
-
-
 void ReportE()
 {
     printf("Solar : %d.%d.%d.%d\t%s\n", solar.year, solar.month, solar.day,
diff --git a/tables.h b/tables.h
index 61a0e4f..8d260f5 100644
--- a/tables.h
+++ b/tables.h
@@ -86,7 +86,7 @@ static long yearInfo[Nyear] = {
     0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954,	/* 2020 */
     0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6,	/* 2025 */
     0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, 0x05aa0,	/* 2030 */
-    0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0,	/* 2035 */
+    0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0,	/* 2035 */
     0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0,	/* 2040 */
     0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0,	/* 2045 */
     0x0aa50, 0x1b255, 0x06d20, 0x0ada0			/* 2049 */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/chinese/lunar.git



More information about the Chinese-commits mailing list