comparison tests/automated/mule-tests.el @ 4623:a9f83990e6bf

Fix a byte compiler bug with characters above ?\xFF. lisp/ChangeLog addition: 2009-02-22 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-force-escape-quoted): New variable, used to force `byte-compile-insert-header' to treat the output as having characters above ?\xFF. (byte-compile-from-buffer): If the compiled output contains characters above ?\xFF, and byte-compile-dynamic-docstrings or byte-compile-dynamic is non-nil (or we're using an inappropriate coding system) recompile the file, turning off the dynamic features and using a more appropriate header. (byte-compile-insert-header): Pay attention to byte-compile-force-escape-quoted. tests/ChangeLog addition: 2009-02-22 Aidan Kehoe <kehoea@parhasard.net> * automated/mule-tests.el: Use more realistic tests for the escape-quoted mule encoding checks; update a comment, change a Known-Bug-Expect-Failure to a normal test now that we've addressed an old bug.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 22 Feb 2009 19:57:28 +0000
parents 4dc42d1fe684
children e4ed58cb0e5b
comparison
equal deleted inserted replaced
4622:8cbca852bcd4 4623:a9f83990e6bf
597 (with-temp-buffer 597 (with-temp-buffer
598 (flet 598 (flet
599 ((Assert-elc-is-escape-quoted () 599 ((Assert-elc-is-escape-quoted ()
600 "Assert the current buffer has an escape-quoted cookie if compiled." 600 "Assert the current buffer has an escape-quoted cookie if compiled."
601 (save-excursion 601 (save-excursion
602 (let ((byte-compile-result (byte-compile-from-buffer 602 (let* ((temporary-file-name (make-temp-name
603 (current-buffer) nil nil)) 603 (expand-file-name "zjPQ2Pk"
604 (temporary-file-name (make-temp-name 604 (temp-directory))))
605 (expand-file-name "zjPQ2Pk" 605 (byte-compile-result (byte-compile-from-buffer
606 (temp-directory))))) 606 (current-buffer) temporary-file-name
607 (byte-compile-insert-header 607 nil)))
608 temporary-file-name
609 (current-buffer)
610 byte-compile-result)
611 (Assert (string-match 608 (Assert (string-match
612 "^;;;###coding system: escape-quoted" 609 "^;;;###coding system: escape-quoted"
613 (buffer-substring nil nil byte-compile-result)))))) 610 (buffer-substring nil nil byte-compile-result))))))
614 (Assert-elc-has-no-specified-encoding () 611 (Assert-elc-has-no-specified-encoding ()
615 "Assert the current buffer has no coding cookie if compiled." 612 "Assert the current buffer has no coding cookie if compiled."
616 (save-excursion 613 (save-excursion
617 (let ((byte-compile-result (byte-compile-from-buffer 614 (let* ((temporary-file-name (make-temp-name
618 (current-buffer) nil nil)) 615 (expand-file-name "zjPQ2Pk"
619 (temporary-file-name (make-temp-name 616 (temp-directory))))
620 (expand-file-name "zjPQ2Pk" 617 (byte-compile-result (byte-compile-from-buffer
621 (temp-directory))))) 618 (current-buffer) temporary-file-name
622 (byte-compile-insert-header 619 nil)))
623 temporary-file-name
624 (current-buffer)
625 byte-compile-result)
626 (Assert (not (string-match 620 (Assert (not (string-match
627 ";;;###coding system:" 621 ";;;###coding system:"
628 (buffer-substring nil nil 622 (buffer-substring nil nil
629 byte-compile-result)))))))) 623 byte-compile-result))))))))
630 (insert 624 (insert
701 (string ?A)) ;; LATIN CAPITAL LETTER A") 695 (string ?A)) ;; LATIN CAPITAL LETTER A")
702 696
703 (Assert-elc-has-no-specified-encoding) 697 (Assert-elc-has-no-specified-encoding)
704 (delete-region (point-min) (point-max)) 698 (delete-region (point-min) (point-max))
705 699
706 ;; This bug exists because the coding-cookie insertion code looks at 700 ;; There used to be a bug here because the coding-cookie insertion code
707 ;; the input buffer, not the output buffer. 701 ;; looks at the input buffer, not the output buffer.
708 ;; 702 ;;
709 ;; It looks at the input buffer because byte-compile-dynamic and 703 ;; It looks at the input buffer because byte-compile-dynamic and
710 ;; byte-compile-dynamic-docstrings currently need to be 704 ;; byte-compile-dynamic-docstrings currently need to be
711 ;; unconditionally turned off for Mule files, since dynamic 705 ;; unconditionally turned off for Mule files, since dynamic
712 ;; compilation of function bodies and docstrings fails if you can't 706 ;; compilation of function bodies and docstrings fails if you can't
713 ;; call (point) and trivially get the byte offset in the file. 707 ;; call (point) and trivially get the byte offset in the file.
714 ;; 708 ;;
715 ;; And to unconditionally turn those two features off, you need to 709 ;; And to unconditionally turn those two features off, you need to know
716 ;; know before byte-compilation whether the byte-compilation output 710 ;; before byte-compilation whether the byte-compilation output file
717 ;; file contains non-Latin-1 characters, or perhaps to check after 711 ;; contains non-Latin-1 characters. Or to check after compilation and
718 ;; compilation and redo; but we don't do the latter. 712 ;; redo; the latter is what we do right now. This will only be necessary
713 ;; in a very small minority of cases, it's not a performance-critical
714 ;; issue.
719 ;; 715 ;;
720 ;; To fix this bug, we need to add Mule support to 716 ;; Martin Buchholz thinks, in bytecomp.el, that we should implement lazy
721 ;; byte-compile-dynamic and byte-compile-dynamic-docstrings. Or drop 717 ;; loading for Mule files; I (Aidan Kehoe) don't think that's worth the
722 ;; support for those features entirely. 718 ;; effort today (February 2009).
723 (insert 719 (insert
724 "(defvar testing-mule-compilation-handling (eval-when-compile 720 "(defvar testing-mule-compilation-handling (eval-when-compile
725 (decode-char 'ucs #x371e))) ;; kDefinition beautiful; pretty, used\"") 721 (decode-char 'ucs #x371e))) ;; kDefinition beautiful; pretty, used\"")
726 (Known-Bug-Expect-Failure 722 (Assert-elc-is-escape-quoted)
727 (Assert-elc-is-escape-quoted))
728 (delete-region (point-min) (point-max)))) 723 (delete-region (point-min) (point-max))))
729 724
730 (Known-Bug-Expect-Error 725 (Known-Bug-Expect-Error
731 invalid-constant 726 invalid-constant
732 (loop 727 (loop