Subject: Re: bug#2435: Bug 2435

From: Kenichi Handa <[email-masked]>
Date: Fri, 06 Mar 2009 13:48:40 +0900

In article <[email-masked]>, Chong Yidong <[email-masked]> writes:

> Kenichi Handa <[email-masked]> writes:
> > We should take care of re_search_2 and re_match_2_internal
> > too.
> >
> > If the problem is only the call of openp in
> > load_charset_map_from_file, and building various Lisp object
> > is ok, we can change load_charset_map_from_file to open a
> > charset map by itself without using openp.

> Not using openp would be troublesome.  How about binding
> file-name-handler-alist to nil inside load_charset_map_from_file?  That
> prevents find-file-name-handler from performing the regexp compilation
> and string search.

That's a good idea if "building various Lisp object is ok"
is true.  

Stefan, what do you think?

---
Kenichi Handa
[email-masked]

*** charset.c.~1.169.~	2009-01-30 21:29:36.000000000 +0900
--- charset.c	2009-03-06 13:44:24.000000000 +0900
***************
*** 494,499 ****
--- 494,509 ----
  
  extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object));
  
+ extern Lisp_Object Vfile_name_handler_alist;
+ 
+ static Lisp_Object
+ load_charset_map_from_file_restore (arg)
+      Lisp_Object arg;
+ {
+   Vfile_name_handler_alist = arg;
+   return Qnil;
+ }
+ 
  static void
  load_charset_map_from_file (charset, mapfile, control_flag)
       struct charset *charset;
***************
*** 508,518 ****
--- 518,533 ----
    Lisp_Object suffixes;
    struct charset_map_entries *head, *entries;
    int n_entries;
+   int count = SPECPDL_INDEX ();
  
    suffixes = Fcons (build_string (".map"),
  		    Fcons (build_string (".TXT"), Qnil));
  
+   record_unwind_protect (load_charset_map_from_file_restore,
+ 			 Vfile_name_handler_alist);
+   Vfile_name_handler_alist = Qnil;
    fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil);
+   unbind_to (count, Qnil);
    if (fd < 0
        || ! (fp = fdopen (fd, "r")))
      {