emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Filename hashing in 'comp-el-to-eln-rel-filename'


From: Eli Zaretskii
Subject: Filename hashing in 'comp-el-to-eln-rel-filename'
Date: Sat, 25 Sep 2021 17:08:12 +0300

Andrea,

I'm looking at the code which computes the .eln file name, which
includes 2 hash values.  The first hash value is computed from the
name of the .el file, after some processing which is meant to remove
the installation directory from it, to allow for "make install" that
copies the *.eln files into a different place.

Here's the code which does that:

  if (NILP (loadsearch_re_list))
    {
      Lisp_Object sys_re =
        concat2 (build_string ("\\`[[:ascii:]]+"),
                 Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/")));
      Lisp_Object dump_load_search =
        Fexpand_file_name (build_string (PATH_DUMPLOADSEARCH "/"), Qnil);
#ifdef WINDOWSNT
      dump_load_search = Fw32_long_file_name (dump_load_search);
#endif
      loadsearch_re_list = list2 (sys_re, Fregexp_quote (dump_load_search));
    }

  Lisp_Object lds_re_tail = loadsearch_re_list;
  FOR_EACH_TAIL (lds_re_tail)
    {
      Lisp_Object match_idx =
        Fstring_match (XCAR (lds_re_tail), filename, Qnil);
      if (EQ (match_idx, make_fixnum (0)))
        {
          filename =
            Freplace_match (build_string ("//"), Qt, Qt, filename, Qnil);
          break;
        }
    }

The loadsearch_re_list is a list of 2 file-name patterns.  The second
member of the list is just the absolute file name of the original
'lisp' directory in the source tree where Emacs was built.  But the
first member is a regular expression like this:

  "\\`[[:ascii:]]+/28\\.0\\.50/lisp/"

The code above then looks for a match of either the second or the
first member, and if found, replaces the match with "//"; the
resulting file name with part of it replaced with "//" will be hashed.
But the match is expected to start at the beginning of the file name,
and the regexp above is anchored.  However, file names don't
necessarily begin with an all-ASCII sequence; some of the leading
directories could include non-ASCII characters.  In which case, AFAIU
the regexp will fail to match, and the .eln file will not be loaded,
because Emacs will think it doesn't match the source .el file.

Should we replace [[:ascii:]] with something more permissive, like
[[:print:]], to support installation into non-ASCII directories?

Or am I missing something?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]