Subject: Re: 23.0.60; directory-files unexpectedly non-nil

From: Chong Yidong <[email-masked]>
Date: Sun, 07 Dec 2008 09:11:36 -0500

Markus Triska <[email-masked]> writes:

> Chong Yidong <[email-masked]> writes:
>
>> compiled regexp gets corrupted).  I've changed it so that
>> inhibit-modification-hooks is disabled in the code conversion buffer.
>
> Thank you; an unfortunate consequence is that modifications of the code
> conversion buffer can now no longer be traced by after-change-functions;
> I'm trying to trace down a different problem (#1125), and would like to
> log buffer modifications as completely as possible. Is there a better
> fix for this problem, i.e., can the regexp be preserved differently?

In general, I think we don't want to let user code run during code
conversion, because there may be other situations like this.

For the purposes of your bug tracking, try reverting the change I made,
and changing directory_files_internal so that it recompiles the regexp
after each call to DECODE_FILE:

*** trunk/src/dired.c.~1.157.~	2008-11-10 14:07:49.000000000 -0500
--- trunk/src/dired.c	2008-12-07 09:07:19.000000000 -0500
***************
*** 153,176 ****
    GCPRO5 (match, directory, list, dirfilename, encoded_directory);
    dirfilename = Fdirectory_file_name (directory);
  
-   if (!NILP (match))
-     {
-       CHECK_STRING (match);
- 
-       /* MATCH might be a flawed regular expression.  Rather than
- 	 catching and signaling our own errors, we just call
- 	 compile_pattern to do the work for us.  */
-       /* Pass 1 for the MULTIBYTE arg
- 	 because we do make multibyte strings if the contents warrant.  */
- # ifdef WINDOWSNT
-       /* Windows users want case-insensitive wildcards.  */
-       bufp = compile_pattern (match, 0,
- 			      buffer_defaults.case_canon_table, 0, 1);
- # else	/* !WINDOWSNT */
-       bufp = compile_pattern (match, 0, Qnil, 0, 1);
- # endif	 /* !WINDOWSNT */
-     }
- 
    /* Note: ENCODE_FILE and DECODE_FILE can GC because they can run
       run_pre_post_conversion_on_str which calls Lisp directly and
       indirectly.  */
--- 153,158 ----
***************
*** 179,187 ****
    encoded_directory = (STRING_MULTIBYTE (directory)
  		       ? ENCODE_FILE (directory) : directory);
  
-   /* Now *bufp is the compiled form of MATCH; don't call anything
-      which might compile a new regexp until we're done with the loop!  */
- 
    BLOCK_INPUT;
    d = opendir (SDATA (dirfilename));
    UNBLOCK_INPUT;
--- 161,166 ----
***************
*** 242,247 ****
--- 221,237 ----
  	  immediate_quit = 1;
  	  QUIT;
  
+ 	  if (!NILP (match))
+ 	    {
+ 	      CHECK_STRING (match);
+ # ifdef WINDOWSNT
+ 	      bufp = compile_pattern (match, 0,
+ 				      buffer_defaults.case_canon_table, 0, 1);
+ # else	/* !WINDOWSNT */
+ 	      bufp = compile_pattern (match, 0, Qnil, 0, 1);
+ # endif	 /* !WINDOWSNT */
+ 	    }
+ 
  	  if (NILP (match)
  	      || (0 <= re_search (bufp, SDATA (name), len, 0, len, 0)))
  	    wanted = 1;