aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-11-15 23:17:18 +0000
committerRichard M. Stallman1995-11-15 23:17:18 +0000
commitc8e9dd5444cb0cc9277d92e65577035d421015d7 (patch)
tree8d7e2244140a9661f1f00099f98c6b9b47334f49
parent91375f8fc631d075be56edd5422151ac26fb8465 (diff)
downloademacs-c8e9dd5444cb0cc9277d92e65577035d421015d7.tar.gz
emacs-c8e9dd5444cb0cc9277d92e65577035d421015d7.zip
(info-insert-file-contents-1): Various rewrites.
Compute EXT-LEFT after removing the dot from SUFFIX.
-rw-r--r--lisp/info.el13
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/info.el b/lisp/info.el
index 13447f330b3..6e8252c10a4 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -142,22 +142,23 @@ the command as standard input. If STRING is nil, no decoding is done.
142Because the SUFFIXes are tried in order, the empty string should 142Because the SUFFIXes are tried in order, the empty string should
143be last in the list.") 143be last in the list.")
144 144
145;; Concatenate SUFFIX onto FILENAME. 145;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
146;; First, on ms-dos, delete some of the extension in FILENAME 146;; First, on ms-dos, delete some of the extension in FILENAME
147;; to make room. 147;; to make room.
148(defun info-insert-file-contents-1 (filename suffix) 148(defun info-insert-file-contents-1 (filename suffix)
149 (if (not (eq system-type 'ms-dos)) 149 (if (not (eq system-type 'ms-dos))
150 (concat filename suffix) 150 (concat filename suffix)
151 (let* ((sans-exts (file-name-sans-extension filename)) 151 (let* ((sans-exts (file-name-sans-extension filename))
152 ;; How long is the extension in FILENAME. 152 ;; How long is the extension in FILENAME (not counting the dot).
153 (ext-len (- (length filename) (length sans-exts) 1)) 153 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
154 ;; How many chars of that extension should we keep? 154 ext-left)
155 (ext-left (max 0 (- 3 (length suffix)))))
156 ;; SUFFIX starts with a dot. If FILENAME already has one, 155 ;; SUFFIX starts with a dot. If FILENAME already has one,
157 ;; get rid of the one in SUFFIX. 156 ;; get rid of the one in SUFFIX.
158 (or (and (zerop ext-len) 157 (or (and (<= ext-len 0)
159 (not (eq (aref filename (1- (length filename))) ?.))) 158 (not (eq (aref filename (1- (length filename))) ?.)))
160 (setq suffix (substring suffix 1))) 159 (setq suffix (substring suffix 1)))
160 ;; How many chars of that extension should we keep?
161 (setq ext-left (min ext-len (max 0 (- 3 (length suffix)))))
161 ;; Get rid of the rest of the extension, and add SUFFIX. 162 ;; Get rid of the rest of the extension, and add SUFFIX.
162 (concat (substring filename 0 (- (length filename) 163 (concat (substring filename 0 (- (length filename)
163 (- ext-len ext-left))) 164 (- ext-len ext-left)))