diff options
| author | Claudio Bley | 2013-11-01 11:10:13 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-11-01 11:10:13 +0200 |
| commit | 0e7690deacc3232f1a0bd3902255ffa34292e5cf (patch) | |
| tree | 9459348a527f4b61408cefe9f08538460a651669 | |
| parent | 019c8218f07fd2acca84661be01147c50908d903 (diff) | |
| download | emacs-0e7690deacc3232f1a0bd3902255ffa34292e5cf.tar.gz emacs-0e7690deacc3232f1a0bd3902255ffa34292e5cf.zip | |
Fix handling of comments in NetPBM image files.
src/image.c (pbm_next_char): New function.
(pbm_scan_number): Use it.
lisp/image.el (image-type-header-regexps): Fix the 'pbm' part to
allow comments in pbm files.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/image.el | 5 | ||||
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/image.c | 51 |
4 files changed, 40 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a73c38bd522..fd8e77c9c53 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2013-11-01 Claudio Bley <claudio.bley@googlemail.com> | 1 | 2013-11-01 Claudio Bley <claudio.bley@googlemail.com> |
| 2 | 2 | ||
| 3 | * image.el (image-type-header-regexps): Fix the 'pbm' part to | ||
| 4 | allow comments in pbm files. | ||
| 5 | |||
| 3 | * term/w32-win.el (dynamic-library-alist): Support newer versions | 6 | * term/w32-win.el (dynamic-library-alist): Support newer versions |
| 4 | of libjpeg starting with v7: look only for the DLL from the | 7 | of libjpeg starting with v7: look only for the DLL from the |
| 5 | version against which Emacs was built. | 8 | version against which Emacs was built. |
diff --git a/lisp/image.el b/lisp/image.el index 6ce5b82ec48..69d890719d2 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -34,7 +34,10 @@ | |||
| 34 | 34 | ||
| 35 | (defconst image-type-header-regexps | 35 | (defconst image-type-header-regexps |
| 36 | `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm) | 36 | `(("\\`/[\t\n\r ]*\\*.*XPM.\\*/" . xpm) |
| 37 | ("\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+" . pbm) | 37 | ("\\`P[1-6]\\\(?:\ |
| 38 | \\(?:\\(?:#[^\r\n]*[\r\n]\\)?[[:space:]]\\)+\ | ||
| 39 | \\(?:\\(?:#[^\r\n]*[\r\n]\\)?[0-9]\\)+\ | ||
| 40 | \\)\\{2\\}" . pbm) | ||
| 38 | ("\\`GIF8[79]a" . gif) | 41 | ("\\`GIF8[79]a" . gif) |
| 39 | ("\\`\x89PNG\r\n\x1a\n" . png) | 42 | ("\\`\x89PNG\r\n\x1a\n" . png) |
| 40 | ("\\`[\t\n\r ]*#define \\([a-z0-9_]+\\)_width [0-9]+\n\ | 43 | ("\\`[\t\n\r ]*#define \\([a-z0-9_]+\\)_width [0-9]+\n\ |
diff --git a/src/ChangeLog b/src/ChangeLog index 0d58733f4bf..bfa28105571 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | 2013-11-01 Claudio Bley <claudio.bley@googlemail.com> | 1 | 2013-11-01 Claudio Bley <claudio.bley@googlemail.com> |
| 2 | 2 | ||
| 3 | * image.c (Qlibjpeg_version): New variable. | 3 | * image.c (pbm_next_char): New function. |
| 4 | (pbm_scan_number): Use it. | ||
| 5 | (Qlibjpeg_version): New variable. | ||
| 4 | (syms_of_image): DEFSYM and initialize it. | 6 | (syms_of_image): DEFSYM and initialize it. |
| 5 | 7 | ||
| 6 | 2013-10-31 Jan Djärv <jan.h.d@swipnet.se> | 8 | 2013-10-31 Jan Djärv <jan.h.d@swipnet.se> |
diff --git a/src/image.c b/src/image.c index fca1bb077f6..958295c5d09 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -5106,6 +5106,27 @@ pbm_image_p (Lisp_Object object) | |||
| 5106 | } | 5106 | } |
| 5107 | 5107 | ||
| 5108 | 5108 | ||
| 5109 | /* Get next char skipping comments in Netpbm header. Returns -1 at | ||
| 5110 | end of input. */ | ||
| 5111 | |||
| 5112 | static int | ||
| 5113 | pbm_next_char (unsigned char **s, unsigned char *end) | ||
| 5114 | { | ||
| 5115 | int c = -1; | ||
| 5116 | |||
| 5117 | while (*s < end && (c = *(*s)++, c == '#')) | ||
| 5118 | { | ||
| 5119 | /* Skip to the next line break. */ | ||
| 5120 | while (*s < end && (c = *(*s)++, c != '\n' && c != '\r')) | ||
| 5121 | ; | ||
| 5122 | |||
| 5123 | c = -1; | ||
| 5124 | } | ||
| 5125 | |||
| 5126 | return c; | ||
| 5127 | } | ||
| 5128 | |||
| 5129 | |||
| 5109 | /* Scan a decimal number from *S and return it. Advance *S while | 5130 | /* Scan a decimal number from *S and return it. Advance *S while |
| 5110 | reading the number. END is the end of the string. Value is -1 at | 5131 | reading the number. END is the end of the string. Value is -1 at |
| 5111 | end of input. */ | 5132 | end of input. */ |
| @@ -5115,28 +5136,16 @@ pbm_scan_number (unsigned char **s, unsigned char *end) | |||
| 5115 | { | 5136 | { |
| 5116 | int c = 0, val = -1; | 5137 | int c = 0, val = -1; |
| 5117 | 5138 | ||
| 5118 | while (*s < end) | 5139 | /* Skip white-space. */ |
| 5119 | { | 5140 | while ((c = pbm_next_char (s, end)) != -1 && c_isspace (c)) |
| 5120 | /* Skip white-space. */ | 5141 | ; |
| 5121 | while (*s < end && (c = *(*s)++, c_isspace (c))) | ||
| 5122 | ; | ||
| 5123 | 5142 | ||
| 5124 | if (c == '#') | 5143 | if (c_isdigit (c)) |
| 5125 | { | 5144 | { |
| 5126 | /* Skip comment to end of line. */ | 5145 | /* Read decimal number. */ |
| 5127 | while (*s < end && (c = *(*s)++, c != '\n')) | 5146 | val = c - '0'; |
| 5128 | ; | 5147 | while ((c = pbm_next_char (s, end)) != -1 && c_isdigit (c)) |
| 5129 | } | 5148 | val = 10 * val + c - '0'; |
| 5130 | else if (c_isdigit (c)) | ||
| 5131 | { | ||
| 5132 | /* Read decimal number. */ | ||
| 5133 | val = c - '0'; | ||
| 5134 | while (*s < end && (c = *(*s)++, c_isdigit (c))) | ||
| 5135 | val = 10 * val + c - '0'; | ||
| 5136 | break; | ||
| 5137 | } | ||
| 5138 | else | ||
| 5139 | break; | ||
| 5140 | } | 5149 | } |
| 5141 | 5150 | ||
| 5142 | return val; | 5151 | return val; |