Date: Sat, 12 Dec 2020 11:51:29 +0000 (UTC) From: =?UTF-8?Q?Stefan_E=c3=9fer?= <se@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368578 - head/usr.bin/calendar Message-ID: <202012121151.0BCBpTlV019480@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: se Date: Sat Dec 12 11:51:29 2020 New Revision: 368578 URL: https://svnweb.freebsd.org/changeset/base/368578 Log: Use getlocalbase() instead of compiled in LOCALBASE to locate calendars Modified: head/usr.bin/calendar/io.c head/usr.bin/calendar/pathnames.h Modified: head/usr.bin/calendar/io.c ============================================================================== --- head/usr.bin/calendar/io.c Sat Dec 12 11:23:52 2020 (r368577) +++ head/usr.bin/calendar/io.c Sat Dec 12 11:51:29 2020 (r368578) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <err.h> #include <errno.h> +#include <libutil.h> #include <locale.h> #include <pwd.h> #include <stdbool.h> @@ -121,6 +122,7 @@ cal_fopen(const char *file) unsigned int i; struct stat sb; static bool warned = false; + char calendarhome[MAXPATHLEN]; if (home == NULL || *home == '\0') { warnx("Cannot get home directory"); @@ -133,12 +135,16 @@ cal_fopen(const char *file) } for (i = 0; i < nitems(calendarHomes); i++) { - if (chdir(calendarHomes[i]) != 0) + if (snprintf(calendarhome, sizeof (calendarhome), calendarHomes[i], + getlocalbase()) >= (int)sizeof (calendarhome)) continue; + if (chdir(calendarhome) != 0) + continue; + if ((fp = fopen(file, "r")) != NULL) { cal_home = home; - cal_dir = calendarHomes[i]; + cal_dir = calendarhome; cal_file = file; return (fp); } Modified: head/usr.bin/calendar/pathnames.h ============================================================================== --- head/usr.bin/calendar/pathnames.h Sat Dec 12 11:23:52 2020 (r368577) +++ head/usr.bin/calendar/pathnames.h Sat Dec 12 11:51:29 2020 (r368578) @@ -35,4 +35,4 @@ #include <paths.h> #define _PATH_INCLUDE "/usr/share/calendar" -#define _PATH_INCLUDE_LOCAL _PATH_LOCALBASE "/share/calendar" +#define _PATH_INCLUDE_LOCAL "%s/share/calendar"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012121151.0BCBpTlV019480>