changeset 4645:f2a991ff6db0

Do not #'split-path on nil #'getenv result. <877hz7lzrt.fsf@yahoo.com.cn>
author Jerry James <james@xemacs.org>
date Mon, 29 Jun 2009 08:20:47 -0600
parents b0ae008bf1a0
children 6c6bfdb80a0c
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 28 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat Jun 20 04:07:12 2009 +0900
+++ b/lisp/ChangeLog	Mon Jun 29 08:20:47 2009 -0600
@@ -1,3 +1,7 @@
+2009-06-20  It's me FKtPp ;)  <m_pupil@yahoo.com.cn>
+	* files.el (cd): Do not #'split-path on nil #'getenv result; Make
+	sure the cd-path value is a list.
+
 2009-06-14  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* help.el (describe-function-1): 
--- a/lisp/files.el	Sat Jun 20 04:07:12 2009 +0900
+++ b/lisp/files.el	Mon Jun 29 08:20:47 2009 -0600
@@ -593,29 +593,33 @@
 			      default-directory default-directory
 			      (and (member cd-path '(nil ("./")))
 				   (null (getenv "CDPATH"))))))
-  (if (file-name-absolute-p dir)
-      (cd-absolute (expand-file-name dir))
-    ;; XEmacs change. I'm not sure respecting CDPATH is the right thing to
-    ;; do under Windows.
-    (unless (and cd-path (equal (getenv "CDPATH") cdpath-previous))
-      (let ((trypath (split-path (setq cdpath-previous (getenv "CDPATH")))))
-	(setq cd-path (or (and trypath 
+
+  (let* ((cdpath-current (getenv "CDPATH"))
+	 (trypath (if cdpath-current
+		      (split-path (setq cdpath-previous cdpath-current))
+		    nil)))		; null list
+    (if (file-name-absolute-p dir)
+	(cd-absolute (expand-file-name dir))
+      ;; XEmacs change. I'm not sure respecting CDPATH is the right thing to
+      ;; do under Windows.
+      (unless (and cd-path (equal cdpath-current cdpath-previous))
+	(setq cd-path (or (and trypath
 			       (mapcar #'file-name-as-directory trypath))
-                          (file-name-as-directory "")))))
-    (or (catch 'found
-	  (mapcar #'(lambda (x)
-		        (let ((f (expand-file-name (concat x dir))))
+			  (list (file-name-as-directory "")))))
+      (or (catch 'found
+	    (mapcar #'(lambda (x)
+			(let ((f (expand-file-name (concat x dir))))
 			  (if (file-directory-p f)
 			      (progn
-			        (cd-absolute f)
-			        (throw 'found t)))))
-		  cd-path)
-	  nil)
-	;; jwz: give a better error message to those of us with the
-	;; good taste not to use a kludge like $CDPATH.
-	(if (equal cd-path '("./"))
-	    (error "No such directory: %s" (expand-file-name dir))
-	  (error "Directory not found in $CDPATH: %s" dir)))))
+				(cd-absolute f)
+				(throw 'found t)))))
+		    cd-path)
+	    nil)
+	  ;; jwz: give a better error message to those of us with the
+	  ;; good taste not to use a kludge like $CDPATH.
+	  (if (equal cd-path '("./"))
+	      (error "No such directory: %s" (expand-file-name dir))
+	    (error "Directory not found in $CDPATH: %s" dir))))))
 
 (defun load-file (file)
   "Load the Lisp file named FILE."