emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/bytecomp.el


From: Glenn Morris
Subject: [Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/bytecomp.el
Date: Thu, 05 Nov 2009 03:25:45 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       09/11/05 03:25:45

Modified files:
        lisp           : ChangeLog 
        lisp/emacs-lisp: bytecomp.el 

Log message:
        (byte-compile-insert-header): Drop test for Emacs 19.  (Bug#1531)
        (byte-compile-fix-header): Update for the above change.
        Drop test for epoch::version.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16565&r2=1.16566
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/bytecomp.el?cvsroot=emacs&r1=2.271&r2=2.272

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16565
retrieving revision 1.16566
diff -u -b -r1.16565 -r1.16566
--- ChangeLog   5 Nov 2009 03:24:08 -0000       1.16565
+++ ChangeLog   5 Nov 2009 03:25:41 -0000       1.16566
@@ -1,5 +1,10 @@
 2009-11-05  Glenn Morris  <address@hidden>
 
+       * emacs-lisp/bytecomp.el (byte-compile-insert-header): Drop test for
+       Emacs 19.  (Bug#1531)
+       (byte-compile-fix-header): Update for the above change.
+       Drop test for epoch::version.
+
        * emacs-lisp/autoload.el (autoload-rubric): Add optional feature arg.
        * cus-dep.el (custom-make-dependencies):
        * finder.el (finder-compile-keywords):

Index: emacs-lisp/bytecomp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.271
retrieving revision 2.272
diff -u -b -r2.271 -r2.272
--- emacs-lisp/bytecomp.el      4 Nov 2009 06:15:45 -0000       2.271
+++ emacs-lisp/bytecomp.el      5 Nov 2009 03:25:45 -0000       2.272
@@ -1922,10 +1922,9 @@
        ;; need to be written carefully.
        (setq overwrite-mode 'overwrite-mode-binary))
      (displaying-byte-compile-warnings
-      (and bytecomp-filename
-          (byte-compile-insert-header bytecomp-filename bytecomp-inbuffer
-                                      bytecomp-outbuffer))
       (with-current-buffer bytecomp-inbuffer
+       (and bytecomp-filename
+            (byte-compile-insert-header bytecomp-filename bytecomp-outbuffer))
        (goto-char (point-min))
        ;; Should we always do this?  When calling multiple files, it
        ;; would be useful to delay this warning until all have been
@@ -1958,49 +1957,55 @@
       ;; Fix up the header at the front of the output
       ;; if the buffer contains multibyte characters.
       (and bytecomp-filename
-          (byte-compile-fix-header bytecomp-filename bytecomp-inbuffer
-                                   bytecomp-outbuffer))))
+          (with-current-buffer bytecomp-outbuffer
+            (byte-compile-fix-header bytecomp-filename)))))
     bytecomp-outbuffer))
 
-(defun byte-compile-fix-header (filename inbuffer outbuffer)
-  (with-current-buffer outbuffer
-    ;; See if the buffer has any multibyte characters.
+(defun byte-compile-fix-header (filename)
+  "If the current buffer has any multibyte characters, insert a version test."
     (when (< (point-max) (position-bytes (point-max)))
       (goto-char (point-min))
-      ;; Find the comment that describes the version test.
-      (search-forward "\n;;; This file")
-      (beginning-of-line)
-      (narrow-to-region (point) (point-max))
-      ;; Find the line of ballast semicolons.
+    ;; Find the comment that describes the version condition.
+    (search-forward "\n;;; This file uses")
+    (narrow-to-region (line-beginning-position) (point-max))
+    ;; Find the first line of ballast semicolons.
       (search-forward ";;;;;;;;;;")
       (beginning-of-line)
-
       (narrow-to-region (point-min) (point))
       (let ((old-header-end (point))
+         (minimum-version "23")
            delta)
-       (goto-char (point-min))
-       (delete-region (point) (progn (re-search-forward "^(")
-                                     (beginning-of-line)
-                                     (point)))
-       (insert ";;; This file contains utf-8 non-ASCII characters\n"
-               ";;; and therefore cannot be loaded into Emacs 22 or 
earlier.\n")
-       ;; Replace "19" or "19.29" with "23", twice.
-       (re-search-forward "19\\(\\.[0-9]+\\)")
-       (replace-match "23")
-       (re-search-forward "19\\(\\.[0-9]+\\)")
-       (replace-match "23")
-       ;; Now compensate for the change in size,
-       ;; to make sure all positions in the file remain valid.
+      (delete-region (point-min) (point-max))
+      (insert
+       ";;; This file contains utf-8 non-ASCII characters,\n"
+       ";;; and so cannot be loaded into Emacs 22 or earlier.\n"
+       ;; Have to check if emacs-version is bound so that this works
+       ;; in files loaded early in loadup.el.
+       "(and (boundp 'emacs-version)\n"
+       ;; If there is a name at the end of emacs-version,
+       ;; don't try to check the version number.
+       "     (< (aref emacs-version (1- (length emacs-version))) ?A)\n"
+       (format "     (string-lessp emacs-version \"%s\")\n" minimum-version)
+       "     (error \"`"
+       ;; prin1-to-string is used to quote backslashes.
+       (substring (prin1-to-string (file-name-nondirectory filename))
+                 1 -1)
+       (format "' was compiled for Emacs %s or later\"))\n\n"
+              minimum-version))
+      ;; Now compensate for any change in size, to make sure all
+      ;; positions in the file remain valid.
        (setq delta (- (point-max) old-header-end))
        (goto-char (point-max))
        (widen)
-       (delete-char delta)))))
+      (delete-char delta))))
 
-(defun byte-compile-insert-header (filename inbuffer outbuffer)
-  (with-current-buffer inbuffer
+(defun byte-compile-insert-header (filename outbuffer)
+  "Insert a header at the start of OUTBUFFER.
+Call from the source buffer."
     (let ((dynamic-docstrings byte-compile-dynamic-docstrings)
-         (dynamic byte-compile-dynamic))
-      (set-buffer outbuffer)
+       (dynamic byte-compile-dynamic)
+       (optimize byte-optimize))
+    (with-current-buffer outbuffer
       (goto-char (point-min))
       ;; The magic number of .elc files is ";ELC", or 0x3B454C43.  After
       ;; that is the file-format version number (18, 19, 20, or 23) as a
@@ -2009,62 +2014,37 @@
       ;; the file so that `diff' will simply say "Binary files differ"
       ;; instead of actually doing a diff of two .elc files.  An extra
       ;; benefit is that you can add this to /etc/magic:
-
       ;; 0     string          ;ELC            GNU Emacs Lisp compiled file,
       ;; >4    byte            x               version %d
-
-      (insert ";ELC" 23 "\000\000\000\n")
-      (insert ";;; Compiled by "
+      (insert
+       ";ELC" 23 "\000\000\000\n"
+       ";;; Compiled by "
              (or (and (boundp 'user-mail-address) user-mail-address)
                  (concat (user-login-name) "@" (system-name)))
-             " on "
-             (current-time-string) "\n;;; from file " filename "\n")
-      (insert ";;; in Emacs version " emacs-version "\n")
-      (insert ";;; "
+       " on " (current-time-string) "\n"
+       ";;; from file " filename "\n"
+       ";;; in Emacs version " emacs-version ", with"
              (cond
-              ((eq byte-optimize 'source) "with source-level optimization 
only")
-              ((eq byte-optimize 'byte) "with byte-level optimization only")
-              (byte-optimize "with all optimizations")
-              (t "without optimization"))
-               ".\n")
-      (if dynamic
-         (insert ";;; Function definitions are lazy-loaded.\n"))
-      (let (intro-string minimum-version)
-       ;; Figure out which Emacs version to require,
-       ;; and what comment to use to explain why.
-       ;; Note that this fails to take account of whether
-       ;; the buffer contains multibyte characters.  We may have to
-       ;; compensate at the end in byte-compile-fix-header.
+       ((eq optimize 'source) " source-level optimization only")
+       ((eq optimize 'byte) " byte-level optimization only")
+       (optimize " all optimizations")
+       (t "out optimization"))
+       ".\n"
+       (if dynamic ";;; Function definitions are lazy-loaded.\n"
+        "")
+       "\n;;; This file uses "
        (if dynamic-docstrings
-           (setq intro-string
-                 ";;; This file uses dynamic docstrings, first added in Emacs 
19.29.\n"
-                 minimum-version "19.29")
-         (setq intro-string
-               ";;; This file uses opcodes which do not exist in Emacs 18.\n"
-               minimum-version "19"))
-       ;; Now insert the comment and the error check.
-       (insert
-        "\n"
-        intro-string
-        ;; Have to check if emacs-version is bound so that this works
-        ;; in files loaded early in loadup.el.
-        "(if (and (boundp 'emacs-version)\n"
-        ;; If there is a name at the end of emacs-version,
-        ;; don't try to check the version number.
-        "\t (< (aref emacs-version (1- (length emacs-version))) ?A)\n"
-        "\t (or (and (boundp 'epoch::version) epoch::version)\n"
-        (format "\t     (string-lessp emacs-version \"%s\")))\n"
-                minimum-version)
-        "    (error \"`"
-        ;; prin1-to-string is used to quote backslashes.
-        (substring (prin1-to-string (file-name-nondirectory filename))
-                   1 -1)
-        (format "' was compiled for Emacs %s or later\"))\n\n"
-                minimum-version)
+          "dynamic docstrings, first added in Emacs 19.29"
+        "opcodes that do not exist in Emacs 18")
+       ".\n\n"
+       ;; Note that byte-compile-fix-header may change this.
+       ";;; This file does not contain utf-8 non-ASCII characters,\n"
+       ";;; and so can be loaded in Emacs versions earlier than 23.\n\n"
         ;; Insert semicolons as ballast, so that byte-compile-fix-header
         ;; can delete them so as to keep the buffer positions
         ;; constant for the actual compiled code.
-        
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")))))
+       ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
+       
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n"))))
 
 ;; Dynamically bound in byte-compile-from-buffer.
 ;; NB also used in cl.el and cl-macs.el.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]