aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ls-lisp.el29
1 files changed, 21 insertions, 8 deletions
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 7d35b1e8dc3..cdcc2f2a73b 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -138,6 +138,7 @@ are: A a c i r S s t u"
138 file-alist 138 file-alist
139 (now (current-time)) 139 (now (current-time))
140 ;; do all bindings here for speed 140 ;; do all bindings here for speed
141 file-size
141 fil attr) 142 fil attr)
142 (cond ((memq ?A switches) 143 (cond ((memq ?A switches)
143 (setq file-list 144 (setq file-list
@@ -168,10 +169,19 @@ are: A a c i r S s t u"
168 (setq elt (car file-alist) 169 (setq elt (car file-alist)
169 file-alist (cdr file-alist) 170 file-alist (cdr file-alist)
170 short (car elt) 171 short (car elt)
171 attr (cdr elt)) 172 attr (cdr elt)
173 file-size (nth 7 attr))
172 (and attr 174 (and attr
173 (setq sum (+ sum (nth 7 attr))) 175 (setq sum
174 (insert (ls-lisp-format short attr switches now)))) 176 ;; Even if neither SUM nor file's size
177 ;; overflow, their sum could.
178 (if (or (< sum (- 134217727 file-size))
179 (floatp sum)
180 (floatp file-size))
181 (+ sum file-size)
182 (+ (float sum) file-size)))
183 (insert (ls-lisp-format short attr file-size switches now))
184 ))
175 ;; Fill in total size of all files: 185 ;; Fill in total size of all files:
176 (save-excursion 186 (save-excursion
177 (search-backward "total \007") 187 (search-backward "total \007")
@@ -182,7 +192,8 @@ are: A a c i r S s t u"
182 ;; file-attributes will not recognize a symlink to a directory 192 ;; file-attributes will not recognize a symlink to a directory
183 ;; must make it a relative filename as ls does: 193 ;; must make it a relative filename as ls does:
184 (setq file (file-name-nondirectory file)) 194 (setq file (file-name-nondirectory file))
185 (insert (ls-lisp-format file (file-attributes file) switches 195 (insert (ls-lisp-format file (file-attributes file)
196 (nth 7 (file-attributes file)) switches
186 (current-time))))))) 197 (current-time)))))))
187 198
188(defun ls-lisp-delete-matching (regexp list) 199(defun ls-lisp-delete-matching (regexp list)
@@ -240,19 +251,21 @@ are: A a c i r S s t u"
240 (< lo0 lo1))))) 251 (< lo0 lo1)))))
241 252
242 253
243(defun ls-lisp-format (file-name file-attr switches now) 254(defun ls-lisp-format (file-name file-attr file-size switches now)
244 (let ((file-type (nth 0 file-attr))) 255 (let ((file-type (nth 0 file-attr)))
245 (concat (if (memq ?i switches) ; inode number 256 (concat (if (memq ?i switches) ; inode number
246 (format "%6d " (nth 10 file-attr))) 257 (format "%6d " (nth 10 file-attr)))
247 ;; nil is treated like "" in concat 258 ;; nil is treated like "" in concat
248 (if (memq ?s switches) ; size in K 259 (if (memq ?s switches) ; size in K
249 (format "%4d " (fceiling (/ (nth 7 file-attr) 1024.0)))) 260 (format "%4d " (fceiling (/ file-size 1024.0))))
250 (nth 8 file-attr) ; permission bits 261 (nth 8 file-attr) ; permission bits
251 ;; numeric uid/gid are more confusing than helpful 262 ;; numeric uid/gid are more confusing than helpful
252 ;; Emacs should be able to make strings of them. 263 ;; Emacs should be able to make strings of them.
253 ;; user-login-name and user-full-name could take an 264 ;; user-login-name and user-full-name could take an
254 ;; optional arg. 265 ;; optional arg.
255 (format " %3d %-8s %-8s %8d " 266 (format (if (floatp file-size)
267 " %3d %-8s %-8s %8.0f "
268 " %3d %-8s %-8s %8d ")
256 (nth 1 file-attr) ; no. of links 269 (nth 1 file-attr) ; no. of links
257 (if (= (user-uid) (nth 2 file-attr)) 270 (if (= (user-uid) (nth 2 file-attr))
258 (user-login-name) 271 (user-login-name)
@@ -260,7 +273,7 @@ are: A a c i r S s t u"
260 (if (eq system-type 'ms-dos) 273 (if (eq system-type 'ms-dos)
261 "root" ; everything is root on MSDOS. 274 "root" ; everything is root on MSDOS.
262 (int-to-string (nth 3 file-attr))) ; gid 275 (int-to-string (nth 3 file-attr))) ; gid
263 (nth 7 file-attr) ; size in bytes 276 file-size
264 ) 277 )
265 (ls-lisp-format-time file-attr switches now) 278 (ls-lisp-format-time file-attr switches now)
266 " " 279 " "