]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/esh-util.el
*** empty log message ***
[gnu-emacs] / lisp / eshell / esh-util.el
index dae9655aff71051a829b70ca017e78be6b1317d3..50ff77c77251efffd893757af368b397684d9254 100644 (file)
@@ -1,6 +1,7 @@
 ;;; esh-util.el --- general utilities
 
-;; Copyright (C) 1999, 2000, 2001 Free Software Foundation
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -18,8 +19,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 (provide 'esh-util)
 
@@ -146,10 +147,6 @@ function `string-to-number'."
   "Return non-nil if we are running under MS-DOS/Windows."
   (memq system-type '(ms-dos windows-nt)))
 
-(defsubst eshell-under-cygwin-p ()
-  "Return non-nil if we are running under Cygwin."
-  (eq system-type 'cygwin32))
-
 (defmacro eshell-condition-case (tag form &rest handlers)
   "Like `condition-case', but only if `eshell-pass-through-errors' is nil."
   (if eshell-handle-errors
@@ -257,14 +254,13 @@ If N or M is nil, it means the end of the list."
        parts)
     (if (and (eshell-under-windows-p)
             (> len 2)
-            (eq (aref path 0) directory-sep-char)
-            (eq (aref path 1) directory-sep-char))
+            (eq (aref path 0) ?/)
+            (eq (aref path 1) ?/))
        (setq i 2))
     (while (< i len)
-      (if (and (eq (aref path i) directory-sep-char)
+      (if (and (eq (aref path i) ?/)
               (not (get-text-property i 'escaped path)))
-         (setq parts (cons (if (= li i)
-                               (char-to-string directory-sep-char)
+         (setq parts (cons (if (= li i) "/"
                              (substring path li (1+ i))) parts)
                li (1+ i)))
       (setq i (1+ i)))
@@ -272,9 +268,7 @@ If N or M is nil, it means the end of the list."
        (setq parts (cons (substring path li i) parts)))
     (if (and (eshell-under-windows-p)
             (string-match "\\`[A-Za-z]:\\'" (car (last parts))))
-       (setcar (last parts)
-               (concat (car (last parts))
-                       (char-to-string directory-sep-char))))
+       (setcar (last parts) (concat (car (last parts)) "/")))
     (nreverse parts)))
 
 (defun eshell-to-flat-string (value)
@@ -454,8 +448,8 @@ list."
                                 (point) (progn (end-of-line)
                                                (point))) ":")))
            (if (and (and fields (nth 0 fields) (nth 2 fields))
-                    (not (assq (string-to-int (nth 2 fields)) names)))
-               (setq names (cons (cons (string-to-int (nth 2 fields))
+                    (not (assq (string-to-number (nth 2 fields)) names)))
+               (setq names (cons (cons (string-to-number (nth 2 fields))
                                        (nth 0 fields))
                                  names))))
          (forward-line))))
@@ -592,14 +586,20 @@ Unless optional argument INPLACE is non-nil, return a new string."
        string)))
 
 (unless (fboundp 'directory-files-and-attributes)
-  (defun directory-files-and-attributes (dir &optional full match nosort)
-    (documentation 'directory-files)
-    (let ((dir (expand-file-name dir)) ange-cache)
+  (defun directory-files-and-attributes (directory &optional full match nosort)
+    "Return a list of names of files and their attributes in DIRECTORY.
+There are three optional arguments:
+If FULL is non-nil, return absolute file names.  Otherwise return names
+ that are relative to the specified directory.
+If MATCH is non-nil, mention only file names that match the regexp MATCH.
+If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
+ NOSORT is useful if you plan to sort the result yourself."
+    (let ((directory (expand-file-name directory)) ange-cache)
       (mapcar
        (function
        (lambda (file)
-         (cons file (eshell-file-attributes (expand-file-name file dir)))))
-       (directory-files dir full match nosort)))))
+         (cons file (eshell-file-attributes (expand-file-name file directory)))))
+       (directory-files directory full match nosort)))))
 
 (eval-when-compile
   (defvar ange-cache))
@@ -787,4 +787,5 @@ Unless optional argument INPLACE is non-nil, return a new string."
 
 ;;; Code:
 
+;;; arch-tag: 70159778-5c7a-480a-bae4-3ad332fca19d
 ;;; esh-util.el ends here