sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 8fc4858a3c3245d4a59cbb65ca5361dc138eb6e5
parent b10b1da57d4d573647d1a528efaecfc54dea8073
Author: Jesse Ogle <jesse.p.ogle@gmail.com>
Date:   Wed Jun 19 16:57:03 -0400

Bugfix for cal when columns specified as 0

cal -c 0 caused an infinite loop. now the number of columns is set to
the number of months when 0 (i.e. the calendars never wrap).

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
cal.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cal.c b/cal.c @@ -28,6 +28,8 @@ drawcal(int year, int month, int day, int ncols, int nmons, int fday) int row = 0; char *days[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", }; + if(!ncols) + ncols = nmons; while(nmons > 0) { last = MIN(nmons, ncols); for(i = 0; i < last; i++) { @@ -179,8 +181,8 @@ main(int argc, char *argv[]) usage(); } - if(ncols < 0 || ncols > MONTHMAX || month < 1 || month > 12 \ - || nmons < 1 || fday < 0 || fday > 6) { + if(ncols < 0 || month < 1 || month > 12 || nmons < 1 \ + || nmons > MONTHMAX || fday < 0 || fday > 6) { usage(); }