# HG changeset patch # User Richard M. Stallman # Date 820540413 0 # Node ID 4e4201bcea5d414bd2bd30b450d0136cfc50d5da # Parent 07d5e992fdc4a66adb1e4fd3dac57d5fc16721d2 (convert-standard-filename): New alternate definition. diff -r 07d5e992fdc4 -r 4e4201bcea5d lisp/dos-fns.el --- a/lisp/dos-fns.el Mon Jan 01 23:50:19 1996 +0000 +++ b/lisp/dos-fns.el Mon Jan 01 23:53:33 1996 +0000 @@ -42,6 +42,45 @@ (setq grep-regexp-alist '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) +;; This overrides a trivial definition in files.el. +(defun convert-standard-filename (filename) + "Convert a standard file's name to something suitable for the current OS. +This function's standard definition is trivial; it just returns the argument. +However, on some systems, the function is redefined +with a definition that really does change some file names." + (let ((dir (file-name-directory filename)) + (string (copy-sequence (file-name-nondirectory filename))) + i firstdot) + ;; Change a leading period to a leading underscore. + (if (= (aref string 0) ?.) + (aset string 0 ?_)) + ;; Get rid of invalid characters. + (while (setq i (string-match "[^a-zA-Z0-9_.%~]" string)) + (aset string i ?_)) + ;; If we don't have a period, + ;; and we have a dash or underscore that isn't the first char, + ;; change that to a period. + (if (and (not (string-match "\\." string)) + (setq i (string-match "[-_]" string 1))) + (aset string i ?\.)) + ;; If we don't have a period in the first 8 chars, insert one. + (if (> (or (string-match "\\." string) + (length string)) + 8) + (setq string + (concat (substring string 0 8) + "." + (substring string 8)))) + (setq firstdot (string-match "\\." string)) + ;; Truncate to 3 chars after the first period. + (if (> (length string) (+ firstdot 4)) + (setq string (substring string 0 (+ firstdot 4)))) + ;; Change all periods except the first one into underscores. + (while (string-match "\\." string (1+ firstdot)) + (setq i (string-match "\\." string (1+ firstdot))) + (aset string i ?_)) + (concat dir string))) + (defvar file-name-buffer-file-type-alist '( ("[:/].*config.sys$" . nil) ; config.sys text