Commits

Anonymous committed 8283b70

2001-08-23 Adrian Aichner <adrian@xemacs.org>

* uniquify.el: Fix the documented bug that prevented uniquify from
working in native Windows XEmacs. Patch is courtesy of Paul
Krause.
* uniquify.el (uniquify-directory-matching-regexp): New.
* uniquify.el (uniquify-get-proposed-name): Use
uniquify-directory-matching-regexp.
* uniquify.el (uniquify-reverse-components): Use
directory-sep-char.

Comments (0)

Files changed (2)

+2001-08-23  Adrian Aichner  <adrian@xemacs.org>
+
+	* uniquify.el: Fix the documented bug that prevented uniquify from
+	working in native Windows XEmacs.  Patch is courtesy of Paul
+	Krause.
+	* uniquify.el (uniquify-directory-matching-regexp): New.
+	* uniquify.el (uniquify-get-proposed-name): Use
+	uniquify-directory-matching-regexp.
+	* uniquify.el (uniquify-reverse-components): Use
+	directory-sep-char.
+
 2001-08-16  Steve Youngs  <youngs@xemacs.org>
 
 	* setnu.el: Moved here from JDE package.
 ;; A version of uniquify.el that works under Emacs 18, Emacs 19, XEmacs 19,
 ;; and InfoDock is available from the maintainer.
 
-;; Doesn't work under NT when backslash is used as a path separator (forward
-;;   slash path separator works fine).  To fix, check system-type against
-;;   'windows-nt, write a routine that breaks paths down into components.
-;;   (Surprisingly, there isn't one built in.)
-
 ;;; Change Log:
 
 ;; Originally by Dick King <king@reasoning.com> 15 May 86
     (uniquify-rationalize-conflicting-sublist
      conflicting-sublist old-name depth)))
 
+(defvar uniquify-directory-matching-regexp
+  (format "\\(^\\|%1$s[^%1$s]*\\)%1$s"
+	  (regexp-quote (string directory-sep-char))))
+
 (defun uniquify-get-proposed-name (item depth)
   (let (index
 	(extra-string "")
 	(fn (uniquify-fix-item-filename item)))
     (while (and (> n 0)
 		(setq index (string-match
-			     (concat "\\(^\\|/[^/]*\\)/"
+			     (concat uniquify-directory-matching-regexp
 				     (regexp-quote extra-string)
 				     (regexp-quote base)
 				     "\\'")
 	(len (length instring))
 	(sep (or uniquify-separator "\\")))
     (while (< cursor len)
-      (if (= (aref instring cursor) ?/)
+      (if (= (aref instring cursor) directory-sep-char)
           (setq sofar (cons sep sofar)
                 cursor (1+ cursor))
-        (let ((first-slash (or (string-match "/" instring cursor) len)))
-          (setq sofar (cons (substring instring cursor first-slash) sofar)
-                cursor first-slash))))
+        (let ((first-dirsep (or (string-match (string directory-sep-char)
+					     instring cursor)
+			       len)))
+          (setq sofar (cons (substring instring cursor first-dirsep) sofar)
+                cursor first-dirsep))))
     (apply (function concat) sofar)))