unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Filename hashing in 'comp-el-to-eln-rel-filename'
@ 2021-09-25 14:08 Eli Zaretskii
  0 siblings, 0 replies; only message in thread
From: Eli Zaretskii @ 2021-09-25 14:08 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: emacs-devel

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?



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-25 14:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25 14:08 Filename hashing in 'comp-el-to-eln-rel-filename' Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).