CVS commit: src/usr.bin/cal
Module Name:src Committed By: kim Date: Mon Jun 29 14:01:14 UTC 2020 Modified Files: src/usr.bin/cal: cal.c Log Message: Use two-letter weekday abbreviations in the heading This matches output from ncal (a.k.a. cal) as found in FreeBSD and bsdmainutils. (Why had "T" been found more ambiguous than "S" already?) To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 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.c diff -u src/usr.bin/cal/cal.c:1.29 src/usr.bin/cal/cal.c:1.30 --- src/usr.bin/cal/cal.c:1.29 Tue Jun 16 22:54:10 2015 +++ src/usr.bin/cal/cal.c Mon Jun 29 14:01:14 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cal.c,v 1.29 2015/06/16 22:54:10 christos Exp $ */ +/* $NetBSD: cal.c,v 1.30 2020/06/29 14:01:14 kim 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.29 2015/06/16 22:54:10 christos Exp $"); +__RCSID("$NetBSD: cal.c,v 1.30 2020/06/29 14:01:14 kim Exp $"); #endif #endif /* not lint */ @@ -88,8 +88,8 @@ static const char *month_names[12] = { "July", "August", "September", "October", "November", "December", }; -static const char *day_headings = " S M Tu W Th F S"; -static const char *j_day_headings = " S M Tu W Th F S"; +static const char *day_headings = "Su Mo Tu We Th Fr Sa"; +static const char *j_day_headings = " Su Mo Tu We Th Fr Sa"; /* leap years according to the julian calendar */ #define j_leap_year(y, m, d) \
CVS commit: src/usr.bin/cal
Module Name:src Committed By: wiz Date: Tue May 29 08:37:33 UTC 2018 Modified Files: src/usr.bin/cal: cal.1 Log Message: Remove superfluous Pp. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/cal/cal.1 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.22 src/usr.bin/cal/cal.1:1.23 --- src/usr.bin/cal/cal.1:1.22 Tue May 29 06:07:26 2018 +++ src/usr.bin/cal/cal.1 Tue May 29 08:37:33 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: cal.1,v 1.22 2018/05/29 06:07:26 kamil Exp $ +.\" $NetBSD: cal.1,v 1.23 2018/05/29 08:37:33 wiz Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -134,7 +134,6 @@ calendar for a very old date. .Nm has a decent built-in list of Gregorian Reform dates and the names of the countries where the reform was adopted: -.Pp .Bd -literal Italy Oct. 5, 1582 Denmark Feb. 19, 1700 Spain Oct. 5, 1582 Great Britain Sep. 3, 1752
CVS commit: src/usr.bin/cal
Module Name:src Committed By: kamil Date: Tue May 29 06:07:26 UTC 2018 Modified Files: src/usr.bin/cal: cal.1 Log Message: After Todd C. Miller[0] - cal(1) first appeared in Version 1 AT UNIX[1][2]. [0] http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/cal/cal.1?rev=1.28=text/x-cvsweb-markup [1] https://www.bell-labs.com/usr/dmr/www/1stEdman.html [2] https://www.bell-labs.com/usr/dmr/www/man61.pdf Patch submitted by @rjc via https://github.com/NetBSD/src/pull/3 To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/cal/cal.1 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.21 src/usr.bin/cal/cal.1:1.22 --- src/usr.bin/cal/cal.1:1.21 Thu Jan 8 03:56:33 2015 +++ src/usr.bin/cal/cal.1 Tue May 29 06:07:26 2018 @@ -1,4 +1,4 @@ -.\" $NetBSD: cal.1,v 1.21 2015/01/08 03:56:33 christos Exp $ +.\" $NetBSD: cal.1,v 1.22 2018/05/29 06:07:26 kamil 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 January 7, 2015 +.Dd May 29, 2018 .Dt CAL 1 .Os .Sh NAME @@ -162,4 +162,4 @@ slight to anyone involved. A .Nm command appeared in -.At v6 . +.At v1 .
CVS commit: src/usr.bin/cal
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); }
CVS commit: src/usr.bin/cal
Module Name:src Committed By: joerg Date: Mon Aug 29 13:55:22 UTC 2011 Modified Files: src/usr.bin/cal: cal.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 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.c diff -u src/usr.bin/cal/cal.c:1.26 src/usr.bin/cal/cal.c:1.27 --- src/usr.bin/cal/cal.c:1.26 Wed Feb 3 15:34:45 2010 +++ src/usr.bin/cal/cal.c Mon Aug 29 13:55:22 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cal.c,v 1.26 2010/02/03 15:34:45 roy Exp $ */ +/* $NetBSD: cal.c,v 1.27 2011/08/29 13:55:22 joerg Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = @(#)cal.c 8.4 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: cal.c,v 1.26 2010/02/03 15:34:45 roy Exp $); +__RCSID($NetBSD: cal.c,v 1.27 2011/08/29 13:55:22 joerg Exp $); #endif #endif /* not lint */ @@ -73,7 +73,7 @@ {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, }; -int empty[MAXDAYS] = { +static int empty[MAXDAYS] = { SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, @@ -81,15 +81,15 @@ SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, SPACE, }; -int shift_days[2][4][MAXDAYS + 1]; +static int shift_days[2][4][MAXDAYS + 1]; -const char *month_names[12] = { +static const char *month_names[12] = { January, February, March, April, May, June, July, August, September, October, November, December, }; -const char *day_headings = S M Tu W Th F S; -const char *j_day_headings = S M Tu W Th F S; +static const char *day_headings = S M Tu W Th F S; +static const char *j_day_headings = S M Tu W Th F S; /* leap years according to the julian calendar */ #define j_leap_year(y, m, d) \ @@ -152,7 +152,7 @@ #define leap_years_since_year_1(yr) \ ((yr) / 4 - centuries_since_reform(yr) + quad_centuries_since_reform(yr)) -struct reform { +static struct reform { const char *country; int ambiguity, year, month, date; long first_missing_day; @@ -195,24 +195,23 @@ { NULL, 0,0, 0, 0, 0, 0 }, }; -int julian; -int dow; -int hilite; -const char *md, *me; - -void init_hilite(void); -int getnum(const char *); -void gregorian_reform(const char *); -void reform_day_array(int, int, int *, int *, int *,int *,int *,int *); -int ascii_day(char *, int); -void center(const char *, int, int); -void day_array(int, int, int *); -int day_in_week(int, int, int); -int day_in_year(int, int, int); -void monthrange(int, int, int, int, int); -int main(int, char **); -void trim_trailing_spaces(char *); -void usage(void); +static int julian; +static int dow; +static int hilite; +static const char *md, *me; + +static void init_hilite(void); +static int getnum(const char *); +static void gregorian_reform(const char *); +static void reform_day_array(int, int, int *, int *, int *,int *,int *,int *); +static int ascii_day(char *, int); +static void center(const char *, int, int); +static void day_array(int, int, int *); +static int day_in_week(int, int, int); +static int day_in_year(int, int, int); +static void monthrange(int, int, int, int, int); +static void trim_trailing_spaces(char *); +__dead static void usage(void); int main(int argc, char **argv) @@ -338,7 +337,7 @@ #define MONTH_PER_ROW 3 /* how many monthes in a row */ #define J_MONTH_PER_ROW 2 -void +static void monthrange(int month, int year, int before, int after, int yearly) { int startmonth, startyear; @@ -484,7 +483,7 @@ * out end to end. You would have 42 numbers or spaces. This routine * builds that array for any month from Jan. 1 through Dec. . */ -void +static void day_array(int month, int year, int *days) { int day, dw, dm; @@ -523,7 +522,7 @@ * day_in_year -- * return the 1 based day number within the year */ -int +static int day_in_year(int day, int month, int year) { int i, leap; @@ -540,7 +539,7 @@ * 31 Dec. . Returns the day of the week of the first * missing day for any given Gregorian shift. */ -int +static int day_in_week(int day, int month, int year) { long temp; @@ -554,7 +553,7 @@ return ((FIRST_MISSING_DAY - dow + 6 + SATURDAY) % 7); } -int +static int ascii_day(char *p, int day) { int display, val, rc; @@ -629,7 +628,7 @@ return (rc); } -void +static void trim_trailing_spaces(char *s) { char *p; @@ -643,7 +642,7 @@ *p = '\0'; } -void +static void center(const char *str, int len, int separate) { @@ -662,7 +661,7 @@ * doing so would not select more than one different built-in * reform point. */ -void +static void gregorian_reform(const char *p) { int year, month, date; @@ -807,7 +806,7 @@ * and julian day representations) with respect for days * skipped during a reform
CVS commit: src/usr.bin/cal
Module Name:src Committed By: lukem Date: Sat Apr 11 11:26:34 UTC 2009 Modified Files: src/usr.bin/cal: cal.c Log Message: fix WARNS=4 issues To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 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.c diff -u src/usr.bin/cal/cal.c:1.24 src/usr.bin/cal/cal.c:1.25 --- src/usr.bin/cal/cal.c:1.24 Mon Jul 21 14:19:21 2008 +++ src/usr.bin/cal/cal.c Sat Apr 11 11:26:34 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cal.c,v 1.24 2008/07/21 14:19:21 lukem Exp $ */ +/* $NetBSD: cal.c,v 1.25 2009/04/11 11:26:34 lukem Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = @(#)cal.c 8.4 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: cal.c,v 1.24 2008/07/21 14:19:21 lukem Exp $); +__RCSID($NetBSD: cal.c,v 1.25 2009/04/11 11:26:34 lukem Exp $); #endif #endif /* not lint */ @@ -83,13 +83,13 @@ }; int shift_days[2][4][MAXDAYS + 1]; -char *month_names[12] = { +const char *month_names[12] = { January, February, March, April, May, June, July, August, September, October, November, December, }; -char *day_headings = S M Tu W Th F S; -char *j_day_headings = S M Tu W Th F S; +const char *day_headings = S M Tu W Th F S; +const char *j_day_headings = S M Tu W Th F S; /* leap years according to the julian calendar */ #define j_leap_year(y, m, d) \ @@ -163,36 +163,36 @@ * days that get displayed, plus a crib slot. */ } *reform, reforms[] = { - { DEFAULT, 0, 1752, 9, 3 }, - { Italy, 1, 1582, 10, 5 }, - { Spain, 1, 1582, 10, 5 }, - { Portugal, 1, 1582, 10, 5 }, - { Poland, 1, 1582, 10, 5 }, - { France, 2, 1582, 12, 10 }, - { Luxembourg, 2, 1582, 12, 22 }, - { Netherlands, 2, 1582, 12, 22 }, - { Bavaria, 0, 1583, 10, 6 }, - { Austria, 2, 1584, 1, 7 }, - { Switzerland, 2, 1584, 1, 12 }, - { Hungary, 0, 1587, 10, 22 }, - { Germany, 0, 1700, 2, 19 }, - { Norway, 0, 1700, 2, 19 }, - { Denmark, 0, 1700, 2, 19 }, - { Great Britain, 0, 1752, 9, 3 }, - { England, 0, 1752, 9, 3 }, - { America, 0, 1752, 9, 3 }, - { Sweden, 0, 1753, 2, 18 }, - { Finland, 0, 1753, 2, 18 }, - { Japan, 0, 1872, 12, 20 }, - { China, 0, 1911, 11, 7 }, - { Bulgaria, 0, 1916, 4, 1 }, - { U.S.S.R., 0, 1918, 2, 1 }, - { Serbia, 0, 1919, 1, 19 }, - { Romania, 0, 1919, 1, 19 }, - { Greece, 0, 1924, 3, 10 }, - { Turkey, 0, 1925, 12, 19 }, - { Egypt, 0, 1928, 9, 18 }, - { NULL, 0,0, 0, 0 }, + { DEFAULT, 0, 1752, 9, 3, 0, 0 }, + { Italy, 1, 1582, 10, 5, 0, 0 }, + { Spain, 1, 1582, 10, 5, 0, 0 }, + { Portugal, 1, 1582, 10, 5, 0, 0 }, + { Poland, 1, 1582, 10, 5, 0, 0 }, + { France, 2, 1582, 12, 10, 0, 0 }, + { Luxembourg, 2, 1582, 12, 22, 0, 0 }, + { Netherlands, 2, 1582, 12, 22, 0, 0 }, + { Bavaria, 0, 1583, 10, 6, 0, 0 }, + { Austria, 2, 1584, 1, 7, 0, 0 }, + { Switzerland, 2, 1584, 1, 12, 0, 0 }, + { Hungary, 0, 1587, 10, 22, 0, 0 }, + { Germany, 0, 1700, 2, 19, 0, 0 }, + { Norway, 0, 1700, 2, 19, 0, 0 }, + { Denmark, 0, 1700, 2, 19, 0, 0 }, + { Great Britain, 0, 1752, 9, 3, 0, 0 }, + { England, 0, 1752, 9, 3, 0, 0 }, + { America, 0, 1752, 9, 3, 0, 0 }, + { Sweden, 0, 1753, 2, 18, 0, 0 }, + { Finland, 0, 1753, 2, 18, 0, 0 }, + { Japan, 0, 1872, 12, 20, 0, 0 }, + { China, 0, 1911, 11, 7, 0, 0 }, + { Bulgaria, 0, 1916, 4, 1, 0, 0 }, + { U.S.S.R., 0, 1918, 2, 1, 0, 0 }, + { Serbia, 0, 1919, 1, 19, 0, 0 }, + { Romania, 0, 1919, 1, 19, 0, 0 }, + { Greece, 0, 1924, 3, 10, 0, 0 }, + { Turkey, 0, 1925, 12, 19, 0, 0 }, + { Egypt, 0, 1928, 9, 18, 0, 0 }, + { NULL, 0,0, 0, 0, 0, 0 }, }; int julian; @@ -205,7 +205,7 @@ void gregorian_reform(const char *); void reform_day_array(int, int, int *, int *, int *,int *,int *,int *); int ascii_day(char *, int); -void center(char *, int, int); +void center(const char *, int, int); void day_array(int, int, int *); int day_in_week(int, int, int); int day_in_year(int, int, int); @@ -559,7 +559,7 @@ { int display, val, rc; char *b; - static char *aday[] = { + static const char *aday[] = { , 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, @@ -643,7 +643,7 @@ } void -center(char *str, int len, int separate) +center(const char *str, int len, int separate) { len -= strlen(str); @@ -863,7 +863,7 @@ int getnum(const char *p) { - long result; + unsigned long result; char *ep; errno = 0; @@ -887,6 +887,7 @@ { static char control[128]; char cap[1024]; + const char *term; char *tc; hilite++; @@ -894,10 +895,10 @@ if (!isatty(fileno(stdout))) return; - tc = getenv(TERM); - if (tc == NULL) - tc = dumb; - if (tgetent(cap[0], tc) != 1) + term = getenv(TERM); + if (term == NULL) + term = dumb; + if (tgetent(cap[0], term) != 1) return; tc = control[0];