diff options
author | kvik <kvik@a-b.xyz> | 2021-06-19 12:00:52 +0000 |
---|---|---|
committer | kvik <kvik@a-b.xyz> | 2021-06-19 12:00:52 +0000 |
commit | 5e098228acee982a11484fc5f5b3d127a521dfdd (patch) | |
tree | f829b34082c4a47ab9d4dbbbb5d82e84eacc6fec | |
parent | b3215c807556cdaaa0f949f1fb3f97c484ffd1da (diff) | |
download | plan9front-5e098228acee982a11484fc5f5b3d127a521dfdd.tar.xz |
cal: fix days of week alignment for year view (thanks igor@9lab.org)
term% cal -s1 2021
2021
Jan Feb Mar
M Tu W Th F Sa Su M Tu W Th F Sa Su M Tu W Th F Sa Su
1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7
4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14
11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21
18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28
25 26 27 28 29 30 31 29 30 31
…
Note how the days (i.e. ' M Tu W Th F Sa Su') for Feb and Mar
do not align with the day numbers.
This is because an extra space is left *before* adding the terminating
'\0' via the pointer `dayw`.
With the patch applied the calendar aligns nicely for the year view:
term% cal -s1 2021
2021
Jan Feb Mar
M Tu W Th F Sa Su M Tu W Th F Sa Su M Tu W Th F Sa Su
1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7
4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14
11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21
18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28
25 26 27 28 29 30 31 29 30 31
…
-rw-r--r-- | sys/src/cmd/cal.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/cmd/cal.c b/sys/src/cmd/cal.c index cb70a243a..e14f41bc1 100644 --- a/sys/src/cmd/cal.c +++ b/sys/src/cmd/cal.c @@ -60,7 +60,7 @@ main(int argc, char *argv[]) Binit(&bout, 1, OWRITE); dayw = dayws + 3*wstart; - dayw[3*7] = '\0'; + dayw[(3*7)-1] = '\0'; /* * no arg, print current month |