comparison lisp/emacs-lisp/bytecomp.el @ 88777:15101779a9a0

(byte-recompile-directory) (batch-byte-recompile-directory): Update from trunk. (byte-compile-fix-header): Adjust for use of utf-8-emacs. (byte-compile-insert-header): Update magic number. Add ballast. (map-char-table): Use byte-compile-funarg-2.
author Dave Love <fx@gnu.org>
date Mon, 24 Jun 2002 18:25:16 +0000
parents 4c6cdfeb929c
children bd4ee6f57fb1
comparison
equal deleted inserted replaced
88776:805a3bb7daf4 88777:15101779a9a0
1 ;;; bytecomp.el --- compilation of Lisp code into byte code 1 ;;; bytecomp.el --- compilation of Lisp code into byte code
2 2
3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1998, 2000, 2001 3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1998, 2000, 2001, 2002
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 5
6 ;; Author: Jamie Zawinski <jwz@lucid.com> 6 ;; Author: Jamie Zawinski <jwz@lucid.com>
7 ;; Hallvard Furuseth <hbf@ulrik.uio.no> 7 ;; Hallvard Furuseth <hbf@ulrik.uio.no>
8 ;; Maintainer: FSF 8 ;; Maintainer: FSF
9 ;; Keywords: lisp 9 ;; Keywords: lisp
10 10
11 ;;; This version incorporates changes up to version 2.10 of the 11 ;;; This version incorporates changes up to version 2.10 of the
12 ;;; Zawinski-Furuseth compiler. 12 ;;; Zawinski-Furuseth compiler.
13 (defconst byte-compile-version "$Revision: 2.93 $") 13 (defconst byte-compile-version "$Revision: 2.94 $")
14 14
15 ;; This file is part of GNU Emacs. 15 ;; This file is part of GNU Emacs.
16 16
17 ;; GNU Emacs is free software; you can redistribute it and/or modify 17 ;; GNU Emacs is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by 18 ;; it under the terms of the GNU General Public License as published by
1247 (defun byte-recompile-directory (directory &optional arg force) 1247 (defun byte-recompile-directory (directory &optional arg force)
1248 "Recompile every `.el' file in DIRECTORY that needs recompilation. 1248 "Recompile every `.el' file in DIRECTORY that needs recompilation.
1249 This is if a `.elc' file exists but is older than the `.el' file. 1249 This is if a `.elc' file exists but is older than the `.el' file.
1250 Files in subdirectories of DIRECTORY are processed also. 1250 Files in subdirectories of DIRECTORY are processed also.
1251 1251
1252 If the `.elc' file does not exist, normally the `.el' file is *not* compiled. 1252 If the `.elc' file does not exist, normally this function *does not*
1253 But a prefix argument (optional second arg) means ask user, 1253 compile the corresponding `.el' file. However,
1254 for each such `.el' file, whether to compile it. Prefix argument 0 means 1254 if ARG (the prefix argument) is 0, that means do compile all those files.
1255 don't ask and compile the file anyway. 1255 A nonzero ARG means ask the user, for each such `.el' file,
1256 1256 whether to compile it.
1257 A nonzero prefix argument also means ask about each subdirectory. 1257
1258 A nonzero ARG also means ask about each subdirectory before scanning it.
1258 1259
1259 If the third argument FORCE is non-nil, 1260 If the third argument FORCE is non-nil,
1260 recompile every `.el' file that already has a `.elc' file." 1261 recompile every `.el' file that already has a `.elc' file."
1261 (interactive "DByte recompile directory: \nP") 1262 (interactive "DByte recompile directory: \nP")
1262 (if arg 1263 (if arg
1579 delta) 1580 delta)
1580 (goto-char (point-min)) 1581 (goto-char (point-min))
1581 (delete-region (point) (progn (re-search-forward "^(") 1582 (delete-region (point) (progn (re-search-forward "^(")
1582 (beginning-of-line) 1583 (beginning-of-line)
1583 (point))) 1584 (point)))
1584 (insert ";;; This file contains multibyte non-ASCII characters\n" 1585 (insert ";;; This file contains utf-8 non-ASCII characters\n"
1585 ";;; and therefore cannot be loaded into Emacs 19.\n") 1586 ";;; and therefore cannot be loaded into Emacs 21 or earlier.\n")
1586 ;; Replace "19" or "19.29" with "20", twice. 1587 ;; Replace "19" or "19.29" with "22", twice.
1587 (re-search-forward "19\\(\\.[0-9]+\\)") 1588 (re-search-forward "19\\(\\.[0-9]+\\)")
1588 (replace-match "20") 1589 (replace-match "22")
1589 (re-search-forward "19\\(\\.[0-9]+\\)") 1590 (re-search-forward "19\\(\\.[0-9]+\\)")
1590 (replace-match "20") 1591 (replace-match "22")
1591 ;; Now compensate for the change in size, 1592 ;; Now compensate for the change in size,
1592 ;; to make sure all positions in the file remain valid. 1593 ;; to make sure all positions in the file remain valid.
1593 (setq delta (- (point-max) old-header-end)) 1594 (setq delta (- (point-max) old-header-end))
1594 (goto-char (point-max)) 1595 (goto-char (point-max))
1595 (widen) 1596 (widen)
1600 (let ((dynamic-docstrings byte-compile-dynamic-docstrings) 1601 (let ((dynamic-docstrings byte-compile-dynamic-docstrings)
1601 (dynamic byte-compile-dynamic)) 1602 (dynamic byte-compile-dynamic))
1602 (set-buffer outbuffer) 1603 (set-buffer outbuffer)
1603 (goto-char 1) 1604 (goto-char 1)
1604 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After 1605 ;; The magic number of .elc files is ";ELC", or 0x3B454C43. After
1605 ;; that is the file-format version number (18, 19 or 20) as a 1606 ;; that is the file-format version number (18, 19, 20 or 22) as a
1606 ;; byte, followed by some nulls. The primary motivation for doing 1607 ;; byte, followed by some nulls. The primary motivation for doing
1607 ;; this is to get some binary characters up in the first line of 1608 ;; this is to get some binary characters up in the first line of
1608 ;; the file so that `diff' will simply say "Binary files differ" 1609 ;; the file so that `diff' will simply say "Binary files differ"
1609 ;; instead of actually doing a diff of two .elc files. An extra 1610 ;; instead of actually doing a diff of two .elc files. An extra
1610 ;; benefit is that you can add this to /etc/magic: 1611 ;; benefit is that you can add this to /etc/magic:
1612 ;; 0 string ;ELC GNU Emacs Lisp compiled file, 1613 ;; 0 string ;ELC GNU Emacs Lisp compiled file,
1613 ;; >4 byte x version %d 1614 ;; >4 byte x version %d
1614 1615
1615 (insert 1616 (insert
1616 ";ELC" 1617 ";ELC"
1617 (if (byte-compile-version-cond byte-compile-compatibility) 18 20) 1618 (if (byte-compile-version-cond byte-compile-compatibility) 18 21)
1618 "\000\000\000\n" 1619 "\000\000\000\n"
1619 ) 1620 )
1620 (insert ";;; Compiled by " 1621 (insert ";;; Compiled by "
1621 (or (and (boundp 'user-mail-address) user-mail-address) 1622 (or (and (boundp 'user-mail-address) user-mail-address)
1622 (concat (user-login-name) "@" (system-name))) 1623 (concat (user-login-name) "@" (system-name)))
1671 (format "' was compiled for Emacs %s or later\"))\n\n" 1672 (format "' was compiled for Emacs %s or later\"))\n\n"
1672 minimum-version) 1673 minimum-version)
1673 ;; Insert semicolons as ballast, so that byte-compile-fix-header 1674 ;; Insert semicolons as ballast, so that byte-compile-fix-header
1674 ;; can delete them so as to keep the buffer positions 1675 ;; can delete them so as to keep the buffer positions
1675 ;; constant for the actual compiled code. 1676 ;; constant for the actual compiled code.
1676 ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")) 1677 ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"))
1677 ;; Here if we want Emacs 18 compatibility. 1678 ;; Here if we want Emacs 18 compatibility.
1678 (when dynamic-docstrings 1679 (when dynamic-docstrings
1679 (error "Version-18 compatibility doesn't support dynamic doc strings")) 1680 (error "Version-18 compatibility doesn't support dynamic doc strings"))
1680 (when byte-compile-dynamic 1681 (when byte-compile-dynamic
1681 (error "Version-18 compatibility doesn't support dynamic byte code")) 1682 (error "Version-18 compatibility doesn't support dynamic byte code"))
2976 (byte-defop-compiler-1 mapcar byte-compile-funarg) 2977 (byte-defop-compiler-1 mapcar byte-compile-funarg)
2977 (byte-defop-compiler-1 mapatoms byte-compile-funarg) 2978 (byte-defop-compiler-1 mapatoms byte-compile-funarg)
2978 (byte-defop-compiler-1 mapconcat byte-compile-funarg) 2979 (byte-defop-compiler-1 mapconcat byte-compile-funarg)
2979 (byte-defop-compiler-1 mapc byte-compile-funarg) 2980 (byte-defop-compiler-1 mapc byte-compile-funarg)
2980 (byte-defop-compiler-1 sort byte-compile-funarg-2) 2981 (byte-defop-compiler-1 sort byte-compile-funarg-2)
2982 (byte-defop-compiler-1 map-char-table byte-compile-funarg-2)
2983 ;; map-charset-chars should be funarg but has optional third arg
2981 (byte-defop-compiler-1 let) 2984 (byte-defop-compiler-1 let)
2982 (byte-defop-compiler-1 let*) 2985 (byte-defop-compiler-1 let*)
2983 2986
2984 (defun byte-compile-progn (form) 2987 (defun byte-compile-progn (form)
2985 (byte-compile-body-do-effect (cdr form))) 2988 (byte-compile-body-do-effect (cdr form)))
3624 (if (not noninteractive) 3627 (if (not noninteractive)
3625 (error "batch-byte-recompile-directory is to be used only with -batch")) 3628 (error "batch-byte-recompile-directory is to be used only with -batch"))
3626 (or command-line-args-left 3629 (or command-line-args-left
3627 (setq command-line-args-left '("."))) 3630 (setq command-line-args-left '(".")))
3628 (while command-line-args-left 3631 (while command-line-args-left
3629 (byte-recompile-directory (car command-line-args-left) 0) 3632 (byte-recompile-directory (car command-line-args-left))
3630 (setq command-line-args-left (cdr command-line-args-left))) 3633 (setq command-line-args-left (cdr command-line-args-left)))
3631 (kill-emacs 0)) 3634 (kill-emacs 0))
3632 3635
3633 3636
3634 (make-obsolete 'dot 'point "before 19.15") 3637 (make-obsolete 'dot 'point "before 19.15")