comparison lisp/auto-save.el @ 278:90d73dddcdc4 r21-0b37

Import from CVS: tag r21-0b37
author cvs
date Mon, 13 Aug 2007 10:31:29 +0200
parents 41ff10fd062f
children 19dcec799385
comparison
equal deleted inserted replaced
277:cfdf3ff11843 278:90d73dddcdc4
419 ;; "Hash string S into a string of length 14. 419 ;; "Hash string S into a string of length 14.
420 ;; A 7-bytes cyclic code for burst correction is calculated on a 420 ;; A 7-bytes cyclic code for burst correction is calculated on a
421 ;; byte-by-byte basis. The polynomial used is D^7 + D^6 + D^3 +1. 421 ;; byte-by-byte basis. The polynomial used is D^7 + D^6 + D^3 +1.
422 ;; The resulting string consists of hexadecimal digits [0-9a-f]. 422 ;; The resulting string consists of hexadecimal digits [0-9a-f].
423 ;; In particular, it contains no slash, so it can be used as autosave name." 423 ;; In particular, it contains no slash, so it can be used as autosave name."
424 (let ((crc (make-string 7 ?\0))) 424 (let ((crc (make-vector 7 ?\0)))
425 (mapc 425 (mapc
426 (lambda (new) 426 (lambda (new)
427 (setq new (+ new (aref crc 6))) 427 (setq new (+ new (aref crc 6)))
428 (aset crc 6 (+ (aref crc 5) new)) 428 (aset crc 6 (+ (aref crc 5) new))
429 (aset crc 5 (aref crc 4)) 429 (aset crc 5 (aref crc 4))
432 (aset crc 2 (aref crc 1)) 432 (aset crc 2 (aref crc 1))
433 (aset crc 1 (aref crc 0)) 433 (aset crc 1 (aref crc 0))
434 (aset crc 0 new)) 434 (aset crc 0 new))
435 s) 435 s)
436 (format "%02x%02x%02x%02x%02x%02x%02x" 436 (format "%02x%02x%02x%02x%02x%02x%02x"
437 (aref crc 0) 437 (logand 255 (aref crc 0))
438 (aref crc 1) 438 (logand 255 (aref crc 1))
439 (aref crc 2) 439 (logand 255 (aref crc 2))
440 (aref crc 3) 440 (logand 255 (aref crc 3))
441 (aref crc 4) 441 (logand 255 (aref crc 4))
442 (aref crc 5) 442 (logand 255 (aref crc 5))
443 (aref crc 6)))) 443 (logand 255 (aref crc 6)))))
444 444
445 ;; #### It is unclear to me how the following function is useful. It 445 ;; #### It is unclear to me how the following function is useful. It
446 ;; should be used in `auto-save-name-in-same-directory', if anywhere. 446 ;; should be used in `auto-save-name-in-same-directory', if anywhere.
447 ;; -hniksic 447 ;; -hniksic
448 448