svn commit: r204663 - user/edwin/ncal

Edwin Groothuis edwin at FreeBSD.org
Wed Mar 3 21:14:12 UTC 2010


Author: edwin
Date: Wed Mar  3 21:14:12 2010
New Revision: 204663
URL: http://svn.freebsd.org/changeset/base/204663

Log:
  Fix the center alignment of month heading in the backwards compatibility mode.

Modified:
  user/edwin/ncal/ncal.c

Modified: user/edwin/ncal/ncal.c
==============================================================================
--- user/edwin/ncal/ncal.c	Wed Mar  3 21:10:13 2010	(r204662)
+++ user/edwin/ncal/ncal.c	Wed Mar  3 21:14:12 2010	(r204663)
@@ -490,7 +490,7 @@ monthrangeb(int y, int jd_flag, int m, i
 	struct monthlines year[12];
 	struct weekdays wds;
 	char	s[80], t[80];
-	wchar_t	ws[80];
+	wchar_t	ws[80], ws1[80];
 	const char	*wdss;
 	int     i, j;
 	int     mpl;
@@ -544,10 +544,11 @@ monthrangeb(int y, int jd_flag, int m, i
 			if (printyearheader)
 				wprintf(L"%-*ls  ",
 				    mw, wcenter(ws, year[i].name, mw));
-			else
-				wprintf(L"%-ls %-*d  ",
-				    wcenter(ws, year[i].name, mw - 10),
-				    mw - wcslen(year[i].name) - 1, M2Y(m + i));
+			else {
+				swprintf(ws, sizeof(ws), L"%-ls %d",
+				    year[i].name, M2Y(m + i));
+				wprintf(L"%-*ls  ", mw, wcenter(ws1, ws, mw));
+			}
 		printf("\n");
 
 		/* Day of the week names */


More information about the svn-src-user mailing list