GNU bug report logs - #6299
In read-file-name: (args-out-of-range "c:" 0 3)

Previous Next

Package: emacs;

Reported by: Lennart Borgman <lennart.borgman <at> gmail.com>

Date: Sat, 29 May 2010 01:36:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 6299 <at> debbugs.gnu.org
Subject: bug#6299: In read-file-name: (args-out-of-range "c:" 0 3)
Date: Sun, 30 May 2010 15:39:00 +0200
On Sun, May 30, 2010 at 2:10 AM, Lennart Borgman
<lennart.borgman <at> gmail.com> wrote:
> On Sun, May 30, 2010 at 1:29 AM, Stefan Monnier
> <monnier <at> iro.umontreal.ca> wrote:
>>> BOUNDARIES string="c:" table=read-file-name-internal pred=file-exists-p suffix=""
>>> BOUNDARIES boundaries=(boundaries 3)
>>
>> This appears to be the problem.
>>
>>  (read-file-name-internal "c:" nil '(boundaries . ""))
>>
>> seems to return (boundaries 3 . 0).
>> Since the code that does that is most likely the one in
>> completion--file-name-table which does:
>>
>>    (let ((start (length (file-name-directory string)))
>>          (end (string-match-p "/" (cdr action))))
>>      (list* 'boundaries start end)))
>>
>> my guess is that (file-name-directory "c:") return "c:/".
>
> Yes, that is the case, it returns "c:/".
>
> But I think that is can't return something. However in my opinion it
> should return an error because "c:" is not a file path. It is just a
> device. It it signaled an error code that tries something like this
> would be more easily found and cured.
>
> So I think the problem is that (file-name-directory "c:") is called.
> There must be some bad assumption somewhere in the code behind that.
>
>
> Another suggestion that might help cleaning the code logic in
> different places: Add a function directory-root-p
>
> w32: (directory-root-p "c:/") => t
> *nix: (directory-root-p "/") => t
>
> w32: (directory-root-p "/") => nil (or signal error, but that would
> fit badly with file-directory-p)
> *nix: (directory-root-p "c;/") => nil -"-


I am looking around at the code a bit. I do not understand the comment
in completion--file-name-table:

  (cond
   ((eq (car-safe action) 'boundaries)
    ;; For the boundaries, we can't really delegate to
    ;; completion-file-name-table and then fix them up, because it
    ;; would require us to track the relationship between `str' and
    ;; `string', which is difficult.  And in any case, if
    ;; substitute-in-file-name turns "fo-$TO-ba" into "fo-o/b-ba", there's
    ;; no way for us to return proper boundaries info, because the
    ;; boundary is not (yet) in `string'.

AFAICS it is doing exactly the same as completion-file-name-table
here. What am I missing?

BTW the doc string for action in completing read etc should be fixed.


>> I guess we should just use (or (string-match "[^/]*\\'" string) 0)
>> instead of (length (file-name-directory string)) but it has N^2
>> complexity :-(
>>
>>
>>        Stefan
>>
>




This bug report was last modified 15 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.