emacs-devel
[Top][All Lists]
Advanced

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

Does image-type-from-data still have multi-line bug?


From: Kim F. Storm
Subject: Does image-type-from-data still have multi-line bug?
Date: Fri, 21 Oct 2005 15:42:32 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

I'm working on cleaning up the  code in image.el, and found this:

In gnus/mm-decode.el, the following piece of code exists -- 

This is very similar to the functionality in image.el, but it
specifically mentions some multi-line bug in image-type-from-data.

Is there still such an error, or has it been fixed?

In any case, it seems like some of the code in image.el can be
simplified by adding image-type-from-buffer to image.el, so I
will do that.


(defconst mm-image-type-regexps
  '(("/\\*.*XPM.\\*/" . xpm)
    ("P[1-6]" . pbm)
    ("GIF8" . gif)
    ("\377\330" . jpeg)
    ("\211PNG\r\n" . png)
    ("#define" . xbm)
    ("\\(MM\0\\*\\)\\|\\(II\\*\0\\)" . tiff)
    ("%!PS" . postscript))
  "Alist of (REGEXP . IMAGE-TYPE) pairs used to auto-detect image types.
When the first bytes of an image file match REGEXP, it is assumed to
be of image type IMAGE-TYPE.")

;; Steal from image.el. image-type-from-data suffers multi-line matching bug.
(defun mm-image-type-from-buffer ()
  "Determine the image type from data in the current buffer.
Value is a symbol specifying the image type or nil if type cannot
be determined."
  (let ((types mm-image-type-regexps)
        type)
    (goto-char (point-min))
    (while (and types (null type))
      (let ((regexp (car (car types)))
            (image-type (cdr (car types))))
        (when (looking-at regexp)
          (setq type image-type))
        (setq types (cdr types))))
    type))




-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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