> On Aug 28, 2024, at 5:33 AM, Eli Zaretskii wrote: > >> From: Yuan Fu >> Date: Tue, 27 Aug 2024 22:36:46 -0700 >> Cc: Stefan Kangas , >> Alan Mackenzie , >> 64830@debbugs.gnu.org >> >> +struct treesit_loaded_lang >> +{ >> + /* The language object. */ >> + TSLanguage *lang; >> + /* The path of the shared library. */ >> + const char *path; > > Gnu Coding Standard frowns on using "path" for anything except > PATH-style directory lists. Please use "filename" or "fname" or > something like that instead. > >> + Dl_info info; >> + if (dladdr(langfn, &info)) >> + loaded_lang.path = info.dli_fname; > > dladdr is non-portable. We have dynlib_addr instead, and since > treesit.c correctly uses dynlib.c functions already, using dynlib_addr > is only natural. > >> + if (!lang.lang || !lang.path) return Qnil; >> + >> + return build_string (lang.path); > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > I think we should do > > return > DECODE_FILE (make_unibyte_string (lang.filename, strlen (lang.filename)); > > instead, because dynlib_addr (and dladdr as well) return encoded file > names. Ah, thanks for the review! TIL. Here’s the revised patch. Yuan