diff options
| author | Karoly Lorentey | 2004-06-24 07:44:13 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-06-24 07:44:13 +0000 |
| commit | 3fa701994755105d1fb4b0b802338fc04e8a6937 (patch) | |
| tree | 02ec9152f5f6e95bbb0b02265f51b832e712e8b5 /src | |
| parent | 8c8d5f3503a2fb4918414c0b0b9dacd81c50f1a9 (diff) | |
| parent | bb72b9d0b5248404a55b599d99c0be5454704e4a (diff) | |
| download | emacs-3fa701994755105d1fb4b0b802338fc04e8a6937.tar.gz emacs-3fa701994755105d1fb4b0b802338fc04e8a6937.zip | |
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410
Make sure image types are initialized for lookup too
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-412
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-413
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-414
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-415
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-417
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-418
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-419
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-202
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 134 | ||||
| -rw-r--r-- | src/abbrev.c | 2 | ||||
| -rw-r--r-- | src/alloc.c | 33 | ||||
| -rw-r--r-- | src/atimer.c | 2 | ||||
| -rw-r--r-- | src/atimer.h | 2 | ||||
| -rw-r--r-- | src/blockinput.h | 2 | ||||
| -rw-r--r-- | src/buffer.c | 8 | ||||
| -rw-r--r-- | src/buffer.h | 2 | ||||
| -rw-r--r-- | src/callproc.c | 4 | ||||
| -rw-r--r-- | src/casefiddle.c | 12 | ||||
| -rw-r--r-- | src/charset.c | 16 | ||||
| -rw-r--r-- | src/coding.c | 8 | ||||
| -rw-r--r-- | src/data.c | 21 | ||||
| -rw-r--r-- | src/dispextern.h | 4 | ||||
| -rw-r--r-- | src/doc.c | 2 | ||||
| -rw-r--r-- | src/editfns.c | 70 | ||||
| -rw-r--r-- | src/fns.c | 107 | ||||
| -rw-r--r-- | src/image.c | 4 | ||||
| -rw-r--r-- | src/keyboard.c | 12 | ||||
| -rw-r--r-- | src/keymap.c | 6 | ||||
| -rw-r--r-- | src/lisp.h | 63 | ||||
| -rw-r--r-- | src/macfns.c | 4 | ||||
| -rw-r--r-- | src/macterm.c | 6 | ||||
| -rw-r--r-- | src/minibuf.c | 78 | ||||
| -rw-r--r-- | src/print.c | 2 | ||||
| -rw-r--r-- | src/search.c | 126 | ||||
| -rw-r--r-- | src/syntax.c | 17 | ||||
| -rw-r--r-- | src/window.c | 14 | ||||
| -rw-r--r-- | src/window.h | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 49 | ||||
| -rw-r--r-- | src/xfaces.c | 15 | ||||
| -rw-r--r-- | src/xselect.c | 4 | ||||
| -rw-r--r-- | src/xsmfns.c | 2 | ||||
| -rw-r--r-- | src/xterm.c | 6 | ||||
| -rw-r--r-- | src/xterm.h | 2 |
35 files changed, 591 insertions, 250 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index e4bcca81ede..6fae7580745 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,10 +1,142 @@ | |||
| 1 | 2004-06-23 David Kastrup <dak@gnu.org> | ||
| 2 | |||
| 3 | * search.c (Freplace_match): Adjust the match-data more | ||
| 4 | thoroughly when replacing strings in the buffer. | ||
| 5 | search.c (match-data): When INTEGERS is non-nil and the last match | ||
| 6 | was in a buffer, add the buffer as last element to the match data. | ||
| 7 | (Fset_match_data): If an additional element of the match-data is | ||
| 8 | a buffer, restore it to last_thing_searched. | ||
| 9 | (save_search_regs): Save last_thing_searched as part of the match | ||
| 10 | data. | ||
| 11 | (restore_match_data): Restore it again. | ||
| 12 | |||
| 13 | 2004-06-23 Luc Teirlinck <teirllm@auburn.edu> | ||
| 14 | |||
| 15 | * keymap.c (Ftext_char_description): Doc fix. | ||
| 16 | * doc.c (Fsnarf_documentation): Doc fix. | ||
| 17 | |||
| 18 | 2004-06-22 Kim F. Storm <storm@cua.dk> | ||
| 19 | |||
| 20 | * fns.c (Fmapcar, Fmapconcat): GCPRO the args array. | ||
| 21 | |||
| 22 | * lisp.h (struct Lisp_Save_Value): New member dogc. | ||
| 23 | (SAFE_ALLOCA_LISP): Change second arg to number of elements. | ||
| 24 | Set dogc member in Lisp_Save_Value object so it will be GC'ed. | ||
| 25 | (SAFE_FREE_LISP): New macro. | ||
| 26 | |||
| 27 | * alloc.c (safe_alloca_unwind): Clear dogc and pointer members. | ||
| 28 | (make_save_value): Init new dogc member. | ||
| 29 | (mark_object): Mark Lisp_Save_Value pointer array if dogc is set. | ||
| 30 | |||
| 31 | * fns.c (Fmapconcat, Fmapcar): Use new SAFE_ALLOCA_LISP and | ||
| 32 | SAFE_FREE_LISP macros. | ||
| 33 | |||
| 34 | 2004-06-22 Kim F. Storm <storm@cua.dk> | ||
| 35 | |||
| 36 | * lisp.h (SAFE_ALLOCA_LISP): New macro to allocate Lisp_Objects. | ||
| 37 | Temporarily inhibits GC if memory is xmalloc'ed, as the Lisp_Objects | ||
| 38 | in that memory area are unknown to GC. Add comments. | ||
| 39 | |||
| 40 | * fns.c (Fmapconcat, Fmapcar): Use SAFE_ALLOCA_LISP. | ||
| 41 | |||
| 42 | 2004-06-21 Kim F. Storm <storm@cua.dk> | ||
| 43 | |||
| 44 | * lisp.h (MAX_ALLOCA): Define here. | ||
| 45 | (safe_alloca_unwind): Add prototype. | ||
| 46 | (USE_SAFE_ALLOCA, SAFE_ALLOCA, SAFE_FREE): New macros. | ||
| 47 | |||
| 48 | * alloc.c (safe_alloca_unwind): New function. | ||
| 49 | |||
| 50 | * casefiddle.c (casify_object): Use SAFE_ALLOCA. | ||
| 51 | |||
| 52 | * charset.c (Fstring): Use SAFE_ALLOCA. | ||
| 53 | |||
| 54 | * coding.c (MAX_ALLOCA): Remove define. | ||
| 55 | |||
| 56 | * data.c (MAX_ALLOCA): Remove define. | ||
| 57 | (Faset): Use SAFE_ALLOCA. | ||
| 58 | |||
| 59 | * editfns.c (Fformat, Ftranspose_regions): Use SAFE_ALLOCA. | ||
| 60 | |||
| 61 | * fns.c (string_make_multibyte, string_to_multibyte) | ||
| 62 | (string_make_unibyte, Fmapconcat, Fmapcar): Use SAFE_ALLOCA. | ||
| 63 | (MAX_ALLOCA): Remove define. | ||
| 64 | (Fbase64_encode_region, Fbase64_encode_string) | ||
| 65 | (Fbase64_decode_region, Fbase64_decode_string): Use SAFE_ALLOCA. | ||
| 66 | (Fbase64_encode_region, Fbase64_encode_string): Fix potential | ||
| 67 | memory leak if encoding fails. | ||
| 68 | |||
| 69 | * xdisp.c (add_to_log): Use SAFE_ALLOCA. | ||
| 70 | |||
| 71 | 2004-06-21 Eli Zaretskii <eliz@gnu.org> | ||
| 72 | |||
| 73 | * print.c (Fwith_output_to_temp_buffer): Doc fix. | ||
| 74 | |||
| 75 | 2004-06-20 Richard M. Stallman <rms@gnu.org> | ||
| 76 | |||
| 77 | * xfaces.c (Finternal_copy_lisp_face): Small cleanup; doc fix. | ||
| 78 | |||
| 79 | * search.c (match_limit): Cleaner err msg when no match data available. | ||
| 80 | |||
| 81 | * window.c (syms_of_window): Doc fix. | ||
| 82 | |||
| 83 | * keyboard.c (command_loop_1): Handle values `only' and `identity' | ||
| 84 | for Vtransient_mark_mode. | ||
| 85 | |||
| 86 | * buffer.c (syms_of_buffer): Doc fix. | ||
| 87 | |||
| 88 | 2004-06-21 David Kastrup <dak@gnu.org> | ||
| 89 | |||
| 90 | * minibuf.c (Ftry_completion, Fall_completions): Do lazy binding | ||
| 91 | and unbinding of `case-fold-search' according to | ||
| 92 | `completion-ignore-case' around calls of string-match and | ||
| 93 | predicates, respectively. Should give satisfactory performance | ||
| 94 | in all relevant cases. | ||
| 95 | |||
| 96 | 2004-06-17 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | ||
| 97 | |||
| 98 | * xterm.c (x_draw_image_foreground_1): Subtract slice.x/y from | ||
| 99 | clip_x/y_origin. | ||
| 100 | |||
| 101 | * fns.c (string_to_multibyte): Use xmalloc/xfree instead of alloca. | ||
| 102 | |||
| 103 | * macfns.c (Fx_display_color_cells): Do not limit return value to 256. | ||
| 104 | |||
| 105 | * macterm.c (mac_initialize_display_info): Initialize n_planes correctly | ||
| 106 | on Mac OSX. | ||
| 107 | |||
| 108 | 2004-06-16 Luc Teirlinck <teirllm@auburn.edu> | ||
| 109 | |||
| 110 | * buffer.c (syms_of_buffer): Clarify `fill-column' docstring. | ||
| 111 | |||
| 112 | 2004-06-16 Kim F. Storm <storm@cua.dk> | ||
| 113 | |||
| 114 | * dispextern.h (Vimage_types): Remove extern. | ||
| 115 | |||
| 116 | 2004-06-16 Miles Bader <miles@gnu.org> | ||
| 117 | |||
| 118 | * image.c (lookup_image_type): Initialize image type if necessary. | ||
| 119 | |||
| 120 | 2004-06-15 Kim F. Storm <storm@cua.dk> | ||
| 121 | |||
| 122 | * xdisp.c (try_cursor_movement): Exclude header line from scroll | ||
| 123 | margin at top of window. | ||
| 124 | (try_window_reusing_current_matrix): Calculate proper cursor position | ||
| 125 | after scrolling up with non-zero scroll margin, as the old cursor | ||
| 126 | position corresponds to value of PT before executing this command. | ||
| 127 | (try_window_id): Consider scroll margin at bottom of window too; | ||
| 128 | otherwise we fail to scroll when hl-line-mode is enabled. | ||
| 129 | |||
| 130 | * syntax.c (skip_chars): Only recognize [:class:] when it has the | ||
| 131 | proper format and class is a lower-case word. | ||
| 132 | |||
| 1 | 2004-06-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | 133 | 2004-06-14 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> |
| 2 | 134 | ||
| 3 | * gtkutil.c (xg_get_image_for_pixmap): New function. | 135 | * gtkutil.c (xg_get_image_for_pixmap): New function. |
| 4 | (xg_get_gdk_pixmap_and_mask): Removed. | 136 | (xg_get_gdk_pixmap_and_mask): Removed. |
| 5 | (update_frame_tool_bar): Call xg_get_image_for_pixmap instead of | 137 | (update_frame_tool_bar): Call xg_get_image_for_pixmap instead of |
| 6 | xg_get_gdk_pixmap_and_mask. | 138 | xg_get_gdk_pixmap_and_mask. |
| 7 | 139 | ||
| 8 | * xterm.h (struct x_display_info): Typo in comment fixed. | 140 | * xterm.h (struct x_display_info): Typo in comment fixed. |
| 9 | 141 | ||
| 10 | 2004-06-14 Juanma Barranquero <lektu@terra.es> | 142 | 2004-06-14 Juanma Barranquero <lektu@terra.es> |
diff --git a/src/abbrev.c b/src/abbrev.c index 41e329ac95d..ac132f20023 100644 --- a/src/abbrev.c +++ b/src/abbrev.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Primitives for word-abbrev mode. | 1 | /* Primitives for word-abbrev mode. |
| 2 | Copyright (C) 1985, 1986, 1993, 1996, 1998, 2001 | 2 | Copyright (C) 1985, 1986, 1993, 1996, 1998, 2001,02,03,04 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
diff --git a/src/alloc.c b/src/alloc.c index 3a3628f40fd..baf7afa0094 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -580,6 +580,21 @@ xstrdup (s) | |||
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | 582 | ||
| 583 | /* Unwind for SAFE_ALLOCA */ | ||
| 584 | |||
| 585 | Lisp_Object | ||
| 586 | safe_alloca_unwind (arg) | ||
| 587 | Lisp_Object arg; | ||
| 588 | { | ||
| 589 | register struct Lisp_Save_Value *p = XSAVE_VALUE (arg); | ||
| 590 | |||
| 591 | p->dogc = 0; | ||
| 592 | xfree (p->pointer); | ||
| 593 | p->pointer = 0; | ||
| 594 | return Qnil; | ||
| 595 | } | ||
| 596 | |||
| 597 | |||
| 583 | /* Like malloc but used for allocating Lisp data. NBYTES is the | 598 | /* Like malloc but used for allocating Lisp data. NBYTES is the |
| 584 | number of bytes to allocate, TYPE describes the intended use of the | 599 | number of bytes to allocate, TYPE describes the intended use of the |
| 585 | allcated memory block (for strings, for conses, ...). */ | 600 | allcated memory block (for strings, for conses, ...). */ |
| @@ -2935,6 +2950,7 @@ make_save_value (pointer, integer) | |||
| 2935 | p = XSAVE_VALUE (val); | 2950 | p = XSAVE_VALUE (val); |
| 2936 | p->pointer = pointer; | 2951 | p->pointer = pointer; |
| 2937 | p->integer = integer; | 2952 | p->integer = integer; |
| 2953 | p->dogc = 0; | ||
| 2938 | return val; | 2954 | return val; |
| 2939 | } | 2955 | } |
| 2940 | 2956 | ||
| @@ -4969,6 +4985,7 @@ mark_object (arg) | |||
| 4969 | if (XMARKER (obj)->gcmarkbit) | 4985 | if (XMARKER (obj)->gcmarkbit) |
| 4970 | break; | 4986 | break; |
| 4971 | XMARKER (obj)->gcmarkbit = 1; | 4987 | XMARKER (obj)->gcmarkbit = 1; |
| 4988 | |||
| 4972 | switch (XMISCTYPE (obj)) | 4989 | switch (XMISCTYPE (obj)) |
| 4973 | { | 4990 | { |
| 4974 | case Lisp_Misc_Buffer_Local_Value: | 4991 | case Lisp_Misc_Buffer_Local_Value: |
| @@ -4993,6 +5010,8 @@ mark_object (arg) | |||
| 4993 | /* DO NOT mark thru the marker's chain. | 5010 | /* DO NOT mark thru the marker's chain. |
| 4994 | The buffer's markers chain does not preserve markers from gc; | 5011 | The buffer's markers chain does not preserve markers from gc; |
| 4995 | instead, markers are removed from the chain when freed by gc. */ | 5012 | instead, markers are removed from the chain when freed by gc. */ |
| 5013 | break; | ||
| 5014 | |||
| 4996 | case Lisp_Misc_Intfwd: | 5015 | case Lisp_Misc_Intfwd: |
| 4997 | case Lisp_Misc_Boolfwd: | 5016 | case Lisp_Misc_Boolfwd: |
| 4998 | case Lisp_Misc_Objfwd: | 5017 | case Lisp_Misc_Objfwd: |
| @@ -5002,7 +5021,21 @@ mark_object (arg) | |||
| 5002 | since all markable slots in current buffer marked anyway. */ | 5021 | since all markable slots in current buffer marked anyway. */ |
| 5003 | /* Don't need to do Lisp_Objfwd, since the places they point | 5022 | /* Don't need to do Lisp_Objfwd, since the places they point |
| 5004 | are protected with staticpro. */ | 5023 | are protected with staticpro. */ |
| 5024 | break; | ||
| 5025 | |||
| 5005 | case Lisp_Misc_Save_Value: | 5026 | case Lisp_Misc_Save_Value: |
| 5027 | { | ||
| 5028 | register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); | ||
| 5029 | /* If DOGC is set, POINTER is the address of a memory | ||
| 5030 | area containing INTEGER potential Lisp_Objects. */ | ||
| 5031 | if (ptr->dogc) | ||
| 5032 | { | ||
| 5033 | Lisp_Object *p = (Lisp_Object *) ptr->pointer; | ||
| 5034 | int nelt; | ||
| 5035 | for (nelt = ptr->integer; nelt > 0; nelt--, p++) | ||
| 5036 | mark_maybe_object (*p); | ||
| 5037 | } | ||
| 5038 | } | ||
| 5006 | break; | 5039 | break; |
| 5007 | 5040 | ||
| 5008 | case Lisp_Misc_Overlay: | 5041 | case Lisp_Misc_Overlay: |
diff --git a/src/atimer.c b/src/atimer.c index 2ddc7427f56..7e78bdad9c0 100644 --- a/src/atimer.c +++ b/src/atimer.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Asynchronous timers. | 1 | /* Asynchronous timers. |
| 2 | Copyright (C) 2000 Free Software Foundation, Inc. | 2 | Copyright (C) 2000, 2004 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
diff --git a/src/atimer.h b/src/atimer.h index 3ecc97e5511..f987a47a6bd 100644 --- a/src/atimer.h +++ b/src/atimer.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Asynchronous timers. | 1 | /* Asynchronous timers. |
| 2 | Copyright (C) 2000 Free Software Foundation, Inc. | 2 | Copyright (C) 2000, 2003 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
diff --git a/src/blockinput.h b/src/blockinput.h index e9f2f3bc217..a4c8a9b9c22 100644 --- a/src/blockinput.h +++ b/src/blockinput.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* blockinput.h - interface to blocking complicated interrupt-driven input. | 1 | /* blockinput.h - interface to blocking complicated interrupt-driven input. |
| 2 | Copyright (C) 1989, 1993 Free Software Foundation, Inc. | 2 | Copyright (C) 1989, 1993, 2004 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is part of GNU Emacs. | 4 | This file is part of GNU Emacs. |
| 5 | 5 | ||
diff --git a/src/buffer.c b/src/buffer.c index 532a768ba50..031f5da8e6e 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -5437,7 +5437,7 @@ nil here means use current buffer's major mode. */); | |||
| 5437 | DEFVAR_PER_BUFFER ("fill-column", ¤t_buffer->fill_column, | 5437 | DEFVAR_PER_BUFFER ("fill-column", ¤t_buffer->fill_column, |
| 5438 | make_number (Lisp_Int), | 5438 | make_number (Lisp_Int), |
| 5439 | doc: /* *Column beyond which automatic line-wrapping should happen. | 5439 | doc: /* *Column beyond which automatic line-wrapping should happen. |
| 5440 | Interactively, you can set this using \\[set-fill-column]. */); | 5440 | Interactively, you can set the buffer local value using \\[set-fill-column]. */); |
| 5441 | 5441 | ||
| 5442 | DEFVAR_PER_BUFFER ("left-margin", ¤t_buffer->left_margin, | 5442 | DEFVAR_PER_BUFFER ("left-margin", ¤t_buffer->left_margin, |
| 5443 | make_number (Lisp_Int), | 5443 | make_number (Lisp_Int), |
| @@ -5847,7 +5847,11 @@ If the buffer has never been shown in a window, the value is nil. */); | |||
| 5847 | doc: /* *Non-nil means deactivate the mark when the buffer contents change. | 5847 | doc: /* *Non-nil means deactivate the mark when the buffer contents change. |
| 5848 | Non-nil also enables highlighting of the region whenever the mark is active. | 5848 | Non-nil also enables highlighting of the region whenever the mark is active. |
| 5849 | The variable `highlight-nonselected-windows' controls whether to highlight | 5849 | The variable `highlight-nonselected-windows' controls whether to highlight |
| 5850 | all windows or just the selected window. */); | 5850 | all windows or just the selected window. |
| 5851 | |||
| 5852 | If the value is `lambda', that enables Transient Mark mode temporarily | ||
| 5853 | until the next buffer modification. If a command sets the value to `only', | ||
| 5854 | that enables Transient Mark mode for the following command only. */); | ||
| 5851 | Vtransient_mark_mode = Qnil; | 5855 | Vtransient_mark_mode = Qnil; |
| 5852 | 5856 | ||
| 5853 | DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only, | 5857 | DEFVAR_LISP ("inhibit-read-only", &Vinhibit_read_only, |
diff --git a/src/buffer.h b/src/buffer.h index b5227cb9981..e59211d4111 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Header file for the buffer manipulation primitives. | 1 | /* Header file for the buffer manipulation primitives. |
| 2 | Copyright (C) 1985, 86, 93, 94, 95, 97, 1998, 1999, 2000, 01, 2003 | 2 | Copyright (C) 1985,86,93,94,95,97,98,99,2000,01,03,04 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
diff --git a/src/callproc.c b/src/callproc.c index 73d81d81b18..c3345eb3707 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Synchronous subprocess invocation for GNU Emacs. | 1 | /* Synchronous subprocess invocation for GNU Emacs. |
| 2 | Copyright (C) 1985,86,87,88,93,94,95,99, 2000, 2001 | 2 | Copyright (C) 1985,86,87,88,93,94,95,99, 2000,01,02,03,04 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -222,7 +222,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 222 | register int pid; | 222 | register int pid; |
| 223 | char buf[16384]; | 223 | char buf[16384]; |
| 224 | char *bufptr = buf; | 224 | char *bufptr = buf; |
| 225 | int bufsize = 16384; | 225 | int bufsize = sizeof buf; |
| 226 | int count = SPECPDL_INDEX (); | 226 | int count = SPECPDL_INDEX (); |
| 227 | 227 | ||
| 228 | register const unsigned char **new_argv | 228 | register const unsigned char **new_argv |
diff --git a/src/casefiddle.c b/src/casefiddle.c index 6387c4bc845..25a5a3d12b8 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* GNU Emacs case conversion functions. | 1 | /* GNU Emacs case conversion functions. |
| 2 | Copyright (C) 1985, 1994, 1997 Free Software Foundation, Inc. | 2 | Copyright (C) 1985,94,97,98,99, 2001, 2002, 2004 |
| 3 | Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -109,8 +110,12 @@ casify_object (flag, obj) | |||
| 109 | /* The work is not yet finished because of a multibyte | 110 | /* The work is not yet finished because of a multibyte |
| 110 | character just encountered. */ | 111 | character just encountered. */ |
| 111 | int fromlen, j_byte = i; | 112 | int fromlen, j_byte = i; |
| 112 | char *buf | 113 | char *buf; |
| 113 | = (char *) alloca ((len - i) * MAX_MULTIBYTE_LENGTH + i); | 114 | int bufsize; |
| 115 | USE_SAFE_ALLOCA; | ||
| 116 | |||
| 117 | bufsize = (len - i) * MAX_MULTIBYTE_LENGTH + i; | ||
| 118 | SAFE_ALLOCA (buf, char *, bufsize); | ||
| 114 | 119 | ||
| 115 | /* Copy data already handled. */ | 120 | /* Copy data already handled. */ |
| 116 | bcopy (SDATA (obj), buf, i); | 121 | bcopy (SDATA (obj), buf, i); |
| @@ -132,6 +137,7 @@ casify_object (flag, obj) | |||
| 132 | } | 137 | } |
| 133 | obj = make_multibyte_string (buf, SCHARS (obj), | 138 | obj = make_multibyte_string (buf, SCHARS (obj), |
| 134 | j_byte); | 139 | j_byte); |
| 140 | SAFE_FREE (bufsize); | ||
| 135 | } | 141 | } |
| 136 | return obj; | 142 | return obj; |
| 137 | } | 143 | } |
diff --git a/src/charset.c b/src/charset.c index 57a12b2398d..8eeddd51c92 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -1645,11 +1645,16 @@ usage: (string &rest CHARACTERS) */) | |||
| 1645 | int n; | 1645 | int n; |
| 1646 | Lisp_Object *args; | 1646 | Lisp_Object *args; |
| 1647 | { | 1647 | { |
| 1648 | int i; | 1648 | int i, bufsize; |
| 1649 | unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n); | 1649 | unsigned char *buf, *p; |
| 1650 | unsigned char *p = buf; | ||
| 1651 | int c; | 1650 | int c; |
| 1652 | int multibyte = 0; | 1651 | int multibyte = 0; |
| 1652 | Lisp_Object ret; | ||
| 1653 | USE_SAFE_ALLOCA; | ||
| 1654 | |||
| 1655 | bufsize = MAX_MULTIBYTE_LENGTH * n; | ||
| 1656 | SAFE_ALLOCA (buf, unsigned char *, bufsize); | ||
| 1657 | p = buf; | ||
| 1653 | 1658 | ||
| 1654 | for (i = 0; i < n; i++) | 1659 | for (i = 0; i < n; i++) |
| 1655 | { | 1660 | { |
| @@ -1667,7 +1672,10 @@ usage: (string &rest CHARACTERS) */) | |||
| 1667 | *p++ = c; | 1672 | *p++ = c; |
| 1668 | } | 1673 | } |
| 1669 | 1674 | ||
| 1670 | return make_string_from_bytes (buf, n, p - buf); | 1675 | ret = make_string_from_bytes (buf, n, p - buf); |
| 1676 | SAFE_FREE (bufsize); | ||
| 1677 | |||
| 1678 | return ret; | ||
| 1671 | } | 1679 | } |
| 1672 | 1680 | ||
| 1673 | #endif /* emacs */ | 1681 | #endif /* emacs */ |
diff --git a/src/coding.c b/src/coding.c index ed4b131b3a9..b36f7fbfbff 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -2094,7 +2094,7 @@ decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) | |||
| 2094 | int dim, M, L; | 2094 | int dim, M, L; |
| 2095 | int size, required; | 2095 | int size, required; |
| 2096 | int produced_chars; | 2096 | int produced_chars; |
| 2097 | 2097 | ||
| 2098 | ONE_MORE_BYTE (dim); | 2098 | ONE_MORE_BYTE (dim); |
| 2099 | ONE_MORE_BYTE (M); | 2099 | ONE_MORE_BYTE (M); |
| 2100 | ONE_MORE_BYTE (L); | 2100 | ONE_MORE_BYTE (L); |
| @@ -4548,10 +4548,6 @@ struct conversion_buffer | |||
| 4548 | unsigned char *data; | 4548 | unsigned char *data; |
| 4549 | }; | 4549 | }; |
| 4550 | 4550 | ||
| 4551 | /* Don't use alloca for allocating memory space larger than this, lest | ||
| 4552 | we overflow their stack. */ | ||
| 4553 | #define MAX_ALLOCA 16*1024 | ||
| 4554 | |||
| 4555 | /* Allocate LEN bytes of memory for BUF (struct conversion_buffer). */ | 4551 | /* Allocate LEN bytes of memory for BUF (struct conversion_buffer). */ |
| 4556 | #define allocate_conversion_buffer(buf, len) \ | 4552 | #define allocate_conversion_buffer(buf, len) \ |
| 4557 | do { \ | 4553 | do { \ |
| @@ -6654,7 +6650,7 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6654 | accept_latin_extra)); | 6650 | accept_latin_extra)); |
| 6655 | } | 6651 | } |
| 6656 | } | 6652 | } |
| 6657 | 6653 | ||
| 6658 | if (! encodable | 6654 | if (! encodable |
| 6659 | && ((CHAR_TABLE_P (translation_table) | 6655 | && ((CHAR_TABLE_P (translation_table) |
| 6660 | && ! NILP (Faref (translation_table, ch))) | 6656 | && ! NILP (Faref (translation_table, ch))) |
diff --git a/src/data.c b/src/data.c index 5a1a648dcb7..1259c5891a1 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -2052,11 +2052,6 @@ or a byte-code object. IDX starts at 0. */) | |||
| 2052 | } | 2052 | } |
| 2053 | } | 2053 | } |
| 2054 | 2054 | ||
| 2055 | /* Don't use alloca for relocating string data larger than this, lest | ||
| 2056 | we overflow their stack. The value is the same as what used in | ||
| 2057 | fns.c for base64 handling. */ | ||
| 2058 | #define MAX_ALLOCA 16*1024 | ||
| 2059 | |||
| 2060 | DEFUN ("aset", Faset, Saset, 3, 3, 0, | 2055 | DEFUN ("aset", Faset, Saset, 3, 3, 0, |
| 2061 | doc: /* Store into the element of ARRAY at index IDX the value NEWELT. | 2056 | doc: /* Store into the element of ARRAY at index IDX the value NEWELT. |
| 2062 | Return NEWELT. ARRAY may be a vector, a string, a char-table or a | 2057 | Return NEWELT. ARRAY may be a vector, a string, a char-table or a |
| @@ -2156,10 +2151,9 @@ bool-vector. IDX starts at 0. */) | |||
| 2156 | /* We must relocate the string data. */ | 2151 | /* We must relocate the string data. */ |
| 2157 | int nchars = SCHARS (array); | 2152 | int nchars = SCHARS (array); |
| 2158 | unsigned char *str; | 2153 | unsigned char *str; |
| 2154 | USE_SAFE_ALLOCA; | ||
| 2159 | 2155 | ||
| 2160 | str = (nbytes <= MAX_ALLOCA | 2156 | SAFE_ALLOCA (str, unsigned char *, nbytes); |
| 2161 | ? (unsigned char *) alloca (nbytes) | ||
| 2162 | : (unsigned char *) xmalloc (nbytes)); | ||
| 2163 | bcopy (SDATA (array), str, nbytes); | 2157 | bcopy (SDATA (array), str, nbytes); |
| 2164 | allocate_string_data (XSTRING (array), nchars, | 2158 | allocate_string_data (XSTRING (array), nchars, |
| 2165 | nbytes + new_bytes - prev_bytes); | 2159 | nbytes + new_bytes - prev_bytes); |
| @@ -2167,8 +2161,7 @@ bool-vector. IDX starts at 0. */) | |||
| 2167 | p1 = SDATA (array) + idxval_byte; | 2161 | p1 = SDATA (array) + idxval_byte; |
| 2168 | bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, | 2162 | bcopy (str + idxval_byte + prev_bytes, p1 + new_bytes, |
| 2169 | nbytes - (idxval_byte + prev_bytes)); | 2163 | nbytes - (idxval_byte + prev_bytes)); |
| 2170 | if (nbytes > MAX_ALLOCA) | 2164 | SAFE_FREE (nbytes); |
| 2171 | xfree (str); | ||
| 2172 | clear_string_char_byte_cache (); | 2165 | clear_string_char_byte_cache (); |
| 2173 | } | 2166 | } |
| 2174 | while (new_bytes--) | 2167 | while (new_bytes--) |
| @@ -2190,14 +2183,13 @@ bool-vector. IDX starts at 0. */) | |||
| 2190 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; | 2183 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; |
| 2191 | unsigned char *origstr = SDATA (array), *str; | 2184 | unsigned char *origstr = SDATA (array), *str; |
| 2192 | int nchars, nbytes; | 2185 | int nchars, nbytes; |
| 2186 | USE_SAFE_ALLOCA; | ||
| 2193 | 2187 | ||
| 2194 | nchars = SCHARS (array); | 2188 | nchars = SCHARS (array); |
| 2195 | nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); | 2189 | nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); |
| 2196 | nbytes += count_size_as_multibyte (origstr + idxval, | 2190 | nbytes += count_size_as_multibyte (origstr + idxval, |
| 2197 | nchars - idxval); | 2191 | nchars - idxval); |
| 2198 | str = (nbytes <= MAX_ALLOCA | 2192 | SAFE_ALLOCA (str, unsigned char *, nbytes); |
| 2199 | ? (unsigned char *) alloca (nbytes) | ||
| 2200 | : (unsigned char *) xmalloc (nbytes)); | ||
| 2201 | copy_text (SDATA (array), str, nchars, 0, 1); | 2193 | copy_text (SDATA (array), str, nchars, 0, 1); |
| 2202 | PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, | 2194 | PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, |
| 2203 | prev_bytes); | 2195 | prev_bytes); |
| @@ -2210,8 +2202,7 @@ bool-vector. IDX starts at 0. */) | |||
| 2210 | *p1++ = *p0++; | 2202 | *p1++ = *p0++; |
| 2211 | bcopy (str + idxval_byte + prev_bytes, p1, | 2203 | bcopy (str + idxval_byte + prev_bytes, p1, |
| 2212 | nbytes - (idxval_byte + prev_bytes)); | 2204 | nbytes - (idxval_byte + prev_bytes)); |
| 2213 | if (nbytes > MAX_ALLOCA) | 2205 | SAFE_FREE (nbytes); |
| 2214 | xfree (str); | ||
| 2215 | clear_string_char_byte_cache (); | 2206 | clear_string_char_byte_cache (); |
| 2216 | } | 2207 | } |
| 2217 | } | 2208 | } |
diff --git a/src/dispextern.h b/src/dispextern.h index 2b9ef2adbf0..f48cdbbe273 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Interface definitions for display code. | 1 | /* Interface definitions for display code. |
| 2 | Copyright (C) 1985, 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003 | 2 | Copyright (C) 1985,93,94,97,98,99, 2000,01,02,03, 2004 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -2645,8 +2645,6 @@ void w32_reset_fringes P_ ((void)); | |||
| 2645 | 2645 | ||
| 2646 | #ifdef HAVE_WINDOW_SYSTEM | 2646 | #ifdef HAVE_WINDOW_SYSTEM |
| 2647 | 2647 | ||
| 2648 | extern Lisp_Object Vimage_types; | ||
| 2649 | |||
| 2650 | extern int x_bitmap_height P_ ((struct frame *, int)); | 2648 | extern int x_bitmap_height P_ ((struct frame *, int)); |
| 2651 | extern int x_bitmap_width P_ ((struct frame *, int)); | 2649 | extern int x_bitmap_width P_ ((struct frame *, int)); |
| 2652 | extern int x_bitmap_pixmap P_ ((struct frame *, int)); | 2650 | extern int x_bitmap_pixmap P_ ((struct frame *, int)); |
| @@ -570,7 +570,7 @@ records them in function and variable definitions. | |||
| 570 | The function takes one argument, FILENAME, a string; | 570 | The function takes one argument, FILENAME, a string; |
| 571 | it specifies the file name (without a directory) of the DOC file. | 571 | it specifies the file name (without a directory) of the DOC file. |
| 572 | That file is found in `../etc' now; later, when the dumped Emacs is run, | 572 | That file is found in `../etc' now; later, when the dumped Emacs is run, |
| 573 | the same file name is found in the `data-directory'. */) | 573 | the same file name is found in the `doc-directory'. */) |
| 574 | (filename) | 574 | (filename) |
| 575 | Lisp_Object filename; | 575 | Lisp_Object filename; |
| 576 | { | 576 | { |
diff --git a/src/editfns.c b/src/editfns.c index c9dd4ecefdf..9fbdc0363bb 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3225,6 +3225,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3225 | int longest_format; | 3225 | int longest_format; |
| 3226 | Lisp_Object val; | 3226 | Lisp_Object val; |
| 3227 | int arg_intervals = 0; | 3227 | int arg_intervals = 0; |
| 3228 | USE_SAFE_ALLOCA; | ||
| 3228 | 3229 | ||
| 3229 | /* discarded[I] is 1 if byte I of the format | 3230 | /* discarded[I] is 1 if byte I of the format |
| 3230 | string was not copied into the output. | 3231 | string was not copied into the output. |
| @@ -3273,7 +3274,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3273 | longest_format = 0; | 3274 | longest_format = 0; |
| 3274 | 3275 | ||
| 3275 | /* Make room in result for all the non-%-codes in the control string. */ | 3276 | /* Make room in result for all the non-%-codes in the control string. */ |
| 3276 | total = 5 + CONVERTED_BYTE_SIZE (multibyte, args[0]); | 3277 | total = 5 + CONVERTED_BYTE_SIZE (multibyte, args[0]) + 1; |
| 3277 | 3278 | ||
| 3278 | /* Allocate the info and discarded tables. */ | 3279 | /* Allocate the info and discarded tables. */ |
| 3279 | { | 3280 | { |
| @@ -3466,10 +3467,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3466 | 3467 | ||
| 3467 | /* Allocate the space for the result. | 3468 | /* Allocate the space for the result. |
| 3468 | Note that TOTAL is an overestimate. */ | 3469 | Note that TOTAL is an overestimate. */ |
| 3469 | if (total < 1000) | 3470 | SAFE_ALLOCA (buf, char *, total); |
| 3470 | buf = (char *) alloca (total + 1); | ||
| 3471 | else | ||
| 3472 | buf = (char *) xmalloc (total + 1); | ||
| 3473 | 3471 | ||
| 3474 | p = buf; | 3472 | p = buf; |
| 3475 | nchars = 0; | 3473 | nchars = 0; |
| @@ -3602,7 +3600,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3602 | maybe_combine_byte = 1; | 3600 | maybe_combine_byte = 1; |
| 3603 | this_nchars = strlen (p); | 3601 | this_nchars = strlen (p); |
| 3604 | if (multibyte) | 3602 | if (multibyte) |
| 3605 | p += str_to_multibyte (p, buf + total - p, this_nchars); | 3603 | p += str_to_multibyte (p, buf + total - 1 - p, this_nchars); |
| 3606 | else | 3604 | else |
| 3607 | p += this_nchars; | 3605 | p += this_nchars; |
| 3608 | nchars += this_nchars; | 3606 | nchars += this_nchars; |
| @@ -3639,7 +3637,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3639 | *p++ = *format++, nchars++; | 3637 | *p++ = *format++, nchars++; |
| 3640 | } | 3638 | } |
| 3641 | 3639 | ||
| 3642 | if (p > buf + total + 1) | 3640 | if (p > buf + total) |
| 3643 | abort (); | 3641 | abort (); |
| 3644 | 3642 | ||
| 3645 | if (maybe_combine_byte) | 3643 | if (maybe_combine_byte) |
| @@ -3647,8 +3645,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3647 | val = make_specified_string (buf, nchars, p - buf, multibyte); | 3645 | val = make_specified_string (buf, nchars, p - buf, multibyte); |
| 3648 | 3646 | ||
| 3649 | /* If we allocated BUF with malloc, free it too. */ | 3647 | /* If we allocated BUF with malloc, free it too. */ |
| 3650 | if (total >= 1000) | 3648 | SAFE_FREE (total); |
| 3651 | xfree (buf); | ||
| 3652 | 3649 | ||
| 3653 | /* If the format string has text properties, or any of the string | 3650 | /* If the format string has text properties, or any of the string |
| 3654 | arguments has text properties, set up text properties of the | 3651 | arguments has text properties, set up text properties of the |
| @@ -4005,12 +4002,9 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4005 | /* First region smaller than second. */ | 4002 | /* First region smaller than second. */ |
| 4006 | if (len1_byte < len2_byte) | 4003 | if (len1_byte < len2_byte) |
| 4007 | { | 4004 | { |
| 4008 | /* We use alloca only if it is small, | 4005 | USE_SAFE_ALLOCA; |
| 4009 | because we want to avoid stack overflow. */ | 4006 | |
| 4010 | if (len2_byte > 20000) | 4007 | SAFE_ALLOCA (temp, unsigned char *, len2_byte); |
| 4011 | temp = (unsigned char *) xmalloc (len2_byte); | ||
| 4012 | else | ||
| 4013 | temp = (unsigned char *) alloca (len2_byte); | ||
| 4014 | 4008 | ||
| 4015 | /* Don't precompute these addresses. We have to compute them | 4009 | /* Don't precompute these addresses. We have to compute them |
| 4016 | at the last minute, because the relocating allocator might | 4010 | at the last minute, because the relocating allocator might |
| @@ -4021,23 +4015,20 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4021 | bcopy (start2_addr, temp, len2_byte); | 4015 | bcopy (start2_addr, temp, len2_byte); |
| 4022 | bcopy (start1_addr, start1_addr + len2_byte, len1_byte); | 4016 | bcopy (start1_addr, start1_addr + len2_byte, len1_byte); |
| 4023 | bcopy (temp, start1_addr, len2_byte); | 4017 | bcopy (temp, start1_addr, len2_byte); |
| 4024 | if (len2_byte > 20000) | 4018 | SAFE_FREE (len2_byte); |
| 4025 | xfree (temp); | ||
| 4026 | } | 4019 | } |
| 4027 | else | 4020 | else |
| 4028 | /* First region not smaller than second. */ | 4021 | /* First region not smaller than second. */ |
| 4029 | { | 4022 | { |
| 4030 | if (len1_byte > 20000) | 4023 | USE_SAFE_ALLOCA; |
| 4031 | temp = (unsigned char *) xmalloc (len1_byte); | 4024 | |
| 4032 | else | 4025 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); |
| 4033 | temp = (unsigned char *) alloca (len1_byte); | ||
| 4034 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4026 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4035 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4027 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4036 | bcopy (start1_addr, temp, len1_byte); | 4028 | bcopy (start1_addr, temp, len1_byte); |
| 4037 | bcopy (start2_addr, start1_addr, len2_byte); | 4029 | bcopy (start2_addr, start1_addr, len2_byte); |
| 4038 | bcopy (temp, start1_addr + len2_byte, len1_byte); | 4030 | bcopy (temp, start1_addr + len2_byte, len1_byte); |
| 4039 | if (len1_byte > 20000) | 4031 | SAFE_FREE (len1_byte); |
| 4040 | xfree (temp); | ||
| 4041 | } | 4032 | } |
| 4042 | graft_intervals_into_buffer (tmp_interval1, start1 + len2, | 4033 | graft_intervals_into_buffer (tmp_interval1, start1 + len2, |
| 4043 | len1, current_buffer, 0); | 4034 | len1, current_buffer, 0); |
| @@ -4054,6 +4045,8 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4054 | if (len1_byte == len2_byte) | 4045 | if (len1_byte == len2_byte) |
| 4055 | /* Regions are same size, though, how nice. */ | 4046 | /* Regions are same size, though, how nice. */ |
| 4056 | { | 4047 | { |
| 4048 | USE_SAFE_ALLOCA; | ||
| 4049 | |||
| 4057 | modify_region (current_buffer, start1, end1); | 4050 | modify_region (current_buffer, start1, end1); |
| 4058 | modify_region (current_buffer, start2, end2); | 4051 | modify_region (current_buffer, start2, end2); |
| 4059 | record_change (start1, len1); | 4052 | record_change (start1, len1); |
| @@ -4065,17 +4058,14 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4065 | Fset_text_properties (make_number (start2), make_number (end2), | 4058 | Fset_text_properties (make_number (start2), make_number (end2), |
| 4066 | Qnil, Qnil); | 4059 | Qnil, Qnil); |
| 4067 | 4060 | ||
| 4068 | if (len1_byte > 20000) | 4061 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); |
| 4069 | temp = (unsigned char *) xmalloc (len1_byte); | ||
| 4070 | else | ||
| 4071 | temp = (unsigned char *) alloca (len1_byte); | ||
| 4072 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4062 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4073 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4063 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4074 | bcopy (start1_addr, temp, len1_byte); | 4064 | bcopy (start1_addr, temp, len1_byte); |
| 4075 | bcopy (start2_addr, start1_addr, len2_byte); | 4065 | bcopy (start2_addr, start1_addr, len2_byte); |
| 4076 | bcopy (temp, start2_addr, len1_byte); | 4066 | bcopy (temp, start2_addr, len1_byte); |
| 4077 | if (len1_byte > 20000) | 4067 | SAFE_FREE (len1_byte); |
| 4078 | xfree (temp); | 4068 | |
| 4079 | graft_intervals_into_buffer (tmp_interval1, start2, | 4069 | graft_intervals_into_buffer (tmp_interval1, start2, |
| 4080 | len1, current_buffer, 0); | 4070 | len1, current_buffer, 0); |
| 4081 | graft_intervals_into_buffer (tmp_interval2, start1, | 4071 | graft_intervals_into_buffer (tmp_interval2, start1, |
| @@ -4085,6 +4075,8 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4085 | else if (len1_byte < len2_byte) /* Second region larger than first */ | 4075 | else if (len1_byte < len2_byte) /* Second region larger than first */ |
| 4086 | /* Non-adjacent & unequal size, area between must also be shifted. */ | 4076 | /* Non-adjacent & unequal size, area between must also be shifted. */ |
| 4087 | { | 4077 | { |
| 4078 | USE_SAFE_ALLOCA; | ||
| 4079 | |||
| 4088 | modify_region (current_buffer, start1, end2); | 4080 | modify_region (current_buffer, start1, end2); |
| 4089 | record_change (start1, (end2 - start1)); | 4081 | record_change (start1, (end2 - start1)); |
| 4090 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4082 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| @@ -4094,18 +4086,15 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4094 | Qnil, Qnil); | 4086 | Qnil, Qnil); |
| 4095 | 4087 | ||
| 4096 | /* holds region 2 */ | 4088 | /* holds region 2 */ |
| 4097 | if (len2_byte > 20000) | 4089 | SAFE_ALLOCA (temp, unsigned char *, len2_byte); |
| 4098 | temp = (unsigned char *) xmalloc (len2_byte); | ||
| 4099 | else | ||
| 4100 | temp = (unsigned char *) alloca (len2_byte); | ||
| 4101 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4090 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4102 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4091 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4103 | bcopy (start2_addr, temp, len2_byte); | 4092 | bcopy (start2_addr, temp, len2_byte); |
| 4104 | bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); | 4093 | bcopy (start1_addr, start1_addr + len_mid + len2_byte, len1_byte); |
| 4105 | safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); | 4094 | safe_bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); |
| 4106 | bcopy (temp, start1_addr, len2_byte); | 4095 | bcopy (temp, start1_addr, len2_byte); |
| 4107 | if (len2_byte > 20000) | 4096 | SAFE_FREE (len2_byte); |
| 4108 | xfree (temp); | 4097 | |
| 4109 | graft_intervals_into_buffer (tmp_interval1, end2 - len1, | 4098 | graft_intervals_into_buffer (tmp_interval1, end2 - len1, |
| 4110 | len1, current_buffer, 0); | 4099 | len1, current_buffer, 0); |
| 4111 | graft_intervals_into_buffer (tmp_interval_mid, start1 + len2, | 4100 | graft_intervals_into_buffer (tmp_interval_mid, start1 + len2, |
| @@ -4116,6 +4105,8 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4116 | else | 4105 | else |
| 4117 | /* Second region smaller than first. */ | 4106 | /* Second region smaller than first. */ |
| 4118 | { | 4107 | { |
| 4108 | USE_SAFE_ALLOCA; | ||
| 4109 | |||
| 4119 | record_change (start1, (end2 - start1)); | 4110 | record_change (start1, (end2 - start1)); |
| 4120 | modify_region (current_buffer, start1, end2); | 4111 | modify_region (current_buffer, start1, end2); |
| 4121 | 4112 | ||
| @@ -4126,18 +4117,15 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4126 | Qnil, Qnil); | 4117 | Qnil, Qnil); |
| 4127 | 4118 | ||
| 4128 | /* holds region 1 */ | 4119 | /* holds region 1 */ |
| 4129 | if (len1_byte > 20000) | 4120 | SAFE_ALLOCA (temp, unsigned char *, len1_byte); |
| 4130 | temp = (unsigned char *) xmalloc (len1_byte); | ||
| 4131 | else | ||
| 4132 | temp = (unsigned char *) alloca (len1_byte); | ||
| 4133 | start1_addr = BYTE_POS_ADDR (start1_byte); | 4121 | start1_addr = BYTE_POS_ADDR (start1_byte); |
| 4134 | start2_addr = BYTE_POS_ADDR (start2_byte); | 4122 | start2_addr = BYTE_POS_ADDR (start2_byte); |
| 4135 | bcopy (start1_addr, temp, len1_byte); | 4123 | bcopy (start1_addr, temp, len1_byte); |
| 4136 | bcopy (start2_addr, start1_addr, len2_byte); | 4124 | bcopy (start2_addr, start1_addr, len2_byte); |
| 4137 | bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); | 4125 | bcopy (start1_addr + len1_byte, start1_addr + len2_byte, len_mid); |
| 4138 | bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); | 4126 | bcopy (temp, start1_addr + len2_byte + len_mid, len1_byte); |
| 4139 | if (len1_byte > 20000) | 4127 | SAFE_FREE (len1_byte); |
| 4140 | xfree (temp); | 4128 | |
| 4141 | graft_intervals_into_buffer (tmp_interval1, end2 - len1, | 4129 | graft_intervals_into_buffer (tmp_interval1, end2 - len1, |
| 4142 | len1, current_buffer, 0); | 4130 | len1, current_buffer, 0); |
| 4143 | graft_intervals_into_buffer (tmp_interval_mid, start1 + len2, | 4131 | graft_intervals_into_buffer (tmp_interval_mid, start1 + len2, |
| @@ -994,6 +994,8 @@ string_make_multibyte (string) | |||
| 994 | { | 994 | { |
| 995 | unsigned char *buf; | 995 | unsigned char *buf; |
| 996 | int nbytes; | 996 | int nbytes; |
| 997 | Lisp_Object ret; | ||
| 998 | USE_SAFE_ALLOCA; | ||
| 997 | 999 | ||
| 998 | if (STRING_MULTIBYTE (string)) | 1000 | if (STRING_MULTIBYTE (string)) |
| 999 | return string; | 1001 | return string; |
| @@ -1005,11 +1007,14 @@ string_make_multibyte (string) | |||
| 1005 | if (nbytes == SBYTES (string)) | 1007 | if (nbytes == SBYTES (string)) |
| 1006 | return string; | 1008 | return string; |
| 1007 | 1009 | ||
| 1008 | buf = (unsigned char *) alloca (nbytes); | 1010 | SAFE_ALLOCA (buf, unsigned char *, nbytes); |
| 1009 | copy_text (SDATA (string), buf, SBYTES (string), | 1011 | copy_text (SDATA (string), buf, SBYTES (string), |
| 1010 | 0, 1); | 1012 | 0, 1); |
| 1011 | 1013 | ||
| 1012 | return make_multibyte_string (buf, SCHARS (string), nbytes); | 1014 | ret = make_multibyte_string (buf, SCHARS (string), nbytes); |
| 1015 | SAFE_FREE (nbytes); | ||
| 1016 | |||
| 1017 | return ret; | ||
| 1013 | } | 1018 | } |
| 1014 | 1019 | ||
| 1015 | 1020 | ||
| @@ -1024,6 +1029,8 @@ string_to_multibyte (string) | |||
| 1024 | { | 1029 | { |
| 1025 | unsigned char *buf; | 1030 | unsigned char *buf; |
| 1026 | int nbytes; | 1031 | int nbytes; |
| 1032 | Lisp_Object ret; | ||
| 1033 | USE_SAFE_ALLOCA; | ||
| 1027 | 1034 | ||
| 1028 | if (STRING_MULTIBYTE (string)) | 1035 | if (STRING_MULTIBYTE (string)) |
| 1029 | return string; | 1036 | return string; |
| @@ -1034,11 +1041,14 @@ string_to_multibyte (string) | |||
| 1034 | if (nbytes == SBYTES (string)) | 1041 | if (nbytes == SBYTES (string)) |
| 1035 | return make_multibyte_string (SDATA (string), nbytes, nbytes); | 1042 | return make_multibyte_string (SDATA (string), nbytes, nbytes); |
| 1036 | 1043 | ||
| 1037 | buf = (unsigned char *) alloca (nbytes); | 1044 | SAFE_ALLOCA (buf, unsigned char *, nbytes); |
| 1038 | bcopy (SDATA (string), buf, SBYTES (string)); | 1045 | bcopy (SDATA (string), buf, SBYTES (string)); |
| 1039 | str_to_multibyte (buf, nbytes, SBYTES (string)); | 1046 | str_to_multibyte (buf, nbytes, SBYTES (string)); |
| 1040 | 1047 | ||
| 1041 | return make_multibyte_string (buf, SCHARS (string), nbytes); | 1048 | ret = make_multibyte_string (buf, SCHARS (string), nbytes); |
| 1049 | SAFE_FREE (nbytes); | ||
| 1050 | |||
| 1051 | return ret; | ||
| 1042 | } | 1052 | } |
| 1043 | 1053 | ||
| 1044 | 1054 | ||
| @@ -1048,17 +1058,24 @@ Lisp_Object | |||
| 1048 | string_make_unibyte (string) | 1058 | string_make_unibyte (string) |
| 1049 | Lisp_Object string; | 1059 | Lisp_Object string; |
| 1050 | { | 1060 | { |
| 1061 | int nchars; | ||
| 1051 | unsigned char *buf; | 1062 | unsigned char *buf; |
| 1063 | Lisp_Object ret; | ||
| 1064 | USE_SAFE_ALLOCA; | ||
| 1052 | 1065 | ||
| 1053 | if (! STRING_MULTIBYTE (string)) | 1066 | if (! STRING_MULTIBYTE (string)) |
| 1054 | return string; | 1067 | return string; |
| 1055 | 1068 | ||
| 1056 | buf = (unsigned char *) alloca (SCHARS (string)); | 1069 | nchars = SCHARS (string); |
| 1057 | 1070 | ||
| 1071 | SAFE_ALLOCA (buf, unsigned char *, nchars); | ||
| 1058 | copy_text (SDATA (string), buf, SBYTES (string), | 1072 | copy_text (SDATA (string), buf, SBYTES (string), |
| 1059 | 1, 0); | 1073 | 1, 0); |
| 1060 | 1074 | ||
| 1061 | return make_unibyte_string (buf, SCHARS (string)); | 1075 | ret = make_unibyte_string (buf, nchars); |
| 1076 | SAFE_FREE (nchars); | ||
| 1077 | |||
| 1078 | return ret; | ||
| 1062 | } | 1079 | } |
| 1063 | 1080 | ||
| 1064 | DEFUN ("string-make-multibyte", Fstring_make_multibyte, Sstring_make_multibyte, | 1081 | DEFUN ("string-make-multibyte", Fstring_make_multibyte, Sstring_make_multibyte, |
| @@ -2983,13 +3000,15 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */) | |||
| 2983 | register Lisp_Object *args; | 3000 | register Lisp_Object *args; |
| 2984 | register int i; | 3001 | register int i; |
| 2985 | struct gcpro gcpro1; | 3002 | struct gcpro gcpro1; |
| 3003 | Lisp_Object ret; | ||
| 3004 | USE_SAFE_ALLOCA; | ||
| 2986 | 3005 | ||
| 2987 | len = Flength (sequence); | 3006 | len = Flength (sequence); |
| 2988 | leni = XINT (len); | 3007 | leni = XINT (len); |
| 2989 | nargs = leni + leni - 1; | 3008 | nargs = leni + leni - 1; |
| 2990 | if (nargs < 0) return build_string (""); | 3009 | if (nargs < 0) return build_string (""); |
| 2991 | 3010 | ||
| 2992 | args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); | 3011 | SAFE_ALLOCA_LISP (args, nargs); |
| 2993 | 3012 | ||
| 2994 | GCPRO1 (separator); | 3013 | GCPRO1 (separator); |
| 2995 | mapcar1 (leni, args, function, sequence); | 3014 | mapcar1 (leni, args, function, sequence); |
| @@ -3001,7 +3020,14 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */) | |||
| 3001 | for (i = 1; i < nargs; i += 2) | 3020 | for (i = 1; i < nargs; i += 2) |
| 3002 | args[i] = separator; | 3021 | args[i] = separator; |
| 3003 | 3022 | ||
| 3004 | return Fconcat (nargs, args); | 3023 | GCPRO1 (*args); |
| 3024 | gcpro1.nvars = nargs; | ||
| 3025 | ret = Fconcat (nargs, args); | ||
| 3026 | UNGCPRO; | ||
| 3027 | |||
| 3028 | SAFE_FREE_LISP (nargs); | ||
| 3029 | |||
| 3030 | return ret; | ||
| 3005 | } | 3031 | } |
| 3006 | 3032 | ||
| 3007 | DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0, | 3033 | DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0, |
| @@ -3014,14 +3040,25 @@ SEQUENCE may be a list, a vector, a bool-vector, or a string. */) | |||
| 3014 | register Lisp_Object len; | 3040 | register Lisp_Object len; |
| 3015 | register int leni; | 3041 | register int leni; |
| 3016 | register Lisp_Object *args; | 3042 | register Lisp_Object *args; |
| 3043 | struct gcpro gcpro1; | ||
| 3044 | Lisp_Object ret; | ||
| 3045 | USE_SAFE_ALLOCA; | ||
| 3017 | 3046 | ||
| 3018 | len = Flength (sequence); | 3047 | len = Flength (sequence); |
| 3019 | leni = XFASTINT (len); | 3048 | leni = XFASTINT (len); |
| 3020 | args = (Lisp_Object *) alloca (leni * sizeof (Lisp_Object)); | 3049 | |
| 3050 | SAFE_ALLOCA_LISP (args, leni); | ||
| 3021 | 3051 | ||
| 3022 | mapcar1 (leni, args, function, sequence); | 3052 | mapcar1 (leni, args, function, sequence); |
| 3023 | 3053 | ||
| 3024 | return Flist (leni, args); | 3054 | GCPRO1 (*args); |
| 3055 | gcpro1.nvars = leni; | ||
| 3056 | ret = Flist (leni, args); | ||
| 3057 | UNGCPRO; | ||
| 3058 | |||
| 3059 | SAFE_FREE_LISP (leni); | ||
| 3060 | |||
| 3061 | return ret; | ||
| 3025 | } | 3062 | } |
| 3026 | 3063 | ||
| 3027 | DEFUN ("mapc", Fmapc, Smapc, 2, 2, 0, | 3064 | DEFUN ("mapc", Fmapc, Smapc, 2, 2, 0, |
| @@ -3636,10 +3673,6 @@ The data read from the system are decoded using `locale-coding-system'. */) | |||
| 3636 | } \ | 3673 | } \ |
| 3637 | while (IS_BASE64_IGNORABLE (c)) | 3674 | while (IS_BASE64_IGNORABLE (c)) |
| 3638 | 3675 | ||
| 3639 | /* Don't use alloca for regions larger than this, lest we overflow | ||
| 3640 | their stack. */ | ||
| 3641 | #define MAX_ALLOCA 16*1024 | ||
| 3642 | |||
| 3643 | /* Table of characters coding the 64 values. */ | 3676 | /* Table of characters coding the 64 values. */ |
| 3644 | static char base64_value_to_char[64] = | 3677 | static char base64_value_to_char[64] = |
| 3645 | { | 3678 | { |
| @@ -3705,6 +3738,7 @@ into shorter lines. */) | |||
| 3705 | int allength, length; | 3738 | int allength, length; |
| 3706 | int ibeg, iend, encoded_length; | 3739 | int ibeg, iend, encoded_length; |
| 3707 | int old_pos = PT; | 3740 | int old_pos = PT; |
| 3741 | USE_SAFE_ALLOCA; | ||
| 3708 | 3742 | ||
| 3709 | validate_region (&beg, &end); | 3743 | validate_region (&beg, &end); |
| 3710 | 3744 | ||
| @@ -3719,10 +3753,7 @@ into shorter lines. */) | |||
| 3719 | allength = length + length/3 + 1; | 3753 | allength = length + length/3 + 1; |
| 3720 | allength += allength / MIME_LINE_LENGTH + 1 + 6; | 3754 | allength += allength / MIME_LINE_LENGTH + 1 + 6; |
| 3721 | 3755 | ||
| 3722 | if (allength <= MAX_ALLOCA) | 3756 | SAFE_ALLOCA (encoded, char *, allength); |
| 3723 | encoded = (char *) alloca (allength); | ||
| 3724 | else | ||
| 3725 | encoded = (char *) xmalloc (allength); | ||
| 3726 | encoded_length = base64_encode_1 (BYTE_POS_ADDR (ibeg), encoded, length, | 3757 | encoded_length = base64_encode_1 (BYTE_POS_ADDR (ibeg), encoded, length, |
| 3727 | NILP (no_line_break), | 3758 | NILP (no_line_break), |
| 3728 | !NILP (current_buffer->enable_multibyte_characters)); | 3759 | !NILP (current_buffer->enable_multibyte_characters)); |
| @@ -3732,8 +3763,7 @@ into shorter lines. */) | |||
| 3732 | if (encoded_length < 0) | 3763 | if (encoded_length < 0) |
| 3733 | { | 3764 | { |
| 3734 | /* The encoding wasn't possible. */ | 3765 | /* The encoding wasn't possible. */ |
| 3735 | if (length > MAX_ALLOCA) | 3766 | SAFE_FREE (allength); |
| 3736 | xfree (encoded); | ||
| 3737 | error ("Multibyte character in data for base64 encoding"); | 3767 | error ("Multibyte character in data for base64 encoding"); |
| 3738 | } | 3768 | } |
| 3739 | 3769 | ||
| @@ -3741,8 +3771,7 @@ into shorter lines. */) | |||
| 3741 | and delete the old. (Insert first in order to preserve markers.) */ | 3771 | and delete the old. (Insert first in order to preserve markers.) */ |
| 3742 | SET_PT_BOTH (XFASTINT (beg), ibeg); | 3772 | SET_PT_BOTH (XFASTINT (beg), ibeg); |
| 3743 | insert (encoded, encoded_length); | 3773 | insert (encoded, encoded_length); |
| 3744 | if (allength > MAX_ALLOCA) | 3774 | SAFE_FREE (allength); |
| 3745 | xfree (encoded); | ||
| 3746 | del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); | 3775 | del_range_byte (ibeg + encoded_length, iend + encoded_length, 1); |
| 3747 | 3776 | ||
| 3748 | /* If point was outside of the region, restore it exactly; else just | 3777 | /* If point was outside of the region, restore it exactly; else just |
| @@ -3768,6 +3797,7 @@ into shorter lines. */) | |||
| 3768 | int allength, length, encoded_length; | 3797 | int allength, length, encoded_length; |
| 3769 | char *encoded; | 3798 | char *encoded; |
| 3770 | Lisp_Object encoded_string; | 3799 | Lisp_Object encoded_string; |
| 3800 | USE_SAFE_ALLOCA; | ||
| 3771 | 3801 | ||
| 3772 | CHECK_STRING (string); | 3802 | CHECK_STRING (string); |
| 3773 | 3803 | ||
| @@ -3779,10 +3809,7 @@ into shorter lines. */) | |||
| 3779 | allength += allength / MIME_LINE_LENGTH + 1 + 6; | 3809 | allength += allength / MIME_LINE_LENGTH + 1 + 6; |
| 3780 | 3810 | ||
| 3781 | /* We need to allocate enough room for decoding the text. */ | 3811 | /* We need to allocate enough room for decoding the text. */ |
| 3782 | if (allength <= MAX_ALLOCA) | 3812 | SAFE_ALLOCA (encoded, char *, allength); |
| 3783 | encoded = (char *) alloca (allength); | ||
| 3784 | else | ||
| 3785 | encoded = (char *) xmalloc (allength); | ||
| 3786 | 3813 | ||
| 3787 | encoded_length = base64_encode_1 (SDATA (string), | 3814 | encoded_length = base64_encode_1 (SDATA (string), |
| 3788 | encoded, length, NILP (no_line_break), | 3815 | encoded, length, NILP (no_line_break), |
| @@ -3793,14 +3820,12 @@ into shorter lines. */) | |||
| 3793 | if (encoded_length < 0) | 3820 | if (encoded_length < 0) |
| 3794 | { | 3821 | { |
| 3795 | /* The encoding wasn't possible. */ | 3822 | /* The encoding wasn't possible. */ |
| 3796 | if (length > MAX_ALLOCA) | 3823 | SAFE_FREE (allength); |
| 3797 | xfree (encoded); | ||
| 3798 | error ("Multibyte character in data for base64 encoding"); | 3824 | error ("Multibyte character in data for base64 encoding"); |
| 3799 | } | 3825 | } |
| 3800 | 3826 | ||
| 3801 | encoded_string = make_unibyte_string (encoded, encoded_length); | 3827 | encoded_string = make_unibyte_string (encoded, encoded_length); |
| 3802 | if (allength > MAX_ALLOCA) | 3828 | SAFE_FREE (allength); |
| 3803 | xfree (encoded); | ||
| 3804 | 3829 | ||
| 3805 | return encoded_string; | 3830 | return encoded_string; |
| 3806 | } | 3831 | } |
| @@ -3913,6 +3938,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ | |||
| 3913 | int decoded_length; | 3938 | int decoded_length; |
| 3914 | int inserted_chars; | 3939 | int inserted_chars; |
| 3915 | int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 3940 | int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
| 3941 | USE_SAFE_ALLOCA; | ||
| 3916 | 3942 | ||
| 3917 | validate_region (&beg, &end); | 3943 | validate_region (&beg, &end); |
| 3918 | 3944 | ||
| @@ -3925,10 +3951,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ | |||
| 3925 | working on a multibyte buffer, each decoded code may occupy at | 3951 | working on a multibyte buffer, each decoded code may occupy at |
| 3926 | most two bytes. */ | 3952 | most two bytes. */ |
| 3927 | allength = multibyte ? length * 2 : length; | 3953 | allength = multibyte ? length * 2 : length; |
| 3928 | if (allength <= MAX_ALLOCA) | 3954 | SAFE_ALLOCA (decoded, char *, allength); |
| 3929 | decoded = (char *) alloca (allength); | ||
| 3930 | else | ||
| 3931 | decoded = (char *) xmalloc (allength); | ||
| 3932 | 3955 | ||
| 3933 | move_gap_both (XFASTINT (beg), ibeg); | 3956 | move_gap_both (XFASTINT (beg), ibeg); |
| 3934 | decoded_length = base64_decode_1 (BYTE_POS_ADDR (ibeg), decoded, length, | 3957 | decoded_length = base64_decode_1 (BYTE_POS_ADDR (ibeg), decoded, length, |
| @@ -3939,8 +3962,7 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ | |||
| 3939 | if (decoded_length < 0) | 3962 | if (decoded_length < 0) |
| 3940 | { | 3963 | { |
| 3941 | /* The decoding wasn't possible. */ | 3964 | /* The decoding wasn't possible. */ |
| 3942 | if (allength > MAX_ALLOCA) | 3965 | SAFE_FREE (allength); |
| 3943 | xfree (decoded); | ||
| 3944 | error ("Invalid base64 data"); | 3966 | error ("Invalid base64 data"); |
| 3945 | } | 3967 | } |
| 3946 | 3968 | ||
| @@ -3948,8 +3970,8 @@ If the region can't be decoded, signal an error and don't modify the buffer. */ | |||
| 3948 | and delete the old. (Insert first in order to preserve markers.) */ | 3970 | and delete the old. (Insert first in order to preserve markers.) */ |
| 3949 | TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg); | 3971 | TEMP_SET_PT_BOTH (XFASTINT (beg), ibeg); |
| 3950 | insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0); | 3972 | insert_1_both (decoded, inserted_chars, decoded_length, 0, 1, 0); |
| 3951 | if (allength > MAX_ALLOCA) | 3973 | SAFE_FREE (allength); |
| 3952 | xfree (decoded); | 3974 | |
| 3953 | /* Delete the original text. */ | 3975 | /* Delete the original text. */ |
| 3954 | del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars, | 3976 | del_range_both (PT, PT_BYTE, XFASTINT (end) + inserted_chars, |
| 3955 | iend + decoded_length, 1); | 3977 | iend + decoded_length, 1); |
| @@ -3974,15 +3996,13 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, | |||
| 3974 | char *decoded; | 3996 | char *decoded; |
| 3975 | int length, decoded_length; | 3997 | int length, decoded_length; |
| 3976 | Lisp_Object decoded_string; | 3998 | Lisp_Object decoded_string; |
| 3999 | USE_SAFE_ALLOCA; | ||
| 3977 | 4000 | ||
| 3978 | CHECK_STRING (string); | 4001 | CHECK_STRING (string); |
| 3979 | 4002 | ||
| 3980 | length = SBYTES (string); | 4003 | length = SBYTES (string); |
| 3981 | /* We need to allocate enough room for decoding the text. */ | 4004 | /* We need to allocate enough room for decoding the text. */ |
| 3982 | if (length <= MAX_ALLOCA) | 4005 | SAFE_ALLOCA (decoded, char *, length); |
| 3983 | decoded = (char *) alloca (length); | ||
| 3984 | else | ||
| 3985 | decoded = (char *) xmalloc (length); | ||
| 3986 | 4006 | ||
| 3987 | /* The decoded result should be unibyte. */ | 4007 | /* The decoded result should be unibyte. */ |
| 3988 | decoded_length = base64_decode_1 (SDATA (string), decoded, length, | 4008 | decoded_length = base64_decode_1 (SDATA (string), decoded, length, |
| @@ -3994,8 +4014,7 @@ DEFUN ("base64-decode-string", Fbase64_decode_string, Sbase64_decode_string, | |||
| 3994 | else | 4014 | else |
| 3995 | decoded_string = Qnil; | 4015 | decoded_string = Qnil; |
| 3996 | 4016 | ||
| 3997 | if (length > MAX_ALLOCA) | 4017 | SAFE_FREE (length); |
| 3998 | xfree (decoded); | ||
| 3999 | if (!STRINGP (decoded_string)) | 4018 | if (!STRINGP (decoded_string)) |
| 4000 | error ("Invalid base64 data"); | 4019 | error ("Invalid base64 data"); |
| 4001 | 4020 | ||
diff --git a/src/image.c b/src/image.c index 3eccf0f001e..438e132807f 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -689,6 +689,10 @@ lookup_image_type (symbol) | |||
| 689 | { | 689 | { |
| 690 | struct image_type *type; | 690 | struct image_type *type; |
| 691 | 691 | ||
| 692 | /* We must initialize the image-type if it hasn't been already. */ | ||
| 693 | if (NILP (Finit_image_library (symbol))) | ||
| 694 | return 0; /* unimplemented */ | ||
| 695 | |||
| 692 | for (type = image_types; type; type = type->next) | 696 | for (type = image_types; type; type = type->next) |
| 693 | if (EQ (symbol, *type->type)) | 697 | if (EQ (symbol, *type->type)) |
| 694 | break; | 698 | break; |
diff --git a/src/keyboard.c b/src/keyboard.c index de2bcf825a0..e9c9edbd239 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -670,6 +670,8 @@ static void handle_interrupt P_ ((void)); | |||
| 670 | to support it. */ | 670 | to support it. */ |
| 671 | static int cannot_suspend; | 671 | static int cannot_suspend; |
| 672 | 672 | ||
| 673 | extern Lisp_Object Qidentity, Qonly; | ||
| 674 | |||
| 673 | /* Install the string STR as the beginning of the string of echoing, | 675 | /* Install the string STR as the beginning of the string of echoing, |
| 674 | so that it serves as a prompt for the next character. | 676 | so that it serves as a prompt for the next character. |
| 675 | Also start echoing. */ | 677 | Also start echoing. */ |
| @@ -1809,6 +1811,16 @@ command_loop_1 () | |||
| 1809 | call1 (Vrun_hooks, intern ("activate-mark-hook")); | 1811 | call1 (Vrun_hooks, intern ("activate-mark-hook")); |
| 1810 | } | 1812 | } |
| 1811 | 1813 | ||
| 1814 | /* Setting transient-mark-mode to `only' is a way of | ||
| 1815 | turning it on for just one command. */ | ||
| 1816 | if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks)) | ||
| 1817 | { | ||
| 1818 | if (EQ (Vtransient_mark_mode, Qidentity)) | ||
| 1819 | Vtransient_mark_mode = Qnil; | ||
| 1820 | if (EQ (Vtransient_mark_mode, Qonly)) | ||
| 1821 | Vtransient_mark_mode = Qidentity; | ||
| 1822 | } | ||
| 1823 | |||
| 1812 | finalize: | 1824 | finalize: |
| 1813 | 1825 | ||
| 1814 | if (current_buffer == prev_buffer | 1826 | if (current_buffer == prev_buffer |
diff --git a/src/keymap.c b/src/keymap.c index 30d66972094..42bbeb92a18 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -2283,7 +2283,11 @@ push_text_char_description (c, p) | |||
| 2283 | 2283 | ||
| 2284 | DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0, | 2284 | DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0, |
| 2285 | doc: /* Return a pretty description of file-character CHARACTER. | 2285 | doc: /* Return a pretty description of file-character CHARACTER. |
| 2286 | Control characters turn into "^char", etc. */) | 2286 | Control characters turn into "^char", etc. This differs from |
| 2287 | `single-key-description' which turns them into "C-char". | ||
| 2288 | Also, this function recognizes the 2**7 bit as the Meta character, | ||
| 2289 | whereas `single-key-description' uses the 2**27 bit for Meta. | ||
| 2290 | See Info node `(elisp)Describing Characters' for examples. */) | ||
| 2287 | (character) | 2291 | (character) |
| 2288 | Lisp_Object character; | 2292 | Lisp_Object character; |
| 2289 | { | 2293 | { |
diff --git a/src/lisp.h b/src/lisp.h index fdf76399e5d..ba2508e827b 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1199,7 +1199,10 @@ struct Lisp_Save_Value | |||
| 1199 | { | 1199 | { |
| 1200 | int type : 16; /* = Lisp_Misc_Save_Value */ | 1200 | int type : 16; /* = Lisp_Misc_Save_Value */ |
| 1201 | unsigned gcmarkbit : 1; | 1201 | unsigned gcmarkbit : 1; |
| 1202 | int spacer : 15; | 1202 | int spacer : 14; |
| 1203 | /* If DOGC is set, POINTER is the address of a memory | ||
| 1204 | area containing INTEGER potential Lisp_Objects. */ | ||
| 1205 | unsigned int dogc : 1; | ||
| 1203 | void *pointer; | 1206 | void *pointer; |
| 1204 | int integer; | 1207 | int integer; |
| 1205 | }; | 1208 | }; |
| @@ -3248,6 +3251,64 @@ extern Lisp_Object Vdirectory_sep_char; | |||
| 3248 | : Fcons ((el), (check))))) | 3251 | : Fcons ((el), (check))))) |
| 3249 | 3252 | ||
| 3250 | 3253 | ||
| 3254 | /* SAFE_ALLOCA normally allocates memory on the stack, but if size is | ||
| 3255 | larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack. */ | ||
| 3256 | |||
| 3257 | #define MAX_ALLOCA 16*1024 | ||
| 3258 | |||
| 3259 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); | ||
| 3260 | |||
| 3261 | #define USE_SAFE_ALLOCA \ | ||
| 3262 | int sa_count = SPECPDL_INDEX () | ||
| 3263 | |||
| 3264 | /* SAFE_ALLOCA allocates a simple buffer. */ | ||
| 3265 | |||
| 3266 | #define SAFE_ALLOCA(buf, type, size) \ | ||
| 3267 | do { \ | ||
| 3268 | if ((size) < MAX_ALLOCA) \ | ||
| 3269 | buf = (type) alloca (size); \ | ||
| 3270 | else \ | ||
| 3271 | { \ | ||
| 3272 | buf = (type) xmalloc (size); \ | ||
| 3273 | record_unwind_protect (safe_alloca_unwind, \ | ||
| 3274 | make_save_value (buf, 0)); \ | ||
| 3275 | } \ | ||
| 3276 | } while (0) | ||
| 3277 | |||
| 3278 | /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ | ||
| 3279 | |||
| 3280 | #define SAFE_FREE(size) \ | ||
| 3281 | do { \ | ||
| 3282 | if ((size) >= MAX_ALLOCA) \ | ||
| 3283 | unbind_to (sa_count, Qnil); \ | ||
| 3284 | } while (0) | ||
| 3285 | |||
| 3286 | |||
| 3287 | /* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ | ||
| 3288 | |||
| 3289 | #define SAFE_ALLOCA_LISP(buf, nelt) \ | ||
| 3290 | do { \ | ||
| 3291 | int size_ = (nelt) * sizeof (Lisp_Object); \ | ||
| 3292 | if (size_ < MAX_ALLOCA) \ | ||
| 3293 | buf = (Lisp_Object *) alloca (size_); \ | ||
| 3294 | else \ | ||
| 3295 | { \ | ||
| 3296 | Lisp_Object arg_; \ | ||
| 3297 | buf = (Lisp_Object *) xmalloc (size_); \ | ||
| 3298 | arg_ = make_save_value (buf, nelt); \ | ||
| 3299 | XSAVE_VALUE (arg_)->dogc = 1; \ | ||
| 3300 | record_unwind_protect (safe_alloca_unwind, arg_); \ | ||
| 3301 | } \ | ||
| 3302 | } while (0) | ||
| 3303 | |||
| 3304 | #define SAFE_FREE_LISP(nelt) \ | ||
| 3305 | do { \ | ||
| 3306 | if (((nelt) * sizeof (Lisp_Object)) >= MAX_ALLOCA) \ | ||
| 3307 | unbind_to (sa_count, Qnil); \ | ||
| 3308 | } while (0) | ||
| 3309 | |||
| 3310 | |||
| 3311 | |||
| 3251 | #endif /* EMACS_LISP_H */ | 3312 | #endif /* EMACS_LISP_H */ |
| 3252 | 3313 | ||
| 3253 | /* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e | 3314 | /* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e |
diff --git a/src/macfns.c b/src/macfns.c index 5c1b7770640..ec014e772e3 100644 --- a/src/macfns.c +++ b/src/macfns.c | |||
| @@ -2939,8 +2939,8 @@ If omitted or nil, that stands for the selected frame's display. */) | |||
| 2939 | { | 2939 | { |
| 2940 | struct mac_display_info *dpyinfo = check_x_display_info (display); | 2940 | struct mac_display_info *dpyinfo = check_x_display_info (display); |
| 2941 | 2941 | ||
| 2942 | /* MAC_TODO: check whether this is right */ | 2942 | /* We force 24+ bit depths to 24-bit to prevent an overflow. */ |
| 2943 | return make_number (dpyinfo->n_planes >= 8 ? 256 : 1 << dpyinfo->n_planes - 1); | 2943 | return make_number (1 << min (dpyinfo->n_planes, 24)); |
| 2944 | } | 2944 | } |
| 2945 | 2945 | ||
| 2946 | DEFUN ("x-server-max-request-size", Fx_server_max_request_size, | 2946 | DEFUN ("x-server-max-request-size", Fx_server_max_request_size, |
diff --git a/src/macterm.c b/src/macterm.c index 6a3cad56f46..2af910c5003 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -8840,10 +8840,16 @@ mac_initialize_display_info () | |||
| 8840 | dpyinfo->resx = 75.0; | 8840 | dpyinfo->resx = 75.0; |
| 8841 | dpyinfo->resy = 75.0; | 8841 | dpyinfo->resy = 75.0; |
| 8842 | dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); | 8842 | dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); |
| 8843 | #ifdef MAC_OSX | ||
| 8844 | /* HasDepth returns true if it is possible to have a 32 bit display, | ||
| 8845 | but this may not be what is actually used. Mac OSX can do better. */ | ||
| 8846 | dpyinfo->n_planes = CGDisplayBitsPerPixel (CGMainDisplayID ()); | ||
| 8847 | #else | ||
| 8843 | for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) | 8848 | for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) |
| 8844 | if (HasDepth (main_device_handle, dpyinfo->n_planes, | 8849 | if (HasDepth (main_device_handle, dpyinfo->n_planes, |
| 8845 | gdDevType, dpyinfo->color_p)) | 8850 | gdDevType, dpyinfo->color_p)) |
| 8846 | break; | 8851 | break; |
| 8852 | #endif | ||
| 8847 | dpyinfo->height = (**main_device_handle).gdRect.bottom; | 8853 | dpyinfo->height = (**main_device_handle).gdRect.bottom; |
| 8848 | dpyinfo->width = (**main_device_handle).gdRect.right; | 8854 | dpyinfo->width = (**main_device_handle).gdRect.right; |
| 8849 | dpyinfo->grabbed = 0; | 8855 | dpyinfo->grabbed = 0; |
diff --git a/src/minibuf.c b/src/minibuf.c index 2f05a56d7dd..d28a5799afa 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -1212,6 +1212,7 @@ is used to further constrain the set of candidates. */) | |||
| 1212 | || NILP (XCAR (alist)))); | 1212 | || NILP (XCAR (alist)))); |
| 1213 | int index = 0, obsize = 0; | 1213 | int index = 0, obsize = 0; |
| 1214 | int matchcount = 0; | 1214 | int matchcount = 0; |
| 1215 | int bindcount = -1; | ||
| 1215 | Lisp_Object bucket, zero, end, tem; | 1216 | Lisp_Object bucket, zero, end, tem; |
| 1216 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1217 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1217 | 1218 | ||
| @@ -1290,21 +1291,22 @@ is used to further constrain the set of candidates. */) | |||
| 1290 | XSETFASTINT (zero, 0); | 1291 | XSETFASTINT (zero, 0); |
| 1291 | 1292 | ||
| 1292 | /* Ignore this element if it fails to match all the regexps. */ | 1293 | /* Ignore this element if it fails to match all the regexps. */ |
| 1293 | if (CONSP (Vcompletion_regexp_list)) | 1294 | { |
| 1294 | { | 1295 | for (regexps = Vcompletion_regexp_list; CONSP (regexps); |
| 1295 | int count = SPECPDL_INDEX (); | 1296 | regexps = XCDR (regexps)) |
| 1296 | specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); | 1297 | { |
| 1297 | for (regexps = Vcompletion_regexp_list; CONSP (regexps); | 1298 | if (bindcount < 0) { |
| 1298 | regexps = XCDR (regexps)) | 1299 | bindcount = SPECPDL_INDEX (); |
| 1299 | { | 1300 | specbind (Qcase_fold_search, |
| 1300 | tem = Fstring_match (XCAR (regexps), eltstring, zero); | 1301 | completion_ignore_case ? Qt : Qnil); |
| 1301 | if (NILP (tem)) | ||
| 1302 | break; | ||
| 1303 | } | 1302 | } |
| 1304 | unbind_to (count, Qnil); | 1303 | tem = Fstring_match (XCAR (regexps), eltstring, zero); |
| 1305 | if (CONSP (regexps)) | 1304 | if (NILP (tem)) |
| 1306 | continue; | 1305 | break; |
| 1307 | } | 1306 | } |
| 1307 | if (CONSP (regexps)) | ||
| 1308 | continue; | ||
| 1309 | } | ||
| 1308 | 1310 | ||
| 1309 | /* Ignore this element if there is a predicate | 1311 | /* Ignore this element if there is a predicate |
| 1310 | and the predicate doesn't like it. */ | 1312 | and the predicate doesn't like it. */ |
| @@ -1315,6 +1317,10 @@ is used to further constrain the set of candidates. */) | |||
| 1315 | tem = Fcommandp (elt, Qnil); | 1317 | tem = Fcommandp (elt, Qnil); |
| 1316 | else | 1318 | else |
| 1317 | { | 1319 | { |
| 1320 | if (bindcount >= 0) { | ||
| 1321 | unbind_to (bindcount, Qnil); | ||
| 1322 | bindcount = -1; | ||
| 1323 | } | ||
| 1318 | GCPRO4 (tail, string, eltstring, bestmatch); | 1324 | GCPRO4 (tail, string, eltstring, bestmatch); |
| 1319 | tem = type == 3 | 1325 | tem = type == 3 |
| 1320 | ? call2 (predicate, elt, | 1326 | ? call2 (predicate, elt, |
| @@ -1396,6 +1402,11 @@ is used to further constrain the set of candidates. */) | |||
| 1396 | } | 1402 | } |
| 1397 | } | 1403 | } |
| 1398 | 1404 | ||
| 1405 | if (bindcount >= 0) { | ||
| 1406 | unbind_to (bindcount, Qnil); | ||
| 1407 | bindcount = -1; | ||
| 1408 | } | ||
| 1409 | |||
| 1399 | if (NILP (bestmatch)) | 1410 | if (NILP (bestmatch)) |
| 1400 | return Qnil; /* No completions found */ | 1411 | return Qnil; /* No completions found */ |
| 1401 | /* If we are ignoring case, and there is no exact match, | 1412 | /* If we are ignoring case, and there is no exact match, |
| @@ -1458,6 +1469,7 @@ are ignored unless STRING itself starts with a space. */) | |||
| 1458 | && (!SYMBOLP (XCAR (alist)) | 1469 | && (!SYMBOLP (XCAR (alist)) |
| 1459 | || NILP (XCAR (alist)))); | 1470 | || NILP (XCAR (alist)))); |
| 1460 | int index = 0, obsize = 0; | 1471 | int index = 0, obsize = 0; |
| 1472 | int bindcount = -1; | ||
| 1461 | Lisp_Object bucket, tem; | 1473 | Lisp_Object bucket, tem; |
| 1462 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1474 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 1463 | 1475 | ||
| @@ -1542,21 +1554,22 @@ are ignored unless STRING itself starts with a space. */) | |||
| 1542 | XSETFASTINT (zero, 0); | 1554 | XSETFASTINT (zero, 0); |
| 1543 | 1555 | ||
| 1544 | /* Ignore this element if it fails to match all the regexps. */ | 1556 | /* Ignore this element if it fails to match all the regexps. */ |
| 1545 | if (CONSP (Vcompletion_regexp_list)) | 1557 | { |
| 1546 | { | 1558 | for (regexps = Vcompletion_regexp_list; CONSP (regexps); |
| 1547 | int count = SPECPDL_INDEX (); | 1559 | regexps = XCDR (regexps)) |
| 1548 | specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); | 1560 | { |
| 1549 | for (regexps = Vcompletion_regexp_list; CONSP (regexps); | 1561 | if (bindcount < 0) { |
| 1550 | regexps = XCDR (regexps)) | 1562 | bindcount = SPECPDL_INDEX (); |
| 1551 | { | 1563 | specbind (Qcase_fold_search, |
| 1552 | tem = Fstring_match (XCAR (regexps), eltstring, zero); | 1564 | completion_ignore_case ? Qt : Qnil); |
| 1553 | if (NILP (tem)) | ||
| 1554 | break; | ||
| 1555 | } | 1565 | } |
| 1556 | unbind_to (count, Qnil); | 1566 | tem = Fstring_match (XCAR (regexps), eltstring, zero); |
| 1557 | if (CONSP (regexps)) | 1567 | if (NILP (tem)) |
| 1558 | continue; | 1568 | break; |
| 1559 | } | 1569 | } |
| 1570 | if (CONSP (regexps)) | ||
| 1571 | continue; | ||
| 1572 | } | ||
| 1560 | 1573 | ||
| 1561 | /* Ignore this element if there is a predicate | 1574 | /* Ignore this element if there is a predicate |
| 1562 | and the predicate doesn't like it. */ | 1575 | and the predicate doesn't like it. */ |
| @@ -1567,6 +1580,10 @@ are ignored unless STRING itself starts with a space. */) | |||
| 1567 | tem = Fcommandp (elt, Qnil); | 1580 | tem = Fcommandp (elt, Qnil); |
| 1568 | else | 1581 | else |
| 1569 | { | 1582 | { |
| 1583 | if (bindcount >= 0) { | ||
| 1584 | unbind_to (bindcount, Qnil); | ||
| 1585 | bindcount = -1; | ||
| 1586 | } | ||
| 1570 | GCPRO4 (tail, eltstring, allmatches, string); | 1587 | GCPRO4 (tail, eltstring, allmatches, string); |
| 1571 | tem = type == 3 | 1588 | tem = type == 3 |
| 1572 | ? call2 (predicate, elt, | 1589 | ? call2 (predicate, elt, |
| @@ -1581,6 +1598,11 @@ are ignored unless STRING itself starts with a space. */) | |||
| 1581 | } | 1598 | } |
| 1582 | } | 1599 | } |
| 1583 | 1600 | ||
| 1601 | if (bindcount >= 0) { | ||
| 1602 | unbind_to (bindcount, Qnil); | ||
| 1603 | bindcount = -1; | ||
| 1604 | } | ||
| 1605 | |||
| 1584 | return Fnreverse (allmatches); | 1606 | return Fnreverse (allmatches); |
| 1585 | } | 1607 | } |
| 1586 | 1608 | ||
diff --git a/src/print.c b/src/print.c index a91276d409a..0abd30b5ce0 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -658,7 +658,7 @@ If variable `temp-buffer-show-function' is non-nil, call it at the end | |||
| 658 | to get the buffer displayed instead of just displaying the non-selected | 658 | to get the buffer displayed instead of just displaying the non-selected |
| 659 | buffer and calling the hook. It gets one argument, the buffer to display. | 659 | buffer and calling the hook. It gets one argument, the buffer to display. |
| 660 | 660 | ||
| 661 | usage: (with-output-to-temp-buffer BUFFNAME BODY ...) */) | 661 | usage: (with-output-to-temp-buffer BUFNAME BODY ...) */) |
| 662 | (args) | 662 | (args) |
| 663 | Lisp_Object args; | 663 | Lisp_Object args; |
| 664 | { | 664 | { |
diff --git a/src/search.c b/src/search.c index 24f21f053a5..dc1ca91e38f 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -2589,15 +2589,20 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2589 | /* Adjust search data for this change. */ | 2589 | /* Adjust search data for this change. */ |
| 2590 | { | 2590 | { |
| 2591 | int oldend = search_regs.end[sub]; | 2591 | int oldend = search_regs.end[sub]; |
| 2592 | int oldstart = search_regs.start[sub]; | ||
| 2592 | int change = newpoint - search_regs.end[sub]; | 2593 | int change = newpoint - search_regs.end[sub]; |
| 2593 | int i; | 2594 | int i; |
| 2594 | 2595 | ||
| 2595 | for (i = 0; i < search_regs.num_regs; i++) | 2596 | for (i = 0; i < search_regs.num_regs; i++) |
| 2596 | { | 2597 | { |
| 2597 | if (search_regs.start[i] > oldend) | 2598 | if (search_regs.start[i] >= oldend) |
| 2598 | search_regs.start[i] += change; | 2599 | search_regs.start[i] += change; |
| 2599 | if (search_regs.end[i] > oldend) | 2600 | else if (search_regs.start[i] > oldstart) |
| 2601 | search_regs.start[i] = oldstart; | ||
| 2602 | if (search_regs.end[i] >= oldend) | ||
| 2600 | search_regs.end[i] += change; | 2603 | search_regs.end[i] += change; |
| 2604 | else if (search_regs.end[i] > oldstart) | ||
| 2605 | search_regs.end[i] = oldstart; | ||
| 2601 | } | 2606 | } |
| 2602 | } | 2607 | } |
| 2603 | 2608 | ||
| @@ -2622,8 +2627,10 @@ match_limit (num, beginningp) | |||
| 2622 | 2627 | ||
| 2623 | CHECK_NUMBER (num); | 2628 | CHECK_NUMBER (num); |
| 2624 | n = XINT (num); | 2629 | n = XINT (num); |
| 2625 | if (n < 0 || search_regs.num_regs <= 0) | 2630 | if (n < 0) |
| 2626 | args_out_of_range (num, make_number (search_regs.num_regs)); | 2631 | args_out_of_range (num, 0); |
| 2632 | if (search_regs.num_regs <= 0) | ||
| 2633 | error ("No match data, because no search succeeded"); | ||
| 2627 | if (n >= search_regs.num_regs | 2634 | if (n >= search_regs.num_regs |
| 2628 | || search_regs.start[n] < 0) | 2635 | || search_regs.start[n] < 0) |
| 2629 | return Qnil; | 2636 | return Qnil; |
| @@ -2664,8 +2671,11 @@ All the elements are markers or nil (nil if the Nth pair didn't match) | |||
| 2664 | if the last match was on a buffer; integers or nil if a string was matched. | 2671 | if the last match was on a buffer; integers or nil if a string was matched. |
| 2665 | Use `store-match-data' to reinstate the data in this list. | 2672 | Use `store-match-data' to reinstate the data in this list. |
| 2666 | 2673 | ||
| 2667 | If INTEGERS (the optional first argument) is non-nil, always use integers | 2674 | If INTEGERS (the optional first argument) is non-nil, always use |
| 2668 | \(rather than markers) to represent buffer positions. | 2675 | integers \(rather than markers) to represent buffer positions. In |
| 2676 | this case, and if the last match was in a buffer, the buffer will get | ||
| 2677 | stored as one additional element at the end of the list. | ||
| 2678 | |||
| 2669 | If REUSE is a list, reuse it as part of the value. If REUSE is long enough | 2679 | If REUSE is a list, reuse it as part of the value. If REUSE is long enough |
| 2670 | to hold all the values, and if INTEGERS is non-nil, no consing is done. | 2680 | to hold all the values, and if INTEGERS is non-nil, no consing is done. |
| 2671 | 2681 | ||
| @@ -2682,10 +2692,10 @@ Return value is undefined if the last search failed. */) | |||
| 2682 | 2692 | ||
| 2683 | prev = Qnil; | 2693 | prev = Qnil; |
| 2684 | 2694 | ||
| 2685 | data = (Lisp_Object *) alloca ((2 * search_regs.num_regs) | 2695 | data = (Lisp_Object *) alloca ((2 * search_regs.num_regs + 1) |
| 2686 | * sizeof (Lisp_Object)); | 2696 | * sizeof (Lisp_Object)); |
| 2687 | 2697 | ||
| 2688 | len = -1; | 2698 | len = 0; |
| 2689 | for (i = 0; i < search_regs.num_regs; i++) | 2699 | for (i = 0; i < search_regs.num_regs; i++) |
| 2690 | { | 2700 | { |
| 2691 | int start = search_regs.start[i]; | 2701 | int start = search_regs.start[i]; |
| @@ -2712,22 +2722,29 @@ Return value is undefined if the last search failed. */) | |||
| 2712 | /* last_thing_searched must always be Qt, a buffer, or Qnil. */ | 2722 | /* last_thing_searched must always be Qt, a buffer, or Qnil. */ |
| 2713 | abort (); | 2723 | abort (); |
| 2714 | 2724 | ||
| 2715 | len = i; | 2725 | len = 2*(i+1); |
| 2716 | } | 2726 | } |
| 2717 | else | 2727 | else |
| 2718 | data[2 * i] = data [2 * i + 1] = Qnil; | 2728 | data[2 * i] = data [2 * i + 1] = Qnil; |
| 2719 | } | 2729 | } |
| 2720 | 2730 | ||
| 2731 | if (BUFFERP(last_thing_searched) | ||
| 2732 | && ! NILP (integers)) | ||
| 2733 | { | ||
| 2734 | XSETBUFFER(data[len], last_thing_searched); | ||
| 2735 | len++; | ||
| 2736 | } | ||
| 2737 | |||
| 2721 | /* If REUSE is not usable, cons up the values and return them. */ | 2738 | /* If REUSE is not usable, cons up the values and return them. */ |
| 2722 | if (! CONSP (reuse)) | 2739 | if (! CONSP (reuse)) |
| 2723 | return Flist (2 * len + 2, data); | 2740 | return Flist (len, data); |
| 2724 | 2741 | ||
| 2725 | /* If REUSE is a list, store as many value elements as will fit | 2742 | /* If REUSE is a list, store as many value elements as will fit |
| 2726 | into the elements of REUSE. */ | 2743 | into the elements of REUSE. */ |
| 2727 | for (i = 0, tail = reuse; CONSP (tail); | 2744 | for (i = 0, tail = reuse; CONSP (tail); |
| 2728 | i++, tail = XCDR (tail)) | 2745 | i++, tail = XCDR (tail)) |
| 2729 | { | 2746 | { |
| 2730 | if (i < 2 * len + 2) | 2747 | if (i < len) |
| 2731 | XSETCAR (tail, data[i]); | 2748 | XSETCAR (tail, data[i]); |
| 2732 | else | 2749 | else |
| 2733 | XSETCAR (tail, Qnil); | 2750 | XSETCAR (tail, Qnil); |
| @@ -2736,8 +2753,8 @@ Return value is undefined if the last search failed. */) | |||
| 2736 | 2753 | ||
| 2737 | /* If we couldn't fit all value elements into REUSE, | 2754 | /* If we couldn't fit all value elements into REUSE, |
| 2738 | cons up the rest of them and add them to the end of REUSE. */ | 2755 | cons up the rest of them and add them to the end of REUSE. */ |
| 2739 | if (i < 2 * len + 2) | 2756 | if (i < len) |
| 2740 | XSETCDR (prev, Flist (2 * len + 2 - i, data + i)); | 2757 | XSETCDR (prev, Flist (len - i, data + i)); |
| 2741 | 2758 | ||
| 2742 | return reuse; | 2759 | return reuse; |
| 2743 | } | 2760 | } |
| @@ -2758,8 +2775,8 @@ LIST should have been created by calling `match-data' previously. */) | |||
| 2758 | if (!CONSP (list) && !NILP (list)) | 2775 | if (!CONSP (list) && !NILP (list)) |
| 2759 | list = wrong_type_argument (Qconsp, list); | 2776 | list = wrong_type_argument (Qconsp, list); |
| 2760 | 2777 | ||
| 2761 | /* Unless we find a marker with a buffer in LIST, assume that this | 2778 | /* Unless we find a marker with a buffer or an explicit buffer |
| 2762 | match data came from a string. */ | 2779 | in LIST, assume that this match data came from a string. */ |
| 2763 | last_thing_searched = Qt; | 2780 | last_thing_searched = Qt; |
| 2764 | 2781 | ||
| 2765 | /* Allocate registers if they don't already exist. */ | 2782 | /* Allocate registers if they don't already exist. */ |
| @@ -2790,42 +2807,49 @@ LIST should have been created by calling `match-data' previously. */) | |||
| 2790 | 2807 | ||
| 2791 | search_regs.num_regs = length; | 2808 | search_regs.num_regs = length; |
| 2792 | } | 2809 | } |
| 2793 | } | ||
| 2794 | 2810 | ||
| 2795 | for (i = 0; i < search_regs.num_regs; i++) | 2811 | for (i = 0; i < length; i++) |
| 2796 | { | 2812 | { |
| 2797 | marker = Fcar (list); | 2813 | marker = Fcar (list); |
| 2798 | if (NILP (marker)) | 2814 | if (NILP (marker)) |
| 2799 | { | 2815 | { |
| 2800 | search_regs.start[i] = -1; | 2816 | search_regs.start[i] = -1; |
| 2801 | list = Fcdr (list); | 2817 | list = Fcdr (list); |
| 2802 | } | 2818 | } |
| 2803 | else | 2819 | else |
| 2804 | { | 2820 | { |
| 2805 | int from; | 2821 | int from; |
| 2806 | 2822 | ||
| 2807 | if (MARKERP (marker)) | 2823 | if (MARKERP (marker)) |
| 2808 | { | 2824 | { |
| 2809 | if (XMARKER (marker)->buffer == 0) | 2825 | if (XMARKER (marker)->buffer == 0) |
| 2810 | XSETFASTINT (marker, 0); | 2826 | XSETFASTINT (marker, 0); |
| 2811 | else | 2827 | else |
| 2812 | XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer); | 2828 | XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer); |
| 2813 | } | 2829 | } |
| 2814 | 2830 | ||
| 2815 | CHECK_NUMBER_COERCE_MARKER (marker); | 2831 | CHECK_NUMBER_COERCE_MARKER (marker); |
| 2816 | from = XINT (marker); | 2832 | from = XINT (marker); |
| 2817 | list = Fcdr (list); | 2833 | list = Fcdr (list); |
| 2834 | |||
| 2835 | marker = Fcar (list); | ||
| 2836 | if (MARKERP (marker) && XMARKER (marker)->buffer == 0) | ||
| 2837 | XSETFASTINT (marker, 0); | ||
| 2838 | |||
| 2839 | CHECK_NUMBER_COERCE_MARKER (marker); | ||
| 2840 | search_regs.start[i] = from; | ||
| 2841 | search_regs.end[i] = XINT (marker); | ||
| 2842 | } | ||
| 2843 | list = Fcdr (list); | ||
| 2844 | } | ||
| 2818 | 2845 | ||
| 2819 | marker = Fcar (list); | 2846 | for (; i < search_regs.num_regs; i++) |
| 2820 | if (MARKERP (marker) && XMARKER (marker)->buffer == 0) | 2847 | search_regs.start[i] = -1; |
| 2821 | XSETFASTINT (marker, 0); | 2848 | } |
| 2822 | 2849 | ||
| 2823 | CHECK_NUMBER_COERCE_MARKER (marker); | 2850 | if (CONSP(list) && BUFFERP(XCAR(list))) { |
| 2824 | search_regs.start[i] = from; | 2851 | XSETBUFFER(last_thing_searched, XCAR(list)); |
| 2825 | search_regs.end[i] = XINT (marker); | 2852 | } |
| 2826 | } | ||
| 2827 | list = Fcdr (list); | ||
| 2828 | } | ||
| 2829 | 2853 | ||
| 2830 | return Qnil; | 2854 | return Qnil; |
| 2831 | } | 2855 | } |
| @@ -2834,6 +2858,7 @@ LIST should have been created by calling `match-data' previously. */) | |||
| 2834 | during the execution of a sentinel or filter. */ | 2858 | during the execution of a sentinel or filter. */ |
| 2835 | static int search_regs_saved; | 2859 | static int search_regs_saved; |
| 2836 | static struct re_registers saved_search_regs; | 2860 | static struct re_registers saved_search_regs; |
| 2861 | static Lisp_Object saved_last_thing_searched; | ||
| 2837 | 2862 | ||
| 2838 | /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data | 2863 | /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data |
| 2839 | if asynchronous code (filter or sentinel) is running. */ | 2864 | if asynchronous code (filter or sentinel) is running. */ |
| @@ -2845,6 +2870,8 @@ save_search_regs () | |||
| 2845 | saved_search_regs.num_regs = search_regs.num_regs; | 2870 | saved_search_regs.num_regs = search_regs.num_regs; |
| 2846 | saved_search_regs.start = search_regs.start; | 2871 | saved_search_regs.start = search_regs.start; |
| 2847 | saved_search_regs.end = search_regs.end; | 2872 | saved_search_regs.end = search_regs.end; |
| 2873 | saved_last_thing_searched = last_thing_searched; | ||
| 2874 | last_thing_searched = Qnil; | ||
| 2848 | search_regs.num_regs = 0; | 2875 | search_regs.num_regs = 0; |
| 2849 | search_regs.start = 0; | 2876 | search_regs.start = 0; |
| 2850 | search_regs.end = 0; | 2877 | search_regs.end = 0; |
| @@ -2867,7 +2894,8 @@ restore_match_data () | |||
| 2867 | search_regs.num_regs = saved_search_regs.num_regs; | 2894 | search_regs.num_regs = saved_search_regs.num_regs; |
| 2868 | search_regs.start = saved_search_regs.start; | 2895 | search_regs.start = saved_search_regs.start; |
| 2869 | search_regs.end = saved_search_regs.end; | 2896 | search_regs.end = saved_search_regs.end; |
| 2870 | 2897 | last_thing_searched = saved_last_thing_searched; | |
| 2898 | saved_last_thing_searched = Qnil; | ||
| 2871 | search_regs_saved = 0; | 2899 | search_regs_saved = 0; |
| 2872 | } | 2900 | } |
| 2873 | } | 2901 | } |
diff --git a/src/syntax.c b/src/syntax.c index 62612620f03..302250c39a4 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -1455,7 +1455,7 @@ skip_chars (forwardp, syntaxp, string, lim, handle_iso_classes) | |||
| 1455 | { | 1455 | { |
| 1456 | const unsigned char *class_beg = str + i_byte + 1; | 1456 | const unsigned char *class_beg = str + i_byte + 1; |
| 1457 | const unsigned char *class_end = class_beg; | 1457 | const unsigned char *class_end = class_beg; |
| 1458 | const unsigned char *class_limit = str + size_byte; | 1458 | const unsigned char *class_limit = str + size_byte - 2; |
| 1459 | /* Leave room for the null. */ | 1459 | /* Leave room for the null. */ |
| 1460 | unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1]; | 1460 | unsigned char class_name[CHAR_CLASS_MAX_LENGTH + 1]; |
| 1461 | re_wctype_t cc; | 1461 | re_wctype_t cc; |
| @@ -1463,17 +1463,13 @@ skip_chars (forwardp, syntaxp, string, lim, handle_iso_classes) | |||
| 1463 | if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH) | 1463 | if (class_limit - class_beg > CHAR_CLASS_MAX_LENGTH) |
| 1464 | class_limit = class_beg + CHAR_CLASS_MAX_LENGTH; | 1464 | class_limit = class_beg + CHAR_CLASS_MAX_LENGTH; |
| 1465 | 1465 | ||
| 1466 | while (class_end != class_limit | 1466 | while (class_end < class_limit |
| 1467 | && ! (*class_end >= 0200 | 1467 | && *class_end >= 'a' && *class_end <= 'z') |
| 1468 | || *class_end <= 040 | ||
| 1469 | || (*class_end == ':' | ||
| 1470 | && class_end[1] == ']'))) | ||
| 1471 | class_end++; | 1468 | class_end++; |
| 1472 | 1469 | ||
| 1473 | if (class_end == class_limit | 1470 | if (class_end == class_beg |
| 1474 | || *class_end >= 0200 | 1471 | || *class_end != ':' || class_end[1] != ']') |
| 1475 | || *class_end <= 040) | 1472 | goto not_a_class_name; |
| 1476 | error ("Invalid ISO C character class"); | ||
| 1477 | 1473 | ||
| 1478 | bcopy (class_beg, class_name, class_end - class_beg); | 1474 | bcopy (class_beg, class_name, class_end - class_beg); |
| 1479 | class_name[class_end - class_beg] = 0; | 1475 | class_name[class_end - class_beg] = 0; |
| @@ -1488,6 +1484,7 @@ skip_chars (forwardp, syntaxp, string, lim, handle_iso_classes) | |||
| 1488 | continue; | 1484 | continue; |
| 1489 | } | 1485 | } |
| 1490 | 1486 | ||
| 1487 | not_a_class_name: | ||
| 1491 | if (c == '\\') | 1488 | if (c == '\\') |
| 1492 | { | 1489 | { |
| 1493 | if (i_byte == size_byte) | 1490 | if (i_byte == size_byte) |
diff --git a/src/window.c b/src/window.c index ff0d810a9c8..5b4c8928232 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -6506,9 +6506,10 @@ using `special-display-function'. See also `special-display-regexps'. | |||
| 6506 | An element of the list can be a list instead of just a string. | 6506 | An element of the list can be a list instead of just a string. |
| 6507 | There are two ways to use a list as an element: | 6507 | There are two ways to use a list as an element: |
| 6508 | (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...) | 6508 | (BUFFER FRAME-PARAMETERS...) (BUFFER FUNCTION OTHER-ARGS...) |
| 6509 | In the first case, FRAME-PARAMETERS are used to create the frame. | 6509 | In the first case, the FRAME-PARAMETERS are pairs of the form |
| 6510 | In the latter case, FUNCTION is called with BUFFER as the first argument, | 6510 | \(PARAMETER . VALUE); these parameter values are used to create the frame. |
| 6511 | followed by OTHER-ARGS--it can display BUFFER in any way it likes. | 6511 | In the second case, FUNCTION is called with BUFFER as the first argument, |
| 6512 | followed by the OTHER-ARGS--it can display BUFFER in any way it likes. | ||
| 6512 | All this is done by the function found in `special-display-function'. | 6513 | All this is done by the function found in `special-display-function'. |
| 6513 | 6514 | ||
| 6514 | If the specified frame parameters include (same-buffer . t), the | 6515 | If the specified frame parameters include (same-buffer . t), the |
| @@ -6531,9 +6532,10 @@ using `special-display-function'. | |||
| 6531 | An element of the list can be a list instead of just a string. | 6532 | An element of the list can be a list instead of just a string. |
| 6532 | There are two ways to use a list as an element: | 6533 | There are two ways to use a list as an element: |
| 6533 | (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...) | 6534 | (REGEXP FRAME-PARAMETERS...) (REGEXP FUNCTION OTHER-ARGS...) |
| 6534 | In the first case, FRAME-PARAMETERS are used to create the frame. | 6535 | In the first case, the FRAME-PARAMETERS are pairs of the form |
| 6535 | In the latter case, FUNCTION is called with the buffer as first argument, | 6536 | \(PARAMETER . VALUE); these parameter values are used to create the frame. |
| 6536 | followed by OTHER-ARGS--it can display the buffer in any way it likes. | 6537 | In the second case, FUNCTION is called with BUFFER as the first argument, |
| 6538 | followed by the OTHER-ARGS--it can display the buffer in any way it likes. | ||
| 6537 | All this is done by the function found in `special-display-function'. | 6539 | All this is done by the function found in `special-display-function'. |
| 6538 | 6540 | ||
| 6539 | If the specified frame parameters include (same-buffer . t), the | 6541 | If the specified frame parameters include (same-buffer . t), the |
diff --git a/src/window.h b/src/window.h index 59052af96a5..63a19cc4b0d 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Window definitions for GNU Emacs. | 1 | /* Window definitions for GNU Emacs. |
| 2 | Copyright (C) 1985, 1986, 1993, 1995, 1997, 1998, 1999, 2000, 2001, 2003 | 2 | Copyright (C) 1985,86,93,95,97,98,99, 2000,01,03,04 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
diff --git a/src/xdisp.c b/src/xdisp.c index d2410aa82bb..b04eb7ab7b7 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -6311,6 +6311,7 @@ add_to_log (format, arg1, arg2) | |||
| 6311 | char *buffer; | 6311 | char *buffer; |
| 6312 | int len; | 6312 | int len; |
| 6313 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 6313 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 6314 | USE_SAFE_ALLOCA; | ||
| 6314 | 6315 | ||
| 6315 | /* Do nothing if called asynchronously. Inserting text into | 6316 | /* Do nothing if called asynchronously. Inserting text into |
| 6316 | a buffer may call after-change-functions and alike and | 6317 | a buffer may call after-change-functions and alike and |
| @@ -6327,10 +6328,12 @@ add_to_log (format, arg1, arg2) | |||
| 6327 | msg = Fformat (3, args); | 6328 | msg = Fformat (3, args); |
| 6328 | 6329 | ||
| 6329 | len = SBYTES (msg) + 1; | 6330 | len = SBYTES (msg) + 1; |
| 6330 | buffer = (char *) alloca (len); | 6331 | SAFE_ALLOCA (buffer, char *, len); |
| 6331 | bcopy (SDATA (msg), buffer, len); | 6332 | bcopy (SDATA (msg), buffer, len); |
| 6332 | 6333 | ||
| 6333 | message_dolog (buffer, len - 1, 1, 0); | 6334 | message_dolog (buffer, len - 1, 1, 0); |
| 6335 | SAFE_FREE (len); | ||
| 6336 | |||
| 6334 | UNGCPRO; | 6337 | UNGCPRO; |
| 6335 | } | 6338 | } |
| 6336 | 6339 | ||
| @@ -11263,7 +11266,7 @@ try_cursor_movement (window, startp, scroll_step) | |||
| 11263 | && (FRAME_WINDOW_P (f) | 11266 | && (FRAME_WINDOW_P (f) |
| 11264 | || !overlay_arrow_in_current_buffer_p ())) | 11267 | || !overlay_arrow_in_current_buffer_p ())) |
| 11265 | { | 11268 | { |
| 11266 | int this_scroll_margin; | 11269 | int this_scroll_margin, top_scroll_margin; |
| 11267 | struct glyph_row *row = NULL; | 11270 | struct glyph_row *row = NULL; |
| 11268 | 11271 | ||
| 11269 | #if GLYPH_DEBUG | 11272 | #if GLYPH_DEBUG |
| @@ -11276,6 +11279,10 @@ try_cursor_movement (window, startp, scroll_step) | |||
| 11276 | this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4); | 11279 | this_scroll_margin = min (this_scroll_margin, WINDOW_TOTAL_LINES (w) / 4); |
| 11277 | this_scroll_margin *= FRAME_LINE_HEIGHT (f); | 11280 | this_scroll_margin *= FRAME_LINE_HEIGHT (f); |
| 11278 | 11281 | ||
| 11282 | top_scroll_margin = this_scroll_margin; | ||
| 11283 | if (WINDOW_WANTS_HEADER_LINE_P (w)) | ||
| 11284 | top_scroll_margin += CURRENT_HEADER_LINE_HEIGHT (w); | ||
| 11285 | |||
| 11279 | /* Start with the row the cursor was displayed during the last | 11286 | /* Start with the row the cursor was displayed during the last |
| 11280 | not paused redisplay. Give up if that row is not valid. */ | 11287 | not paused redisplay. Give up if that row is not valid. */ |
| 11281 | if (w->last_cursor.vpos < 0 | 11288 | if (w->last_cursor.vpos < 0 |
| @@ -11336,7 +11343,7 @@ try_cursor_movement (window, startp, scroll_step) | |||
| 11336 | && (MATRIX_ROW_START_CHARPOS (row) > PT | 11343 | && (MATRIX_ROW_START_CHARPOS (row) > PT |
| 11337 | || (MATRIX_ROW_START_CHARPOS (row) == PT | 11344 | || (MATRIX_ROW_START_CHARPOS (row) == PT |
| 11338 | && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row))) | 11345 | && MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P (row))) |
| 11339 | && (row->y > this_scroll_margin | 11346 | && (row->y > top_scroll_margin |
| 11340 | || CHARPOS (startp) == BEGV)) | 11347 | || CHARPOS (startp) == BEGV)) |
| 11341 | { | 11348 | { |
| 11342 | xassert (row->enabled_p); | 11349 | xassert (row->enabled_p); |
| @@ -11364,7 +11371,7 @@ try_cursor_movement (window, startp, scroll_step) | |||
| 11364 | ++row; | 11371 | ++row; |
| 11365 | 11372 | ||
| 11366 | /* If within the scroll margin, scroll. */ | 11373 | /* If within the scroll margin, scroll. */ |
| 11367 | if (row->y < this_scroll_margin | 11374 | if (row->y < top_scroll_margin |
| 11368 | && CHARPOS (startp) != BEGV) | 11375 | && CHARPOS (startp) != BEGV) |
| 11369 | scroll_p = 1; | 11376 | scroll_p = 1; |
| 11370 | } | 11377 | } |
| @@ -12537,9 +12544,8 @@ try_window_reusing_current_matrix (w) | |||
| 12537 | position. */ | 12544 | position. */ |
| 12538 | if (pt_row) | 12545 | if (pt_row) |
| 12539 | { | 12546 | { |
| 12540 | w->cursor.vpos -= MATRIX_ROW_VPOS (first_reusable_row, | 12547 | w->cursor.vpos -= nrows_scrolled; |
| 12541 | w->current_matrix); | 12548 | w->cursor.y -= first_reusable_row->y - start_row->y; |
| 12542 | w->cursor.y -= first_reusable_row->y; | ||
| 12543 | } | 12549 | } |
| 12544 | 12550 | ||
| 12545 | /* Scroll the display. */ | 12551 | /* Scroll the display. */ |
| @@ -12584,6 +12590,29 @@ try_window_reusing_current_matrix (w) | |||
| 12584 | for (row -= nrows_scrolled; row < bottom_row; ++row) | 12590 | for (row -= nrows_scrolled; row < bottom_row; ++row) |
| 12585 | row->enabled_p = 0; | 12591 | row->enabled_p = 0; |
| 12586 | 12592 | ||
| 12593 | /* Point may have moved to a different line, so we cannot assume that | ||
| 12594 | the previous cursor position is valid; locate the correct row. */ | ||
| 12595 | if (pt_row) | ||
| 12596 | { | ||
| 12597 | for (row = MATRIX_ROW (w->current_matrix, w->cursor.vpos); | ||
| 12598 | row < bottom_row && PT >= MATRIX_ROW_END_CHARPOS (row); | ||
| 12599 | row++) | ||
| 12600 | { | ||
| 12601 | w->cursor.vpos++; | ||
| 12602 | w->cursor.y = row->y; | ||
| 12603 | } | ||
| 12604 | if (row < bottom_row) | ||
| 12605 | { | ||
| 12606 | struct glyph *glyph = row->glyphs[TEXT_AREA] + w->cursor.hpos; | ||
| 12607 | while (glyph->charpos < PT) | ||
| 12608 | { | ||
| 12609 | w->cursor.hpos++; | ||
| 12610 | w->cursor.x += glyph->pixel_width; | ||
| 12611 | glyph++; | ||
| 12612 | } | ||
| 12613 | } | ||
| 12614 | } | ||
| 12615 | |||
| 12587 | /* Adjust window end. A null value of last_text_row means that | 12616 | /* Adjust window end. A null value of last_text_row means that |
| 12588 | the window end is in reused rows which in turn means that | 12617 | the window end is in reused rows which in turn means that |
| 12589 | only its vpos can have changed. */ | 12618 | only its vpos can have changed. */ |
| @@ -13367,9 +13396,9 @@ try_window_id (w) | |||
| 13367 | 13396 | ||
| 13368 | if ((w->cursor.y < this_scroll_margin | 13397 | if ((w->cursor.y < this_scroll_margin |
| 13369 | && CHARPOS (start) > BEGV) | 13398 | && CHARPOS (start) > BEGV) |
| 13370 | /* Don't take scroll margin into account at the bottom because | 13399 | /* Old redisplay didn't take scroll margin into account at the bottom, |
| 13371 | old redisplay didn't do it either. */ | 13400 | but then global-hl-line-mode doesn't scroll. KFS 2004-06-14 */ |
| 13372 | || w->cursor.y + cursor_height > it.last_visible_y) | 13401 | || w->cursor.y + cursor_height + this_scroll_margin > it.last_visible_y) |
| 13373 | { | 13402 | { |
| 13374 | w->cursor.vpos = -1; | 13403 | w->cursor.vpos = -1; |
| 13375 | clear_glyph_matrix (w->desired_matrix); | 13404 | clear_glyph_matrix (w->desired_matrix); |
diff --git a/src/xfaces.c b/src/xfaces.c index 171472dbb31..a5d5c97a332 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -3899,12 +3899,13 @@ Otherwise check for the existence of a global face. */) | |||
| 3899 | DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, | 3899 | DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, |
| 3900 | Sinternal_copy_lisp_face, 4, 4, 0, | 3900 | Sinternal_copy_lisp_face, 4, 4, 0, |
| 3901 | doc: /* Copy face FROM to TO. | 3901 | doc: /* Copy face FROM to TO. |
| 3902 | If FRAME is t, copy the global face definition of FROM to the | 3902 | If FRAME is t, copy the global face definition of FROM. |
| 3903 | global face definition of TO. Otherwise, copy the frame-local | 3903 | Otherwise, copy the frame-local definition of FROM on FRAME. |
| 3904 | definition of FROM on FRAME to the frame-local definition of TO | 3904 | If NEW-FRAME is a frame, copy that data into the frame-local |
| 3905 | on NEW-FRAME, or FRAME if NEW-FRAME is nil. | 3905 | definition of TO on NEW-FRAME. If NEW-FRAME is nil. |
| 3906 | FRAME controls where the data is copied to. | ||
| 3906 | 3907 | ||
| 3907 | Value is TO. */) | 3908 | The value is TO. */) |
| 3908 | (from, to, frame, new_frame) | 3909 | (from, to, frame, new_frame) |
| 3909 | Lisp_Object from, to, frame, new_frame; | 3910 | Lisp_Object from, to, frame, new_frame; |
| 3910 | { | 3911 | { |
| @@ -3912,8 +3913,6 @@ Value is TO. */) | |||
| 3912 | 3913 | ||
| 3913 | CHECK_SYMBOL (from); | 3914 | CHECK_SYMBOL (from); |
| 3914 | CHECK_SYMBOL (to); | 3915 | CHECK_SYMBOL (to); |
| 3915 | if (NILP (new_frame)) | ||
| 3916 | new_frame = frame; | ||
| 3917 | 3916 | ||
| 3918 | if (EQ (frame, Qt)) | 3917 | if (EQ (frame, Qt)) |
| 3919 | { | 3918 | { |
| @@ -3925,6 +3924,8 @@ Value is TO. */) | |||
| 3925 | else | 3924 | else |
| 3926 | { | 3925 | { |
| 3927 | /* Copy frame-local definition of FROM. */ | 3926 | /* Copy frame-local definition of FROM. */ |
| 3927 | if (NILP (new_frame)) | ||
| 3928 | new_frame = frame; | ||
| 3928 | CHECK_LIVE_FRAME (frame); | 3929 | CHECK_LIVE_FRAME (frame); |
| 3929 | CHECK_LIVE_FRAME (new_frame); | 3930 | CHECK_LIVE_FRAME (new_frame); |
| 3930 | lface = lface_from_face_name (XFRAME (frame), from, 1); | 3931 | lface = lface_from_face_name (XFRAME (frame), from, 1); |
diff --git a/src/xselect.c b/src/xselect.c index 637b39272b7..8c8f1f98668 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* X Selection processing for Emacs. | 1 | /* X Selection processing for Emacs. |
| 2 | Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003 | 2 | Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2003, 2004 |
| 3 | Free Software Foundation. | 3 | Free Software Foundation. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -2608,7 +2608,7 @@ are ignored. */) | |||
| 2608 | if (event.xclient.format != 8 && event.xclient.format != 16 | 2608 | if (event.xclient.format != 8 && event.xclient.format != 16 |
| 2609 | && event.xclient.format != 32) | 2609 | && event.xclient.format != 32) |
| 2610 | error ("FORMAT must be one of 8, 16 or 32"); | 2610 | error ("FORMAT must be one of 8, 16 or 32"); |
| 2611 | 2611 | ||
| 2612 | if (FRAMEP (dest) || NILP (dest)) | 2612 | if (FRAMEP (dest) || NILP (dest)) |
| 2613 | { | 2613 | { |
| 2614 | struct frame *fdest = check_x_frame (dest); | 2614 | struct frame *fdest = check_x_frame (dest); |
diff --git a/src/xsmfns.c b/src/xsmfns.c index 35c7429b66b..080f998e779 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Session management module for systems which understand the X Session | 1 | /* Session management module for systems which understand the X Session |
| 2 | management protocol. | 2 | management protocol. |
| 3 | Copyright (C) 2002 Free Software Foundation, Inc. | 3 | Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 6 | 6 | ||
diff --git a/src/xterm.c b/src/xterm.c index 289f7771852..c17146bde1d 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* X Communication module for terminals which understand the X protocol. | 1 | /* X Communication module for terminals which understand the X protocol. |
| 2 | Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999, 2000, 01, 02, 2003 | 2 | Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999, 2000,01,02,03,04 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -2359,8 +2359,8 @@ x_draw_image_foreground_1 (s, pixmap) | |||
| 2359 | XGCValues xgcv; | 2359 | XGCValues xgcv; |
| 2360 | 2360 | ||
| 2361 | xgcv.clip_mask = s->img->mask; | 2361 | xgcv.clip_mask = s->img->mask; |
| 2362 | xgcv.clip_x_origin = x; | 2362 | xgcv.clip_x_origin = x - s->slice.x; |
| 2363 | xgcv.clip_y_origin = y; | 2363 | xgcv.clip_y_origin = y - s->slice.y; |
| 2364 | xgcv.function = GXcopy; | 2364 | xgcv.function = GXcopy; |
| 2365 | XChangeGC (s->display, s->gc, mask, &xgcv); | 2365 | XChangeGC (s->display, s->gc, mask, &xgcv); |
| 2366 | 2366 | ||
diff --git a/src/xterm.h b/src/xterm.h index a71bd275e6f..f0e86f0ecab 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Definitions and headers for communication with X protocol. | 1 | /* Definitions and headers for communication with X protocol. |
| 2 | Copyright (C) 1989, 1993, 1994, 1998, 1999, 2000, 2001, 2001 | 2 | Copyright (C) 1989, 1993, 1994, 1998, 1999, 2000,01,02,03,04 |
| 3 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |