Function: command-line-normalize-file-name

command-line-normalize-file-name is a byte-compiled function defined in startup.el.gz.

Signature

(command-line-normalize-file-name FILE)

Documentation

Collapse multiple slashes to one, to handle non-Emacs file names.

Source Code

;; Defined in /usr/src/emacs/lisp/startup.el.gz
(defun command-line-normalize-file-name (file)
  "Collapse multiple slashes to one, to handle non-Emacs file names."
  (save-match-data
    ;; Use arg 1 so that we don't collapse // at the start of the file name.
    ;; That is significant on some systems.
    ;; However, /// at the beginning is supposed to mean just /, not //.
    (if (string-match
	 (if (memq system-type '(ms-dos windows-nt))
	     "^\\([\\/][\\/][\\/]\\)+"
	   "^///+")
	 file)
	(setq file (replace-match "/" t t file)))
    (if (memq system-type '(ms-dos windows-nt))
	(while (string-match "\\([\\/][\\/]\\)+" file 1)
	  (setq file (replace-match "/" t t file)))
      (while (string-match "//+" file 1)
	(setq file (replace-match "/" t t file))))
    file))