Subject: bug#7112: closed (Re: 24.0.50; [PATCH] `ls-lisp-insert-directory' should be no-op for empty FILE)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 02 Aug 2011 21:34:01 +0000

Your bug report

#7112: 24.0.50; [PATCH] `ls-lisp-insert-directory' should be no-op for empty FILE

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
7112: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7112
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: 24.0.50; [PATCH] `ls-lisp-insert-directory' should be no-op for empty FILE
From: Lars Magne Ingebrigtsen <[email-masked]>
To: Drew Adams <[email-masked]>
Cc: [email-masked]
Date: Tue, 02 Aug 2011 23:32:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Drew Adams <[email-masked]> writes:

> `ls-lisp-insert-directory' should not raise a low-level, Args out of
> range error.  It should itself DTRT for an empty file name.

Which is to give an error.  It's a nonsensical input.

>> > Why not try it yourself, using the emacs -Q recipe:
>> >
>> > M-: (dired '("foobar" "111.el" ""))
>> 
>> Why would you call this function with an empty string as a parameter?
>
> Because you can?  No experienced programmer takes refuge behind the argument
> "Why would anyone ever do that?" or "Don't worry; no one would ever do that."

It gives an error.  If you call `dired' with `t', you get

Debugger entered--Lisp error: (wrong-type-argument stringp t)
  file-name-as-directory(t)
  dired-noselect(t nil)

Don't do that, then.  I'm closing this report.
-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/

Subject: 24.0.50; [PATCH] `ls-lisp-insert-directory' should be no-op for empty FILE
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Sun, 26 Sep 2010 17:21:58 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

You can call `dired' passing a cons arg that includes a list of file
names.  An empty file name causes this ugly error: 
 
(error "Args out of range: \"\", -1")
 
The reason is the following code near the end of
`ls-lisp-insert-directory':
 
;; If not full-directory-p, FILE *must not* end in /, as
;; file-attributes will not recognize a symlink to a directory,
;; so must make it a relative filename as ls does:
(if (file-name-absolute-p file) (setq file (expand-file-name file)))
(if (eq (aref file (1- (length file))) ?/)
    (setq file (substring file 0 -1)))
 
`ls-lisp-insert-directory' should in fact do nothing at all (no-op) if
FILE is "".  The entire body should be wrapped in this:
 
(when (> (length file) 0)
  ...)

In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2010-09-20 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4) --no-opt --cflags
-Ic:/imagesupport/include'