diff options
| author | Joakim Verona | 2013-08-14 09:11:58 +0200 |
|---|---|---|
| committer | Joakim Verona | 2013-08-14 09:11:58 +0200 |
| commit | cfb926eb66f52143a3951aaa0b1ac6b11f686c53 (patch) | |
| tree | 5218ec25e4ba8a4490fd2e8b5e324e25e7cd64c4 /src | |
| parent | 0d50a0024015b4198a75dc70475b351d7c98d74f (diff) | |
| parent | aab1fcdf812a7ebd32b8312c05ffcdd1bf610d2b (diff) | |
| download | emacs-cfb926eb66f52143a3951aaa0b1ac6b11f686c53.tar.gz emacs-cfb926eb66f52143a3951aaa0b1ac6b11f686c53.zip | |
merge from trunk
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/image.c | 69 | ||||
| -rw-r--r-- | src/window.h | 4 | ||||
| -rw-r--r-- | src/xdisp.c | 2 |
4 files changed, 38 insertions, 45 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 88df9f13762..a120cf1b182 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2013-08-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | * xdisp.c (cursor_type_changed): Now static. | ||
| 4 | |||
| 5 | * image.c (imagemagick_filename_hint): New arg HINT_BUFFER. | ||
| 6 | Use changed. This avoids the need to call xmalloc and for the | ||
| 7 | caller to call xfree, and avoids memory leaks in some situations. | ||
| 8 | |||
| 1 | 2013-08-14 Dmitry Antipov <dmantipov@yandex.ru> | 9 | 2013-08-14 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 10 | ||
| 3 | * xdisp.c (adjust_window_ends): Move duplicated code to new function. | 11 | * xdisp.c (adjust_window_ends): Move duplicated code to new function. |
diff --git a/src/image.c b/src/image.c index 99bb9d8c135..d93d1b517bf 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7845,35 +7845,27 @@ imagemagick_error (MagickWand *wand) | |||
| 7845 | } | 7845 | } |
| 7846 | 7846 | ||
| 7847 | /* Possibly give ImageMagick some extra help to determine the image | 7847 | /* Possibly give ImageMagick some extra help to determine the image |
| 7848 | type by supplying a "dummy" filename based on the Content-Type. */ | 7848 | type by supplying a "dummy" filename based on the Content-Type. */ |
| 7849 | 7849 | ||
| 7850 | static char* | 7850 | static char * |
| 7851 | imagemagick_filename_hint (Lisp_Object spec) | 7851 | imagemagick_filename_hint (Lisp_Object spec, char hint_buffer[MaxTextExtent]) |
| 7852 | { | 7852 | { |
| 7853 | Lisp_Object format = image_spec_value (spec, intern (":format"), NULL); | 7853 | Lisp_Object symbol = intern ("image-format-suffixes"); |
| 7854 | Lisp_Object val, symbol = intern ("image-format-suffixes"); | 7854 | Lisp_Object val = find_symbol_value (symbol); |
| 7855 | const char *prefix = "/tmp/foo."; | 7855 | Lisp_Object format; |
| 7856 | char *name; | ||
| 7857 | 7856 | ||
| 7858 | if (NILP (Fboundp (symbol))) | ||
| 7859 | return NULL; | ||
| 7860 | |||
| 7861 | val = Fassq (format, Fsymbol_value (symbol)); | ||
| 7862 | if (! CONSP (val)) | ||
| 7863 | return NULL; | ||
| 7864 | |||
| 7865 | val = Fcdr (val); | ||
| 7866 | if (! CONSP (val)) | 7857 | if (! CONSP (val)) |
| 7867 | return NULL; | 7858 | return NULL; |
| 7868 | 7859 | ||
| 7869 | val = Fcar (val); | 7860 | format = image_spec_value (spec, intern (":format"), NULL); |
| 7861 | val = Fcar_safe (Fcdr_safe (Fassq (format, val))); | ||
| 7870 | if (! STRINGP (val)) | 7862 | if (! STRINGP (val)) |
| 7871 | return NULL; | 7863 | return NULL; |
| 7872 | 7864 | ||
| 7873 | name = xmalloc (strlen (prefix) + SBYTES (val) + 1); | 7865 | /* It's OK to truncate the hint if it has MaxTextExtent or more bytes, |
| 7874 | strcpy (name, prefix); | 7866 | as ImageMagick would ignore the extra bytes anyway. */ |
| 7875 | strcat (name, SSDATA (val)); | 7867 | snprintf (hint_buffer, MaxTextExtent, "/tmp/foo.%s", SSDATA (val)); |
| 7876 | return name; | 7868 | return hint_buffer; |
| 7877 | } | 7869 | } |
| 7878 | 7870 | ||
| 7879 | /* Helper function for imagemagick_load, which does the actual loading | 7871 | /* Helper function for imagemagick_load, which does the actual loading |
| @@ -7909,6 +7901,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7909 | int desired_width, desired_height; | 7901 | int desired_width, desired_height; |
| 7910 | double rotation; | 7902 | double rotation; |
| 7911 | int pixelwidth; | 7903 | int pixelwidth; |
| 7904 | char hint_buffer[MaxTextExtent]; | ||
| 7912 | char *filename_hint = NULL; | 7905 | char *filename_hint = NULL; |
| 7913 | 7906 | ||
| 7914 | /* Handle image index for image types who can contain more than one image. | 7907 | /* Handle image index for image types who can contain more than one image. |
| @@ -7923,15 +7916,14 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7923 | ping_wand = NewMagickWand (); | 7916 | ping_wand = NewMagickWand (); |
| 7924 | /* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */ | 7917 | /* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */ |
| 7925 | 7918 | ||
| 7926 | if (! filename) | 7919 | if (filename) |
| 7927 | filename_hint = imagemagick_filename_hint (img->spec); | 7920 | status = MagickPingImage (ping_wand, filename); |
| 7928 | 7921 | else | |
| 7929 | if (filename_hint) | 7922 | { |
| 7930 | MagickSetFilename (ping_wand, filename_hint); | 7923 | filename_hint = imagemagick_filename_hint (img->spec, hint_buffer); |
| 7931 | 7924 | MagickSetFilename (ping_wand, filename_hint); | |
| 7932 | status = filename | 7925 | status = MagickPingImageBlob (ping_wand, contents, size); |
| 7933 | ? MagickPingImage (ping_wand, filename) | 7926 | } |
| 7934 | : MagickPingImageBlob (ping_wand, contents, size); | ||
| 7935 | 7927 | ||
| 7936 | if (status == MagickFalse) | 7928 | if (status == MagickFalse) |
| 7937 | { | 7929 | { |
| @@ -7961,13 +7953,15 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7961 | 7953 | ||
| 7962 | image_wand = NewMagickWand (); | 7954 | image_wand = NewMagickWand (); |
| 7963 | 7955 | ||
| 7964 | if (filename_hint) | 7956 | if (filename) |
| 7965 | MagickSetFilename (image_wand, filename_hint); | 7957 | status = MagickReadImage (image_wand, filename); |
| 7958 | else | ||
| 7959 | { | ||
| 7960 | MagickSetFilename (image_wand, filename_hint); | ||
| 7961 | status = MagickReadImageBlob (image_wand, contents, size); | ||
| 7962 | } | ||
| 7966 | 7963 | ||
| 7967 | if ((filename | 7964 | if (status == MagickFalse) |
| 7968 | ? MagickReadImage (image_wand, filename) | ||
| 7969 | : MagickReadImageBlob (image_wand, contents, size)) | ||
| 7970 | == MagickFalse) | ||
| 7971 | { | 7965 | { |
| 7972 | imagemagick_error (image_wand); | 7966 | imagemagick_error (image_wand); |
| 7973 | goto imagemagick_error; | 7967 | goto imagemagick_error; |
| @@ -8207,16 +8201,11 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 8207 | /* `MagickWandTerminus' terminates the imagemagick environment. */ | 8201 | /* `MagickWandTerminus' terminates the imagemagick environment. */ |
| 8208 | MagickWandTerminus (); | 8202 | MagickWandTerminus (); |
| 8209 | 8203 | ||
| 8210 | if (filename_hint) | ||
| 8211 | free (filename_hint); | ||
| 8212 | |||
| 8213 | return 1; | 8204 | return 1; |
| 8214 | 8205 | ||
| 8215 | imagemagick_error: | 8206 | imagemagick_error: |
| 8216 | DestroyMagickWand (image_wand); | 8207 | DestroyMagickWand (image_wand); |
| 8217 | if (bg_wand) DestroyPixelWand (bg_wand); | 8208 | if (bg_wand) DestroyPixelWand (bg_wand); |
| 8218 | if (filename_hint) | ||
| 8219 | free (filename_hint); | ||
| 8220 | 8209 | ||
| 8221 | MagickWandTerminus (); | 8210 | MagickWandTerminus (); |
| 8222 | /* TODO more cleanup. */ | 8211 | /* TODO more cleanup. */ |
diff --git a/src/window.h b/src/window.h index 585697f0805..c64641825e3 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -906,10 +906,6 @@ extern int update_mode_lines; | |||
| 906 | 906 | ||
| 907 | extern int windows_or_buffers_changed; | 907 | extern int windows_or_buffers_changed; |
| 908 | 908 | ||
| 909 | /* Nonzero means a frame's cursor type has been changed. */ | ||
| 910 | |||
| 911 | extern int cursor_type_changed; | ||
| 912 | |||
| 913 | /* If *ROWS or *COLS are too small a size for FRAME, set them to the | 909 | /* If *ROWS or *COLS are too small a size for FRAME, set them to the |
| 914 | minimum allowable size. */ | 910 | minimum allowable size. */ |
| 915 | 911 | ||
diff --git a/src/xdisp.c b/src/xdisp.c index b30d9d57578..d2e49c76d4b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -528,7 +528,7 @@ int windows_or_buffers_changed; | |||
| 528 | 528 | ||
| 529 | /* Nonzero means a frame's cursor type has been changed. */ | 529 | /* Nonzero means a frame's cursor type has been changed. */ |
| 530 | 530 | ||
| 531 | int cursor_type_changed; | 531 | static int cursor_type_changed; |
| 532 | 532 | ||
| 533 | /* Nonzero after display_mode_line if %l was used and it displayed a | 533 | /* Nonzero after display_mode_line if %l was used and it displayed a |
| 534 | line number. */ | 534 | line number. */ |