summaryrefslogtreecommitdiff
path: root/system/less/search-path-lesskey-file.patch
blob: 4223769301d3dd0f469a48b518414369af2f098b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From d3edebf528da8a9e15d6be518c24e90462a28698 Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Tue, 19 Oct 2021 14:24:04 -0700
Subject: [PATCH] Add $HOME/.config to possible locations of lesskey file.

---
 NEWS         |  4 ++++
 decode.c     | 13 ++++++++++++-
 less.nro.VER |  2 +-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/decode.c b/decode.c
index e1a55198..2eb480fa 100644
--- a/decode.c
+++ b/decode.c
@@ -952,9 +952,20 @@ add_hometable(call_lesskey, envname, def_filename, sysvar)
 		filename = save(def_filename);
 	else /* def_filename is just basename */
 	{
+		/* Remove first char (normally a dot) unless stored in $HOME. */
 		char *xdg = lgetenv("XDG_CONFIG_HOME");
 		if (!isnullenv(xdg))
-			filename = dirfile(xdg, def_filename+1, 1);
+			filename = dirfile(xdg, &def_filename[1], 1);
+		if (filename == NULL)
+		{
+			char *home = lgetenv("HOME");
+			if (!isnullenv(home))
+			{
+				char *cfg_dir = dirfile(home, ".config", 0);
+				filename = dirfile(cfg_dir, &def_filename[1], 1);
+				free(cfg_dir);
+			}
+		}
 		if (filename == NULL)
 			filename = homefile(def_filename);
 	}