From nobody Thu Dec 12 07:23:24 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y83q118NBz5h7yS; Thu, 12 Dec 2024 07:23:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y83q10h42z4sR4; Thu, 12 Dec 2024 07:23:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733988205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TyQeXM9eh2kM8l81fpGmUf9+cDmeUykj4irHXjO0U5E=; b=PVPyiq8MFad9LZ7fHie8MMwv2/SaQ1DKKeygu2B2sgC95E7VqfE+iMUuJozbjBH9g+wMgX 5ZHzCfoXnm65aRKjJt1Smpx04NDtCOv36L4V4YsapZLmnBF/ATUZ1IARQnWMYXS3Kwa9z+ o4uUMlqa7/7RJXlSLoG4hWhAI7+/Rqx6L7Hs397npXY8ev4BT5wdO0FbD3T9boh/9HL6q8 hPdQLJzNDRw3fhu/thYBDMbRxIAuJw/avR7XNgdduF1XO/MBiGNLUNC6kgXW7XYH9lLHjz bu2EdemytjClzFF/7ziEn4/YUlV0Gy23gagiDNfihDSxZM98GXBhXqittmmFlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733988205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TyQeXM9eh2kM8l81fpGmUf9+cDmeUykj4irHXjO0U5E=; b=LFGrINOWUotGSlNpyTZ/Nu1Q4LhVBWd27vNmxjgWft8DAvS1qAHd8Bm3QNrRGd3gPlj6Cc 6oW9eNRCFKAwMJUYOVHDD2Huhgf3/DtvlpscCb/VO6Qs1Lo5qleMZ8RG4BWMH7/LUTh5r8 43i7bY8zaxGn1Sp0xslqQh9423zsqbYruPAj+9LH0vj/ufNInnHWfItHEKjqbqUs05y9o5 q0SJLbkz72o7GhQEJ0HeYlA7I5o9LZw8WL5QNI5aKNZ5HMhpajdM71sibs+E0ZSUIytuiO /Z5c0P2ctLfSWLj+/KOZi+0hsOXYJpwIgnPJORHt7s8KmKpXlh+tbg5kY6tbsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733988205; a=rsa-sha256; cv=none; b=VgcFo+U1/S0smox622WWL1j1oysjxTsfJKRzMi4jmlqRFIzjTXWsRS/vqZnewFv8RAFAgA kBwVtQYUDWDMji3iwqye0jlc/uDgQq63kSziepiHMd8i5wA4JSq9MP64xjIoasmobHO5oL KW5kN9440p9xz0dTRLifFtdCZHAnizT1LbbUHeNEryzovt3lJOK7veashpb6cIBETRsCkt VtYcXu/DYVWkvGYGKhOaM/Be3XhQ53h0LifdE/Nibz1MHBCvieA3gQ18UK7+UJWcLz4qwM MSrNBdvg7NJBN807aKk8dssNU4l68S5/xFkRaUPtBMzej0MnwMonIhbSyYhJ2w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Y83q1018tzjtR; Thu, 12 Dec 2024 07:23:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BC7NOqi079032; Thu, 12 Dec 2024 07:23:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BC7NOCt079029; Thu, 12 Dec 2024 07:23:24 GMT (envelope-from git) Date: Thu, 12 Dec 2024 07:23:24 GMT Message-Id: <202412120723.4BC7NOCt079029@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 49224311fe6d - main - ncal: make -h toggle highlighting of today. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 49224311fe6d850e5c25a7e79328c87029df6be8 Auto-Submitted: auto-generated The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=49224311fe6d850e5c25a7e79328c87029df6be8 commit 49224311fe6d850e5c25a7e79328c87029df6be8 Author: Poul-Henning Kamp AuthorDate: 2024-12-12 07:22:14 +0000 Commit: Poul-Henning Kamp CommitDate: 2024-12-12 07:22:14 +0000 ncal: make -h toggle highlighting of today. --- usr.bin/ncal/ncal.1 | 3 ++- usr.bin/ncal/ncal.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/usr.bin/ncal/ncal.1 b/usr.bin/ncal/ncal.1 index 8ece31b79cc1..2c7c82fd318e 100644 --- a/usr.bin/ncal/ncal.1 +++ b/usr.bin/ncal/ncal.1 @@ -79,7 +79,8 @@ the current month is displayed. The options are as follows: .Bl -tag -width indent .It Fl h -Turns off highlighting of today. +Toggle highlighting of today. +By default highlighting is enabled if stdout is a TTY. .It Fl J Display Julian Calendar, if combined with the .Fl e diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c index 2829caf8a6a0..dc50dd60bf0b 100644 --- a/usr.bin/ncal/ncal.c +++ b/usr.bin/ncal/ncal.c @@ -158,7 +158,7 @@ static char jdaystr[] = " 1 2 3 4 5 6 7 8 9" " 350 351 352 353 354 355 356 357 358 359" " 360 361 362 363 364 365 366"; -static int flag_nohighlight; /* user doesn't want a highlighted today */ +static int flag_highlight; /* highlighted today */ static int flag_weeks; /* user wants number of week */ static int nswitch; /* user defined switch date */ static int nswitchb; /* switch date for backward compatibility */ @@ -216,7 +216,7 @@ main(int argc, char *argv[]) int before, after; const char *locale; /* locale to get country code */ - flag_nohighlight = 0; + flag_highlight = isatty(STDOUT_FILENO); flag_weeks = 0; flag_monday = false; @@ -299,7 +299,7 @@ main(int argc, char *argv[]) flag_highlightdate = optarg; break; case 'h': - flag_nohighlight = 1; + flag_highlight = !flag_highlight; break; case 'e': if (flag_backward) @@ -834,8 +834,7 @@ mkmonthr(int y, int m, int jd_flag, struct monthlines *mlines) dt.d = j - jan1 + 1; else sdater(j, &dt); - if (j == highlightdate && !flag_nohighlight - && isatty(STDOUT_FILENO)) + if (j == highlightdate && flag_highlight) highlight(mlines->lines[i] + k, ds + dt.d * dw, dw, &l); else @@ -942,8 +941,7 @@ mkmonthb(int y, int m, int jd_flag, struct monthlines *mlines) dt.d = j - jan1 + 1; else sdateb(j, &dt); - if (j == highlightdate && !flag_nohighlight - && isatty(STDOUT_FILENO)) + if (j == highlightdate && flag_highlight) highlight(mlines->lines[i] + k, ds + dt.d * dw, dw, &l); else @@ -1143,7 +1141,7 @@ highlight(char *dst, char *src, int len, int *extralen) * This check is not necessary, should have been handled before calling * this function. */ - if (flag_nohighlight) { + if (!flag_highlight) { memcpy(dst, src, len); return; }