Subject: Re: bug#64830: 30.0.50 C++ treesitter mode no coloration

From: Eli Zaretskii <[email-masked]>
Date: Wed, 28 Aug 2024 15:33:28 +0300

> From: Yuan Fu <[email-masked]>
> Date: Tue, 27 Aug 2024 22:36:46 -0700
> Cc: Stefan Kangas <[email-masked]>,
>  Alan Mackenzie <[email-masked]>,
>  [email-masked]
> 
> +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.