[Midnightbsd-cvs] src [11468] trunk/usr.bin/ncal/ncal.c: make some things static

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jul 7 12:54:50 EDT 2018


Revision: 11468
          http://svnweb.midnightbsd.org/src/?rev=11468
Author:   laffer1
Date:     2018-07-07 12:54:49 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
make some things static

Modified Paths:
--------------
    trunk/usr.bin/ncal/Makefile
    trunk/usr.bin/ncal/ncal.1
    trunk/usr.bin/ncal/ncal.c

Property Changed:
----------------
    trunk/usr.bin/ncal/ncal.1

Modified: trunk/usr.bin/ncal/Makefile
===================================================================
--- trunk/usr.bin/ncal/Makefile	2018-07-07 16:54:32 UTC (rev 11467)
+++ trunk/usr.bin/ncal/Makefile	2018-07-07 16:54:49 UTC (rev 11468)
@@ -1,5 +1,8 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/ncal/Makefile 264996 2014-04-27 01:15:10Z jmmv $
 
+.include <bsd.own.mk>
+
 PROG=	ncal
 
 DPADD=	${LIBCALENDAR} ${LIBTERMCAP}
@@ -8,4 +11,8 @@
 LINKS=	${BINDIR}/ncal ${BINDIR}/cal
 MLINKS=	ncal.1 cal.1
 
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
 .include <bsd.prog.mk>

Modified: trunk/usr.bin/ncal/ncal.1
===================================================================
--- trunk/usr.bin/ncal/ncal.1	2018-07-07 16:54:32 UTC (rev 11467)
+++ trunk/usr.bin/ncal/ncal.1	2018-07-07 16:54:49 UTC (rev 11468)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1997 Wolfgang Helbig
 .\" All rights reserved.
 .\"
@@ -22,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/ncal/ncal.1 223932 2011-07-11 10:42:36Z edwin $
 .\"
 .Dd March 14, 2009
 .Dt CAL 1


Property changes on: trunk/usr.bin/ncal/ncal.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/ncal/ncal.c
===================================================================
--- trunk/usr.bin/ncal/ncal.c	2018-07-07 16:54:32 UTC (rev 11467)
+++ trunk/usr.bin/ncal/ncal.c	2018-07-07 16:54:49 UTC (rev 11468)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1997 Wolfgang Helbig
  * All rights reserved.
@@ -24,10 +25,8 @@
  * SUCH DAMAGE.
  */
 
-#ifndef lint
-static const char rcsid[] =
-  "$MidnightBSD$";
-#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/usr.bin/ncal/ncal.c 309336 2016-11-30 20:51:51Z vangyzen $");
 
 #include <calendar.h>
 #include <ctype.h>
@@ -111,77 +110,81 @@
 	{"YU", "Yugoslavia",    {1919,  3,  4}}
 };
 
-struct djswitch *dftswitch =
+static struct djswitch *dftswitch =
     switches + sizeof(switches) / sizeof(struct djswitch) - 2;
     /* default switch (should be "US") */
 
 /* Table used to print day of month and week numbers */
-char daystr[] = "     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";
+static char daystr[] = "     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";
 
 /* Table used to print day of year and week numbers */
-char jdaystr[] = "       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  91  92  93  94  95  96  97  98  99"
-		 " 100 101 102 103 104 105 106 107 108 109"
-		 " 110 111 112 113 114 115 116 117 118 119"
-		 " 120 121 122 123 124 125 126 127 128 129"
-		 " 130 131 132 133 134 135 136 137 138 139"
-		 " 140 141 142 143 144 145 146 147 148 149"
-		 " 150 151 152 153 154 155 156 157 158 159"
-		 " 160 161 162 163 164 165 166 167 168 169"
-		 " 170 171 172 173 174 175 176 177 178 179"
-		 " 180 181 182 183 184 185 186 187 188 189"
-		 " 190 191 192 193 194 195 196 197 198 199"
-		 " 200 201 202 203 204 205 206 207 208 209"
-		 " 210 211 212 213 214 215 216 217 218 219"
-		 " 220 221 222 223 224 225 226 227 228 229"
-		 " 230 231 232 233 234 235 236 237 238 239"
-		 " 240 241 242 243 244 245 246 247 248 249"
-		 " 250 251 252 253 254 255 256 257 258 259"
-		 " 260 261 262 263 264 265 266 267 268 269"
-		 " 270 271 272 273 274 275 276 277 278 279"
-		 " 280 281 282 283 284 285 286 287 288 289"
-		 " 290 291 292 293 294 295 296 297 298 299"
-		 " 300 301 302 303 304 305 306 307 308 309"
-		 " 310 311 312 313 314 315 316 317 318 319"
-		 " 320 321 322 323 324 325 326 327 328 329"
-		 " 330 331 332 333 334 335 336 337 338 339"
-		 " 340 341 342 343 344 345 346 347 348 349"
-		 " 350 351 352 353 354 355 356 357 358 359"
-		 " 360 361 362 363 364 365 366";
+static char jdaystr[] = "       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  91  92  93  94  95  96  97  98  99"
+			" 100 101 102 103 104 105 106 107 108 109"
+			" 110 111 112 113 114 115 116 117 118 119"
+			" 120 121 122 123 124 125 126 127 128 129"
+			" 130 131 132 133 134 135 136 137 138 139"
+			" 140 141 142 143 144 145 146 147 148 149"
+			" 150 151 152 153 154 155 156 157 158 159"
+			" 160 161 162 163 164 165 166 167 168 169"
+			" 170 171 172 173 174 175 176 177 178 179"
+			" 180 181 182 183 184 185 186 187 188 189"
+			" 190 191 192 193 194 195 196 197 198 199"
+			" 200 201 202 203 204 205 206 207 208 209"
+			" 210 211 212 213 214 215 216 217 218 219"
+			" 220 221 222 223 224 225 226 227 228 229"
+			" 230 231 232 233 234 235 236 237 238 239"
+			" 240 241 242 243 244 245 246 247 248 249"
+			" 250 251 252 253 254 255 256 257 258 259"
+			" 260 261 262 263 264 265 266 267 268 269"
+			" 270 271 272 273 274 275 276 277 278 279"
+			" 280 281 282 283 284 285 286 287 288 289"
+			" 290 291 292 293 294 295 296 297 298 299"
+			" 300 301 302 303 304 305 306 307 308 309"
+			" 310 311 312 313 314 315 316 317 318 319"
+			" 320 321 322 323 324 325 326 327 328 329"
+			" 330 331 332 333 334 335 336 337 338 339"
+			" 340 341 342 343 344 345 346 347 348 349"
+			" 350 351 352 353 354 355 356 357 358 359"
+			" 360 361 362 363 364 365 366";
 
-int	flag_nohighlight;	/* user doesn't want a highlighted today */
-int     flag_weeks;		/* user wants number of week */
-int     nswitch;		/* user defined switch date */
-int	nswitchb;		/* switch date for backward compatibility */
-int	highlightdate;
+static int flag_nohighlight;	/* user doesn't want a highlighted today */
+static int flag_weeks;		/* user wants number of week */
+static int nswitch;		/* user defined switch date */
+static int nswitchb;		/* switch date for backward compatibility */
+static int highlightdate;
 
-char	*center(char *s, char *t, int w);
-wchar_t *wcenter(wchar_t *s, wchar_t *t, int w);
-int	firstday(int y, int m);
-void	highlight(char *dst, char *src, int len, int *extraletters);
-void	mkmonthr(int year, int month, int jd_flag, struct monthlines * monthl);
-void	mkmonthb(int year, int month, int jd_flag, struct monthlines * monthl);
-void	mkweekdays(struct weekdays * wds);
-void	monthranger(int year, int m, int jd_flag, int before, int after);
-void	monthrangeb(int year, int m, int jd_flag, int before, int after);
-int	parsemonth(const char *s, int *m, int *y);
-void	printcc(void);
-void	printeaster(int year, int julian, int orthodox);
-date	*sdater(int ndays, struct date * d);
-date	*sdateb(int ndays, struct date * d);
-int	sndaysr(struct date * d);
-int	sndaysb(struct date * d);
+static char	*center(char *s, char *t, int w);
+static wchar_t *wcenter(wchar_t *s, wchar_t *t, int w);
+static int	firstday(int y, int m);
+static void	highlight(char *dst, char *src, int len, int *extraletters);
+static void	mkmonthr(int year, int month, int jd_flag,
+    struct monthlines * monthl);
+static void	mkmonthb(int year, int month, int jd_flag,
+    struct monthlines * monthl);
+static void	mkweekdays(struct weekdays * wds);
+static void	monthranger(int year, int m, int jd_flag,
+    int before, int after);
+static void	monthrangeb(int year, int m, int jd_flag,
+    int before, int after);
+static int	parsemonth(const char *s, int *m, int *y);
+static void	printcc(void);
+static void	printeaster(int year, int julian, int orthodox);
+static date	*sdater(int ndays, struct date * d);
+static date	*sdateb(int ndays, struct date * d);
+static int	sndaysr(struct date * d);
+static int	sndaysb(struct date * d);
 static void	usage(void);
 
 int
@@ -513,7 +516,7 @@
 }
 
 /* Print the assumed switches for all countries. */
-void
+static void
 printcc(void)
 {
 	struct djswitch *p;
@@ -534,7 +537,7 @@
 }
 
 /* Print the date of easter sunday. */
-void
+static void
 printeaster(int y, int julian, int orthodox)
 {
 	date    dt;
@@ -579,7 +582,7 @@
 #define	M2M(m)	(1 + (m) % 12) 
 
 /* Print all months for the period in the range [ before .. y-m .. after ]. */
-void
+static void
 monthrangeb(int y, int m, int jd_flag, int before, int after)
 {
 	struct monthlines year[12];
@@ -640,8 +643,8 @@
 				wprintf(L"%-*ls  ",
 				    mw, wcenter(ws, year[i].name, mw));
 			else {
-				swprintf(ws, sizeof(ws), L"%-ls %d",
-				    year[i].name, M2Y(m + i));
+				swprintf(ws, sizeof(ws)/sizeof(ws[0]),
+				    L"%-ls %d", year[i].name, M2Y(m + i));
 				wprintf(L"%-*ls  ", mw, wcenter(ws1, ws, mw));
 			}
 		printf("\n");
@@ -669,7 +672,7 @@
 	}
 }
 
-void
+static void
 monthranger(int y, int m, int jd_flag, int before, int after)
 {
 	struct monthlines year[12];
@@ -757,7 +760,7 @@
 	return;
 }
 
-void
+static void
 mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines)
 {
 
@@ -848,7 +851,7 @@
 	}
 }
 
-void
+static void
 mkmonthb(int y, int m, int jd_flag, struct monthlines *mlines)
 {
 
@@ -945,7 +948,7 @@
 }
 
 /* Put the local names of weekdays into the wds. */
-void
+static void
 mkweekdays(struct weekdays *wds)
 {
 	int i, len, width = 0;
@@ -956,7 +959,7 @@
 
 	for (i = 0; i != 7; i++) {
 		tm.tm_wday = (i+1) % 7;
-		wcsftime(buf, sizeof(buf), L"%a", &tm);
+		wcsftime(buf, sizeof(buf)/sizeof(buf[0]), L"%a", &tm);
 		for (len = 2; len > 0; --len) {
 			if ((width = wcswidth(buf, len)) <= 2)
 				break;
@@ -973,7 +976,7 @@
  * Compute the day number of the first existing date after the first day in
  * month. (the first day in month and even the month might not exist!)
  */
-int
+static int
 firstday(int y, int m)
 {
 	date dt;
@@ -997,7 +1000,7 @@
  * Compute the number of days from date, obey the local switch from
  * Julian to Gregorian if specified by the user.
  */
-int
+static int
 sndaysr(struct date *d)
 {
 
@@ -1014,7 +1017,7 @@
  * Compute the number of days from date, obey the switch from
  * Julian to Gregorian as used by UK and her colonies.
  */
-int
+static int
 sndaysb(struct date *d)
 {
 
@@ -1025,7 +1028,7 @@
 }
 
 /* Inverse of sndays. */
-struct date *
+static struct date *
 sdater(int nd, struct date *d)
 {
 
@@ -1036,7 +1039,7 @@
 }
 
 /* Inverse of sndaysb. */
-struct date *
+static struct date *
 sdateb(int nd, struct date *d)
 {
 
@@ -1047,7 +1050,7 @@
 }
 
 /* Center string t in string s of length w by putting enough leading blanks. */
-char *
+static char *
 center(char *s, char *t, int w)
 {
 	char blanks[MAX_WIDTH];
@@ -1058,7 +1061,7 @@
 }
 
 /* Center string t in string s of length w by putting enough leading blanks. */
-wchar_t *
+static wchar_t *
 wcenter(wchar_t *s, wchar_t *t, int w)
 {
 	char blanks[MAX_WIDTH];
@@ -1068,7 +1071,7 @@
 	return (s);
 }
 
-int
+static int
 parsemonth(const char *s, int *m, int *y)
 {
 	int nm, ny;
@@ -1101,7 +1104,7 @@
 	return (1);
 }
 
-void
+static void
 highlight(char *dst, char *src, int len, int *extralen)
 {
 	static int first = 1;
@@ -1108,7 +1111,8 @@
 	static const char *term_so, *term_se;
 
 	if (first) {
-		char tbuf[1024], cbuf[512], *b;
+		static char cbuf[512];
+		char tbuf[1024], *b;
 
 		term_se = term_so = NULL;
 



More information about the Midnightbsd-cvs mailing list