Re: cal: add option to highlight the current day

[email protected]
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
Le Fri, Jul 03, 2026 at 04:37:29PM +0000, Johannes Thyssen Tishman a écrit :
> Please find below a patch to add an option (-h) to cal to allow
> highlighting the current day.
> 
> For testing purposes, the -h flag takes an optional argument specifying
> the date to highlight, e.g., cal -h2026-10-10 oct. I intend to remove
> this before committing if the patch is accepted.
> 
> The highlight_day function was mostly taken from FreeBSD[1]. Their
> implementation falls back to underlining the date (IIUC) if the terminal
> has no standout mode. I decided to leave this out for now and simply
> ignore the -h flag in this case.
> 
> To test this and check for regressions, I used the attached script. The
> script tests the in-tree patched cal against the unpatched installed
> one. It probably doesn't cover all scenarios, but hopefully enough.  In
> fact, it is probably a little excessive, as it tests every day of 28
> years, hehe. There's probably a smarter way to do this.
> 
> Lastly, I'm not super confident in my C skills yet so please don't hold
> back on your feedback. I've added some comments with questions in parts
> I'm not so sure about. I'd be grateful for any input on these.

i wont be able to comment on the code itself but the feature works and
is much welcome.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.