all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: emacs-devel@gnu.org
Subject: Re: Unicode handling breaks Jpeg image detection?
Date: Wed, 25 Jun 2008 14:37:40 +0200	[thread overview]
Message-ID: <87tzfhadwr.fsf@escher.local.home> (raw)
In-Reply-To: E1KBL3i-00070z-0B@etlken.m17n.org

[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

On Wed, 25 Jun 2008 11:48:34 +0900 Kenichi Handa <handa@m17n.org> wrote:

> In article <87od5qbn0b.fsf@stupidchicken.com>, Chong Yidong <cyd@stupidchicken.com> 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


[-- Attachment #2: backtrace --]
[-- Type: text/plain, Size: 3862 bytes --]

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	other threads:[~2008-06-25 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24 20:23 Unicode handling breaks Jpeg image detection? Chong Yidong
2008-06-25  2:48 ` Kenichi Handa
2008-06-25 12:37   ` Stephen Berman [this message]
2008-07-04  7:20     ` Kenichi Handa
2008-07-04  8:40       ` Stephen Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tzfhadwr.fsf@escher.local.home \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.