emacs-devel
[Top][All Lists]
Advanced

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

Re: Unicode handling breaks Jpeg image detection?


From: Stephen Berman
Subject: Re: Unicode handling breaks Jpeg image detection?
Date: Wed, 25 Jun 2008 14:37:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On Wed, 25 Jun 2008 11:48:34 +0900 Kenichi Handa <address@hidden> wrote:

> In article <address@hidden>, Chong Yidong <address@hidden> writes:
>
>> In Emacs 23, jpeg content autodetection seems to be broken.  I think
>> this may be an encoding issue.  To see this, rename any jpeg image from
>> foo.jpg to foo.JPG (to turn off file-name detection), and open it in
>> Emacs.  Emacs 23 fails to detect the image, while Emacs 22 works.
>
>> In a buffer containing the exact same jpeg data, do
>
>>   M-: (string-match "\\`\xff\xd8" (buffer-string)) RET
>
>> This gives 0 in Emacs 22, and nil in Emacs 23.  This is the check that
>> makes image-type-header-regexps and image-jpeg-p fail for Emacs 23.
>
> I've just installed a fix.

This fix results in a file mode specification error.  To reproduce:
1. C-x C-f /tmp/test
2. Type the letter "รค" (a-umlaut).
3. C-x C-s
4. C-x k RET
5. C-x C-f /tmp/test
==> File mode specification error: (error "Can't convert the 0th
character to unibyte")

Backtrace attached.

Steve Berman

Debugger entered--Lisp error: (error "Can't convert the 0th character to 
unibyte")
  string-to-unibyte("\x00e4")
  (setq data (string-to-unibyte data))
  image-jpeg-p("\x00e4")
  funcall(image-jpeg-p "\x00e4")
  (and (consp image-type) (funcall (car image-type) (or data ...)) (setq 
image-type (cdr image-type)))
  (or (and (symbolp image-type) (looking-at regexp)) (and (consp image-type) 
(funcall ... ...) (setq image-type ...)))
  (if (or (and ... ...) (and ... ... ...)) (setq type image-type types nil) 
(setq types (cdr types)))
  (let ((regexp ...) (image-type ...) data) (if (or ... ...) (setq type 
image-type types nil) (setq types ...)))
  (while types (let (... ... data) (if ... ... ...)))
  (let ((types image-type-header-regexps) type (opoint ...)) (goto-char 
(point-min)) (while types (let ... ...)) (goto-char opoint) type)
  image-type-from-buffer()
  (let* ((type ...) (auto ...)) (and auto (or ... ...)))
  image-type-auto-detected-p()
  funcall(image-type-auto-detected-p)
  (if (functionp re) (funcall re) (looking-at re))
  (lambda (re dummy) (if (functionp re) (funcall re) (looking-at 
re)))(image-type-auto-detected-p nil)
  assoc-default(nil ((image-type-auto-detected-p . image-mode) ("\\(?:<\\?xml[  
\n]+[^>]*>\\)?[         
\n]*<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->[  
\n]*<\\)*\\(?:!DOCTYPE[         
\n]+[^>]*>[     
\n]*<[  
\n]*\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->[   
\n]*<\\)*\\)?[Hh][Tt][Mm][Ll]" . html-mode) ("<!DOCTYPE[        
\n]+[Hh][Tt][Mm][Ll]" . html-mode) ("<\\?xml " . xml-mode) ("[  
\n]*<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->[  
\n]*<\\)*!DOCTYPE " . sgml-mode) ("%!PS" . ps-mode) ("# xmcd " . 
conf-unix-mode)) (lambda (re dummy) (if (functionp re) (funcall re) (looking-at 
re))))
  (save-restriction (narrow-to-region (point-min) (min ... ...)) (assoc-default 
nil magic-fallback-mode-alist (lambda ... ...)))
  (save-excursion (goto-char (point-min)) (save-restriction (narrow-to-region 
... ...) (assoc-default nil magic-fallback-mode-alist ...)))
  (setq done (save-excursion (goto-char ...) (save-restriction ... ...)))
  (if (setq done (save-excursion ... ...)) (set-auto-mode-0 done 
keep-mode-if-same))
  (if done nil (if (setq done ...) (set-auto-mode-0 done keep-mode-if-same)))
  (unless done (if (setq done ...) (set-auto-mode-0 done keep-mode-if-same)))
  (let (end done mode modes) (save-excursion (goto-char ...) 
(skip-chars-forward "      \n") (and enable-local-variables ... ...)) (if modes 
(catch ... ...)) (unless done (setq mode ... done ...) (if done ...)) (unless 
done (if ... ...)) (unless done (if buffer-file-name ...)) (unless done (if ... 
...)))
  set-auto-mode()
  (progn (set-auto-mode))
  (if debug-on-error (progn (set-auto-mode)) (condition-case err (progn ...) 
(error ...)))
  (report-errors "File mode specification error: %s" (set-auto-mode))
  (let ((enable-local-variables ...)) (report-errors "File mode specification 
error: %s" (set-auto-mode)) (report-errors "Project local-variables error: %s" 
(hack-project-variables)) (report-errors "File local-variables error: %s" 
(hack-local-variables)))
  normal-mode(t)
  (if nomodes nil (when (and view-read-only view-mode) (view-mode-disable)) 
(normal-mode t) (and (memq require-final-newline ...) (> ... ...) (/= ... 10) 
(not ...) (save-excursion ... ...)) (when (and buffer-read-only view-read-only 
...) (view-mode-enter)) (run-hooks (quote find-file-hook)))
  (unless nomodes (when (and view-read-only view-mode) (view-mode-disable)) 
(normal-mode t) (and (memq require-final-newline ...) (> ... ...) (/= ... 10) 
(not ...) (save-excursion ... ...)) (when (and buffer-read-only view-read-only 
...) (view-mode-enter)) (run-hooks (quote find-file-hook)))
  after-find-file(nil t)
  find-file-noselect-1(#<buffer test> "/tmp/test" nil nil "/tmp/test" (251763 
2055))
  find-file-noselect("/tmp/test" nil nil t)
  find-file("/tmp/test" t)
  call-interactively(find-file nil nil)

reply via email to

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