Subject: Re: bug#11585: 24.0.50; corrupted byte compiled files

From: Pierre Lorenzon <[email-masked]>
Date: Wed, 30 May 2012 17:31:50 +0200 (CEST)

From: Stefan Monnier <[email-masked]>
Subject: Re: bug#11585: 24.0.50; corrupted byte compiled files
Date: Wed, 30 May 2012 11:24:49 -0400

>> Certain of my .el files are incorrectly compiled. See the .elc
>> file with a long name.
> 
> Duh, indeed it was byte-compile-fix-header, thanks for investigating.
> I think your patch has the problem that it changes the byte-position of
> the text in the rest of the buffer, which will break lazy-loaded
> docstrings and byte-code.

  OK ! Anyway when I tried to load this .elc files compiled
  with my patch I encounter problem ....

  Pierre

> Can you try the patch below instead, which will simply report the actual
> load-file-name rather than file name of the source.
> 
> 
>         Stefan
> 
> 
> === modified file 'lisp/emacs-lisp/bytecomp.el'
> --- lisp/emacs-lisp/bytecomp.el	2012-05-30 03:59:42 +0000
> +++ lisp/emacs-lisp/bytecomp.el	2012-05-30 15:18:29 +0000
> @@ -1937,7 +1937,7 @@
>  	     (byte-compile-fix-header byte-compile-current-file))))
>       byte-compile--outbuffer)))
>  
> -(defun byte-compile-fix-header (filename)
> +(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))
> @@ -1962,11 +1962,8 @@
>         ;; 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"
> +       "     (error \"`%s"
> +       (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.
> @@ -2037,7 +2034,7 @@
>          (print-gensym t)
>          (print-circle                   ; Handle circular data structures.
>           (not byte-compile-disable-print-circle)))
> -    (if (and (memq (car-safe form) '(defun defmacro defvar defvaralias defconst
> +    (if (and (memq (car-safe form) '(defvar defvaralias defconst
>                                        autoload custom-declare-variable))
>               (stringp (nth 3 form)))
>          (byte-compile-output-docform nil nil '("\n(" 3 ")") form nil
>