Function: tar-header-block-checksum

tar-header-block-checksum is a byte-compiled function defined in tar-mode.el.gz.

Signature

(tar-header-block-checksum STRING)

Documentation

Compute and return a tar-acceptable checksum for this block.

Source Code

;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
(defun tar-header-block-checksum (string)
  "Compute and return a tar-acceptable checksum for this block."
  (cl-assert (not (multibyte-string-p string)))
  (let* ((chk-field-start tar-chk-offset)
	 (chk-field-end (+ chk-field-start 8))
	 (sum 0)
	 (i 0))
    ;; Add up all of the characters except the ones in the checksum field.
    ;; Add that field as if it were filled with spaces.
    (while (< i chk-field-start)
      (setq sum (+ sum (aref string i))
	    i (1+ i)))
    (setq i chk-field-end)
    (while (< i 512)
      (setq sum (+ sum (aref string i))
	    i (1+ i)))
    (+ sum (* 32 8))))