From 6c32ce3c61b6f369b4d0ac0dff3900e2bdd8cb52 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Fri, 15 Dec 2023 10:36:17 +0100 Subject: [PATCH] [gettext] Let it work also on Windows When elinks.exe is located in the src subdirectory, .gmo files are read from the po subdirectory. --- src/intl/gettext/loadmsgcat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intl/gettext/loadmsgcat.c b/src/intl/gettext/loadmsgcat.c index 3e32b738..d89f3770 100644 --- a/src/intl/gettext/loadmsgcat.c +++ b/src/intl/gettext/loadmsgcat.c @@ -216,8 +216,15 @@ _nl_free_domain_conv(struct loaded_domain *domain) static struct string * add_filename_to_string(struct string *str, struct loaded_l10nfile *domain_file) { - char *slash = strrchr(program.path, '/'); - size_t dirnamelen = (slash ? slash - program.path + 1 : 0); + char *sep; + size_t dirnamelen; + + for (sep = program.path + strlen((const char *)program.path); sep > program.path; sep--) { + if (dir_sep(sep[0])) { + break; + } + } + dirnamelen = (sep ? sep - program.path + 1 : 0); /* Check if elinks is being run from the source tree. */ if (dirnamelen < 4