Module Name:    src
Committed By:   christos
Date:           Thu Jan  8 03:56:33 UTC 2015

Modified Files:
        src/usr.bin/cal: cal.1 cal.c

Log Message:
Provide -C == -A + -B like fgrep, from Anon Ymous


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/cal/cal.1
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/cal/cal.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/cal/cal.1
diff -u src/usr.bin/cal/cal.1:1.20 src/usr.bin/cal/cal.1:1.21
--- src/usr.bin/cal/cal.1:1.20	Mon Dec 24 08:56:00 2007
+++ src/usr.bin/cal/cal.1	Wed Jan  7 22:56:33 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: cal.1,v 1.20 2007/12/24 13:56:00 wiz Exp $
+.\"	$NetBSD: cal.1,v 1.21 2015/01/08 03:56:33 christos Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"     @(#)cal.1	8.2 (Berkeley) 4/28/95
 .\"
-.Dd December 21, 2007
+.Dd January 7, 2015
 .Dt CAL 1
 .Os
 .Sh NAME
@@ -43,6 +43,7 @@
 .Op Fl 3hjry
 .Op Fl A Ar after
 .Op Fl B Ar before
+.Op Fl C Ar context
 .Op Fl d Ar day-of-week
 .Op Fl R Ar reform-spec
 .Op Oo Ar month Oc Ar year
@@ -64,6 +65,10 @@ months after the specified month.
 Display
 .Ar before
 months before the specified month.
+.It Fl C Ar context
+Display
+.Ar context
+months before and after the specified month.
 .It Fl d Ar day-of-week
 Specifies the day of the week on which the calendar should start.
 Valid values are 0 through 6, presenting Sunday through Saturday,

Index: src/usr.bin/cal/cal.c
diff -u src/usr.bin/cal/cal.c:1.27 src/usr.bin/cal/cal.c:1.28
--- src/usr.bin/cal/cal.c:1.27	Mon Aug 29 09:55:22 2011
+++ src/usr.bin/cal/cal.c	Wed Jan  7 22:56:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cal.c,v 1.27 2011/08/29 13:55:22 joerg Exp $	*/
+/*	$NetBSD: cal.c,v 1.28 2015/01/08 03:56:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)cal.c	8.4 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: cal.c,v 1.27 2011/08/29 13:55:22 joerg Exp $");
+__RCSID("$NetBSD: cal.c,v 1.28 2015/01/08 03:56:33 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -227,7 +227,7 @@ main(int argc, char **argv)
 	before = after = 0;
 	use_reform = yflag = year = 0;
 	when = NULL;
-	while ((ch = getopt(argc, argv, "A:B:d:hjR:ry3")) != -1) {
+	while ((ch = getopt(argc, argv, "A:B:C:d:hjR:ry3")) != -1) {
 		switch (ch) {
 		case 'A':
 			after = getnum(optarg);
@@ -239,6 +239,11 @@ main(int argc, char **argv)
 			if (before < 0)
 				errx(1, "Argument to -B must be positive");
 			break;
+		case 'C':
+			after = before = getnum(optarg);
+			if (after < 0)
+				errx(1, "Argument to -C must be positive");
+			break;
 		case 'd':
 			dow = getnum(optarg);
 			if (dow < 0 || dow > 6)
@@ -764,7 +769,7 @@ gregorian_reform(const char *p)
 		errx(1, "reform name %s invalid", p);
 
 	/*
-	 * 
+	 *
 	 */
 	reform->missing_days =
 		j_leap_days(reform->year, reform->month, reform->date) -
@@ -913,7 +918,7 @@ usage(void)
 {
 
 	(void)fprintf(stderr,
-	    "usage: cal [-3hjry] [-A after] [-B before] [-d day-of-week] "
+	    "usage: cal [-3hjry] [-A after] [-B before] [-C context] [-d day-of-week] "
 	    "[-R reform-spec]\n           [[month] year]\n");
 	exit(1);
 }

Reply via email to