git: 65e9eb07012a - main - Look in getlocalbase() for the calendar-data package data

From: David E. O'Brien <obrien_at_FreeBSD.org>
Date: Mon, 13 Mar 2023 01:43:42 UTC
The branch main has been updated by obrien:

URL: https://cgit.FreeBSD.org/src/commit/?id=65e9eb07012a0bf2d6940175c98fb463d169c984

commit 65e9eb07012a0bf2d6940175c98fb463d169c984
Author:     David E. O'Brien <obrien@FreeBSD.org>
AuthorDate: 2023-03-08 03:51:27 +0000
Commit:     David E. O'Brien <obrien@FreeBSD.org>
CommitDate: 2023-03-13 01:40:07 +0000

    Look in getlocalbase() for the calendar-data package data
    
    Fix d20d6550187a95a78bb532909aad8ef7ac62be66 where getlocalbase()
    wasn't used to fill out the printf(3) format of _PATH_INCLUDE_LOCAL.
    
    Differential Revision:  https://reviews.freebsd.org/D38975
    Reviewed by:    imp
---
 usr.bin/calendar/io.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 5afcb1a33314..5a77455d0ff6 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -151,9 +151,12 @@ cal_fopen(const char *file)
 	}
 
 	warnx("can't open calendar file \"%s\"", file);
-	if (!warned && stat(_PATH_INCLUDE_LOCAL, &sb) != 0) {
-		warnx("calendar data files now provided by calendar-data pkg.");
-		warned = true;
+	if (!warned) {
+		snprintf(path, sizeof(path), _PATH_INCLUDE_LOCAL, getlocalbase());
+		if (stat(path, &sb) != 0) {
+			warnx("calendar data files now provided by calendar-data pkg.");
+			warned = true;
+		}
 	}
 
 	return (NULL);