From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.bugs Subject: bug#7112: 24.0.50; [PATCH] `ls-lisp-insert-directory' should be no-op for empty FILE Date: Wed, 13 Jul 2011 08:13:59 -0700 Message-ID: References: <68BA79A0F7304F01870834FE12F89A36@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1310574159 30292 80.91.229.12 (13 Jul 2011 16:22:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 13 Jul 2011 16:22:39 +0000 (UTC) Cc: 7112@debbugs.gnu.org To: "'Lars Magne Ingebrigtsen'" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 13 18:22:34 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qh2Co-0006YR-AQ for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2011 18:22:34 +0200 Original-Received: from localhost ([::1]:40256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qh2Cm-0007gb-V6 for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2011 12:22:33 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qh19W-0005hI-PG for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2011 11:15:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qh19T-0003LB-Nw for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2011 11:15:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qh19T-0003L7-EY for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2011 11:15:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Qh19S-0006fz-Hw; Wed, 13 Jul 2011 11:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Jul 2011 15:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7112 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 7112-submit@debbugs.gnu.org id=B7112.131057006025575 (code B ref 7112); Wed, 13 Jul 2011 15:15:02 +0000 Original-Received: (at 7112) by debbugs.gnu.org; 13 Jul 2011 15:14:20 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qh18k-0006eS-JJ for submit@debbugs.gnu.org; Wed, 13 Jul 2011 11:14:19 -0400 Original-Received: from rcsinet15.oracle.com ([148.87.113.117]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qh18h-0006eF-Ih for 7112@debbugs.gnu.org; Wed, 13 Jul 2011 11:14:16 -0400 Original-Received: from rtcsinet21.oracle.com (rtcsinet21.oracle.com [66.248.204.29]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p6DFE6gC026980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Jul 2011 15:14:09 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by rtcsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p6DFE56b012945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Jul 2011 15:14:06 GMT Original-Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p6DFDxxs015852; Wed, 13 Jul 2011 10:13:59 -0500 Original-Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Jul 2011 08:13:59 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: AcxBYmog2j+ZTje9Ry2Pr2pjskeW2QACwdVg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-Source-IP: rtcsinet21.oracle.com [66.248.204.29] X-CT-RefId: str=0001.0A090208.4E1DB641.00CC:SCFSTAT5015188, ss=1, re=-6.300, fgs=0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 13 Jul 2011 11:15:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:48867 Archived-At: > > 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': > > I think this should most likely be fixed in the caller (i.e., in > dired.el). What does that mean? dired.el is a file, not a caller. > What's the backtrace for this bug? Why not try it yourself, using the emacs -Q recipe: M-: (dired '("foobar" "111.el" "")) Anyway: Debugger entered--Lisp error: (args-out-of-range "" -1) aref("" -1) (eq (aref file (1- (length file))) 47) (if (eq (aref file (1- (length file))) 47) (setq file (substring file 0 -1))) (if (or wildcard-regexp full-directory-p) (let* ((dir (file-name-as-directory file)) (default-directory dir) (file-alist (directory-files-and-attributes dir nil wildcard-regexp t (if (memq 110 switches) (quote integer) (quote string)))) (sum 0) (max-uid-len 0) (max-gid-len 0) (max-file-size 0) total-line files elt short file-size attr fuid fgid uid-len gid-len) (cond ((memq 65 switches) (setq file-alist (ls-lisp-delete-matching "^\\.\\.?$" file-alist))) ((not (memq 97 switches)) (setq file-alist (ls-lisp-delete-matching "^\\." file-alist)))) (setq file-alist (ls-lisp-handle-switches file-alist switches)) (if (memq 67 switches) (ls-lisp-column-format file-alist) (setq total-line (cons (point) (car-safe file-alist))) (dolist (elt file-alist) (setq attr (cdr elt) fuid (nth 2 attr) uid-len (if (stringp fuid) (string-width fuid) (length (format "%d" fuid))) fgid (nth 3 attr) gid-len (if (stringp fgid) (string-width fgid) (length (format "%d" fgid))) file-size (nth 7 attr)) (if (> uid-len max-uid-len) (setq max-uid-len uid-len)) (if (> gid-len max-gid-len) (setq max-gid-len gid-len)) (if (> file-size max-file-size) (setq max-file-size file-size))) (setq ls-lisp-uid-d-fmt (format " %%-%dd" max-uid-len)) (setq ls-lisp-uid-s-fmt (format " %%-%ds" max-uid-len)) (setq ls-lisp-gid-d-fmt (format " %%-%dd" max-gid-len)) (setq ls-lisp-gid-s-fmt (format " %%-%ds" max-gid-len)) (setq ls-lisp-filesize-d-fmt (format " %%%dd" (if (memq 115 switches) (length (format "%.0f" ...)) (length (format "%.0f" max-file-size))))) (setq ls-lisp-filesize-f-fmt (format " %%%d.0f" (if (memq 115 switches) (length (format "%.0f" ...)) (length (format "%.0f" max-file-size))))) (setq files file-alist) (while files (setq elt (car files) files (cdr files) short (car elt) attr (cdr elt) file-size (nth 7 attr)) (and attr (setq sum (+ file-size (if ... sum ...))) (insert (ls-lisp-format short attr file-size switches time-index)))) (save-excursion (goto-char (car total-line)) (or (cdr total-line) (insert "(No match)\n")) (insert (format "total %.0f\n" (fceiling (/ sum 1024.0)))))) (if (memq 82 switches) (while file-alist (setq elt (car file-alist) file-alist (cdr file-alist)) (when (and (eq (cadr elt) t) (not (string-match "\\`\\.\\.?/?\\'" ...))) (setq elt (expand-file-name (car elt) dir)) (insert "\n" elt ":\n") (ls-lisp-insert-directory elt switches time-index wildcard-regexp full-directory-p))))) (if (file-name-absolute-p file) (setq file (expand-file-name file))) (if (eq (aref file (1- (length file))) 47) (setq file (substring file 0 -1))) (let ((fattr (file-attributes file (quote string)))) (if fattr (insert (ls-lisp-format (if (memq 70 switches) (ls-lisp-classify-file file fattr) file) fattr (nth 7 fattr) switches time-index)) (message "%s: doesn't exist or is inaccessible" file) (ding) (sit-for 2)))) ls-lisp-insert-directory("" (97 108) nil nil nil) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp (if (memq 66 switches) "[^~]\\'") file (file-relative-name orig-file)) (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) nil full-directory-p)) (signal (car err) (cdr err))))) (if handler (funcall handler (quote insert-directory) file switches wildcard full-directory-p) (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) (setq switches (delete 32 (delete 45 (append switches nil)))) (if (and ls-lisp-support-shell-wildcards (string-match "[[?*]" file) (not (file-exists-p file))) (progn (or (not (eq (aref file (1- ...)) 47)) (setq file (substring file 0 (1- (length file))))) (setq wildcard t))) (if wildcard (setq wildcard-regexp (if ls-lisp-support-shell-wildcards (wildcard-to-regexp (file-name-nondirectory file)) (file-name-nondirectory file)) file (file-name-directory file)) (if (memq 66 switches) (setq wildcard-regexp "[^~]\\'"))) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp (if (memq 66 switches) "[^~]\\'") file (file-relative-name orig-file)) (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) nil full-directory-p)) (signal (car err) (cdr err))))) (save-excursion (goto-char (point-min)) (when (re-search-forward "^total" nil t) (let ((available (get-free-disk-space "."))) (when available (replace-match "total used in directory") (end-of-line) (insert " available " available)))))) (let ((handler (find-file-name-handler (expand-file-name file) (quote insert-directory))) (orig-file file) wildcard-regexp) (if handler (funcall handler (quote insert-directory) file switches wildcard full-directory-p) (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) (setq switches (delete 32 (delete 45 (append switches nil)))) (if (and ls-lisp-support-shell-wildcards (string-match "[[?*]" file) (not (file-exists-p file))) (progn (or (not (eq (aref file ...) 47)) (setq file (substring file 0 (1- ...)))) (setq wildcard t))) (if wildcard (setq wildcard-regexp (if ls-lisp-support-shell-wildcards (wildcard-to-regexp (file-name-nondirectory file)) (file-name-nondirectory file)) file (file-name-directory file)) (if (memq 66 switches) (setq wildcard-regexp "[^~]\\'"))) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp (if ... "[^~]\\'") file (file-relative-name orig-file)) (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) nil full-directory-p)) (signal (car err) (cdr err))))) (save-excursion (goto-char (point-min)) (when (re-search-forward "^total" nil t) (let ((available (get-free-disk-space "."))) (when available (replace-match "total used in directory") (end-of-line) (insert " available " available))))))) (if ls-lisp-use-insert-directory-program (funcall original-insert-directory file switches wildcard full-directory-p) (let ((handler (find-file-name-handler (expand-file-name file) (quote insert-directory))) (orig-file file) wildcard-regexp) (if handler (funcall handler (quote insert-directory) file switches wildcard full-directory-p) (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) (setq switches (delete 32 (delete 45 (append switches nil)))) (if (and ls-lisp-support-shell-wildcards (string-match "[[?*]" file) (not (file-exists-p file))) (progn (or (not (eq ... 47)) (setq file (substring file 0 ...))) (setq wildcard t))) (if wildcard (setq wildcard-regexp (if ls-lisp-support-shell-wildcards (wildcard-to-regexp (file-name-nondirectory file)) (file-name-nondirectory file)) file (file-name-directory file)) (if (memq 66 switches) (setq wildcard-regexp "[^~]\\'"))) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp ... file ...) (ls-lisp-insert-directory file switches ... nil full-directory-p)) (signal (car err) (cdr err))))) (save-excursion (goto-char (point-min)) (when (re-search-forward "^total" nil t) (let ((available ...)) (when available (replace-match "total used in directory") (end-of-line) (insert " available " available)))))))) insert-directory("" "-al" nil nil) apply(insert-directory ("" "-al" nil nil)) (let* ((inhibit-file-name-handlers (\` (tramp-completion-file-name-handler cygwin-mount-name-hook-function cygwin-mount-map-drive-hook-function \, (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers)))) (inhibit-file-name-operation operation)) (apply operation args)) tramp-completion-run-real-handler(insert-directory ("" "-al" nil nil)) (if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (save-match-data (apply (cdr fn) args)) (tramp-completion-run-real-handler operation args)) (let ((directory-sep-char 47) (fn (assoc operation tramp-completion-file-name-handler-alist))) (if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (save-match-data (apply (cdr fn) args)) (tramp-completion-run-real-handler operation args))) tramp-completion-file-name-handler(insert-directory "" "-al" nil nil) funcall(tramp-completion-file-name-handler insert-directory "" "-al" nil nil) (if handler (funcall handler (quote insert-directory) file switches wildcard full-directory-p) (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) (setq switches (delete 32 (delete 45 (append switches nil)))) (if (and ls-lisp-support-shell-wildcards (string-match "[[?*]" file) (not (file-exists-p file))) (progn (or (not (eq (aref file (1- ...)) 47)) (setq file (substring file 0 (1- (length file))))) (setq wildcard t))) (if wildcard (setq wildcard-regexp (if ls-lisp-support-shell-wildcards (wildcard-to-regexp (file-name-nondirectory file)) (file-name-nondirectory file)) file (file-name-directory file)) (if (memq 66 switches) (setq wildcard-regexp "[^~]\\'"))) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp (if (memq 66 switches) "[^~]\\'") file (file-relative-name orig-file)) (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) nil full-directory-p)) (signal (car err) (cdr err))))) (save-excursion (goto-char (point-min)) (when (re-search-forward "^total" nil t) (let ((available (get-free-disk-space "."))) (when available (replace-match "total used in directory") (end-of-line) (insert " available " available)))))) (let ((handler (find-file-name-handler (expand-file-name file) (quote insert-directory))) (orig-file file) wildcard-regexp) (if handler (funcall handler (quote insert-directory) file switches wildcard full-directory-p) (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) (setq switches (delete 32 (delete 45 (append switches nil)))) (if (and ls-lisp-support-shell-wildcards (string-match "[[?*]" file) (not (file-exists-p file))) (progn (or (not (eq (aref file ...) 47)) (setq file (substring file 0 (1- ...)))) (setq wildcard t))) (if wildcard (setq wildcard-regexp (if ls-lisp-support-shell-wildcards (wildcard-to-regexp (file-name-nondirectory file)) (file-name-nondirectory file)) file (file-name-directory file)) (if (memq 66 switches) (setq wildcard-regexp "[^~]\\'"))) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp (if ... "[^~]\\'") file (file-relative-name orig-file)) (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) nil full-directory-p)) (signal (car err) (cdr err))))) (save-excursion (goto-char (point-min)) (when (re-search-forward "^total" nil t) (let ((available (get-free-disk-space "."))) (when available (replace-match "total used in directory") (end-of-line) (insert " available " available))))))) (if ls-lisp-use-insert-directory-program (funcall original-insert-directory file switches wildcard full-directory-p) (let ((handler (find-file-name-handler (expand-file-name file) (quote insert-directory))) (orig-file file) wildcard-regexp) (if handler (funcall handler (quote insert-directory) file switches wildcard full-directory-p) (if (string-match "--dired " switches) (setq switches (replace-match "" nil nil switches))) (setq switches (delete 32 (delete 45 (append switches nil)))) (if (and ls-lisp-support-shell-wildcards (string-match "[[?*]" file) (not (file-exists-p file))) (progn (or (not (eq ... 47)) (setq file (substring file 0 ...))) (setq wildcard t))) (if wildcard (setq wildcard-regexp (if ls-lisp-support-shell-wildcards (wildcard-to-regexp (file-name-nondirectory file)) (file-name-nondirectory file)) file (file-name-directory file)) (if (memq 66 switches) (setq wildcard-regexp "[^~]\\'"))) (condition-case err (ls-lisp-insert-directory file switches (ls-lisp-time-index switches) wildcard-regexp full-directory-p) (invalid-regexp (if (equal (cadr err) "Unmatched [ or [^") (progn (setq wildcard-regexp ... file ...) (ls-lisp-insert-directory file switches ... nil full-directory-p)) (signal (car err) (cdr err))))) (save-excursion (goto-char (point-min)) (when (re-search-forward "^total" nil t) (let ((available ...)) (when available (replace-match "total used in directory") (end-of-line) (insert " available " available)))))))) insert-directory("" "-al" nil nil) dired-insert-directory("c:/drews-lisp-20/foobar" "-al" ("111.el" "") nil t) dired-readin-insert() dired-readin() dired-internal-noselect(("c:/drews-lisp-20/foobar" "111.el" "") nil) dired-noselect(("foobar" "111.el" "") nil) dired(("foobar" "111.el" "")) eval((dired (quote ("foobar" "111.el" ""))) nil) eval-expression((dired (quote ("foobar" "111.el" ""))) nil) call-interactively(eval-expression nil nil) But I already pointed you to the code that needs to be changed. And I already provided the fix: > `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) ...) Simply wrap the body of `ls-lisp-insert-directory' with (when (> (length file) 0) ...), and the problem is fixed. And that is the right way to fix it.