Mercurial > emacs
comparison lisp/emacs-lisp/bytecomp.el @ 23135:99ab9c46504a
(byte-compile-output-as-comment):
Calculate the total bytes using position-bytes instead of
char-bytes.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 28 Aug 1998 12:22:39 +0000 |
parents | 2f2375c24426 |
children | 8cc9aa86ee9d |
comparison
equal
deleted
inserted
replaced
23134:173e15236628 | 23135:99ab9c46504a |
---|---|
7 ;; Maintainer: FSF | 7 ;; Maintainer: FSF |
8 ;; Keywords: lisp | 8 ;; Keywords: lisp |
9 | 9 |
10 ;;; This version incorporates changes up to version 2.10 of the | 10 ;;; This version incorporates changes up to version 2.10 of the |
11 ;;; Zawinski-Furuseth compiler. | 11 ;;; Zawinski-Furuseth compiler. |
12 (defconst byte-compile-version "$Revision: 2.49 $") | 12 (defconst byte-compile-version "$Revision: 2.50 $") |
13 | 13 |
14 ;; This file is part of GNU Emacs. | 14 ;; This file is part of GNU Emacs. |
15 | 15 |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | 16 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17 ;; it under the terms of the GNU General Public License as published by | 17 ;; it under the terms of the GNU General Public License as published by |
1905 | 1905 |
1906 ;; Print Lisp object EXP in the output file, inside a comment, | 1906 ;; Print Lisp object EXP in the output file, inside a comment, |
1907 ;; and return the file position it will have. | 1907 ;; and return the file position it will have. |
1908 ;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting. | 1908 ;; If QUOTED is non-nil, print with quoting; otherwise, print without quoting. |
1909 (defun byte-compile-output-as-comment (exp quoted) | 1909 (defun byte-compile-output-as-comment (exp quoted) |
1910 (let ((position (point)) | 1910 (let ((position (point))) |
1911 total-bytes) | |
1912 (set-buffer | 1911 (set-buffer |
1913 (prog1 (current-buffer) | 1912 (prog1 (current-buffer) |
1914 (set-buffer outbuffer) | 1913 (set-buffer outbuffer) |
1915 | 1914 |
1916 ;; Insert EXP, and make it a comment with #@LENGTH. | 1915 ;; Insert EXP, and make it a comment with #@LENGTH. |
1930 (while (search-forward "\037" nil t) | 1929 (while (search-forward "\037" nil t) |
1931 (replace-match "\^A_" t t)) | 1930 (replace-match "\^A_" t t)) |
1932 (goto-char (point-max)) | 1931 (goto-char (point-max)) |
1933 (insert "\037") | 1932 (insert "\037") |
1934 (goto-char position) | 1933 (goto-char position) |
1935 (setq total-bytes 0) | 1934 (insert "#@" (format "%d" (- (position-bytes (point-max)) |
1936 (while (not (eobp)) | 1935 (position-bytes position)))) |
1937 (setq total-bytes (+ total-bytes (char-bytes (char-after (point))))) | |
1938 (forward-char 1)) | |
1939 (goto-char position) | |
1940 (insert "#@" (format "%d" total-bytes)) | |
1941 | 1936 |
1942 ;; Save the file position of the object. | 1937 ;; Save the file position of the object. |
1943 ;; Note we should add 1 to skip the space | 1938 ;; Note we should add 1 to skip the space |
1944 ;; that we inserted before the actual doc string, | 1939 ;; that we inserted before the actual doc string, |
1945 ;; and subtract 1 to convert from an 1-origin Emacs position | 1940 ;; and subtract 1 to convert from an 1-origin Emacs position |