Subject: bug#36502: Fwd: bug#36502: 27.0.50; infinite loop in file-name-case-insensitive-p

From: Ken Brown <[email-masked]>
Date: Mon, 8 Jul 2019 15:17:06 +0000

On 7/8/2019 9:59 AM, Eli Zaretskii wrote:
>> From: Ken Brown <[email-masked]>
>> CC: "[email-masked]" <[email-masked]>, "[email-masked]"
>> 	<[email-masked]>, "[email-masked]" <[email-masked]>
>> Date: Mon, 8 Jul 2019 13:36:38 +0000
>>
>>>>       if (NILP (default_directory))
>>>> -    default_directory = BVAR (current_buffer, directory);
>>>> +    {
>>>> +      default_directory = BVAR (current_buffer, directory);
>>>> +      if (NILP (Ffile_name_absolute_p (default_directory)))
>>>> +       default_directory = Qnil;
>>>> +    }
>>>
>>> Hmm... why nullify it?  Why not simply call expand-file-name
>>> recursively?
>>
>> If the current buffer's default-directory is not absolute, then that variable is
>> invalid and we can't use it.
> 
> I'm asking why not do this instead:
> 
>    if (NILP (default_directory))
>      {
>        default_directory = BVAR (current_buffer, directory);
>        if (NILP (Ffile_name_absolute_p (default_directory)))
>          default_directory = Fexpand_file_name (default_directory,
> 	                                       Vinvocation_directory);
>      }

Oh, I see.  I misunderstood what you were suggesting.

> Or will the above not work for some reason?

I think something like this should work, with some care.  First, 
invocation-directory might be nil, so we have to avoid an infinite loop in that 
case.  Second, the code in emacs.c that sets Vinvocation_directory calls 
Fexpand_file_name in some cases, so there's another potential infinite loop 
resulting from that.

I'll see what I can come up with, also taking Andreas's comment into account.

Ken