Skip to content

Commit 599434a

Browse files
committed
[terminfo] add default dirs
1 parent 702d2a6 commit 599434a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/third-party/notcurses/src/lib/terminfo.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
const char*
1414
terminfo_find_path_for_term(const char* term_name)
1515
{
16+
static const char* DEFAULT_DIRS[] = {
17+
"/usr/share/terminfo/",
18+
"/lib/terminfo/",
19+
"/usr/lib/terminfo/",
20+
"/etc/terminfo/",
21+
NULL,
22+
};
23+
1624
if (!term_name || !term_name[0]) {
1725
return NULL;
1826
}
@@ -53,6 +61,18 @@ terminfo_find_path_for_term(const char* term_name)
5361
dirs = next_colon + 1;
5462
}
5563

64+
for (int lpc = 0; DEFAULT_DIRS[lpc]; lpc++) {
65+
snprintf(path,
66+
sizeof(path),
67+
"%s/%02x/%s",
68+
DEFAULT_DIRS[lpc],
69+
term_name[0],
70+
term_name);
71+
if (access(path, R_OK) == 0) {
72+
return strdup(path);
73+
}
74+
}
75+
5676
return NULL;
5777
}
5878

0 commit comments

Comments
 (0)