summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoredwin <edwin@FreeBSD.org>2010-03-21 21:33:21 +0000
committeredwin <edwin@FreeBSD.org>2010-03-21 21:33:21 +0000
commit9792f6e953c151c5df861e4c49cf9ed1d3762f38 (patch)
tree80c16fd52abe3a449fc3567be35758dc7ae6e2f0
parent78363cb37359be16ff42d36fdd2cdf51b9f33ae0 (diff)
downloadFreeBSD-src-9792f6e953c151c5df861e4c49cf9ed1d3762f38.zip
FreeBSD-src-9792f6e953c151c5df861e4c49cf9ed1d3762f38.tar.gz
Replace -b with -C and -B (as proposed by Alexander).
Add -3, -A and -B to the usage. Update regression test for the new parameters.
-rw-r--r--tools/regression/usr.bin/ncal/regress.sh71
-rw-r--r--usr.bin/ncal/ncal.114
-rw-r--r--usr.bin/ncal/ncal.c18
3 files changed, 60 insertions, 43 deletions
diff --git a/tools/regression/usr.bin/ncal/regress.sh b/tools/regression/usr.bin/ncal/regress.sh
index 7657e83..3dc188d 100644
--- a/tools/regression/usr.bin/ncal/regress.sh
+++ b/tools/regression/usr.bin/ncal/regress.sh
@@ -1,7 +1,8 @@
# $FreeBSD$
CAL_BIN="ncal"
-CAL="${CAL_BIN}"
+CAL="${CAL_BIN} -C"
+NCAL="${CAL_BIN} -N"
YEARS="2008 2009 2010 2011"
ONEYEAR="2009"
@@ -18,13 +19,13 @@ echo 1..16
for y in ${YEARS}; do
# Regular calendar, Month days, No-highlight
- REGRESSION_TEST(`r-y${y}-md-nhl', `$CAL -h ${y}')
+ REGRESSION_TEST(`r-y${y}-md-nhl', `$NCAL -h ${y}')
# Backwards calendar, Month days, No-highlight
- REGRESSION_TEST(`b-y${y}-md-nhl', `$CAL -bh ${y}')
+ REGRESSION_TEST(`b-y${y}-md-nhl', `$CAL -h ${y}')
# Regular calendar, Julian days, No-highlight
- REGRESSION_TEST(`r-y${y}-jd-nhl', `$CAL -jh ${y}')
+ REGRESSION_TEST(`r-y${y}-jd-nhl', `$NCAL -jh ${y}')
# Backwards calendar, Julian days, No-highlight
- REGRESSION_TEST(`b-y${y}-jd-nhl', `$CAL -jbh ${y}')
+ REGRESSION_TEST(`b-y${y}-jd-nhl', `$CAL -jh ${y}')
done
# 3 month calendars
@@ -33,13 +34,15 @@ echo 17 .. 29
for m in $(jot -w %02d 12); do
# Regular calendar, Month days, No-highlight
- REGRESSION_TEST(`r-3m${ONEYEAR}${m}-md-nhl', `$CAL -h3 ${m} ${ONEYEAR}')
+ REGRESSION_TEST(`r-3m${ONEYEAR}${m}-md-nhl',
+ `$NCAL -h3 ${m} ${ONEYEAR}')
# Backwards calendar, Month days, No-highlight
- REGRESSION_TEST(`b-3m${ONEYEAR}${m}-md-nhl', `$CAL -bh3 ${m} ${ONEYEAR}')
+ REGRESSION_TEST(`b-3m${ONEYEAR}${m}-md-nhl', `$CAL -h3 ${m} ${ONEYEAR}')
# Regular calendar, Julian days, No-highlight
- REGRESSION_TEST(`r-3m${ONEYEAR}${m}-jd-nhl', `$CAL -jh3 ${m} ${ONEYEAR}')
+ REGRESSION_TEST(`r-3m${ONEYEAR}${m}-jd-nhl',
+ `$NCAL -jh3 ${m} ${ONEYEAR}')
# Backwards calendar, Julian days, No-highlight
- REGRESSION_TEST(`b-3m${ONEYEAR}${m}-jd-nhl', `$CAL -jbh3 ${m} ${ONEYEAR}')
+ REGRESSION_TEST(`b-3m${ONEYEAR}${m}-jd-nhl', `$CAL -jh3 ${m} ${ONEYEAR}')
done
#
@@ -47,33 +50,33 @@ done
#
# These should fail
-REGRESSION_TEST(`f-3y-nhl', `$CAL -3 -y 2>&1')
-REGRESSION_TEST(`f-3A-nhl', `$CAL -3 -A 3 2>&1')
-REGRESSION_TEST(`f-3B-nhl', `$CAL -3 -B 3 2>&1')
-REGRESSION_TEST(`f-3gy-nhl', `$CAL -3 2008 2>&1')
-REGRESSION_TEST(`f-3AB-nhl', `$CAL -3 -A 3 -B 3 2>&1')
-REGRESSION_TEST(`f-mgm-nhl', `$CAL -m 3 2 2008 2>&1')
-REGRESSION_TEST(`f-ym-nhl', `$CAL -y -m 2 2>&1')
-REGRESSION_TEST(`f-ygm-nhl', `$CAL -y 2 2008 2>&1')
-REGRESSION_TEST(`f-yA-nhl', `$CAL -y -A 3 2>&1')
-REGRESSION_TEST(`f-yB-nhl', `$CAL -y -B 3 2>&1')
-REGRESSION_TEST(`f-yAB-nhl', `$CAL -y -A 3 -B 3 2>&1')
+REGRESSION_TEST(`f-3y-nhl', `$NCAL -3 -y 2>&1')
+REGRESSION_TEST(`f-3A-nhl', `$NCAL -3 -A 3 2>&1')
+REGRESSION_TEST(`f-3B-nhl', `$NCAL -3 -B 3 2>&1')
+REGRESSION_TEST(`f-3gy-nhl', `$NCAL -3 2008 2>&1')
+REGRESSION_TEST(`f-3AB-nhl', `$NCAL -3 -A 3 -B 3 2>&1')
+REGRESSION_TEST(`f-mgm-nhl', `$NCAL -m 3 2 2008 2>&1')
+REGRESSION_TEST(`f-ym-nhl', `$NCAL -y -m 2 2>&1')
+REGRESSION_TEST(`f-ygm-nhl', `$NCAL -y 2 2008 2>&1')
+REGRESSION_TEST(`f-yA-nhl', `$NCAL -y -A 3 2>&1')
+REGRESSION_TEST(`f-yB-nhl', `$NCAL -y -B 3 2>&1')
+REGRESSION_TEST(`f-yAB-nhl', `$NCAL -y -A 3 -B 3 2>&1')
# These should be successful
-REGRESSION_TEST(`s-b-3-nhl', `$CAL -b -d 2008.03 -3')
-REGRESSION_TEST(`s-b-A-nhl', `$CAL -b -d 2008.03 -A 1')
-REGRESSION_TEST(`s-b-B-nhl', `$CAL -b -d 2008.03 -B 1')
-REGRESSION_TEST(`s-b-AB-nhl', `$CAL -b -d 2008.03 -A 1 -B 1')
-REGRESSION_TEST(`s-b-m-nhl', `$CAL -b -d 2008.03 -m 1')
-REGRESSION_TEST(`s-b-mgy-nhl', `$CAL -b -d 2008.03 -m 1 2007')
-REGRESSION_TEST(`s-b-gmgy-nhl', `$CAL -b -d 2008.03 1 2007')
-REGRESSION_TEST(`s-r-3-nhl', `$CAL -d 2008.03 -3')
-REGRESSION_TEST(`s-r-A-nhl', `$CAL -d 2008.03 -A 1')
-REGRESSION_TEST(`s-r-B-nhl', `$CAL -d 2008.03 -B 1')
-REGRESSION_TEST(`s-r-AB-nhl', `$CAL -d 2008.03 -A 1 -B 1')
-REGRESSION_TEST(`s-r-m-nhl', `$CAL -d 2008.03 -m 1')
-REGRESSION_TEST(`s-r-mgy-nhl', `$CAL -d 2008.03 -m 1 2007')
-REGRESSION_TEST(`s-r-gmgy-nhl', `$CAL -d 2008.03 1 2007')
+REGRESSION_TEST(`s-b-3-nhl', `$CAL -d 2008.03 -3')
+REGRESSION_TEST(`s-b-A-nhl', `$CAL -d 2008.03 -A 1')
+REGRESSION_TEST(`s-b-B-nhl', `$CAL -d 2008.03 -B 1')
+REGRESSION_TEST(`s-b-AB-nhl', `$CAL -d 2008.03 -A 1 -B 1')
+REGRESSION_TEST(`s-b-m-nhl', `$CAL -d 2008.03 -m 1')
+REGRESSION_TEST(`s-b-mgy-nhl', `$CAL -d 2008.03 -m 1 2007')
+REGRESSION_TEST(`s-b-gmgy-nhl', `$CAL -d 2008.03 1 2007')
+REGRESSION_TEST(`s-r-3-nhl', `$NCAL -d 2008.03 -3')
+REGRESSION_TEST(`s-r-A-nhl', `$NCAL -d 2008.03 -A 1')
+REGRESSION_TEST(`s-r-B-nhl', `$NCAL -d 2008.03 -B 1')
+REGRESSION_TEST(`s-r-AB-nhl', `$NCAL -d 2008.03 -A 1 -B 1')
+REGRESSION_TEST(`s-r-m-nhl', `$NCAL -d 2008.03 -m 1')
+REGRESSION_TEST(`s-r-mgy-nhl', `$NCAL -d 2008.03 -m 1 2007')
+REGRESSION_TEST(`s-r-gmgy-nhl', `$NCAL -d 2008.03 1 2007')
REGRESSION_END()
diff --git a/usr.bin/ncal/ncal.1 b/usr.bin/ncal/ncal.1
index d9973c2..8429906 100644
--- a/usr.bin/ncal/ncal.1
+++ b/usr.bin/ncal/ncal.1
@@ -60,6 +60,10 @@
.Op Fl A Ar number
.Op Fl B Ar number
.Op Ar year
+.Nm ncal
+.Op Fl CN
+.Op Fl H Ar yyyy-mm-dd
+.Op Fl d Ar yyyy-mm
.Sh DESCRIPTION
The
.Nm
@@ -127,8 +131,14 @@ of months after the current month.
Display the
.Ar number
of months before the current month.
-.It Fl b
-Switch to backwards compatibility mode (for debugging).
+.It Fl C
+Switch to
+.Nm cal
+mode.
+.It Fl N
+Switch to
+.Nm ncal
+mode.
.It Fl d Ar yyyy-mm
Use
.Ar yyyy-mm
diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c
index 9f077fb..5ab9a21 100644
--- a/usr.bin/ncal/ncal.c
+++ b/usr.bin/ncal/ncal.c
@@ -256,7 +256,7 @@ main(int argc, char *argv[])
before = after = -1;
- while ((ch = getopt(argc, argv, "A:B:3Jbd:eH:hjm:ops:wy")) != -1)
+ while ((ch = getopt(argc, argv, "3A:B:Cd:eH:hjJm:Nops:wy")) != -1)
switch (ch) {
case '3':
flag_3months = 1;
@@ -283,9 +283,12 @@ main(int argc, char *argv[])
nswitch = ndaysj(&never);
flag_julian_cal = 1;
break;
- case 'b':
+ case 'C':
flag_backward = 1;
break;
+ case 'N':
+ flag_backward = 0;
+ break;
case 'd':
flag_today = optarg;
break;
@@ -500,11 +503,12 @@ usage(void)
{
fputs(
- "usage: cal [-hjy] [[month] year]\n"
- " cal [-hj] [-m month] [year]\n"
- " ncal [-hJjpwy] [-s country_code] [[month] year]\n"
- " ncal [-hJeo] [year]\n"
- "for debug the highlighting: [-b] [-H yyyy-mm-dd] [-d yyyy-mm]\n",
+"Usage: cal [general options] [-hjy] [[month] year]\n"
+" cal [general options] [-hj] [-m month] [year]\n"
+" ncal [general options] [-hJjpwy] [-s country_code] [[month] year]\n"
+" ncal [general options] [-hJeo] [year]\n"
+"General options: [-NC3] [-A months] [-B months]\n"
+"For debug the highlighting: [-H yyyy-mm-dd] [-d yyyy-mm]\n",
stderr);
exit(EX_USAGE);
}
OpenPOWER on IntegriCloud