aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2004-12-08 05:02:30 +0000
committerMiles Bader2004-12-08 05:02:30 +0000
commit000fc2b1fad05ccd9e6cdb5810febb091f4b5738 (patch)
tree808f1473847c7c44bc8b28d8edfa086ec25035d1 /src
parent5bc63b073c3c75dbfab1f14423f01cc615e26eeb (diff)
parentad136a7c3b310fa7240dd2adf62f23b454782bd0 (diff)
downloademacs-000fc2b1fad05ccd9e6cdb5810febb091f4b5738.tar.gz
emacs-000fc2b1fad05ccd9e6cdb5810febb091f4b5738.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-74
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-715 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-74 Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog531
-rw-r--r--src/Makefile.in4
-rw-r--r--src/alloc.c310
-rw-r--r--src/buffer.c17
-rw-r--r--src/callint.c2
-rw-r--r--src/coding.c89
-rw-r--r--src/coding.h25
-rw-r--r--src/config.in25
-rw-r--r--src/data.c7
-rw-r--r--src/dispextern.h6
-rw-r--r--src/emacs.c20
-rw-r--r--src/eval.c25
-rw-r--r--src/filelock.c6
-rw-r--r--src/fns.c8
-rw-r--r--src/fringe.c45
-rw-r--r--src/gtkutil.c38
-rw-r--r--src/image.c3
-rw-r--r--src/indent.c12
-rw-r--r--src/insdel.c8
-rw-r--r--src/keyboard.c44
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h32
-rw-r--r--src/lread.c19
-rw-r--r--src/mac.c16
-rw-r--r--src/macfns.c35
-rw-r--r--src/macmenu.c3
-rw-r--r--src/macterm.c237
-rw-r--r--src/macterm.h4
-rw-r--r--src/minibuf.c52
-rw-r--r--src/regex.c122
-rw-r--r--src/s/darwin.h11
-rw-r--r--src/s/gnu-linux.h14
-rw-r--r--src/search.c23
-rw-r--r--src/sysdep.c26
-rw-r--r--src/term.c12
-rw-r--r--src/w32console.c3
-rw-r--r--src/w32term.c19
-rw-r--r--src/window.c21
-rw-r--r--src/xdisp.c184
-rw-r--r--src/xfaces.c13
-rw-r--r--src/xfns.c20
-rw-r--r--src/xmenu.c48
-rw-r--r--src/xterm.c19
43 files changed, 1628 insertions, 532 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0d0a33d747e..45a69442444 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,400 @@
12004-12-07 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2
3 * emacs.c (Fdump_emacs): Add ! defined (SYSTEM_MALLOC) around
4 reset_malloc_hooks.
5
6 * keyboard.c (handle_async_input, input_available_signal): Add
7 ! defined (SYSTEM_MALLOC) around thread code.
8
9 * alloc.c: Add comment about the reason for (UN)BLOCK_INPUT_ALLOC.
10
112004-12-07 Stefan <monnier@iro.umontreal.ca>
12
13 * eval.c (init_eval_once): Increase max_specpdl_size to 1000.
14
15 * config.in: Regenerate.
16
172004-12-07 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
18
19 * xmenu.c (Fx_popup_menu): Correct documentation about position.
20 (xmenu_show): Do not call XTranslateCoordinates. Adjust position
21 if not given by a mouse click to correspond with x-popup-menu
22 documentation.
23
24 * config.in: Regenerate.
25
26 * gtkutil.c: Include signal.h and syssignal.h.
27 (xg_get_file_name): Block and unblock __SIGRTMIN if defined.
28
29 * alloc.c: If HAVE_GTK_AND_PTHREAD, include pthread.h,
30 new variables main_thread and alloc_mutex,
31 define (UN)BLOCK_INPUT_ALLOC to use alloc_mutex to protect
32 emacs_blocked_* calls and only do (UN)BLOCK_INPUT in the main thread.
33 If not HAVE_GTK_AND_PTHREAD, (UN)BLOCK_INPUT_ALLOC is the same as
34 (UN)BLOCK_INPUT.
35 (emacs_blocked_free, emacs_blocked_malloc)
36 (emacs_blocked_realloc): Use (UN)BLOCK_INPUT_ALLOC.
37 (uninterrupt_malloc): Initialize main_thread and alloc_mutex.
38 (reset_malloc_hooks): New function.
39
40 * lisp.h: Declare reset_malloc_hooks.
41
42 * emacs.c (Fdump_emacs): Call reset_malloc_hooks.
43
44 * keyboard.c: Conditionally include pthread.h
45 (handle_async_inpu, input_available_signalt): If not in the main
46 thread, block signal, send signal to main thread and return.
47
48 * gtkutil.c (xg_get_file_with_chooser): Handle local files only.
49 Set current folder in file chooser if default_filename is a
50 directory.
51
522004-12-05 Stefan Monnier <monnier@iro.umontreal.ca>
53
54 * regex.c (GET_UNSIGNED_NUMBER): Signal an error when reaching the end.
55 Remove redundant correctness checks.
56 (regex_compile): Fix up error codes for \{..\} expressions.
57
582004-12-05 Richard M. Stallman <rms@gnu.org>
59
60 * regex.c (regex_compile): Fix end-of-pattern case for space.
61
622004-12-03 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
63
64 * macterm.h (cfstring_create_with_utf8_cstring): Add prototype.
65 * mac.c (cfstring_create_with_utf8_cstring): Add to prevent
66 crashes with invalid characters.
67 * macmenu.c (add_menu_item): Use it.
68 * image.c (image_load_quartz2d): Likewise.
69 * macfns.c (x_set_name, x_set_title): Likewise.
70 (Fx_file_dialog): Likewise. Use constant CFRefs instead of
71 creating them each time for labels.
72
732004-12-02 Richard M. Stallman <rms@gnu.org>
74
75 * config.in (RE_TRANSLATE_P): If make_number is not a macro,
76 don't use it here.
77
78 * eval.c (Fcalled_interactively_p): Don't check INTERACTIVE.
79 (interactive_p): Skip Scalled_interactively_p frames
80 like Sinteractive_p frames.
81
82 * data.c (Fmake_variable_buffer_local): Doc fix.
83 (Fmake_local_variable): Doc fix.
84
85 * insdel.c (insert_from_string_before_markers)
86 (insert_from_string): Don't modify buffer on empty insertion.
87
88 * window.c (Fget_lru_window, Fget_largest_window): Doc fixes.
89
902004-12-01 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
91
92 * macmenu.c (add_menu_item): Fallback on MacRoman if encoding
93 menu text as UTF8 fails.
94
952004-12-01 Kim F. Storm <storm@cua.dk>
96
97 * alloc.c: Add commentary for last change.
98 (XMALLOC_PUT_SIZE, XMALLOC_GET_SIZE): New macros to handle
99 sizeof(size_t) != 4.
100 (overrun_check_malloc, overrun_check_realloc, overrun_check_free):
101 Use them. Also clear header and trailer of freed memory.
102 (GC_STRING_OVERRUN_COOKIE_SIZE): Rename from GC_STRING_EXTRA.
103 (string_overrun_cookie): Rename from string_overrun_pattern.
104 (GC_STRING_EXTRA): Define from GC_STRING_OVERRUN_COOKIE_SIZE.
105
1062004-12-01 Andreas Schwab <schwab@suse.de>
107
108 * lisp.h: Declare string_to_multibyte.
109
1102004-12-01 Kenichi Handa <handa@m17n.org>
111
112 * w32console.c (w32con_write_glyphs): Decide coding here.
113 Adjusted for the change of encode_terminal_code.
114
115 * term.c (encode_terminal_code): Don't make it "static".
116
1172004-11-30 Kenichi Handa <handa@m17n.org>
118
119 * term.c (encode_terminal_buf, encode_terminal_bufsize): New variables.
120 (encode_terminal_code): Argument changed. Encode all
121 characters at once, and return a pointer to the result of encoding.
122 (write_glyphs): Decide coding here. Adjusted for the above change.
123 (insert_glyphs): Likewise.
124 (term_init): Initialize encode_terminal_bufsize to 0.
125
126 * coding.c (Vcode_conversion_workbuf_name): New variable.
127 (syms_of_coding): Initialize and staticpro it.
128 (set_conversion_work_buffer): New function.
129 (run_pre_post_conversion_on_str): Use it.
130 (run_pre_write_conversin_on_c_str): New function.
131
132 * coding.h (run_pre_write_conversin_on_c_str): Extern it.
133
1342004-11-30 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
135
136 * keyboard.c: Don't undef SIGIO
137 * s/darwin.h (NO_SOCK_SIGIO): Define NO_SOCK_SIGIO on carbon
138 * Makefile.in (mac.o): Depend on blockinput.h and atimer.h.
139 (macfns.o): Don't depend on ccl.h.
140 * macfns.c (mac_frame_parm_handlers): Set handlers for
141 Qleft_fringe and Qright_fringe.
142 * macterm.c (mac_fill_rectangle_to_pixmap)
143 (mac_draw_rectangle_to_pixmap, mac_copy_area_to_pixmap)
144 (mac_copy_area_with_mask_to_pixmap, x_draw_image_foreground_1):
145 Put in #if 0.
146 (mac_scroll_area) [TARGET_API_MAC_CARBON]: Use ScrollWindowRect.
147 (x_flush) [TARGET_API_MAC_CARBON]: Don't traverse frames.
148 (XFlush) [TARGET_API_MAC_CARBON]: Define to an empty replacement.
149 (x_draw_glyph_string_background, x_draw_glyph_string_foreground)
150 [!MAC_OS8]: Added ifdef'd out code for os8. Don't use
151 XDrawImageString. Always draw background and foreground separately.
152 (x_draw_image_foreground): Use clipping instead of computing the
153 intersection rectangle.
154 (x_draw_image_glyph_string): Don't draw an image with mask to a
155 pixmap.
156 (x_redisplay_interface): Set flush_display_optional member to 0.
157 (XTread_socket): Correctly reset the TEConverter
158 object.
159
1602004-11-30 Kim F. Storm <storm@cua.dk>
161
162 * lisp.h: New defines to enable buffer overrun checking.
163 (GC_CHECK_STRING_OVERRUN, GC_CHECK_STRING_FREE_LIST)
164 (XMALLOC_OVERRUN_CHECK, GC_CHECK_CONS_LIST): Add.
165
166 * alloc.c: Add more checks for buffer overruns.
167 (XMALLOC_OVERRUN_CHECK_SIZE, xmalloc_overrun_check_header)
168 xmalloc_overrun_check_trailer, overrun_check_malloc)
169 overrun_check_realloc, overrun_check_free): Add.
170 (GC_STRING_EXTRA, string_overrun_pattern): Add.
171 (check_sblock, allocate_string_data, compact_small_strings):
172 Set and check string_overrun_pattern if GC_CHECK_STRING_OVERRUN.
173 (check_cons_list): Condition on GC_CHECK_CONS_LIST.
174 (check_string_free_list): Add.
175 (allocate_string, sweep_strings): Call check_string_free_list.
176
177 * emacs.c (malloc_initialize_hook): Don't free malloc_state_ptr if
178 XMALLOC_OVERRUN_CHECK to avoid crash during load.
179
1802004-11-29 Kim F. Storm <storm@cua.dk>
181
182 * fns.c (concat): Use SAFE_ALLOCA.
183
1842004-11-29 Stefan Monnier <monnier@iro.umontreal.ca>
185
186 * sysdep.c (emacs_write): Don't use QUIT.
187
1882004-11-29 Kenichi Handa <handa@m17n.org>
189
190 * buffer.c (init_buffer): Set current_buffer->directory to a
191 multibyte string made by string_to_multibyte.
192
193 * emacs.c (init_cmdargs): Set unibyte strings in Vcommand_line_args.
194
1952004-11-27 Andreas Schwab <schwab@suse.de>
196
197 * alloc.c (mark_stack): Call GC_MARK_SECONDARY_STACK if defined.
198
199 * s/gnu-linux.h: Enable no-op gcpros on ia64.
200 (GC_MARK_SECONDARY_STACK) [__ia64__]: Define.
201
202 * filelock.c (lock_file_1): Call get_boot_time early.
203 Increase buffer size.
204
2052004-11-27 Eli Zaretskii <eliz@gnu.org>
206
207 * lisp.h (DECL_ALIGN): Define non-trivially only if NO_DECL_ALIGN
208 is not defined.
209
2102004-11-27 Kim F. Storm <storm@cua.dk>
211
212 * search.c (syms_of_search) <search-spaces-regexp>: Move 'doc:'
213 marker out of doc string.
214
2152004-11-26 Stefan Monnier <monnier@iro.umontreal.ca>
216
217 * s/darwin.h (POSIX_SIGNALS): Undo the removal of 2002-08-25,
218 which was not mentioned in the log.
219
2202004-11-26 Kim F. Storm <storm@cua.dk>
221
222 * fringe.c (update_window_fringes): Prefer truncation bitmaps over
223 angle bitmaps at top/bottom line.
224
225 * xdisp.c: Undo recent changes for restoring saved_face_id. Instead,
226 set it when it->method is set to next_element_from_display_vector.
227 (setup_for_ellipsis): Add LEN argument. Callers changed.
228 Set it->saved_face_id.
229 (get_next_display_element): Use loop instead of recursion.
230 Set it->saved_face_id. Combine duplicate code for ctr chars.
231 (next_element_from_display_vector): Do not set it->saved_face_id.
232 (next_element_from_ellipsis): Use setup_for_ellipsis.
233
2342004-11-26 Eli Zaretskii <eliz@gnu.org>
235
236 * eval.c (Fdefvar): Declare pdl from last change as `volatile' to
237 prevent compiler warnings.
238
2392004-11-25 Stefan Monnier <monnier@iro.umontreal.ca>
240
241 * keyboard.c (command_loop_1): Print a message describing the key
242 the user just pressed when this key has no binding.
243
244 * sysdep.c (sys_signal): Don't use SA_RESTART if SYNC_INPUT is set.
245 (emacs_open, emacs_read, emacs_write): Check QUIT when interrupted.
246
247 * lread.c (readchar): Check QUIT when `getc' is interrupted.
248
2492004-11-24 Richard M. Stallman <rms@gnu.org>
250
251 * coding.c (run_pre_post_conversion_on_str): Bind Qinhibit_read_only.
252
253 * buffer.c (syms_of_buffer) <indicate-buffer-boundaries>: Doc fix.
254
2552004-11-24 Kim F. Storm <storm@cua.dk>
256
257 * xdisp.c (move_it_in_display_line_to, display_line):
258 Restore saved_face_id also when truncate-lines or hscrolled.
259
2602004-11-23 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
261
262 * gtkutil.c (xg_get_file_name): Rename use-old-gtk-file-dialog to
263 x-use-old-gtk-file-dialog.
264
265 * xfns.c: Define x_use_old_gtk_file_dialog.
266 (syms_of_xfns): Rename use-old-gtk-file-dialog to x-... Move it
267 outside ifdef USE_GTK.
268
2692004-11-23 Stefan Monnier <monnier@iro.umontreal.ca>
270
271 * coding.h (ENCODE_FILE, DECODE_FILE, ENCODE_SYSTEM, DECODE_SYSTEM):
272 Don't use XFASTINT blindly.
273
274 * config.in (RE_TRANSLATE_P): Don't use XFASTINT blindly.
275
276 * indent.c (skip_invisible): Avoid non-idempotent side-effects
277 in macro arguments.
278
279 * keymap.c (Flookup_key): Check INTEGERP before XINT.
280
281 * lread.c (oblookup): Don't use XFASTINT blindly.
282
283 * window.c (Fset_window_scroll_bars): Don't use XINT if it isn't int.
284 (decode_next_window_args, window_loop): Don't use XFASTINT blindly.
285
2862004-11-23 Kim F. Storm <storm@cua.dk>
287
288 * dispextern.h (MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P)
289 (MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P): Not if dpvec_index is zero.
290
291 * xfaces.c (lookup_named_face): Add signal_p arg. Return -1 if
292 signal_p is zero and face name is unknown.
293 (Fx_list_fonts): Don't signal error in lookup_named_face.
294 (Fface_font): Signal error in lookup_named_face.
295 (ascii_face_of_lisp_face): Likewise.
296
297 * dispextern.h (lookup_named_face): Fix prototype.
298
299 * xdisp.c (handle_single_display_prop): Don't signal error in
300 lookup_named_face for unknown fringe face name.
301 (highlight_trailing_whitespace): Don't signal error in
302 lookup_named_face if trailing-whitespace face unknown.
303 (calc_line_height_property): Don't signal error in
304 lookup_named_face if specified face name is unknown.
305
306 * fringe.c (update_window_fringes): Show top row indicator if
307 window has header-line. Don't show arrow at bob and eob
308 if the boundary indicators are not used.
309 (Fset_fringe_bitmap_face): Signal error in lookup_named_face.
310
311 * window.c (set_window_buffer): Clear display_error_modiff.
312
3132004-11-22 Kim F. Storm <storm@cua.dk>
314
315 * fringe.c (update_window_fringes): Provide sensible fall-back
316 value for non-nil indicate-buffer-boundaries setting.
317
3182004-11-22 Markus Rost <rost@ias.edu>
319
320 * minibuf.c (Fminibuffer_complete_and_exit): Fix previous change.
321
3222004-11-22 Stefan Monnier <monnier@iro.umontreal.ca>
323
324 * eval.c (Fdefvar): Warn when var is let-bound but globally void.
325
3262004-11-21 Kim F. Storm <storm@cua.dk>
327
328 * xdisp.c (erase_phys_cursor): Clear hollow cursor inside TEXT_AREA.
329
330 * xterm.c (x_clip_to_row): Add area arg. Callers changed.
331 (x_draw_hollow_cursor, x_draw_bar_cursor): Clip to TEXT_AREA.
332
333 * w32term.c (w32_clip_to_row): Add area arg. Callers changed.
334 (x_draw_hollow_cursor, x_draw_bar_cursor): Clip to TEXT_AREA.
335
336 * macterm.c (x_clip_to_row): Add area arg. Callers changed.
337 (x_draw_hollow_cursor, x_draw_bar_cursor): Clip to TEXT_AREA.
338
339 * xdisp.c (move_it_in_display_line_to, display_line):
340 Restore saved_face_id if overflow-newline-into-fringe is enabled and
341 line is continued before or in middle of element from display vector.
342
343 * indent.c (Fvertical_motion): Fix last change. Use another
344 method to detect if iterator moved too far ahead after reseat.
345
346 * xdisp.c (IT_EXPAND_MATRIX_WIDTH): New macro. Do not
347 expand matrix width for overflow in zero-width area.
348 (append_glyph, append_composite_glyph, produce_image_glyph)
349 (append_stretch_glyph): Use it to avoid loop in redisplay.
350 (note_mode_line_or_margin_highlight): Don't let help-echo from
351 string override help-echo from image map.
352
3532004-11-20 Luc Teirlinck <teirllm@auburn.edu>
354
355 * fns.c (Fyes_or_no_p): Call Fread_from_minibuffer with extra argument.
356 * callint.c (Fcall_interactively): Ditto.
357
3582004-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
359
360 * minibuf.c (Fminibuffer_complete_and_exit):
361 Fixup the case of the completed value, for case-indep completion.
362
3632004-11-20 Richard M. Stallman <rms@gnu.org>
364
365 * lisp.h (Fread_from_minibuffer): Add arg in decl.
366
367 * minibuf.c (read_minibuf): New arg KEEP_ALL. Callers changed.
368 (Fread_from_minibuffer): New arg KEEP_ALL. Callers changed.
369
370 * search.c (Vsearch_spaces_regexp):
371 Rename from Vsearch_whitespace_regexp. All uses changed.
372
3732004-11-20 Thien-Thi Nguyen <ttn@gnu.org>
374
375 * eval.c (init_eval_once): Increase `max_specpdl_size' to 650.
376
3772004-11-19 Richard M. Stallman <rms@gnu.org>
378
379 * search.c (Vsearch_whitespace_regexp): New variable.
380 (syms_of_search): Defvar it.
381 (compile_pattern_1): Call re_set_whitespace_regexp with it.
382 (search_buffer): No regexp is trivial if Vsearch_whitespace_regexp
383 is non-nil.
384 (struct regexp_cache): New element whitespace_regexp.
385 (syms_of_search): Initialize whitespace_regexp elements.
386 (compile_pattern): Compare whitespace_regexp elements.
387 (compile_pattern_1): Set whitespace_regexp elements.
388
389 * regex.c (regex_compile): Substitute whitespace_regexp
390 for spaces, if it is nonzero.
391 (whitespace_regexp): New variable.
392 (re_set_whitespace_regexp): New function.
393
3942004-11-19 Kim F. Storm <storm@cua.dk>
395
396 * indent.c (Fvertical_motion): Fix last change.
397
12004-11-18 Kim F. Storm <storm@cua.dk> 3982004-11-18 Kim F. Storm <storm@cua.dk>
2 399
3 * indent.c (Fvertical_motion): Undo 2004-11-16 change. 400 * indent.c (Fvertical_motion): Undo 2004-11-16 change.
@@ -13,8 +410,7 @@
13 410
142004-11-16 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 4112004-11-16 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
15 412
16 * gtkutil.c (xg_get_file_name): Fix typo in 413 * gtkutil.c (xg_get_file_name): Typo in HAVE_GTK_FILE_SELECTION_NEW.
17 HAVE_GTK_FILE_SELECTION_NEW.
18 414
19 * xmenu.c (x_menu_in_use): Remove. 415 * xmenu.c (x_menu_in_use): Remove.
20 (x_menu_set_in_use): Also set popup_activated_flag. 416 (x_menu_set_in_use): Also set popup_activated_flag.
@@ -6262,7 +6658,7 @@
6262 6658
62632003-06-01 David Ponce <david@dponce.com> 66592003-06-01 David Ponce <david@dponce.com>
6264 6660
6265 * termhooks.h (enum event_kind): Added new WHEEL_EVENT event. 6661 * termhooks.h (enum event_kind): Add new WHEEL_EVENT event.
6266 Declare MOUSE_WHEEL_EVENT only if MAC_OSX defined. 6662 Declare MOUSE_WHEEL_EVENT only if MAC_OSX defined.
6267 6663
6268 * keyboard.c (Qmouse_wheel): Declare only if MAC_OSX defined. 6664 * keyboard.c (Qmouse_wheel): Declare only if MAC_OSX defined.
@@ -6270,8 +6666,7 @@
6270 (discard_mouse_events): Discard WHEEL_EVENT events too. 6666 (discard_mouse_events): Discard WHEEL_EVENT events too.
6271 (lispy_wheel_names, wheel_syms): New. 6667 (lispy_wheel_names, wheel_syms): New.
6272 (syms_of_keyboard): Init and staticpro `wheel_syms'. Init and 6668 (syms_of_keyboard): Init and staticpro `wheel_syms'. Init and
6273 staticpro `Qmouse_wheel' and `mouse_wheel_syms' only if MAC_OSX 6669 staticpro `Qmouse_wheel' and `mouse_wheel_syms' only if MAC_OSX defined.
6274 defined.
6275 (make_lispy_event): Add WHEEL_EVENT handler. 6670 (make_lispy_event): Add WHEEL_EVENT handler.
6276 6671
6277 * w32term.c (construct_mouse_wheel): Construct WHEEL_EVENT. 6672 * w32term.c (construct_mouse_wheel): Construct WHEEL_EVENT.
@@ -6313,8 +6708,7 @@
6313 6708
6314 * ccl.h (struct ccl_program) <eight_bit_control>: Comment fixed. 6709 * ccl.h (struct ccl_program) <eight_bit_control>: Comment fixed.
6315 6710
6316 * ccl.c (CCL_WRITE_CHAR): Increment extra_bytes only when it is 6711 * ccl.c (CCL_WRITE_CHAR): Increment extra_bytes only when it is nonzero.
6317 nonzero.
6318 (ccl_driver): Initialize extra_bytes to ccl->eight_bit_control. 6712 (ccl_driver): Initialize extra_bytes to ccl->eight_bit_control.
6319 (setup_ccl_program): Initialize ccl->eight_bit_control to zero. 6713 (setup_ccl_program): Initialize ccl->eight_bit_control to zero.
6320 6714
@@ -6330,19 +6724,18 @@
6330 6724
63312003-05-28 Kenichi Handa <handa@m17n.org> 67252003-05-28 Kenichi Handa <handa@m17n.org>
6332 6726
6333 * coding.c (ENCODE_UNSAFE_CHARACTER): Adjusted for the name change 6727 * coding.c (ENCODE_UNSAFE_CHARACTER): Adjust for the name change
6334 of CODING_REPLACEMENT_CHARACTER. 6728 of CODING_REPLACEMENT_CHARACTER.
6335 (decode_coding_iso2022): If CODING_FLAG_ISO_SAFE, set 6729 (decode_coding_iso2022): If CODING_FLAG_ISO_SAFE, set
6336 CODING_MODE_INHIBIT_UNENCODABLE_CHAR flag in coding->mode, and 6730 CODING_MODE_INHIBIT_UNENCODABLE_CHAR flag in coding->mode, and
6337 check this flag on encoding. 6731 check this flag on encoding.
6338 (encode_coding_sjis_big5): Check 6732 (encode_coding_sjis_big5):
6339 CODING_MODE_INHIBIT_UNENCODABLE_CHAR flag of coding->mode. 6733 Check CODING_MODE_INHIBIT_UNENCODABLE_CHAR flag of coding->mode.
6340 (Fset_terminal_coding_system_internal): Set 6734 (Fset_terminal_coding_system_internal):
6341 CODING_MODE_INHIBIT_UNENCODABLE_CHAR flag in terminal_coding.mode 6735 Set CODING_MODE_INHIBIT_UNENCODABLE_CHAR flag in terminal_coding.mode
6342 instead of setting CODING_FLAG_ISO_SAFE flag in 6736 instead of setting CODING_FLAG_ISO_SAFE flag in terminal_coding.flags.
6343 terminal_coding.flags. 6737
6344 6738 * coding.h (CODING_REPLACEMENT_CHARACTER): Rename from
6345 * coding.h (CODING_REPLACEMENT_CHARACTER): Renamed from
6346 CODING_INHIBIT_CHARACTER_SUBSTITUTION. 6739 CODING_INHIBIT_CHARACTER_SUBSTITUTION.
6347 (CODING_MODE_INHIBIT_UNENCODABLE_CHAR): New macro. 6740 (CODING_MODE_INHIBIT_UNENCODABLE_CHAR): New macro.
6348 6741
@@ -6484,65 +6877,65 @@
6484 (struct frame): New member scroll_bar_actual_width which 6877 (struct frame): New member scroll_bar_actual_width which
6485 consolidates and renames the vertical_scroll_bar_extra member of 6878 consolidates and renames the vertical_scroll_bar_extra member of
6486 x_output, w32_output, and mac_output structures. All uses changed. 6879 x_output, w32_output, and mac_output structures. All uses changed.
6487 (FRAME_PIXEL_HEIGHT): Renamed from PIXEL_HEIGHT and moved 6880 (FRAME_PIXEL_HEIGHT): Rename from PIXEL_HEIGHT and moved
6488 from x/w32/macterm.h files. All uses changed. Also change code 6881 from x/w32/macterm.h files. All uses changed. Also change code
6489 which referred to f->output_data...->pixel_height. 6882 which referred to f->output_data...->pixel_height.
6490 (FRAME_PIXEL_WIDTH): Renamed from PIXEL_WIDTH and moved 6883 (FRAME_PIXEL_WIDTH): Rename from PIXEL_WIDTH and moved
6491 from x/w32/macterm.h files. All uses changed. Also change code 6884 from x/w32/macterm.h files. All uses changed. Also change code
6492 which referred to f->output_data...->pixel_width. 6885 which referred to f->output_data...->pixel_width.
6493 (FRAME_LINES): Renamed from FRAME_HEIGHT. All uses changed. 6886 (FRAME_LINES): Rename from FRAME_HEIGHT. All uses changed.
6494 Also change code which referred to f->height. 6887 Also change code which referred to f->height.
6495 (FRAME_COLS): Renamed from FRAME_WIDTH. All uses changed. 6888 (FRAME_COLS): Rename from FRAME_WIDTH. All uses changed.
6496 Also change code which referred to f->width. 6889 Also change code which referred to f->width.
6497 (FRAME_NEW_HEIGHT, FRAME_NEW_WIDTH): Remove macros; change uses 6890 (FRAME_NEW_HEIGHT, FRAME_NEW_WIDTH): Remove macros; change uses
6498 to update new_text_lines and new_text_cols members directly. 6891 to update new_text_lines and new_text_cols members directly.
6499 (FRAME_CONFIG_SCROLL_BAR_WIDTH): Renamed from 6892 (FRAME_CONFIG_SCROLL_BAR_WIDTH): Rename from
6500 FRAME_SCROLL_BAR_PIXEL_WIDTH. All uses changed. 6893 FRAME_SCROLL_BAR_PIXEL_WIDTH. All uses changed.
6501 (FRAME_CONFIG_SCROLL_BAR_COLS): Renamed from 6894 (FRAME_CONFIG_SCROLL_BAR_COLS): Rename from
6502 FRAME_SCROLL_BAR_COLS. All uses changed. 6895 FRAME_SCROLL_BAR_COLS. All uses changed.
6503 (FRAME_LEFT_SCROLL_BAR_COLS, FRAME_RIGHT_SCROLL_BAR_COLS): 6896 (FRAME_LEFT_SCROLL_BAR_COLS, FRAME_RIGHT_SCROLL_BAR_COLS):
6504 Renamed from FRAME_LEFT_SCROLL_BAR_WIDTH and 6897 Rename from FRAME_LEFT_SCROLL_BAR_WIDTH and
6505 FRAME_RIGHT_SCROLL_BAR_WIDTH, resp. All uses changed. 6898 FRAME_RIGHT_SCROLL_BAR_WIDTH, resp. All uses changed.
6506 (FRAME_SCROLL_BAR_AREA_WIDTH, FRAME_LEFT_SCROLL_BAR_AREA_WIDTH) 6899 (FRAME_SCROLL_BAR_AREA_WIDTH, FRAME_LEFT_SCROLL_BAR_AREA_WIDTH)
6507 (FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH): New macros. 6900 (FRAME_RIGHT_SCROLL_BAR_AREA_WIDTH): New macros.
6508 (FRAME_TOTAL_COLS): Renamed from FRAME_WINDOW_WIDTH. 6901 (FRAME_TOTAL_COLS): Rename from FRAME_WINDOW_WIDTH.
6509 (SET_FRAME_COLS): Renamed from SET_FRAME_WIDTH. 6902 (SET_FRAME_COLS): Rename from SET_FRAME_WIDTH.
6510 (FRAME_TOTAL_COLS_ARG): Renamed from FRAME_WINDOW_WIDTH_ARG. 6903 (FRAME_TOTAL_COLS_ARG): Rename from FRAME_WINDOW_WIDTH_ARG.
6511 (WINDOW_VERTICAL_SCROLL_BAR_COLUMN): Remove unused macro. 6904 (WINDOW_VERTICAL_SCROLL_BAR_COLUMN): Remove unused macro.
6512 (WINDOW_VERTICAL_SCROLL_BAR_HEIGHT): Remove unused macro. 6905 (WINDOW_VERTICAL_SCROLL_BAR_HEIGHT): Remove unused macro.
6513 (FRAME_LINE_HEIGHT): Renamed from CANON_Y_UNIT. Unconditionally 6906 (FRAME_LINE_HEIGHT): Rename from CANON_Y_UNIT.
6514 return line_height member (it now has proper value also for 6907 Unconditionally return line_height member (it now has proper value
6515 non-window frames). 6908 also for non-window frames).
6516 (FRAME_COLUMN_WIDTH): Renamed from CANON_X_UNIT. Unconditionally 6909 (FRAME_COLUMN_WIDTH): Rename from CANON_X_UNIT. Unconditionally
6517 return new column_width member (rather than the default font width). 6910 return new column_width member (rather than the default font width).
6518 (FRAME_FRINGE_COLS, FRAME_LEFT_FRINGE_WIDTH) 6911 (FRAME_FRINGE_COLS, FRAME_LEFT_FRINGE_WIDTH)
6519 (FRAME_RIGHT_FRINGE_WIDTH): Renamed from FRAME_X_... and moved 6912 (FRAME_RIGHT_FRINGE_WIDTH): Rename from FRAME_X_... and moved
6520 from x/w32/macterm.h files. Unconditionally return corresponding 6913 from x/w32/macterm.h files. Unconditionally return corresponding
6521 member of frame structure (they now have proper values also for 6914 member of frame structure (they now have proper values also for
6522 non-window frames). 6915 non-window frames).
6523 (FRAME_TOTAL_FRINGE_WIDTH): Renamed from FRAME_FRINGE_WIDTH. 6916 (FRAME_TOTAL_FRINGE_WIDTH): Rename from FRAME_FRINGE_WIDTH.
6524 Calculate return value from left and right widths. 6917 Calculate return value from left and right widths.
6525 (FRAME_INTERNAL_BORDER_WIDTH): Unconditionally return 6918 (FRAME_INTERNAL_BORDER_WIDTH): Unconditionally return
6526 internal_border_width member (has proper value for non-window frame). 6919 internal_border_width member (has proper value for non-window frame).
6527 (FRAME_PIXEL_X_FROM_CANON_X): Renamed from PIXEL_X_FROM_CANON_X. 6920 (FRAME_PIXEL_X_FROM_CANON_X): Rename from PIXEL_X_FROM_CANON_X.
6528 (FRAME_PIXEL_Y_FROM_CANON_Y): Renamed from PIXEL_Y_FROM_CANON_Y. 6921 (FRAME_PIXEL_Y_FROM_CANON_Y): Rename from PIXEL_Y_FROM_CANON_Y.
6529 (FRAME_CANON_X_FROM_PIXEL_X): Renamed from CANON_X_FROM_PIXEL_X. 6922 (FRAME_CANON_X_FROM_PIXEL_X): Rename from CANON_X_FROM_PIXEL_X.
6530 (FRAME_CANON_Y_FROM_PIXEL_Y): Renamed from CANON_Y_FROM_PIXEL_Y. 6923 (FRAME_CANON_Y_FROM_PIXEL_Y): Rename from CANON_Y_FROM_PIXEL_Y.
6531 (FRAME_LINE_TO_PIXEL_Y): Renamed from CHAR_TO_PIXEL_ROW, 6924 (FRAME_LINE_TO_PIXEL_Y): Rename from CHAR_TO_PIXEL_ROW,
6532 consolidated from xterm.h, macterm.h, and w32term.h. 6925 consolidated from xterm.h, macterm.h, and w32term.h.
6533 (FRAME_COL_TO_PIXEL_X): Renamed from CHAR_TO_PIXEL_COL, 6926 (FRAME_COL_TO_PIXEL_X): Rename from CHAR_TO_PIXEL_COL,
6534 consolidated from xterm.h, macterm.h, and w32term.h. 6927 consolidated from xterm.h, macterm.h, and w32term.h.
6535 (FRAME_TEXT_COLS_TO_PIXEL_WIDTH): Renamed from 6928 (FRAME_TEXT_COLS_TO_PIXEL_WIDTH): Rename from
6536 CHAR_TO_PIXEL_WIDTH consolidated from x/mac/w32term.h. 6929 CHAR_TO_PIXEL_WIDTH consolidated from x/mac/w32term.h.
6537 (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT): Renamed from 6930 (FRAME_TEXT_LINES_TO_PIXEL_HEIGHT): Rename from
6538 CHAR_TO_PIXEL_HEIGHT consolidated from x/mac/w32term.h. 6931 CHAR_TO_PIXEL_HEIGHT consolidated from x/mac/w32term.h.
6539 (FRAME_PIXEL_Y_TO_LINE): Renamed from PIXEL_TO_CHAR_ROW 6932 (FRAME_PIXEL_Y_TO_LINE): Rename from PIXEL_TO_CHAR_ROW
6540 consolidated from x/mac/w32term.h. 6933 consolidated from x/mac/w32term.h.
6541 (FRAME_PIXEL_X_TO_COL): Renamed from PIXEL_TO_CHAR_COL 6934 (FRAME_PIXEL_X_TO_COL): Rename from PIXEL_TO_CHAR_COL
6542 consolidated from x/mac/w32term.h. 6935 consolidated from x/mac/w32term.h.
6543 (FRAME_PIXEL_WIDTH_TO_TEXT_COLS): Renamed from 6936 (FRAME_PIXEL_WIDTH_TO_TEXT_COLS): Rename from
6544 PIXEL_TO_CHAR_WIDTH consolidated from x/mac/w32term.h. 6937 PIXEL_TO_CHAR_WIDTH consolidated from x/mac/w32term.h.
6545 (FRAME_PIXEL_HEIGHT_TO_TEXT_LINES): Renamed from 6938 (FRAME_PIXEL_HEIGHT_TO_TEXT_LINES): Rename from
6546 PIXEL_TO_CHAR_HEIGHT consolidated from x/mac/w32term.h. 6939 PIXEL_TO_CHAR_HEIGHT consolidated from x/mac/w32term.h.
6547 6940
6548 * window.h (struct window): Rename members left to left_col, 6941 * window.h (struct window): Rename members left to left_col,
@@ -6564,7 +6957,7 @@
6564 referred to XINT (w->height) * canon_y_unit. 6957 referred to XINT (w->height) * canon_y_unit.
6565 (WINDOW_LEFT_EDGE_COL): New macro. Change relevant code that 6958 (WINDOW_LEFT_EDGE_COL): New macro. Change relevant code that
6566 referred to XINT (w->left). 6959 referred to XINT (w->left).
6567 (WINDOW_RIGHT_EDGE_COL): Renamed from WINDOW_RIGHT_EDGE. Change 6960 (WINDOW_RIGHT_EDGE_COL): Rename from WINDOW_RIGHT_EDGE. Change
6568 all uses and code that referred to XINT (w->left) + XINT (w->width). 6961 all uses and code that referred to XINT (w->left) + XINT (w->width).
6569 (WINDOW_TOP_EDGE_LINE): New macro. Change relevant code that 6962 (WINDOW_TOP_EDGE_LINE): New macro. Change relevant code that
6570 referred to XINT (w->top). 6963 referred to XINT (w->top).
@@ -6579,14 +6972,14 @@
6579 (WINDOW_BOTTOM_EDGE_Y): New macro. Change relevant code that 6972 (WINDOW_BOTTOM_EDGE_Y): New macro. Change relevant code that
6580 referred to (XINT (w->top) + XINT (w->height)) * canon_y_unit. 6973 referred to (XINT (w->top) + XINT (w->height)) * canon_y_unit.
6581 (WINDOW_LEFTMOST_P): New macro. 6974 (WINDOW_LEFTMOST_P): New macro.
6582 (WINDOW_BOX_LEFT_EDGE_COL): Renamed from WINDOW_LEFT_MARGIN. 6975 (WINDOW_BOX_LEFT_EDGE_COL): Rename from WINDOW_LEFT_MARGIN.
6583 All uses changed. 6976 All uses changed.
6584 (WINDOW_BOX_RIGHT_EDGE_COL): Renamed from WINDOW_RIGHT_MARGIN. 6977 (WINDOW_BOX_RIGHT_EDGE_COL): Rename from WINDOW_RIGHT_MARGIN.
6585 All uses changed. 6978 All uses changed.
6586 (WINDOW_BOX_LEFT_EDGE_X): Renamed from 6979 (WINDOW_BOX_LEFT_EDGE_X): Rename from
6587 WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X, moved from dispextern.h. 6980 WINDOW_DISPLAY_LEFT_EDGE_PIXEL_X, moved from dispextern.h.
6588 Do not exclude left fringe width. 6981 Do not exclude left fringe width.
6589 (WINDOW_BOX_RIGHT_EDGE_X): Renamed from 6982 (WINDOW_BOX_RIGHT_EDGE_X): Rename from
6590 WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X, moved from dispextern.h. 6983 WINDOW_DISPLAY_RIGHT_EDGE_PIXEL_X, moved from dispextern.h.
6591 Do not exclude fringe widths. 6984 Do not exclude fringe widths.
6592 (WINDOW_LEFT_FRINGE_WIDTH, WINDOW_RIGHT_FRINGE_WIDTH) 6985 (WINDOW_LEFT_FRINGE_WIDTH, WINDOW_RIGHT_FRINGE_WIDTH)
@@ -6613,18 +7006,18 @@
6613 FRAME_SCROLL_BAR_WIDTH. 7006 FRAME_SCROLL_BAR_WIDTH.
6614 (WINDOW_SCROLL_BAR_COLS, WINDOW_SCROLL_BAR_AREA_WIDTH) 7007 (WINDOW_SCROLL_BAR_COLS, WINDOW_SCROLL_BAR_AREA_WIDTH)
6615 (WINDOW_SCROLL_BAR_AREA_X): New macros. 7008 (WINDOW_SCROLL_BAR_AREA_X): New macros.
6616 (WINDOW_HEADER_LINE_HEIGHT): Renamed from 7009 (WINDOW_HEADER_LINE_HEIGHT): Rename from
6617 WINDOW_DISPLAY_HEADER_LINE_HEIGHT, moved from dispextern.h. 7010 WINDOW_DISPLAY_HEADER_LINE_HEIGHT, moved from dispextern.h.
6618 (WINDOW_BOX_HEIGHT_NO_MODE_LINE): Renamed from 7011 (WINDOW_BOX_HEIGHT_NO_MODE_LINE): Rename from
6619 WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE, moved from dispextern.h. 7012 WINDOW_DISPLAY_HEIGHT_NO_MODE_LINE, moved from dispextern.h.
6620 (WINDOW_BOX_TEXT_HEIGHT): Renamed from 7013 (WINDOW_BOX_TEXT_HEIGHT): Rename from
6621 WINDOW_DISPLAY_PIXEL_WIDTH, moved from dispextern.h. 7014 WINDOW_DISPLAY_PIXEL_WIDTH, moved from dispextern.h.
6622 (WINDOW_TO_FRAME_PIXEL_X, WINDOW_TO_FRAME_PIXEL_Y) 7015 (WINDOW_TO_FRAME_PIXEL_X, WINDOW_TO_FRAME_PIXEL_Y)
6623 (FRAME_TO_WINDOW_PIXEL_X, FRAME_TO_WINDOW_PIXEL_Y) 7016 (FRAME_TO_WINDOW_PIXEL_X, FRAME_TO_WINDOW_PIXEL_Y)
6624 (WINDOW_TEXT_TO_FRAME_PIXEL_X): Moved here from dispextern.h. 7017 (WINDOW_TEXT_TO_FRAME_PIXEL_X): Move here from dispextern.h.
6625 (WINDOW_LEFT_MARGIN_WIDTH): Renamed from 7018 (WINDOW_LEFT_MARGIN_WIDTH): Rename from
6626 WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH, moved from dispextern.h. 7019 WINDOW_DISPLAY_LEFT_AREA_PIXEL_WIDTH, moved from dispextern.h.
6627 (WINDOW_RIGHT_MARGIN_WIDTH): Renamed from 7020 (WINDOW_RIGHT_MARGIN_WIDTH): Rename from
6628 WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH, moved from dispextern.h. 7021 WINDOW_DISPLAY_RIGHT_AREA_PIXEL_WIDTH, moved from dispextern.h.
6629 (window_from_coordinates): Update prototype. 7022 (window_from_coordinates): Update prototype.
6630 (Fset_window_buffer): Update EXFUN. 7023 (Fset_window_buffer): Update EXFUN.
@@ -6718,7 +7111,7 @@
6718 left_margin_cols, right_margin_cols, left_fringe_width, 7111 left_margin_cols, right_margin_cols, left_fringe_width,
6719 right_fringe_width, fringes_outside_margins, scroll_bar_width, 7112 right_fringe_width, fringes_outside_margins, scroll_bar_width,
6720 and vertical_scroll_bar_type. 7113 and vertical_scroll_bar_type.
6721 (coordinates_in_window): Adapted to new fringe/margin positions 7114 (coordinates_in_window): Adapt to new fringe/margin positions
6722 and per-window fringes and scroll-bars. 7115 and per-window fringes and scroll-bars.
6723 Fix bug related to incorrectly adjusting coordinates by 7116 Fix bug related to incorrectly adjusting coordinates by
6724 frame's internal_border_width (the effect normally negible since 7117 frame's internal_border_width (the effect normally negible since
@@ -6753,7 +7146,7 @@
6753 narrow. This fixes a bug which could cause Emacs to trap if the 7146 narrow. This fixes a bug which could cause Emacs to trap if the
6754 width of the split window was less than the width of the display 7147 width of the split window was less than the width of the display
6755 margins. 7148 margins.
6756 (window_box_text_cols): Renamed from window_internal_width. 7149 (window_box_text_cols): Rename from window_internal_width.
6757 All uses changed. Adapt to per-window fringes and scroll bars. 7150 All uses changed. Adapt to per-window fringes and scroll bars.
6758 Fix bug that caused vertical separator to be subtracted also on 7151 Fix bug that caused vertical separator to be subtracted also on
6759 window frames. Fix another bug that did not reduce the returned 7152 window frames. Fix another bug that did not reduce the returned
@@ -6785,8 +7178,7 @@
6785 the width of the window. 7178 the width of the window.
6786 (Fset_window_fringes): New defun to allow user to specifically set 7179 (Fset_window_fringes): New defun to allow user to specifically set
6787 this window's fringe widths and position vs. display margins. 7180 this window's fringe widths and position vs. display margins.
6788 (Fwindow_fringes): New defun to return window's actual fringe 7181 (Fwindow_fringes): New defun to return window's actual fringe settings.
6789 settings.
6790 (Fset_window_scroll_bars): New defun to allow user to specifically 7182 (Fset_window_scroll_bars): New defun to allow user to specifically
6791 set this window's scroll bar width and position. 7183 set this window's scroll bar width and position.
6792 (Fwindow_scroll_bars): New defun to return window's actual scroll 7184 (Fwindow_scroll_bars): New defun to return window's actual scroll
@@ -6853,17 +7245,16 @@
6853 (FRAME_DEFAULT_FONT_WIDTH): Remove macro. 7245 (FRAME_DEFAULT_FONT_WIDTH): Remove macro.
6854 (PIXEL_WIDTH, PIXEL_HEIGHT) 7246 (PIXEL_WIDTH, PIXEL_HEIGHT)
6855 (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH) 7247 (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH)
6856 (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Moved to 7248 (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Move to
6857 frame.h and renamed [see frame.h changes]. 7249 frame.h and renamed [see frame.h changes].
6858 (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH) 7250 (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH)
6859 (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL) 7251 (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL)
6860 (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Moved to frame.h 7252 (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Move to frame.h
6861 and renamed [see frame.h changes]. 7253 and renamed [see frame.h changes].
6862 7254
6863 * xterm.c: Make (several) trivial substitutions for renamed and 7255 * xterm.c: Make (several) trivial substitutions for renamed and
6864 new macros in dispextern.h, frame.h and window.h. 7256 new macros in dispextern.h, frame.h and window.h.
6865 (x_draw_glyph_string_box): Adapt to per-window fringes and 7257 (x_draw_glyph_string_box): Adapt to per-window fringes and scroll-bars.
6866 scroll-bars.
6867 (scroll_run): Adapt to new fringe position. 7258 (scroll_run): Adapt to new fringe position.
6868 (glyph_rect): Use window coordinates returned from 7259 (glyph_rect): Use window coordinates returned from
6869 window_from_coordinates rather than frame_to_window_pixel_xy. 7260 window_from_coordinates rather than frame_to_window_pixel_xy.
@@ -6887,17 +7278,16 @@
6887 (FRAME_DEFAULT_FONT_WIDTH): Remove macro. 7278 (FRAME_DEFAULT_FONT_WIDTH): Remove macro.
6888 (PIXEL_WIDTH, PIXEL_HEIGHT) 7279 (PIXEL_WIDTH, PIXEL_HEIGHT)
6889 (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH) 7280 (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH)
6890 (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Moved to 7281 (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Move to
6891 frame.h and renamed [see frame.h changes]. 7282 frame.h and renamed [see frame.h changes].
6892 (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH) 7283 (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH)
6893 (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL) 7284 (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL)
6894 (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Moved to frame.h 7285 (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Move to frame.h
6895 and renamed [see frame.h changes]. 7286 and renamed [see frame.h changes].
6896 7287
6897 * w32term.c: Make (several) trivial substitutions for renamed and 7288 * w32term.c: Make (several) trivial substitutions for renamed and
6898 new macros in dispextern.h, frame.h and window.h. 7289 new macros in dispextern.h, frame.h and window.h.
6899 (x_draw_glyph_string_box): Adapt to per-window fringes and 7290 (x_draw_glyph_string_box): Adapt to per-window fringes and scroll-bars.
6900 scroll-bars.
6901 (glyph_rect): Use window coordinates returned from 7291 (glyph_rect): Use window coordinates returned from
6902 window_from_coordinates rather than frame_to_window_pixel_xy. 7292 window_from_coordinates rather than frame_to_window_pixel_xy.
6903 (XTset_vertical_scroll_bar): Adapt to per-window fringes and 7293 (XTset_vertical_scroll_bar): Adapt to per-window fringes and
@@ -6928,17 +7318,16 @@
6928 (FRAME_DEFAULT_FONT_WIDTH): Remove macro. 7318 (FRAME_DEFAULT_FONT_WIDTH): Remove macro.
6929 (PIXEL_WIDTH, PIXEL_HEIGHT) 7319 (PIXEL_WIDTH, PIXEL_HEIGHT)
6930 (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH) 7320 (FRAME_X_FRINGE_COLS, FRAME_X_FRINGE_WIDTH)
6931 (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Moved to 7321 (FRAME_X_LEFT_FRINGE_WIDTH, FRAME_X_RIGHT_FRINGE_WIDTH): Move to
6932 frame.h and renamed [see frame.h changes]. 7322 frame.h and renamed [see frame.h changes].
6933 (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH) 7323 (CHAR_TO_PIXEL_ROW, CHAR_TO_PIXEL_COL, CHAR_TO_PIXEL_WIDTH)
6934 (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL) 7324 (CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_ROW, PIXEL_TO_CHAR_COL)
6935 (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Moved to frame.h 7325 (PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): Move to frame.h
6936 and renamed [see frame.h changes]. 7326 and renamed [see frame.h changes].
6937 7327
6938 * macterm.c: Make (several) trivial substitutions for renamed and 7328 * macterm.c: Make (several) trivial substitutions for renamed and
6939 new macros in dispextern.h, frame.h and window.h. 7329 new macros in dispextern.h, frame.h and window.h.
6940 (x_draw_glyph_string_box): Adapt to per-window fringes and 7330 (x_draw_glyph_string_box): Adapt to per-window fringes and scroll-bars.
6941 scroll-bars.
6942 (glyph_rect): Use window coordinates returned from 7331 (glyph_rect): Use window coordinates returned from
6943 window_from_coordinates rather than frame_to_window_pixel_xy. 7332 window_from_coordinates rather than frame_to_window_pixel_xy.
6944 (XTset_vertical_scroll_bar): Adapt to per-window fringes and 7333 (XTset_vertical_scroll_bar): Adapt to per-window fringes and
diff --git a/src/Makefile.in b/src/Makefile.in
index 40d7e2df53c..8423a630937 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1220,10 +1220,10 @@ abbrev.o buffer.o callint.o cmds.o dispnew.o editfns.o fileio.o frame.o \
1220 fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \ 1220 fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \
1221 scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \ 1221 scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \
1222 xterm.o xselect.o sound.o: macgui.h 1222 xterm.o xselect.o sound.o: macgui.h
1223mac.o: mac.c process.h sysselect.h systime.h $(config_h) 1223mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h $(config_h)
1224macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \ 1224macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \
1225 dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \ 1225 dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \
1226 atimer.h systime.h epaths.h termhooks.h coding.h ccl.h systime.h $(config_h) 1226 atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h)
1227macmenu.o: macmenu.c termhooks.h frame.h window.h dispextern.h macgui.h \ 1227macmenu.o: macmenu.c termhooks.h frame.h window.h dispextern.h macgui.h \
1228 keyboard.h blockinput.h atimer.h systime.h buffer.h macterm.h $(config_h) 1228 keyboard.h blockinput.h atimer.h systime.h buffer.h macterm.h $(config_h)
1229macterm.o: blockinput.h atimer.h systime.h syssignal.h macterm.h macgui.h \ 1229macterm.o: blockinput.h atimer.h systime.h syssignal.h macterm.h macgui.h \
diff --git a/src/alloc.c b/src/alloc.c
index e783ba581e0..2a539920f22 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -31,6 +31,10 @@ Boston, MA 02111-1307, USA. */
31 31
32#include <signal.h> 32#include <signal.h>
33 33
34#ifdef HAVE_GTK_AND_PTHREAD
35#include <pthread.h>
36#endif
37
34/* This file is part of the core Lisp implementation, and thus must 38/* This file is part of the core Lisp implementation, and thus must
35 deal with the real data structures. If the Lisp implementation is 39 deal with the real data structures. If the Lisp implementation is
36 replaced, this file likely will not be used. */ 40 replaced, this file likely will not be used. */
@@ -85,6 +89,52 @@ extern __malloc_size_t __malloc_extra_blocks;
85 89
86#endif /* not DOUG_LEA_MALLOC */ 90#endif /* not DOUG_LEA_MALLOC */
87 91
92#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD)
93
94/* When GTK uses the file chooser dialog, different backends can be loaded
95 dynamically. One such a backend is the Gnome VFS backend that gets loaded
96 if you run Gnome. That backend creates several threads and also allocates
97 memory with malloc.
98
99 If Emacs sets malloc hooks (! SYSTEM_MALLOC) and the emacs_blocked_*
100 functions below are called from malloc, there is a chance that one
101 of these threads preempts the Emacs main thread and the hook variables
102 end up in a inconsistent state. So we have a mutex to prevent that (note
103 that the backend handles concurrent access to malloc within its own threads
104 but Emacs code running in the main thread is not included in that control).
105
106 When UNBLOCK_INPUT is called, revoke_input_signal may be called. If this
107 happens in one of the backend threads we will have two threads that tries
108 to run Emacs code at once, and the code is not prepared for that.
109 To prevent that, we only call BLOCK/UNBLOCK from the main thread. */
110
111static pthread_mutex_t alloc_mutex;
112pthread_t main_thread;
113
114#define BLOCK_INPUT_ALLOC \
115 do \
116 { \
117 pthread_mutex_lock (&alloc_mutex); \
118 if (pthread_self () == main_thread) \
119 BLOCK_INPUT; \
120 } \
121 while (0)
122#define UNBLOCK_INPUT_ALLOC \
123 do \
124 { \
125 if (pthread_self () == main_thread) \
126 UNBLOCK_INPUT; \
127 pthread_mutex_unlock (&alloc_mutex); \
128 } \
129 while (0)
130
131#else /* SYSTEM_MALLOC || not HAVE_GTK_AND_PTHREAD */
132
133#define BLOCK_INPUT_ALLOC BLOCK_INPUT
134#define UNBLOCK_INPUT_ALLOC UNBLOCK_INPUT
135
136#endif /* SYSTEM_MALLOC || not HAVE_GTK_AND_PTHREAD */
137
88/* Value of _bytes_used, when spare_memory was freed. */ 138/* Value of _bytes_used, when spare_memory was freed. */
89 139
90static __malloc_size_t bytes_used_when_full; 140static __malloc_size_t bytes_used_when_full;
@@ -516,6 +566,140 @@ buffer_memory_full ()
516} 566}
517 567
518 568
569#ifdef XMALLOC_OVERRUN_CHECK
570
571/* Check for overrun in malloc'ed buffers by wrapping a 16 byte header
572 and a 16 byte trailer around each block.
573
574 The header consists of 12 fixed bytes + a 4 byte integer contaning the
575 original block size, while the trailer consists of 16 fixed bytes.
576
577 The header is used to detect whether this block has been allocated
578 through these functions -- as it seems that some low-level libc
579 functions may bypass the malloc hooks.
580*/
581
582
583#define XMALLOC_OVERRUN_CHECK_SIZE 16
584
585static char xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZE-4] =
586 { 0x9a, 0x9b, 0xae, 0xaf,
587 0xbf, 0xbe, 0xce, 0xcf,
588 0xea, 0xeb, 0xec, 0xed };
589
590static char xmalloc_overrun_check_trailer[XMALLOC_OVERRUN_CHECK_SIZE] =
591 { 0xaa, 0xab, 0xac, 0xad,
592 0xba, 0xbb, 0xbc, 0xbd,
593 0xca, 0xcb, 0xcc, 0xcd,
594 0xda, 0xdb, 0xdc, 0xdd };
595
596/* Macros to insert and extract the block size in the header. */
597
598#define XMALLOC_PUT_SIZE(ptr, size) \
599 (ptr[-1] = (size & 0xff), \
600 ptr[-2] = ((size >> 8) & 0xff), \
601 ptr[-3] = ((size >> 16) & 0xff), \
602 ptr[-4] = ((size >> 24) & 0xff))
603
604#define XMALLOC_GET_SIZE(ptr) \
605 (size_t)((unsigned)(ptr[-1]) | \
606 ((unsigned)(ptr[-2]) << 8) | \
607 ((unsigned)(ptr[-3]) << 16) | \
608 ((unsigned)(ptr[-4]) << 24))
609
610
611/* Like malloc, but wraps allocated block with header and trailer. */
612
613POINTER_TYPE *
614overrun_check_malloc (size)
615 size_t size;
616{
617 register unsigned char *val;
618
619 val = (unsigned char *) malloc (size + XMALLOC_OVERRUN_CHECK_SIZE*2);
620 if (val)
621 {
622 bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4);
623 val += XMALLOC_OVERRUN_CHECK_SIZE;
624 XMALLOC_PUT_SIZE(val, size);
625 bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE);
626 }
627 return (POINTER_TYPE *)val;
628}
629
630
631/* Like realloc, but checks old block for overrun, and wraps new block
632 with header and trailer. */
633
634POINTER_TYPE *
635overrun_check_realloc (block, size)
636 POINTER_TYPE *block;
637 size_t size;
638{
639 register unsigned char *val = (unsigned char *)block;
640
641 if (val
642 && bcmp (xmalloc_overrun_check_header,
643 val - XMALLOC_OVERRUN_CHECK_SIZE,
644 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
645 {
646 size_t osize = XMALLOC_GET_SIZE (val);
647 if (bcmp (xmalloc_overrun_check_trailer,
648 val + osize,
649 XMALLOC_OVERRUN_CHECK_SIZE))
650 abort ();
651 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
652 val -= XMALLOC_OVERRUN_CHECK_SIZE;
653 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
654 }
655
656 val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + XMALLOC_OVERRUN_CHECK_SIZE*2);
657
658 if (val)
659 {
660 bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4);
661 val += XMALLOC_OVERRUN_CHECK_SIZE;
662 XMALLOC_PUT_SIZE(val, size);
663 bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE);
664 }
665 return (POINTER_TYPE *)val;
666}
667
668/* Like free, but checks block for overrun. */
669
670void
671overrun_check_free (block)
672 POINTER_TYPE *block;
673{
674 unsigned char *val = (unsigned char *)block;
675
676 if (val
677 && bcmp (xmalloc_overrun_check_header,
678 val - XMALLOC_OVERRUN_CHECK_SIZE,
679 XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
680 {
681 size_t osize = XMALLOC_GET_SIZE (val);
682 if (bcmp (xmalloc_overrun_check_trailer,
683 val + osize,
684 XMALLOC_OVERRUN_CHECK_SIZE))
685 abort ();
686 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
687 val -= XMALLOC_OVERRUN_CHECK_SIZE;
688 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
689 }
690
691 free (val);
692}
693
694#undef malloc
695#undef realloc
696#undef free
697#define malloc overrun_check_malloc
698#define realloc overrun_check_realloc
699#define free overrun_check_free
700#endif
701
702
519/* Like malloc but check for no memory and block interrupt input.. */ 703/* Like malloc but check for no memory and block interrupt input.. */
520 704
521POINTER_TYPE * 705POINTER_TYPE *
@@ -602,7 +786,9 @@ safe_alloca_unwind (arg)
602 number of bytes to allocate, TYPE describes the intended use of the 786 number of bytes to allocate, TYPE describes the intended use of the
603 allcated memory block (for strings, for conses, ...). */ 787 allcated memory block (for strings, for conses, ...). */
604 788
789#ifndef USE_LSB_TAG
605static void *lisp_malloc_loser; 790static void *lisp_malloc_loser;
791#endif
606 792
607static POINTER_TYPE * 793static POINTER_TYPE *
608lisp_malloc (nbytes, type) 794lisp_malloc (nbytes, type)
@@ -932,7 +1118,7 @@ static void
932emacs_blocked_free (ptr) 1118emacs_blocked_free (ptr)
933 void *ptr; 1119 void *ptr;
934{ 1120{
935 BLOCK_INPUT; 1121 BLOCK_INPUT_ALLOC;
936 1122
937#ifdef GC_MALLOC_CHECK 1123#ifdef GC_MALLOC_CHECK
938 if (ptr) 1124 if (ptr)
@@ -970,7 +1156,7 @@ emacs_blocked_free (ptr)
970 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY); 1156 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
971 1157
972 __free_hook = emacs_blocked_free; 1158 __free_hook = emacs_blocked_free;
973 UNBLOCK_INPUT; 1159 UNBLOCK_INPUT_ALLOC;
974} 1160}
975 1161
976 1162
@@ -996,7 +1182,7 @@ emacs_blocked_malloc (size)
996{ 1182{
997 void *value; 1183 void *value;
998 1184
999 BLOCK_INPUT; 1185 BLOCK_INPUT_ALLOC;
1000 __malloc_hook = old_malloc_hook; 1186 __malloc_hook = old_malloc_hook;
1001#ifdef DOUG_LEA_MALLOC 1187#ifdef DOUG_LEA_MALLOC
1002 mallopt (M_TOP_PAD, malloc_hysteresis * 4096); 1188 mallopt (M_TOP_PAD, malloc_hysteresis * 4096);
@@ -1028,7 +1214,7 @@ emacs_blocked_malloc (size)
1028#endif /* GC_MALLOC_CHECK */ 1214#endif /* GC_MALLOC_CHECK */
1029 1215
1030 __malloc_hook = emacs_blocked_malloc; 1216 __malloc_hook = emacs_blocked_malloc;
1031 UNBLOCK_INPUT; 1217 UNBLOCK_INPUT_ALLOC;
1032 1218
1033 /* fprintf (stderr, "%p malloc\n", value); */ 1219 /* fprintf (stderr, "%p malloc\n", value); */
1034 return value; 1220 return value;
@@ -1044,7 +1230,7 @@ emacs_blocked_realloc (ptr, size)
1044{ 1230{
1045 void *value; 1231 void *value;
1046 1232
1047 BLOCK_INPUT; 1233 BLOCK_INPUT_ALLOC;
1048 __realloc_hook = old_realloc_hook; 1234 __realloc_hook = old_realloc_hook;
1049 1235
1050#ifdef GC_MALLOC_CHECK 1236#ifdef GC_MALLOC_CHECK
@@ -1089,17 +1275,45 @@ emacs_blocked_realloc (ptr, size)
1089#endif /* GC_MALLOC_CHECK */ 1275#endif /* GC_MALLOC_CHECK */
1090 1276
1091 __realloc_hook = emacs_blocked_realloc; 1277 __realloc_hook = emacs_blocked_realloc;
1092 UNBLOCK_INPUT; 1278 UNBLOCK_INPUT_ALLOC;
1093 1279
1094 return value; 1280 return value;
1095} 1281}
1096 1282
1097 1283
1284#ifdef HAVE_GTK_AND_PTHREAD
1285/* Called from Fdump_emacs so that when the dumped Emacs starts, it has a
1286 normal malloc. Some thread implementations need this as they call
1287 malloc before main. The pthread_self call in BLOCK_INPUT_ALLOC then
1288 calls malloc because it is the first call, and we have an endless loop. */
1289
1290void
1291reset_malloc_hooks ()
1292{
1293 __free_hook = 0;
1294 __malloc_hook = 0;
1295 __realloc_hook = 0;
1296}
1297#endif /* HAVE_GTK_AND_PTHREAD */
1298
1299
1098/* Called from main to set up malloc to use our hooks. */ 1300/* Called from main to set up malloc to use our hooks. */
1099 1301
1100void 1302void
1101uninterrupt_malloc () 1303uninterrupt_malloc ()
1102{ 1304{
1305#ifdef HAVE_GTK_AND_PTHREAD
1306 pthread_mutexattr_t attr;
1307
1308 /* GLIBC has a faster way to do this, but lets keep it portable.
1309 This is according to the Single UNIX Specification. */
1310 pthread_mutexattr_init (&attr);
1311 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
1312 pthread_mutex_init (&alloc_mutex, &attr);
1313
1314 main_thread = pthread_self ();
1315#endif /* HAVE_GTK_AND_PTHREAD */
1316
1103 if (__free_hook != emacs_blocked_free) 1317 if (__free_hook != emacs_blocked_free)
1104 old_free_hook = __free_hook; 1318 old_free_hook = __free_hook;
1105 __free_hook = emacs_blocked_free; 1319 __free_hook = emacs_blocked_free;
@@ -1428,6 +1642,21 @@ static int total_string_size;
1428 1642
1429#endif /* not GC_CHECK_STRING_BYTES */ 1643#endif /* not GC_CHECK_STRING_BYTES */
1430 1644
1645
1646#ifdef GC_CHECK_STRING_OVERRUN
1647
1648/* We check for overrun in string data blocks by appending a small
1649 "cookie" after each allocated string data block, and check for the
1650 presense of this cookie during GC. */
1651
1652#define GC_STRING_OVERRUN_COOKIE_SIZE 4
1653static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
1654 { 0xde, 0xad, 0xbe, 0xef };
1655
1656#else
1657#define GC_STRING_OVERRUN_COOKIE_SIZE 0
1658#endif
1659
1431/* Value is the size of an sdata structure large enough to hold NBYTES 1660/* Value is the size of an sdata structure large enough to hold NBYTES
1432 bytes of string data. The value returned includes a terminating 1661 bytes of string data. The value returned includes a terminating
1433 NUL byte, the size of the sdata structure, and padding. */ 1662 NUL byte, the size of the sdata structure, and padding. */
@@ -1451,6 +1680,10 @@ static int total_string_size;
1451 1680
1452#endif /* not GC_CHECK_STRING_BYTES */ 1681#endif /* not GC_CHECK_STRING_BYTES */
1453 1682
1683/* Extra bytes to allocate for each string. */
1684
1685#define GC_STRING_EXTRA (GC_STRING_OVERRUN_COOKIE_SIZE)
1686
1454/* Initialize string allocation. Called from init_alloc_once. */ 1687/* Initialize string allocation. Called from init_alloc_once. */
1455 1688
1456void 1689void
@@ -1515,7 +1748,7 @@ check_sblock (b)
1515 nbytes = SDATA_NBYTES (from); 1748 nbytes = SDATA_NBYTES (from);
1516 1749
1517 nbytes = SDATA_SIZE (nbytes); 1750 nbytes = SDATA_SIZE (nbytes);
1518 from_end = (struct sdata *) ((char *) from + nbytes); 1751 from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA);
1519 } 1752 }
1520} 1753}
1521 1754
@@ -1548,6 +1781,28 @@ check_string_bytes (all_p)
1548 1781
1549#endif /* GC_CHECK_STRING_BYTES */ 1782#endif /* GC_CHECK_STRING_BYTES */
1550 1783
1784#ifdef GC_CHECK_STRING_FREE_LIST
1785
1786/* Walk through the string free list looking for bogus next pointers.
1787 This may catch buffer overrun from a previous string. */
1788
1789static void
1790check_string_free_list ()
1791{
1792 struct Lisp_String *s;
1793
1794 /* Pop a Lisp_String off the free-list. */
1795 s = string_free_list;
1796 while (s != NULL)
1797 {
1798 if ((unsigned)s < 1024)
1799 abort();
1800 s = NEXT_FREE_LISP_STRING (s);
1801 }
1802}
1803#else
1804#define check_string_free_list()
1805#endif
1551 1806
1552/* Return a new Lisp_String. */ 1807/* Return a new Lisp_String. */
1553 1808
@@ -1579,6 +1834,8 @@ allocate_string ()
1579 total_free_strings += STRING_BLOCK_SIZE; 1834 total_free_strings += STRING_BLOCK_SIZE;
1580 } 1835 }
1581 1836
1837 check_string_free_list ();
1838
1582 /* Pop a Lisp_String off the free-list. */ 1839 /* Pop a Lisp_String off the free-list. */
1583 s = string_free_list; 1840 s = string_free_list;
1584 string_free_list = NEXT_FREE_LISP_STRING (s); 1841 string_free_list = NEXT_FREE_LISP_STRING (s);
@@ -1648,7 +1905,7 @@ allocate_string_data (s, nchars, nbytes)
1648 mallopt (M_MMAP_MAX, 0); 1905 mallopt (M_MMAP_MAX, 0);
1649#endif 1906#endif
1650 1907
1651 b = (struct sblock *) lisp_malloc (size, MEM_TYPE_NON_LISP); 1908 b = (struct sblock *) lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP);
1652 1909
1653#ifdef DOUG_LEA_MALLOC 1910#ifdef DOUG_LEA_MALLOC
1654 /* Back to a reasonable maximum of mmap'ed areas. */ 1911 /* Back to a reasonable maximum of mmap'ed areas. */
@@ -1663,7 +1920,7 @@ allocate_string_data (s, nchars, nbytes)
1663 else if (current_sblock == NULL 1920 else if (current_sblock == NULL
1664 || (((char *) current_sblock + SBLOCK_SIZE 1921 || (((char *) current_sblock + SBLOCK_SIZE
1665 - (char *) current_sblock->next_free) 1922 - (char *) current_sblock->next_free)
1666 < needed)) 1923 < (needed + GC_STRING_EXTRA)))
1667 { 1924 {
1668 /* Not enough room in the current sblock. */ 1925 /* Not enough room in the current sblock. */
1669 b = (struct sblock *) lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP); 1926 b = (struct sblock *) lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP);
@@ -1692,7 +1949,11 @@ allocate_string_data (s, nchars, nbytes)
1692 s->size = nchars; 1949 s->size = nchars;
1693 s->size_byte = nbytes; 1950 s->size_byte = nbytes;
1694 s->data[nbytes] = '\0'; 1951 s->data[nbytes] = '\0';
1695 b->next_free = (struct sdata *) ((char *) data + needed); 1952#ifdef GC_CHECK_STRING_OVERRUN
1953 bcopy (string_overrun_cookie, (char *) data + needed,
1954 GC_STRING_OVERRUN_COOKIE_SIZE);
1955#endif
1956 b->next_free = (struct sdata *) ((char *) data + needed + GC_STRING_EXTRA);
1696 1957
1697 /* If S had already data assigned, mark that as free by setting its 1958 /* If S had already data assigned, mark that as free by setting its
1698 string back-pointer to null, and recording the size of the data 1959 string back-pointer to null, and recording the size of the data
@@ -1797,9 +2058,13 @@ sweep_strings ()
1797 } 2058 }
1798 } 2059 }
1799 2060
2061 check_string_free_list ();
2062
1800 string_blocks = live_blocks; 2063 string_blocks = live_blocks;
1801 free_large_strings (); 2064 free_large_strings ();
1802 compact_small_strings (); 2065 compact_small_strings ();
2066
2067 check_string_free_list ();
1803} 2068}
1804 2069
1805 2070
@@ -1871,28 +2136,38 @@ compact_small_strings ()
1871 else 2136 else
1872 nbytes = SDATA_NBYTES (from); 2137 nbytes = SDATA_NBYTES (from);
1873 2138
2139 if (nbytes > LARGE_STRING_BYTES)
2140 abort ();
2141
1874 nbytes = SDATA_SIZE (nbytes); 2142 nbytes = SDATA_SIZE (nbytes);
1875 from_end = (struct sdata *) ((char *) from + nbytes); 2143 from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA);
2144
2145#ifdef GC_CHECK_STRING_OVERRUN
2146 if (bcmp (string_overrun_cookie,
2147 ((char *) from_end) - GC_STRING_OVERRUN_COOKIE_SIZE,
2148 GC_STRING_OVERRUN_COOKIE_SIZE))
2149 abort ();
2150#endif
1876 2151
1877 /* FROM->string non-null means it's alive. Copy its data. */ 2152 /* FROM->string non-null means it's alive. Copy its data. */
1878 if (from->string) 2153 if (from->string)
1879 { 2154 {
1880 /* If TB is full, proceed with the next sblock. */ 2155 /* If TB is full, proceed with the next sblock. */
1881 to_end = (struct sdata *) ((char *) to + nbytes); 2156 to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
1882 if (to_end > tb_end) 2157 if (to_end > tb_end)
1883 { 2158 {
1884 tb->next_free = to; 2159 tb->next_free = to;
1885 tb = tb->next; 2160 tb = tb->next;
1886 tb_end = (struct sdata *) ((char *) tb + SBLOCK_SIZE); 2161 tb_end = (struct sdata *) ((char *) tb + SBLOCK_SIZE);
1887 to = &tb->first_data; 2162 to = &tb->first_data;
1888 to_end = (struct sdata *) ((char *) to + nbytes); 2163 to_end = (struct sdata *) ((char *) to + nbytes + GC_STRING_EXTRA);
1889 } 2164 }
1890 2165
1891 /* Copy, and update the string's `data' pointer. */ 2166 /* Copy, and update the string's `data' pointer. */
1892 if (from != to) 2167 if (from != to)
1893 { 2168 {
1894 xassert (tb != b || to <= from); 2169 xassert (tb != b || to <= from);
1895 safe_bcopy ((char *) from, (char *) to, nbytes); 2170 safe_bcopy ((char *) from, (char *) to, nbytes + GC_STRING_EXTRA);
1896 to->string->data = SDATA_DATA (to); 2171 to->string->data = SDATA_DATA (to);
1897 } 2172 }
1898 2173
@@ -2402,9 +2677,9 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
2402void 2677void
2403check_cons_list () 2678check_cons_list ()
2404{ 2679{
2680#ifdef GC_CHECK_CONS_LIST
2405 struct Lisp_Cons *tail = cons_free_list; 2681 struct Lisp_Cons *tail = cons_free_list;
2406 2682
2407#if 0
2408 while (tail) 2683 while (tail)
2409 tail = *(struct Lisp_Cons **)&tail->cdr; 2684 tail = *(struct Lisp_Cons **)&tail->cdr;
2410#endif 2685#endif
@@ -4056,6 +4331,11 @@ mark_stack ()
4056#endif 4331#endif
4057 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT) 4332 for (i = 0; i < sizeof (Lisp_Object); i += GC_LISP_OBJECT_ALIGNMENT)
4058 mark_memory ((char *) stack_base + i, end); 4333 mark_memory ((char *) stack_base + i, end);
4334 /* Allow for marking a secondary stack, like the register stack on the
4335 ia64. */
4336#ifdef GC_MARK_SECONDARY_STACK
4337 GC_MARK_SECONDARY_STACK ();
4338#endif
4059 4339
4060#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS 4340#if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS
4061 check_gcpros (); 4341 check_gcpros ();
diff --git a/src/buffer.c b/src/buffer.c
index b3dd6149487..15dbd2df34f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5178,7 +5178,13 @@ init_buffer ()
5178 } 5178 }
5179#endif /* not VMS */ 5179#endif /* not VMS */
5180 5180
5181 current_buffer->directory = build_string (buf); 5181 current_buffer->directory = make_unibyte_string (buf, strlen (buf));
5182 if (! NILP (buffer_defaults.enable_multibyte_characters))
5183 /* At this momemnt, we still don't know how to decode the
5184 direcotry name. So, we keep the bytes in multibyte form so
5185 that ENCODE_FILE correctly gets the original bytes. */
5186 current_buffer->directory
5187 = string_to_multibyte (current_buffer->directory);
5182 5188
5183 /* Add /: to the front of the name 5189 /* Add /: to the front of the name
5184 if it would otherwise be treated as magic. */ 5190 if it would otherwise be treated as magic. */
@@ -5700,10 +5706,13 @@ scrolled, the top and bottom line of the window are marked with up and down
5700arrow bitmaps. 5706arrow bitmaps.
5701 5707
5702If value is a symbol `left' or `right', both angle and arrow bitmaps 5708If value is a symbol `left' or `right', both angle and arrow bitmaps
5703are displayed in the left or right fringe, resp. 5709are displayed in the left or right fringe, resp. Any other value
5710that doesn't look like an alist means displat the angle bitmaps in
5711the left fringe but no arrows.
5704 5712
5705If value is an alist, each element (INDICATOR . POSITION) specifies 5713You can exercise more precise control by using an alist as the
5706the position of one of the indicators. INDICATOR is one of `top', 5714value. Each alist element (INDICATOR . POSITION) specifies
5715where to show one of the indicators. INDICATOR is one of `top',
5707`bottom', `up', `down', or t, which specifies the default position, 5716`bottom', `up', `down', or t, which specifies the default position,
5708and POSITION is one of `left', `right', or nil, meaning do not show 5717and POSITION is one of `left', `right', or nil, meaning do not show
5709this indicator. 5718this indicator.
diff --git a/src/callint.c b/src/callint.c
index bb71ad50f44..933601f67d0 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -723,7 +723,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
723 723
724 tem = Fread_from_minibuffer (build_string (callint_message), 724 tem = Fread_from_minibuffer (build_string (callint_message),
725 Qnil, Qnil, Qnil, Qnil, Qnil, 725 Qnil, Qnil, Qnil, Qnil, Qnil,
726 Qnil); 726 Qnil, Qnil);
727 if (! STRINGP (tem) || SCHARS (tem) == 0) 727 if (! STRINGP (tem) || SCHARS (tem) == 0)
728 args[i] = Qnil; 728 args[i] = Qnil;
729 else 729 else
diff --git a/src/coding.c b/src/coding.c
index 8ca1d19c4c3..de65884254f 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6578,6 +6578,37 @@ code_conversion_restore (arg)
6578 return Qnil; 6578 return Qnil;
6579} 6579}
6580 6580
6581/* Name (or base name) of work buffer for code conversion. */
6582static Lisp_Object Vcode_conversion_workbuf_name;
6583
6584/* Set the current buffer to the working buffer prepared for
6585 code-conversion. MULTIBYTE specifies the multibyteness of the
6586 buffer. */
6587
6588static struct buffer *
6589set_conversion_work_buffer (multibyte)
6590 int multibyte;
6591{
6592 Lisp_Object buffer;
6593 struct buffer *buf;
6594
6595 buffer = Fget_buffer_create (Vcode_conversion_workbuf_name);
6596 buf = XBUFFER (buffer);
6597 delete_all_overlays (buf);
6598 buf->directory = current_buffer->directory;
6599 buf->read_only = Qnil;
6600 buf->filename = Qnil;
6601 buf->undo_list = Qt;
6602 eassert (buf->overlays_before == NULL);
6603 eassert (buf->overlays_after == NULL);
6604 set_buffer_internal (buf);
6605 if (BEG != BEGV || Z != ZV)
6606 Fwiden ();
6607 del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0);
6608 buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
6609 return buf;
6610}
6611
6581Lisp_Object 6612Lisp_Object
6582code_conversion_save (with_work_buf, multibyte) 6613code_conversion_save (with_work_buf, multibyte)
6583 int with_work_buf, multibyte; 6614 int with_work_buf, multibyte;
@@ -6995,6 +7026,64 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
6995} 7026}
6996 7027
6997 7028
7029
7030/* Run pre-write-conversion function of CODING on NCHARS/NBYTES
7031 text in *STR. *SIZE is the allocated bytes for STR. As it
7032 is intended that this function is called from encode_terminal_code,
7033 the pre-write-conversion function is run by safe_call and thus
7034 "Error during redisplay: ..." is logged when an error occurs.
7035
7036 Store the resulting text in *STR and set CODING->produced_char and
7037 CODING->produced to the number of characters and bytes
7038 respectively. If the size of *STR is too small, enlarge it by
7039 xrealloc and update *STR and *SIZE. */
7040
7041void
7042run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
7043 unsigned char **str;
7044 int *size, nchars, nbytes;
7045 struct coding_system *coding;
7046{
7047 struct gcpro gcpro1, gcpro2;
7048 struct buffer *cur = current_buffer;
7049 Lisp_Object old_deactivate_mark, old_last_coding_system_used;
7050 Lisp_Object args[3];
7051
7052 /* It is not crucial to specbind this. */
7053 old_deactivate_mark = Vdeactivate_mark;
7054 old_last_coding_system_used = Vlast_coding_system_used;
7055 GCPRO2 (old_deactivate_mark, old_last_coding_system_used);
7056
7057 /* We must insert the contents of STR as is without
7058 unibyte<->multibyte conversion. For that, we adjust the
7059 multibyteness of the working buffer to that of STR. */
7060 set_conversion_work_buffer (coding->src_multibyte);
7061 insert_1_both (*str, nchars, nbytes, 0, 0, 0);
7062 UNGCPRO;
7063 inhibit_pre_post_conversion = 1;
7064 args[0] = coding->pre_write_conversion;
7065 args[1] = make_number (BEG);
7066 args[2] = make_number (Z);
7067 safe_call (3, args);
7068 inhibit_pre_post_conversion = 0;
7069 Vdeactivate_mark = old_deactivate_mark;
7070 Vlast_coding_system_used = old_last_coding_system_used;
7071 coding->produced_char = Z - BEG;
7072 coding->produced = Z_BYTE - BEG_BYTE;
7073 if (coding->produced > *size)
7074 {
7075 *size = coding->produced;
7076 *str = xrealloc (*str, *size);
7077 }
7078 if (BEG < GPT && GPT < Z)
7079 move_gap (BEG);
7080 bcopy (BEG_ADDR, *str, coding->produced);
7081 coding->src_multibyte
7082 = ! NILP (current_buffer->enable_multibyte_characters);
7083 set_buffer_internal (cur);
7084}
7085
7086
6998Lisp_Object 7087Lisp_Object
6999preferred_coding_system () 7088preferred_coding_system ()
7000{ 7089{
diff --git a/src/coding.h b/src/coding.h
index d970c1ea257..39bd62867af 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -1,4 +1,5 @@
1/* Header for coding system handler. 1/* Header for coding system handler.
2 Copyright (C) 2004 Free Software Foundation, Inc.
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN. 3 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation. 4 Licensed to the Free Software Foundation.
4 Copyright (C) 2003 5 Copyright (C) 2003
@@ -579,10 +580,10 @@ struct coding_system
579 for file names, if any. */ 580 for file names, if any. */
580#define ENCODE_FILE(name) \ 581#define ENCODE_FILE(name) \
581 (! NILP (Vfile_name_coding_system) \ 582 (! NILP (Vfile_name_coding_system) \
582 && XFASTINT (Vfile_name_coding_system) != 0 \ 583 && !EQ (Vfile_name_coding_system, make_number (0)) \
583 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ 584 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
584 : (! NILP (Vdefault_file_name_coding_system) \ 585 : (! NILP (Vdefault_file_name_coding_system) \
585 && XFASTINT (Vdefault_file_name_coding_system) != 0 \ 586 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
586 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ 587 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
587 : name)) 588 : name))
588 589
@@ -591,10 +592,10 @@ struct coding_system
591 for file names, if any. */ 592 for file names, if any. */
592#define DECODE_FILE(name) \ 593#define DECODE_FILE(name) \
593 (! NILP (Vfile_name_coding_system) \ 594 (! NILP (Vfile_name_coding_system) \
594 && XFASTINT (Vfile_name_coding_system) != 0 \ 595 && !EQ (Vfile_name_coding_system, make_number (0)) \
595 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ 596 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \
596 : (! NILP (Vdefault_file_name_coding_system) \ 597 : (! NILP (Vdefault_file_name_coding_system) \
597 && XFASTINT (Vdefault_file_name_coding_system) != 0 \ 598 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
598 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ 599 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
599 : name)) 600 : name))
600 601
@@ -602,18 +603,18 @@ struct coding_system
602#ifdef WINDOWSNT 603#ifdef WINDOWSNT
603/* Encode the string STR using the specified coding system 604/* Encode the string STR using the specified coding system
604 for w32 system functions, if any. */ 605 for w32 system functions, if any. */
605#define ENCODE_SYSTEM(str) \ 606#define ENCODE_SYSTEM(str) \
606 (! NILP (Vlocale_coding_system) \ 607 (! NILP (Vlocale_coding_system) \
607 && XFASTINT (Vlocale_coding_system) != 0 \ 608 && !EQ (Vlocale_coding_system, make_number (0)) \
608 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ 609 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \
609 : str) 610 : str)
610 611
611/* Decode the string STR using the specified coding system 612/* Decode the string STR using the specified coding system
612 for w32 system functions, if any. */ 613 for w32 system functions, if any. */
613#define DECODE_SYSTEM(name) \ 614#define DECODE_SYSTEM(name) \
614 (! NILP (Vlocale_coding_system) \ 615 (! NILP (Vlocale_coding_system) \
615 && XFASTINT (Vlocale_coding_system) != 0 \ 616 && !EQ (Vlocale_coding_system, make_number (0)) \
616 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ 617 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \
617 : str) 618 : str)
618 619
619#else /* WINDOWSNT */ 620#else /* WINDOWSNT */
diff --git a/src/config.in b/src/config.in
index fe1adc39f9d..87e37e65ef2 100644
--- a/src/config.in
+++ b/src/config.in
@@ -1,7 +1,8 @@
1/* src/config.in. Generated from configure.in by autoheader. */ 1/* src/config.in. Generated from configure.in by autoheader. */
2 2
3/* GNU Emacs site configuration template file. 3/* GNU Emacs site configuration template file.
4 Copyright (C) 1988, 93, 94, 99, 2000, 2002 Free Software Foundation, Inc. 4 Copyright (C) 1988, 1993, 1994, 1999, 2000, 2002, 2004
5 Free Software Foundation, Inc.
5 6
6This file is part of GNU Emacs. 7This file is part of GNU Emacs.
7 8
@@ -220,6 +221,9 @@ Boston, MA 02111-1307, USA. */
220/* Define to 1 if using GTK. */ 221/* Define to 1 if using GTK. */
221#undef HAVE_GTK 222#undef HAVE_GTK
222 223
224/* Define to 1 if you have GTK and pthread (-lpthread). */
225#undef HAVE_GTK_AND_PTHREAD
226
223/* Define to 1 if GTK has both file selection and chooser dialog. */ 227/* Define to 1 if GTK has both file selection and chooser dialog. */
224#undef HAVE_GTK_FILE_BOTH 228#undef HAVE_GTK_FILE_BOTH
225 229
@@ -441,6 +445,9 @@ Boston, MA 02111-1307, USA. */
441/* Define to 1 if you have the `pstat_getdynamic' function. */ 445/* Define to 1 if you have the `pstat_getdynamic' function. */
442#undef HAVE_PSTAT_GETDYNAMIC 446#undef HAVE_PSTAT_GETDYNAMIC
443 447
448/* Define to 1 if you have the <pthread.h> header file. */
449#undef HAVE_PTHREAD_H
450
444/* Define to 1 if you have the <pty.h> header file. */ 451/* Define to 1 if you have the <pty.h> header file. */
445#undef HAVE_PTY_H 452#undef HAVE_PTY_H
446 453
@@ -769,9 +776,9 @@ Boston, MA 02111-1307, USA. */
769/* If using the C implementation of alloca, define if you know the 776/* If using the C implementation of alloca, define if you know the
770 direction of stack growth for your system; otherwise it will be 777 direction of stack growth for your system; otherwise it will be
771 automatically deduced at run-time. 778 automatically deduced at run-time.
772 STACK_DIRECTION > 0 => grows toward higher addresses 779 STACK_DIRECTION > 0 => grows toward higher addresses
773 STACK_DIRECTION < 0 => grows toward lower addresses 780 STACK_DIRECTION < 0 => grows toward lower addresses
774 STACK_DIRECTION = 0 => direction of growth unknown */ 781 STACK_DIRECTION = 0 => direction of growth unknown */
775#undef STACK_DIRECTION 782#undef STACK_DIRECTION
776 783
777/* Define to 1 if you have the ANSI C header files. */ 784/* Define to 1 if you have the ANSI C header files. */
@@ -920,7 +927,7 @@ Boston, MA 02111-1307, USA. */
920/* Don't try to switch on inline handling as detected by AC_C_INLINE 927/* Don't try to switch on inline handling as detected by AC_C_INLINE
921 generally, because even if non-gcc compilers accept `inline', they 928 generally, because even if non-gcc compilers accept `inline', they
922 may reject `extern inline'. */ 929 may reject `extern inline'. */
923#ifdef __GNUC__ 930#if defined (__GNUC__) && defined (OPTIMIZE)
924#define INLINE __inline__ 931#define INLINE __inline__
925#else 932#else
926#define INLINE 933#define INLINE
@@ -968,7 +975,13 @@ Boston, MA 02111-1307, USA. */
968/* Tell regex.c to use a type compatible with Emacs. */ 975/* Tell regex.c to use a type compatible with Emacs. */
969#define RE_TRANSLATE_TYPE Lisp_Object 976#define RE_TRANSLATE_TYPE Lisp_Object
970#define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C) 977#define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C)
971#define RE_TRANSLATE_P(TBL) (XFASTINT (TBL) != 0) 978#ifdef make_number
979/* If make_number is a macro, use it. */
980#define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
981#else
982/* If make_number is a function, avoid it. */
983#define RE_TRANSLATE_P(TBL) (!(INTEGERP (TBL) && XINT (TBL) == 0))
984#endif
972#endif 985#endif
973 986
974/* Avoid link-time collision with system mktime if we will use our own. */ 987/* Avoid link-time collision with system mktime if we will use our own. */
diff --git a/src/data.c b/src/data.c
index 7f68cc864df..0439d5763bc 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1509,6 +1509,9 @@ Note that binding the variable with `let', or setting it while
1509a `let'-style binding made in this buffer is in effect, 1509a `let'-style binding made in this buffer is in effect,
1510does not make the variable buffer-local. Return VARIABLE. 1510does not make the variable buffer-local. Return VARIABLE.
1511 1511
1512In most cases it is better to use `make-local-variable',
1513which makes a variable local in just one buffer.
1514
1512The function `default-value' gets the default value and `set-default' sets it. */) 1515The function `default-value' gets the default value and `set-default' sets it. */)
1513 (variable) 1516 (variable)
1514 register Lisp_Object variable; 1517 register Lisp_Object variable;
@@ -1552,7 +1555,7 @@ DEFUN ("make-local-variable", Fmake_local_variable, Smake_local_variable,
1552Other buffers will continue to share a common default value. 1555Other buffers will continue to share a common default value.
1553\(The buffer-local value of VARIABLE starts out as the same value 1556\(The buffer-local value of VARIABLE starts out as the same value
1554VARIABLE previously had. If VARIABLE was void, it remains void.\) 1557VARIABLE previously had. If VARIABLE was void, it remains void.\)
1555See also `make-variable-buffer-local'. Return VARIABLE. 1558Return VARIABLE.
1556 1559
1557If the variable is already arranged to become local when set, 1560If the variable is already arranged to become local when set,
1558this function causes a local value to exist for this buffer, 1561this function causes a local value to exist for this buffer,
@@ -1562,6 +1565,8 @@ This function returns VARIABLE, and therefore
1562 (set (make-local-variable 'VARIABLE) VALUE-EXP) 1565 (set (make-local-variable 'VARIABLE) VALUE-EXP)
1563works. 1566works.
1564 1567
1568See also `make-variable-buffer-local'.
1569
1565Do not use `make-local-variable' to make a hook variable buffer-local. 1570Do not use `make-local-variable' to make a hook variable buffer-local.
1566Instead, use `add-hook' and specify t for the LOCAL argument. */) 1571Instead, use `add-hook' and specify t for the LOCAL argument. */)
1567 (variable) 1572 (variable)
diff --git a/src/dispextern.h b/src/dispextern.h
index 463e719d1bc..f88db043b27 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -974,7 +974,7 @@ struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int));
974 or a control char, or an overlay string. */ 974 or a control char, or an overlay string. */
975 975
976#define MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P(ROW) \ 976#define MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P(ROW) \
977 ((ROW)->end.dpvec_index >= 0 \ 977 ((ROW)->end.dpvec_index > 0 \
978 || (ROW)->end.overlay_string_index >= 0 \ 978 || (ROW)->end.overlay_string_index >= 0 \
979 || (ROW)->ends_in_middle_of_char_p) 979 || (ROW)->ends_in_middle_of_char_p)
980 980
@@ -986,7 +986,7 @@ struct glyph_row *matrix_row P_ ((struct glyph_matrix *, int));
986/* Non-zero if ROW starts in the middle of a character. See above. */ 986/* Non-zero if ROW starts in the middle of a character. See above. */
987 987
988#define MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P(ROW) \ 988#define MATRIX_ROW_STARTS_IN_MIDDLE_OF_CHAR_P(ROW) \
989 ((ROW)->start.dpvec_index >= 0 \ 989 ((ROW)->start.dpvec_index > 0 \
990 || (ROW)->starts_in_middle_of_char_p \ 990 || (ROW)->starts_in_middle_of_char_p \
991 || ((ROW)->start.overlay_string_index >= 0 \ 991 || ((ROW)->start.overlay_string_index >= 0 \
992 && (ROW)->start.string_pos.charpos > 0)) 992 && (ROW)->start.string_pos.charpos > 0))
@@ -2737,7 +2737,7 @@ void prepare_face_for_display P_ ((struct frame *, struct face *));
2737int xstricmp P_ ((const unsigned char *, const unsigned char *)); 2737int xstricmp P_ ((const unsigned char *, const unsigned char *));
2738int lookup_face P_ ((struct frame *, Lisp_Object *)); 2738int lookup_face P_ ((struct frame *, Lisp_Object *));
2739int lookup_non_ascii_face P_ ((struct frame *, int, struct face *)); 2739int lookup_non_ascii_face P_ ((struct frame *, int, struct face *));
2740int lookup_named_face P_ ((struct frame *, Lisp_Object)); 2740int lookup_named_face P_ ((struct frame *, Lisp_Object, int));
2741int smaller_face P_ ((struct frame *, int, int)); 2741int smaller_face P_ ((struct frame *, int, int));
2742int face_with_height P_ ((struct frame *, int, int)); 2742int face_with_height P_ ((struct frame *, int, int));
2743int lookup_derived_face P_ ((struct frame *, Lisp_Object, int)); 2743int lookup_derived_face P_ ((struct frame *, Lisp_Object, int));
diff --git a/src/emacs.c b/src/emacs.c
index 16ae1129840..03f20b9e97b 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -580,8 +580,12 @@ init_cmdargs (argc, argv, skip_args)
580 for (i = argc - 1; i >= 0; i--) 580 for (i = argc - 1; i >= 0; i--)
581 { 581 {
582 if (i == 0 || i > skip_args) 582 if (i == 0 || i > skip_args)
583 /* For the moment, we keep arguments as is in unibyte strings.
584 They are decoded in the function command-line after we know
585 locale-coding-system. */
583 Vcommand_line_args 586 Vcommand_line_args
584 = Fcons (build_string (argv[i]), Vcommand_line_args); 587 = Fcons (make_unibyte_string (argv[i], strlen (argv[i])),
588 Vcommand_line_args);
585 } 589 }
586 590
587 unbind_to (count, Qnil); 591 unbind_to (count, Qnil);
@@ -744,7 +748,9 @@ malloc_initialize_hook ()
744 } 748 }
745 749
746 malloc_set_state (malloc_state_ptr); 750 malloc_set_state (malloc_state_ptr);
751#ifndef XMALLOC_OVERRUN_CHECK
747 free (malloc_state_ptr); 752 free (malloc_state_ptr);
753#endif
748 } 754 }
749 else 755 else
750 { 756 {
@@ -1988,9 +1994,9 @@ sort_args (argc, argv)
1988 1994
1989 bcopy (new, argv, sizeof (char *) * argc); 1995 bcopy (new, argv, sizeof (char *) * argc);
1990 1996
1991 free (options); 1997 xfree (options);
1992 free (new); 1998 xfree (new);
1993 free (priority); 1999 xfree (priority);
1994} 2000}
1995 2001
1996DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", 2002DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
@@ -2240,6 +2246,12 @@ You must run Emacs in batch mode in order to dump it. */)
2240 memory_warnings (my_edata, malloc_warning); 2246 memory_warnings (my_edata, malloc_warning);
2241#endif /* not WINDOWSNT */ 2247#endif /* not WINDOWSNT */
2242#endif 2248#endif
2249#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD)
2250 /* Pthread may call malloc before main, and then we will get an endless
2251 loop, because pthread_self (see alloc.c) calls malloc the first time
2252 it is called on some systems. */
2253 reset_malloc_hooks ();
2254#endif
2243#ifdef DOUG_LEA_MALLOC 2255#ifdef DOUG_LEA_MALLOC
2244 malloc_state_ptr = malloc_get_state (); 2256 malloc_state_ptr = malloc_get_state ();
2245#endif 2257#endif
diff --git a/src/eval.c b/src/eval.c
index d1d5d195762..0eb519fbfca 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -204,7 +204,7 @@ init_eval_once ()
204 specpdl_size = 50; 204 specpdl_size = 50;
205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); 205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding));
206 specpdl_ptr = specpdl; 206 specpdl_ptr = specpdl;
207 max_specpdl_size = 600; 207 max_specpdl_size = 1000;
208 max_lisp_eval_depth = 300; 208 max_lisp_eval_depth = 300;
209 209
210 Vrun_hooks = Qnil; 210 Vrun_hooks = Qnil;
@@ -573,7 +573,7 @@ optional argument, and making the `interactive' spec specify non-nil
573unconditionally for that argument. (`p' is a good way to do this.) */) 573unconditionally for that argument. (`p' is a good way to do this.) */)
574 () 574 ()
575{ 575{
576 return (INTERACTIVE && interactive_p (1)) ? Qt : Qnil; 576 return interactive_p (1) ? Qt : Qnil;
577} 577}
578 578
579 579
@@ -595,7 +595,8 @@ interactive_p (exclude_subrs_p)
595 /* If this isn't a byte-compiled function, there may be a frame at 595 /* If this isn't a byte-compiled function, there may be a frame at
596 the top for Finteractive_p. If so, skip it. */ 596 the top for Finteractive_p. If so, skip it. */
597 fun = Findirect_function (*btp->function); 597 fun = Findirect_function (*btp->function);
598 if (SUBRP (fun) && XSUBR (fun) == &Sinteractive_p) 598 if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p
599 || XSUBR (fun) == &Scalled_interactively_p))
599 btp = btp->next; 600 btp = btp->next;
600 601
601 /* If we're running an Emacs 18-style byte-compiled function, there 602 /* If we're running an Emacs 18-style byte-compiled function, there
@@ -786,6 +787,21 @@ usage: (defvar SYMBOL &optional INITVALUE DOCSTRING) */)
786 { 787 {
787 if (NILP (tem)) 788 if (NILP (tem))
788 Fset_default (sym, Feval (Fcar (tail))); 789 Fset_default (sym, Feval (Fcar (tail)));
790 else
791 { /* Check if there is really a global binding rather than just a let
792 binding that shadows the global unboundness of the var. */
793 volatile struct specbinding *pdl = specpdl_ptr;
794 while (--pdl >= specpdl)
795 {
796 if (EQ (pdl->symbol, sym) && !pdl->func
797 && EQ (pdl->old_value, Qunbound))
798 {
799 message_with_string ("Warning: defvar ignored because %s is let-bound",
800 SYMBOL_NAME (sym), 1);
801 break;
802 }
803 }
804 }
789 tail = Fcdr (tail); 805 tail = Fcdr (tail);
790 tem = Fcar (tail); 806 tem = Fcar (tail);
791 if (!NILP (tem)) 807 if (!NILP (tem))
@@ -1158,9 +1174,10 @@ unwind_to_catch (catch, value)
1158 /* Save the value in the tag. */ 1174 /* Save the value in the tag. */
1159 catch->val = value; 1175 catch->val = value;
1160 1176
1161 /* Restore the polling-suppression count. */ 1177 /* Restore certain special C variables. */
1162 set_poll_suppress_count (catch->poll_suppress_count); 1178 set_poll_suppress_count (catch->poll_suppress_count);
1163 interrupt_input_blocked = catch->interrupt_input_blocked; 1179 interrupt_input_blocked = catch->interrupt_input_blocked;
1180 handling_signal = 0;
1164 1181
1165 do 1182 do
1166 { 1183 {
diff --git a/src/filelock.c b/src/filelock.c
index b802d0e2a51..fc214b5a34a 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -377,6 +377,9 @@ lock_file_1 (lfname, force)
377 char *host_name; 377 char *host_name;
378 char *lock_info_str; 378 char *lock_info_str;
379 379
380 /* Call this first because it can GC. */
381 boot_time = get_boot_time ();
382
380 if (STRINGP (Fuser_login_name (Qnil))) 383 if (STRINGP (Fuser_login_name (Qnil)))
381 user_name = (char *)SDATA (Fuser_login_name (Qnil)); 384 user_name = (char *)SDATA (Fuser_login_name (Qnil));
382 else 385 else
@@ -386,9 +389,8 @@ lock_file_1 (lfname, force)
386 else 389 else
387 host_name = ""; 390 host_name = "";
388 lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name) 391 lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
389 + LOCK_PID_MAX + 5); 392 + LOCK_PID_MAX + 30);
390 393
391 boot_time = get_boot_time ();
392 if (boot_time) 394 if (boot_time)
393 sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name, 395 sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
394 (unsigned long) getpid (), (unsigned long) boot_time); 396 (unsigned long) getpid (), (unsigned long) boot_time);
diff --git a/src/fns.c b/src/fns.c
index 8d63b731fcf..f7a6246d15d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -522,6 +522,7 @@ concat (nargs, args, target_type, last_special)
522 struct textprop_rec *textprops = NULL; 522 struct textprop_rec *textprops = NULL;
523 /* Number of elments in textprops. */ 523 /* Number of elments in textprops. */
524 int num_textprops = 0; 524 int num_textprops = 0;
525 USE_SAFE_ALLOCA;
525 526
526 tail = Qnil; 527 tail = Qnil;
527 528
@@ -630,8 +631,7 @@ concat (nargs, args, target_type, last_special)
630 631
631 prev = Qnil; 632 prev = Qnil;
632 if (STRINGP (val)) 633 if (STRINGP (val))
633 textprops 634 SAFE_ALLOCA (textprops, struct textprop_rec *, sizeof (struct textprop_rec) * nargs);
634 = (struct textprop_rec *) alloca (sizeof (struct textprop_rec) * nargs);
635 635
636 for (argnum = 0; argnum < nargs; argnum++) 636 for (argnum = 0; argnum < nargs; argnum++)
637 { 637 {
@@ -769,6 +769,8 @@ concat (nargs, args, target_type, last_special)
769 last_to_end = textprops[argnum].to + SCHARS (this); 769 last_to_end = textprops[argnum].to + SCHARS (this);
770 } 770 }
771 } 771 }
772
773 SAFE_FREE ();
772 return val; 774 return val;
773} 775}
774 776
@@ -2767,7 +2769,7 @@ is nil, and `use-dialog-box' is non-nil. */)
2767 { 2769 {
2768 ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil, 2770 ans = Fdowncase (Fread_from_minibuffer (prompt, Qnil, Qnil, Qnil,
2769 Qyes_or_no_p_history, Qnil, 2771 Qyes_or_no_p_history, Qnil,
2770 Qnil)); 2772 Qnil, Qnil));
2771 if (SCHARS (ans) == 3 && !strcmp (SDATA (ans), "yes")) 2773 if (SCHARS (ans) == 3 && !strcmp (SDATA (ans), "yes"))
2772 { 2774 {
2773 UNGCPRO; 2775 UNGCPRO;
diff --git a/src/fringe.c b/src/fringe.c
index 591d6acb290..52273af13ef 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -809,12 +809,13 @@ update_window_fringes (w, force_p)
809 arrow_bot = XCDR (pos); 809 arrow_bot = XCDR (pos);
810 } 810 }
811 else 811 else
812 ind = Qnil; 812 /* Anything else means boundary on left and no arrows. */
813 boundary_top = boundary_bot = Qleft;
813 } 814 }
814 815
815 if (!NILP (ind)) 816 if (!NILP (ind))
816 { 817 {
817 int do_eob = 1, do_bob = 1; 818 int done_top = 0, done_bot = 0;
818 819
819 for (y = 0, rn = 0; 820 for (y = 0, rn = 0;
820 y < yb && rn < nrows; 821 y < yb && rn < nrows;
@@ -835,19 +836,25 @@ update_window_fringes (w, force_p)
835 row->indicate_bob_p = row->indicate_top_line_p = 0; 836 row->indicate_bob_p = row->indicate_top_line_p = 0;
836 row->indicate_eob_p = row->indicate_bottom_line_p = 0; 837 row->indicate_eob_p = row->indicate_bottom_line_p = 0;
837 838
838 if (!NILP (boundary_top) 839 if (!row->mode_line_p)
839 && MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer))) 840 {
840 row->indicate_bob_p = do_bob, do_bob = 0; 841 if (!done_top)
841 else if (!NILP (arrow_top) 842 {
842 && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn) 843 if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)))
843 row->indicate_top_line_p = 1; 844 row->indicate_bob_p = !NILP (boundary_top);
845 else
846 row->indicate_top_line_p = !NILP (arrow_top);
847 done_top = 1;
848 }
844 849
845 if (!NILP (boundary_bot) 850 if (!done_bot)
846 && MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer))) 851 {
847 row->indicate_eob_p = do_eob, do_eob = 0; 852 if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)))
848 else if (!NILP (arrow_bot) 853 row->indicate_eob_p = !NILP (boundary_bot), done_bot = 1;
849 && y + row->height >= yb) 854 else if (y + row->height >= yb)
850 row->indicate_bottom_line_p = 1; 855 row->indicate_bottom_line_p = !NILP (arrow_bot), done_bot = 1;
856 }
857 }
851 858
852 if (indicate_bob_p != row->indicate_bob_p 859 if (indicate_bob_p != row->indicate_bob_p
853 || indicate_top_line_p != row->indicate_top_line_p 860 || indicate_top_line_p != row->indicate_top_line_p
@@ -883,13 +890,13 @@ update_window_fringes (w, force_p)
883 left = row->left_user_fringe_bitmap; 890 left = row->left_user_fringe_bitmap;
884 left_face_id = row->left_user_fringe_face_id; 891 left_face_id = row->left_user_fringe_face_id;
885 } 892 }
893 else if (row->truncated_on_left_p)
894 left = LEFT_TRUNCATION_BITMAP;
886 else if (row->indicate_bob_p && EQ (boundary_top, Qleft)) 895 else if (row->indicate_bob_p && EQ (boundary_top, Qleft))
887 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft)) 896 left = ((row->indicate_eob_p && EQ (boundary_bot, Qleft))
888 ? LEFT_BRACKET_BITMAP : TOP_LEFT_ANGLE_BITMAP); 897 ? LEFT_BRACKET_BITMAP : TOP_LEFT_ANGLE_BITMAP);
889 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft)) 898 else if (row->indicate_eob_p && EQ (boundary_bot, Qleft))
890 left = BOTTOM_LEFT_ANGLE_BITMAP; 899 left = BOTTOM_LEFT_ANGLE_BITMAP;
891 else if (row->truncated_on_left_p)
892 left = LEFT_TRUNCATION_BITMAP;
893 else if (MATRIX_ROW_CONTINUATION_LINE_P (row)) 900 else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
894 left = CONTINUATION_LINE_BITMAP; 901 left = CONTINUATION_LINE_BITMAP;
895 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft)) 902 else if (row->indicate_empty_line_p && EQ (empty_pos, Qleft))
@@ -909,13 +916,13 @@ update_window_fringes (w, force_p)
909 right = row->right_user_fringe_bitmap; 916 right = row->right_user_fringe_bitmap;
910 right_face_id = row->right_user_fringe_face_id; 917 right_face_id = row->right_user_fringe_face_id;
911 } 918 }
919 else if (row->truncated_on_right_p)
920 right = RIGHT_TRUNCATION_BITMAP;
912 else if (row->indicate_bob_p && EQ (boundary_top, Qright)) 921 else if (row->indicate_bob_p && EQ (boundary_top, Qright))
913 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright)) 922 right = ((row->indicate_eob_p && EQ (boundary_bot, Qright))
914 ? RIGHT_BRACKET_BITMAP : TOP_RIGHT_ANGLE_BITMAP); 923 ? RIGHT_BRACKET_BITMAP : TOP_RIGHT_ANGLE_BITMAP);
915 else if (row->indicate_eob_p && EQ (boundary_bot, Qright)) 924 else if (row->indicate_eob_p && EQ (boundary_bot, Qright))
916 right = BOTTOM_RIGHT_ANGLE_BITMAP; 925 right = BOTTOM_RIGHT_ANGLE_BITMAP;
917 else if (row->truncated_on_right_p)
918 right = RIGHT_TRUNCATION_BITMAP;
919 else if (row->continued_p) 926 else if (row->continued_p)
920 right = CONTINUED_LINE_BITMAP; 927 right = CONTINUED_LINE_BITMAP;
921 else if (row->indicate_top_line_p && EQ (arrow_top, Qright)) 928 else if (row->indicate_top_line_p && EQ (arrow_top, Qright))
@@ -1346,7 +1353,7 @@ If FACE is nil, reset face to default fringe face. */)
1346 1353
1347 if (!NILP (face)) 1354 if (!NILP (face))
1348 { 1355 {
1349 face_id = lookup_named_face (SELECTED_FRAME (), face); 1356 face_id = lookup_named_face (SELECTED_FRAME (), face, 1);
1350 if (face_id < 0) 1357 if (face_id < 0)
1351 error ("No such face"); 1358 error ("No such face");
1352 } 1359 }
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 25dd88d544e..317f7824267 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -23,10 +23,12 @@ Boston, MA 02111-1307, USA. */
23 23
24#ifdef USE_GTK 24#ifdef USE_GTK
25#include <string.h> 25#include <string.h>
26#include <signal.h>
26#include <stdio.h> 27#include <stdio.h>
27#include "lisp.h" 28#include "lisp.h"
28#include "xterm.h" 29#include "xterm.h"
29#include "blockinput.h" 30#include "blockinput.h"
31#include "syssignal.h"
30#include "window.h" 32#include "window.h"
31#include "atimer.h" 33#include "atimer.h"
32#include "gtkutil.h" 34#include "gtkutil.h"
@@ -1122,10 +1124,6 @@ create_dialog (wv, select_cb, deactivate_cb)
1122/*********************************************************************** 1124/***********************************************************************
1123 File dialog functions 1125 File dialog functions
1124 ***********************************************************************/ 1126 ***********************************************************************/
1125#ifdef HAVE_GTK_FILE_BOTH
1126int use_old_gtk_file_dialog;
1127#endif
1128
1129/* Function that is called when the file dialog pops down. 1127/* Function that is called when the file dialog pops down.
1130 W is the dialog widget, RESPONSE is the response code. 1128 W is the dialog widget, RESPONSE is the response code.
1131 USER_DATA is what we passed in to g_signal_connect (pointer to int). */ 1129 USER_DATA is what we passed in to g_signal_connect (pointer to int). */
@@ -1204,6 +1202,7 @@ xg_get_file_with_chooser (f, prompt, default_filename,
1204 GTK_STOCK_OPEN : GTK_STOCK_OK), 1202 GTK_STOCK_OPEN : GTK_STOCK_OK),
1205 GTK_RESPONSE_OK, 1203 GTK_RESPONSE_OK,
1206 NULL); 1204 NULL);
1205 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (filewin), TRUE);
1207 1206
1208 if (default_filename) 1207 if (default_filename)
1209 { 1208 {
@@ -1211,16 +1210,20 @@ xg_get_file_with_chooser (f, prompt, default_filename,
1211 struct gcpro gcpro1; 1210 struct gcpro gcpro1;
1212 GCPRO1 (file); 1211 GCPRO1 (file);
1213 1212
1213 file = build_string (default_filename);
1214
1214 /* File chooser does not understand ~/... in the file name. It must be 1215 /* File chooser does not understand ~/... in the file name. It must be
1215 an absolute name starting with /. */ 1216 an absolute name starting with /. */
1216 if (default_filename[0] != '/') 1217 if (default_filename[0] != '/')
1217 { 1218 file = Fexpand_file_name (file, Qnil);
1218 file = Fexpand_file_name (build_string (default_filename), Qnil);
1219 default_filename = SDATA (file);
1220 }
1221 1219
1222 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin), 1220 default_filename = SDATA (file);
1223 default_filename); 1221 if (Ffile_directory_p (file))
1222 gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filewin),
1223 default_filename);
1224 else
1225 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filewin),
1226 default_filename);
1224 1227
1225 UNGCPRO; 1228 UNGCPRO;
1226 } 1229 }
@@ -1310,8 +1313,17 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p)
1310 int filesel_done = 0; 1313 int filesel_done = 0;
1311 xg_get_file_func func; 1314 xg_get_file_func func;
1312 1315
1316#if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN)
1317 /* I really don't know why this is needed, but without this the GLIBC add on
1318 library linuxthreads hangs when the Gnome file chooser backend creates
1319 threads. */
1320 sigblock (sigmask (__SIGRTMIN));
1321#endif /* HAVE_GTK_AND_PTHREAD */
1322
1313#ifdef HAVE_GTK_FILE_BOTH 1323#ifdef HAVE_GTK_FILE_BOTH
1314 if (use_old_gtk_file_dialog) 1324 extern int x_use_old_gtk_file_dialog;
1325
1326 if (x_use_old_gtk_file_dialog)
1315 w = xg_get_file_with_selection (f, prompt, default_filename, 1327 w = xg_get_file_with_selection (f, prompt, default_filename,
1316 mustmatch_p, only_dir_p, &func); 1328 mustmatch_p, only_dir_p, &func);
1317 else 1329 else
@@ -1355,6 +1367,10 @@ xg_get_file_name (f, prompt, default_filename, mustmatch_p, only_dir_p)
1355 gtk_main_iteration (); 1367 gtk_main_iteration ();
1356 } 1368 }
1357 1369
1370#if defined (HAVE_GTK_AND_PTHREAD) && defined (__SIGRTMIN)
1371 sigunblock (sigmask (__SIGRTMIN));
1372#endif
1373
1358 if (filesel_done == GTK_RESPONSE_OK) 1374 if (filesel_done == GTK_RESPONSE_OK)
1359 fn = (*func) (w); 1375 fn = (*func) (w);
1360 1376
diff --git a/src/image.c b/src/image.c
index 4ab672ca58e..d1925cf36e4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2416,8 +2416,7 @@ image_load_quartz2d (f, img, png_p)
2416 UNGCPRO; 2416 UNGCPRO;
2417 return 0; 2417 return 0;
2418 } 2418 }
2419 path = CFStringCreateWithCString (NULL, SDATA (file), 2419 path = cfstring_create_with_utf8_cstring (SDATA (file));
2420 kCFStringEncodingUTF8);
2421 url = CFURLCreateWithFileSystemPath (NULL, path, 2420 url = CFURLCreateWithFileSystemPath (NULL, path,
2422 kCFURLPOSIXPathStyle, 0); 2421 kCFURLPOSIXPathStyle, 0);
2423 CFRelease (path); 2422 CFRelease (path);
diff --git a/src/indent.c b/src/indent.c
index 5b2faba7fda..b573c53e666 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -220,7 +220,7 @@ skip_invisible (pos, next_boundary_p, to, window)
220 Lisp_Object window; 220 Lisp_Object window;
221{ 221{
222 Lisp_Object prop, position, overlay_limit, proplimit; 222 Lisp_Object prop, position, overlay_limit, proplimit;
223 Lisp_Object buffer; 223 Lisp_Object buffer, tmp;
224 int end, inv_p; 224 int end, inv_p;
225 225
226 XSETFASTINT (position, pos); 226 XSETFASTINT (position, pos);
@@ -251,8 +251,9 @@ skip_invisible (pos, next_boundary_p, to, window)
251 /* No matter what. don't go past next overlay change. */ 251 /* No matter what. don't go past next overlay change. */
252 if (XFASTINT (overlay_limit) < XFASTINT (proplimit)) 252 if (XFASTINT (overlay_limit) < XFASTINT (proplimit))
253 proplimit = overlay_limit; 253 proplimit = overlay_limit;
254 end = XFASTINT (Fnext_single_property_change (position, Qinvisible, 254 tmp = Fnext_single_property_change (position, Qinvisible,
255 buffer, proplimit)); 255 buffer, proplimit);
256 end = XFASTINT (tmp);
256#if 0 257#if 0
257 /* Don't put the boundary in the middle of multibyte form if 258 /* Don't put the boundary in the middle of multibyte form if
258 there is no actual property change. */ 259 there is no actual property change. */
@@ -2069,6 +2070,8 @@ whether or not it is currently displayed in some window. */)
2069 } 2070 }
2070 else 2071 else
2071 { 2072 {
2073 int it_start;
2074
2072 SET_TEXT_POS (pt, PT, PT_BYTE); 2075 SET_TEXT_POS (pt, PT, PT_BYTE);
2073 start_display (&it, w, pt); 2076 start_display (&it, w, pt);
2074 2077
@@ -2078,13 +2081,14 @@ whether or not it is currently displayed in some window. */)
2078 we end up with the iterator placed at where it thinks X is 0, 2081 we end up with the iterator placed at where it thinks X is 0,
2079 while the end position is really at some X > 0, the same X that 2082 while the end position is really at some X > 0, the same X that
2080 PT had. */ 2083 PT had. */
2084 it_start = IT_CHARPOS (it);
2081 reseat_at_previous_visible_line_start (&it); 2085 reseat_at_previous_visible_line_start (&it);
2082 it.current_x = it.hpos = 0; 2086 it.current_x = it.hpos = 0;
2083 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); 2087 move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
2084 2088
2085 /* Move back if we got too far. This may happen if 2089 /* Move back if we got too far. This may happen if
2086 truncate-lines is on and PT is beyond right margin. */ 2090 truncate-lines is on and PT is beyond right margin. */
2087 if (IT_CHARPOS (it) > PT && XINT (lines) > 0) 2091 if (IT_CHARPOS (it) > it_start && XINT (lines) > 0)
2088 move_it_by_lines (&it, -1, 0); 2092 move_it_by_lines (&it, -1, 0);
2089 2093
2090 it.vpos = 0; 2094 it.vpos = 0;
diff --git a/src/insdel.c b/src/insdel.c
index 4a97eab79ef..aec393692a2 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1046,6 +1046,10 @@ insert_from_string (string, pos, pos_byte, length, length_byte, inherit)
1046 int inherit; 1046 int inherit;
1047{ 1047{
1048 int opoint = PT; 1048 int opoint = PT;
1049
1050 if (SCHARS (string) == 0)
1051 return;
1052
1049 insert_from_string_1 (string, pos, pos_byte, length, length_byte, 1053 insert_from_string_1 (string, pos, pos_byte, length, length_byte,
1050 inherit, 0); 1054 inherit, 0);
1051 signal_after_change (opoint, 0, PT - opoint); 1055 signal_after_change (opoint, 0, PT - opoint);
@@ -1063,6 +1067,10 @@ insert_from_string_before_markers (string, pos, pos_byte,
1063 int inherit; 1067 int inherit;
1064{ 1068{
1065 int opoint = PT; 1069 int opoint = PT;
1070
1071 if (SCHARS (string) == 0)
1072 return;
1073
1066 insert_from_string_1 (string, pos, pos_byte, length, length_byte, 1074 insert_from_string_1 (string, pos, pos_byte, length, length_byte,
1067 inherit, 1); 1075 inherit, 1);
1068 signal_after_change (opoint, 0, PT - opoint); 1076 signal_after_change (opoint, 0, PT - opoint);
diff --git a/src/keyboard.c b/src/keyboard.c
index 75bfa2180c7..c77c53790b1 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -45,6 +45,9 @@ Boston, MA 02111-1307, USA. */
45#include <setjmp.h> 45#include <setjmp.h>
46#include <errno.h> 46#include <errno.h>
47 47
48#ifdef HAVE_GTK_AND_PTHREAD
49#include <pthread.h>
50#endif
48#ifdef MSDOS 51#ifdef MSDOS
49#include "msdos.h" 52#include "msdos.h"
50#include <time.h> 53#include <time.h>
@@ -607,7 +610,7 @@ int flow_control;
607 610
608/* We are unable to use interrupts if FIONREAD is not available, 611/* We are unable to use interrupts if FIONREAD is not available,
609 so flush SIGIO so we won't try. */ 612 so flush SIGIO so we won't try. */
610#if !defined (FIONREAD) || defined(HAVE_CARBON) 613#if !defined (FIONREAD)
611#ifdef SIGIO 614#ifdef SIGIO
612#undef SIGIO 615#undef SIGIO
613#endif 616#endif
@@ -1618,7 +1621,10 @@ command_loop_1 ()
1618 if (NILP (Vthis_command)) 1621 if (NILP (Vthis_command))
1619 { 1622 {
1620 /* nil means key is undefined. */ 1623 /* nil means key is undefined. */
1624 Lisp_Object keys = Fvector (i, keybuf);
1625 keys = Fkey_description (keys, Qnil);
1621 bitch_at_user (); 1626 bitch_at_user ();
1627 message_with_string ("%s is undefined", keys, 0);
1622 current_kboard->defining_kbd_macro = Qnil; 1628 current_kboard->defining_kbd_macro = Qnil;
1623 update_mode_lines = 1; 1629 update_mode_lines = 1;
1624 current_kboard->Vprefix_arg = Qnil; 1630 current_kboard->Vprefix_arg = Qnil;
@@ -6773,6 +6779,25 @@ handle_async_input ()
6773#ifdef BSD4_1 6779#ifdef BSD4_1
6774 extern int select_alarmed; 6780 extern int select_alarmed;
6775#endif 6781#endif
6782#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD)
6783 extern pthread_t main_thread;
6784 if (pthread_self () != main_thread)
6785 {
6786 /* POSIX says any thread can receive the signal. On GNU/Linux that is
6787 not true, but for other systems (FreeBSD at least) it is. So direct
6788 the signal to the correct thread and block it from this thread. */
6789#ifdef SIGIO
6790 sigset_t new_mask;
6791
6792 sigemptyset (&new_mask);
6793 sigaddset (&new_mask, SIGIO);
6794 pthread_sigmask (SIG_BLOCK, &new_mask, 0);
6795 pthread_kill (main_thread, SIGIO);
6796#endif
6797 return;
6798 }
6799#endif
6800
6776 interrupt_input_pending = 0; 6801 interrupt_input_pending = 0;
6777 6802
6778 while (1) 6803 while (1)
@@ -6800,7 +6825,22 @@ input_available_signal (signo)
6800{ 6825{
6801 /* Must preserve main program's value of errno. */ 6826 /* Must preserve main program's value of errno. */
6802 int old_errno = errno; 6827 int old_errno = errno;
6803 6828#if ! defined (SYSTEM_MALLOC) && defined (HAVE_GTK_AND_PTHREAD)
6829 extern pthread_t main_thread;
6830 if (pthread_self () != main_thread)
6831 {
6832 /* POSIX says any thread can receive the signal. On GNU/Linux that is
6833 not true, but for other systems (FreeBSD at least) it is. So direct
6834 the signal to the correct thread and block it from this thread. */
6835 sigset_t new_mask;
6836
6837 sigemptyset (&new_mask);
6838 sigaddset (&new_mask, SIGIO);
6839 pthread_sigmask (SIG_BLOCK, &new_mask, 0);
6840 pthread_kill (main_thread, SIGIO);
6841 return;
6842 }
6843#endif /* HAVE_GTK_AND_PTHREAD */
6804#if defined (USG) && !defined (POSIX_SIGNALS) 6844#if defined (USG) && !defined (POSIX_SIGNALS)
6805 /* USG systems forget handlers when they are used; 6845 /* USG systems forget handlers when they are used;
6806 must reestablish each time */ 6846 must reestablish each time */
diff --git a/src/keymap.c b/src/keymap.c
index e76cbf5c00a..5a7c8b19123 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1273,7 +1273,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1273 c = Fevent_convert_list (c); 1273 c = Fevent_convert_list (c);
1274 1274
1275 /* Turn the 8th bit of string chars into a meta modifier. */ 1275 /* Turn the 8th bit of string chars into a meta modifier. */
1276 if (XINT (c) & 0x80 && STRINGP (key)) 1276 if (INTEGERP (c) && XINT (c) & 0x80 && STRINGP (key))
1277 XSETINT (c, (XINT (c) | meta_modifier) & ~0x80); 1277 XSETINT (c, (XINT (c) | meta_modifier) & ~0x80);
1278 1278
1279 /* Allow string since binding for `menu-bar-select-buffer' 1279 /* Allow string since binding for `menu-bar-select-buffer'
diff --git a/src/lisp.h b/src/lisp.h
index e89f778aa0e..47eb7604b41 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -35,6 +35,22 @@ Boston, MA 02111-1307, USA. */
35 be compared to the sizes recorded in Lisp strings. */ 35 be compared to the sizes recorded in Lisp strings. */
36 36
37#define GC_CHECK_STRING_BYTES 1 37#define GC_CHECK_STRING_BYTES 1
38
39/* Define this to check for short string overrun. */
40
41#define GC_CHECK_STRING_OVERRUN 1
42
43/* Define this to check the string free list. */
44
45#define GC_CHECK_STRING_FREE_LIST 1
46
47/* Define this to check for malloc buffer overrun. */
48
49#define XMALLOC_OVERRUN_CHECK 1
50
51/* Define this to check for errors in cons list. */
52/* #define GC_CHECK_CONS_LIST 1 */
53
38#endif /* 0 */ 54#endif /* 0 */
39 55
40 56
@@ -305,11 +321,13 @@ enum pvec_type
305/* First, try and define DECL_ALIGN(type,var) which declares a static 321/* First, try and define DECL_ALIGN(type,var) which declares a static
306 variable VAR of type TYPE with the added requirement that it be 322 variable VAR of type TYPE with the added requirement that it be
307 TYPEBITS-aligned. */ 323 TYPEBITS-aligned. */
308#ifndef DECL_ALIGN 324#ifndef NO_DECL_ALIGN
325# ifndef DECL_ALIGN
309/* What compiler directive should we use for non-gcc compilers? -stef */ 326/* What compiler directive should we use for non-gcc compilers? -stef */
310# if defined (__GNUC__) 327# if defined (__GNUC__)
311# define DECL_ALIGN(type, var) \ 328# define DECL_ALIGN(type, var) \
312 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var 329 type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
330# endif
313# endif 331# endif
314#endif 332#endif
315 333
@@ -324,7 +342,7 @@ enum pvec_type
324# endif 342# endif
325#endif 343#endif
326 344
327/* Just remove the alignment annotation if we don't use it. */ 345/* If we cannot use 8-byte alignment, make DECL_ALIGN a no-op. */
328#ifndef DECL_ALIGN 346#ifndef DECL_ALIGN
329# ifdef USE_LSB_TAG 347# ifdef USE_LSB_TAG
330# error "USE_LSB_TAG used without defining DECL_ALIGN" 348# error "USE_LSB_TAG used without defining DECL_ALIGN"
@@ -2325,6 +2343,7 @@ extern void clear_string_char_byte_cache P_ ((void));
2325extern int string_char_to_byte P_ ((Lisp_Object, int)); 2343extern int string_char_to_byte P_ ((Lisp_Object, int));
2326extern int string_byte_to_char P_ ((Lisp_Object, int)); 2344extern int string_byte_to_char P_ ((Lisp_Object, int));
2327extern Lisp_Object string_make_multibyte P_ ((Lisp_Object)); 2345extern Lisp_Object string_make_multibyte P_ ((Lisp_Object));
2346extern Lisp_Object string_to_multibyte P_ ((Lisp_Object));
2328extern Lisp_Object string_make_unibyte P_ ((Lisp_Object)); 2347extern Lisp_Object string_make_unibyte P_ ((Lisp_Object));
2329EXFUN (Fcopy_alist, 1); 2348EXFUN (Fcopy_alist, 1);
2330EXFUN (Fplist_get, 2); 2349EXFUN (Fplist_get, 2);
@@ -2455,6 +2474,7 @@ extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ()));
2455/* Defined in alloc.c */ 2474/* Defined in alloc.c */
2456extern void check_pure_size P_ ((void)); 2475extern void check_pure_size P_ ((void));
2457extern void allocate_string_data P_ ((struct Lisp_String *, int, int)); 2476extern void allocate_string_data P_ ((struct Lisp_String *, int, int));
2477extern void reset_malloc_hooks P_ ((void));
2458extern void uninterrupt_malloc P_ ((void)); 2478extern void uninterrupt_malloc P_ ((void));
2459extern void malloc_warning P_ ((char *)); 2479extern void malloc_warning P_ ((char *));
2460extern void memory_full P_ ((void)); 2480extern void memory_full P_ ((void));
@@ -2849,7 +2869,7 @@ extern void syms_of_search P_ ((void));
2849extern Lisp_Object last_minibuf_string; 2869extern Lisp_Object last_minibuf_string;
2850extern void choose_minibuf_frame P_ ((void)); 2870extern void choose_minibuf_frame P_ ((void));
2851EXFUN (Fcompleting_read, 8); 2871EXFUN (Fcompleting_read, 8);
2852EXFUN (Fread_from_minibuffer, 7); 2872EXFUN (Fread_from_minibuffer, 8);
2853EXFUN (Fread_variable, 2); 2873EXFUN (Fread_variable, 2);
2854EXFUN (Fread_buffer, 3); 2874EXFUN (Fread_buffer, 3);
2855EXFUN (Fread_minibuffer, 2); 2875EXFUN (Fread_minibuffer, 2);
diff --git a/src/lread.c b/src/lread.c
index 5e733f22a6d..49ec852eff3 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1,6 +1,6 @@
1/* Lisp parsing and input streams. 1/* Lisp parsing and input streams.
2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98,99,2000,01,03,2004 2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997, 1998,
3 Free Software Foundation, Inc. 3 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -484,12 +484,13 @@ readbyte_from_file (c, readcharfun)
484 484
485 c = getc (instream); 485 c = getc (instream);
486#ifdef EINTR 486#ifdef EINTR
487 /* Interrupted reads have been observed while reading over the network */ 487 /* Interrupted reads have been observed while reading over the network */
488 while (c == EOF && ferror (instream) && errno == EINTR) 488 while (c == EOF && ferror (instream) && errno == EINTR)
489 { 489 {
490 clearerr (instream); 490 QUIT;
491 c = getc (instream); 491 clearerr (instream);
492 } 492 c = getc (instream);
493 }
493#endif 494#endif
494 return (c == EOF ? -1 : c); 495 return (c == EOF ? -1 : c);
495} 496}
@@ -3414,7 +3415,7 @@ oblookup (obarray, ptr, size, size_byte)
3414 hash %= obsize; 3415 hash %= obsize;
3415 bucket = XVECTOR (obarray)->contents[hash]; 3416 bucket = XVECTOR (obarray)->contents[hash];
3416 oblookup_last_bucket_number = hash; 3417 oblookup_last_bucket_number = hash;
3417 if (XFASTINT (bucket) == 0) 3418 if (EQ (bucket, make_number (0)))
3418 ; 3419 ;
3419 else if (!SYMBOLP (bucket)) 3420 else if (!SYMBOLP (bucket))
3420 error ("Bad data in guts of obarray"); /* Like CADR error message */ 3421 error ("Bad data in guts of obarray"); /* Like CADR error message */
diff --git a/src/mac.c b/src/mac.c
index 91d07372578..53e56cfb541 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -262,6 +262,22 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
262 return 1; 262 return 1;
263} 263}
264 264
265#if TARGET_API_MAC_CARBON
266CFStringRef
267cfstring_create_with_utf8_cstring (c_str)
268 const char *c_str;
269{
270 CFStringRef str;
271
272 str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingUTF8);
273 if (str == NULL)
274 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
275 str = CFStringCreateWithCString (NULL, c_str, kCFStringEncodingMacRoman);
276
277 return str;
278}
279#endif
280
265#ifndef MAC_OSX 281#ifndef MAC_OSX
266 282
267/* The following functions with "sys_" prefix are stubs to Unix 283/* The following functions with "sys_" prefix are stubs to Unix
diff --git a/src/macfns.c b/src/macfns.c
index 401c7011fea..fdfe7a52416 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1932,8 +1932,7 @@ x_set_name (f, name, explicit)
1932 { 1932 {
1933#if TARGET_API_MAC_CARBON 1933#if TARGET_API_MAC_CARBON
1934 CFStringRef windowTitle = 1934 CFStringRef windowTitle =
1935 CFStringCreateWithCString (NULL, SDATA (name), 1935 cfstring_create_with_utf8_cstring (SDATA (name));
1936 kCFStringEncodingUTF8);
1937 1936
1938 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); 1937 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
1939 CFRelease (windowTitle); 1938 CFRelease (windowTitle);
@@ -2015,8 +2014,7 @@ x_set_title (f, name, old_name)
2015 { 2014 {
2016#if TARGET_API_MAC_CARBON 2015#if TARGET_API_MAC_CARBON
2017 CFStringRef windowTitle = 2016 CFStringRef windowTitle =
2018 CFStringCreateWithCString (NULL, SDATA (name), 2017 cfstring_create_with_utf8_cstring (SDATA (name));
2019 kCFStringEncodingUTF8);
2020 2018
2021 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); 2019 SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle);
2022 CFRelease (windowTitle); 2020 CFRelease (windowTitle);
@@ -4246,8 +4244,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4246 NavDialogRef dialogRef; 4244 NavDialogRef dialogRef;
4247 NavTypeListHandle fileTypes = NULL; 4245 NavTypeListHandle fileTypes = NULL;
4248 NavUserAction userAction; 4246 NavUserAction userAction;
4249 CFStringRef message=NULL, client=NULL, saveName = NULL, ok = NULL; 4247 CFStringRef message=NULL, saveName = NULL;
4250 CFStringRef title = NULL;
4251 4248
4252 BLOCK_INPUT; 4249 BLOCK_INPUT;
4253 /* No need for a callback function because we are modal */ 4250 /* No need for a callback function because we are modal */
@@ -4259,15 +4256,11 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4259 options.optionFlags |= kNavSelectAllReadableItem; 4256 options.optionFlags |= kNavSelectAllReadableItem;
4260 if (!NILP(prompt)) 4257 if (!NILP(prompt))
4261 { 4258 {
4262 message = CFStringCreateWithCStringNoCopy(NULL, SDATA(prompt), 4259 message = cfstring_create_with_utf8_cstring (SDATA (prompt));
4263 kCFStringEncodingUTF8,
4264 kCFAllocatorNull);
4265 options.message = message; 4260 options.message = message;
4266 } 4261 }
4267 /* Don't set the application, let it use default. 4262 /* Don't set the application, let it use default.
4268 client = CFStringCreateWithCStringNoCopy(NULL, "Emacs", 4263 options.clientName = CFSTR ("Emacs");
4269 kCFStringEncodingMacRoman, NULL);
4270 options.clientName = client;
4271 */ 4264 */
4272 4265
4273 if (!NILP (only_dir_p)) 4266 if (!NILP (only_dir_p))
@@ -4276,17 +4269,14 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4276 else if (NILP (mustmatch)) 4269 else if (NILP (mustmatch))
4277 { 4270 {
4278 /* This is a save dialog */ 4271 /* This is a save dialog */
4279 ok = CFStringCreateWithCString (NULL, "Ok", kCFStringEncodingUTF8);
4280 title = CFStringCreateWithCString (NULL, "Enter name",
4281 kCFStringEncodingUTF8);
4282 options.optionFlags |= kNavDontConfirmReplacement; 4272 options.optionFlags |= kNavDontConfirmReplacement;
4283 options.actionButtonLabel = ok; 4273 options.actionButtonLabel = CFSTR ("Ok");
4284 options.windowTitle = title; 4274 options.windowTitle = CFSTR ("Enter name");
4285 4275
4286 if (!NILP(default_filename)) 4276 if (!NILP(default_filename))
4287 { 4277 {
4288 saveName = CFStringCreateWithCString(NULL, SDATA(default_filename), 4278 saveName =
4289 kCFStringEncodingUTF8); 4279 cfstring_create_with_utf8_cstring (SDATA (default_filename));
4290 options.saveFileName = saveName; 4280 options.saveFileName = saveName;
4291 options.optionFlags |= kNavSelectDefaultLocation; 4281 options.optionFlags |= kNavSelectDefaultLocation;
4292 } 4282 }
@@ -4320,10 +4310,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4320 } 4310 }
4321 4311
4322 if (saveName) CFRelease(saveName); 4312 if (saveName) CFRelease(saveName);
4323 if (client) CFRelease(client);
4324 if (message) CFRelease(message); 4313 if (message) CFRelease(message);
4325 if (ok) CFRelease(ok);
4326 if (title) CFRelease(title);
4327 4314
4328 if (status == noErr) { 4315 if (status == noErr) {
4329 userAction = NavDialogGetUserAction(dialogRef); 4316 userAction = NavDialogGetUserAction(dialogRef);
@@ -4415,8 +4402,8 @@ frame_parm_handler mac_frame_parm_handlers[] =
4415 0, /* MAC_TODO: x_set_scroll_bar_background, */ 4402 0, /* MAC_TODO: x_set_scroll_bar_background, */
4416 x_set_screen_gamma, 4403 x_set_screen_gamma,
4417 x_set_line_spacing, 4404 x_set_line_spacing,
4418 0, /* MAC_TODO: x_set_fringe_width, */ 4405 x_set_fringe_width,
4419 0, /* MAC_TODO: x_set_fringe_width, */ 4406 x_set_fringe_width,
4420 0, /* x_set_wait_for_wm, */ 4407 0, /* x_set_wait_for_wm, */
4421 0, /* MAC_TODO: x_set_fullscreen, */ 4408 0, /* MAC_TODO: x_set_fullscreen, */
4422}; 4409};
diff --git a/src/macmenu.c b/src/macmenu.c
index 007fab15eab..f0696a49774 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -2264,8 +2264,7 @@ add_menu_item (MenuHandle menu, widget_value *wv, int submenu,
2264 item_name[255] = 0; 2264 item_name[255] = 0;
2265#if TARGET_API_MAC_CARBON 2265#if TARGET_API_MAC_CARBON
2266 { 2266 {
2267 CFStringRef string = 2267 CFStringRef string = cfstring_create_with_utf8_cstring (item_name);
2268 CFStringCreateWithCString (NULL, item_name, kCFStringEncodingUTF8);
2269 2268
2270 SetMenuItemTextWithCFString (menu, pos, string); 2269 SetMenuItemTextWithCFString (menu, pos, string);
2271 CFRelease (string); 2270 CFRelease (string);
diff --git a/src/macterm.c b/src/macterm.c
index bc35ab21547..ba19e0fbc31 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -281,7 +281,7 @@ static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
281static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 281static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
282 enum text_cursor_kinds)); 282 enum text_cursor_kinds));
283 283
284static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC)); 284static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC));
285static void x_flush P_ ((struct frame *f)); 285static void x_flush P_ ((struct frame *f));
286static void x_update_begin P_ ((struct frame *)); 286static void x_update_begin P_ ((struct frame *));
287static void x_update_window_begin P_ ((struct window *)); 287static void x_update_window_begin P_ ((struct window *));
@@ -569,7 +569,7 @@ XCreatePixmap (display, w, width, height, depth)
569 Display *display; /* not used */ 569 Display *display; /* not used */
570 WindowPtr w; 570 WindowPtr w;
571 unsigned int width, height; 571 unsigned int width, height;
572 unsigned int depth; /* not used */ 572 unsigned int depth;
573{ 573{
574 Pixmap pixmap; 574 Pixmap pixmap;
575 Rect r; 575 Rect r;
@@ -645,6 +645,7 @@ XFillRectangle (display, w, gc, x, y, width, height)
645} 645}
646 646
647 647
648#if 0 /* TODO: figure out if we need to do this on Mac. */
648static void 649static void
649mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) 650mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
650 Display *display; 651 Display *display;
@@ -668,6 +669,7 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
668 669
669 SetGWorld (old_port, old_gdh); 670 SetGWorld (old_port, old_gdh);
670} 671}
672#endif
671 673
672 674
673/* Mac replacement for XDrawRectangle: dest is a window. */ 675/* Mac replacement for XDrawRectangle: dest is a window. */
@@ -691,6 +693,7 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
691} 693}
692 694
693 695
696#if 0 /* TODO: figure out if we need to do this on Mac. */
694/* Mac replacement for XDrawRectangle: dest is a Pixmap. */ 697/* Mac replacement for XDrawRectangle: dest is a Pixmap. */
695 698
696static void 699static void
@@ -716,6 +719,7 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
716 719
717 SetGWorld (old_port, old_gdh); 720 SetGWorld (old_port, old_gdh);
718} 721}
722#endif
719 723
720 724
721static void 725static void
@@ -910,24 +914,13 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
910 int dest_x, dest_y; 914 int dest_x, dest_y;
911{ 915{
912#if TARGET_API_MAC_CARBON 916#if TARGET_API_MAC_CARBON
913 Rect gw_r, src_r, dest_r; 917 Rect src_r;
918 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
914 919
915 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 920 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
916 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 921 ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y,
917 922 kScrollWindowNoOptions, dummy);
918 SetPortWindowPort (w); 923 DisposeRgn (dummy);
919
920 ForeColor (blackColor);
921 BackColor (whiteColor);
922
923 LockPortBits (GetWindowPort (w));
924 {
925 const BitMap *bitmap = GetPortBitMapForCopyBits (GetWindowPort (w));
926 CopyBits (bitmap, bitmap, &src_r, &dest_r, srcCopy, 0);
927 }
928 UnlockPortBits (GetWindowPort (w));
929
930 mac_set_colors (gc);
931#else /* not TARGET_API_MAC_CARBON */ 924#else /* not TARGET_API_MAC_CARBON */
932 Rect src_r, dest_r; 925 Rect src_r, dest_r;
933 926
@@ -961,6 +954,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
961} 954}
962 955
963 956
957#if 0 /* TODO: figure out if we need to do this on Mac. */
964/* Mac replacement for XCopyArea: dest must be Pixmap. */ 958/* Mac replacement for XCopyArea: dest must be Pixmap. */
965 959
966static void 960static void
@@ -1039,6 +1033,7 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1039 1033
1040 SetGWorld (old_port, old_gdh); 1034 SetGWorld (old_port, old_gdh);
1041} 1035}
1036#endif
1042 1037
1043 1038
1044/* Mac replacement for XChangeGC. */ 1039/* Mac replacement for XChangeGC. */
@@ -1133,40 +1128,32 @@ x_sync (f)
1133} 1128}
1134 1129
1135 1130
1136/* Remove calls to XFlush by defining XFlush to an empty replacement.
1137 Calls to XFlush should be unnecessary because the X output buffer
1138 is flushed automatically as needed by calls to XPending,
1139 XNextEvent, or XWindowEvent according to the XFlush man page.
1140 XTread_socket calls XPending. Removing XFlush improves
1141 performance. */
1142
1143#if TARGET_API_MAC_CARBON
1144#define XFlush(DISPLAY) QDFlushPortBuffer (GetQDGlobalsThePort (), NULL)
1145#else
1146#define XFlush(DISPLAY) (void) 0
1147#endif
1148
1149/* Flush display of frame F, or of all frames if F is null. */ 1131/* Flush display of frame F, or of all frames if F is null. */
1150 1132
1151void 1133static void
1152x_flush (f) 1134x_flush (f)
1153 struct frame *f; 1135 struct frame *f;
1154{ 1136{
1155#if TARGET_API_MAC_CARBON 1137#if TARGET_API_MAC_CARBON
1156 BLOCK_INPUT; 1138 BLOCK_INPUT;
1157 if (f == NULL) 1139 if (f)
1158 { 1140 QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL);
1159 Lisp_Object rest, frame; 1141 else
1160 FOR_EACH_FRAME (rest, frame) 1142 QDFlushPortBuffer (GetQDGlobalsThePort (), NULL);
1161 x_flush (XFRAME (frame));
1162 }
1163 else if (FRAME_MAC_P (f))
1164 XFlush (FRAME_MAC_DISPLAY (f));
1165 UNBLOCK_INPUT; 1143 UNBLOCK_INPUT;
1166#endif /* TARGET_API_MAC_CARBON */ 1144#endif
1167} 1145}
1168 1146
1169 1147
1148/* Remove calls to XFlush by defining XFlush to an empty replacement.
1149 Calls to XFlush should be unnecessary because the X output buffer
1150 is flushed automatically as needed by calls to XPending,
1151 XNextEvent, or XWindowEvent according to the XFlush man page.
1152 XTread_socket calls XPending. Removing XFlush improves
1153 performance. */
1154
1155#define XFlush(DISPLAY) (void) 0
1156
1170 1157
1171/* Return the struct mac_display_info corresponding to DPY. There's 1158/* Return the struct mac_display_info corresponding to DPY. There's
1172 only one. */ 1159 only one. */
@@ -1456,12 +1443,12 @@ x_draw_fringe_bitmap (w, row, p)
1456 int oldVH = row->visible_height; 1443 int oldVH = row->visible_height;
1457 row->visible_height = p->h; 1444 row->visible_height = p->h;
1458 row->y -= rowY - p->y; 1445 row->y -= rowY - p->y;
1459 x_clip_to_row (w, row, gc); 1446 x_clip_to_row (w, row, -1, gc);
1460 row->y = oldY; 1447 row->y = oldY;
1461 row->visible_height = oldVH; 1448 row->visible_height = oldVH;
1462 } 1449 }
1463 else 1450 else
1464 x_clip_to_row (w, row, gc); 1451 x_clip_to_row (w, row, -1, gc);
1465 1452
1466 if (p->bx >= 0 && !p->overlay_p) 1453 if (p->bx >= 0 && !p->overlay_p)
1467 { 1454 {
@@ -1963,6 +1950,14 @@ x_clear_glyph_string_rect (s, x, y, w, h)
1963} 1950}
1964 1951
1965 1952
1953/* We prefer not to use XDrawImageString (srcCopy text transfer mode)
1954 on Mac OS X because:
1955 - Screen is double-buffered. (In srcCopy mode, a text is drawn
1956 into an offscreen graphics world first. So performance gain
1957 cannot be expected.)
1958 - It lowers rendering quality.
1959 - Some fonts leave garbage on cursor movement. */
1960
1966/* Draw the background of glyph_string S. If S->background_filled_p 1961/* Draw the background of glyph_string S. If S->background_filled_p
1967 is non-zero don't draw it. FORCE_P non-zero means draw the 1962 is non-zero don't draw it. FORCE_P non-zero means draw the
1968 background even if it wouldn't be drawn normally. This is used 1963 background even if it wouldn't be drawn normally. This is used
@@ -1994,10 +1989,12 @@ x_draw_glyph_string_background (s, force_p)
1994 } 1989 }
1995 else 1990 else
1996#endif 1991#endif
1992#if 0 /* defined(MAC_OS8)*/
1997 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width 1993 if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
1998 || s->font_not_found_p 1994 || s->font_not_found_p
1999 || s->extends_to_end_of_line_p 1995 || s->extends_to_end_of_line_p
2000 || force_p) 1996 || force_p)
1997#endif
2001 { 1998 {
2002 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, 1999 x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
2003 s->background_width, 2000 s->background_width,
@@ -2050,6 +2047,7 @@ x_draw_glyph_string_foreground (s)
2050 for (i = 0; i < s->nchars; ++i) 2047 for (i = 0; i < s->nchars; ++i)
2051 char1b[i] = s->char2b[i].byte2; 2048 char1b[i] = s->char2b[i].byte2;
2052 2049
2050#if 0 /* defined(MAC_OS8) */
2053 /* Draw text with XDrawString if background has already been 2051 /* Draw text with XDrawString if background has already been
2054 filled. Otherwise, use XDrawImageString. (Note that 2052 filled. Otherwise, use XDrawImageString. (Note that
2055 XDrawImageString is usually faster than XDrawString.) Always 2053 XDrawImageString is usually faster than XDrawString.) Always
@@ -2057,6 +2055,7 @@ x_draw_glyph_string_foreground (s)
2057 no chance that characters under a box cursor are invisible. */ 2055 no chance that characters under a box cursor are invisible. */
2058 if (s->for_overlaps_p 2056 if (s->for_overlaps_p
2059 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 2057 || (s->background_filled_p && s->hl != DRAW_CURSOR))
2058#endif
2060 { 2059 {
2061 /* Draw characters with 16-bit or 8-bit functions. */ 2060 /* Draw characters with 16-bit or 8-bit functions. */
2062 if (s->two_byte_p) 2061 if (s->two_byte_p)
@@ -2066,6 +2065,7 @@ x_draw_glyph_string_foreground (s)
2066 XDrawString (s->display, s->window, s->gc, x, 2065 XDrawString (s->display, s->window, s->gc, x,
2067 s->ybase - boff, char1b, s->nchars); 2066 s->ybase - boff, char1b, s->nchars);
2068 } 2067 }
2068#if 0 /* defined(MAC_OS8)*/
2069 else 2069 else
2070 { 2070 {
2071 if (s->two_byte_p) 2071 if (s->two_byte_p)
@@ -2075,6 +2075,7 @@ x_draw_glyph_string_foreground (s)
2075 XDrawImageString (s->display, s->window, s->gc, x, 2075 XDrawImageString (s->display, s->window, s->gc, x,
2076 s->ybase - boff, char1b, s->nchars); 2076 s->ybase - boff, char1b, s->nchars);
2077 } 2077 }
2078#endif
2078 } 2079 }
2079} 2080}
2080 2081
@@ -2641,38 +2642,17 @@ x_draw_image_foreground (s)
2641 2642
2642 if (s->img->pixmap) 2643 if (s->img->pixmap)
2643 { 2644 {
2645 x_set_glyph_string_clipping (s);
2646
2644 if (s->img->mask) 2647 if (s->img->mask)
2645 { 2648 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
2646 Rect nr; 2649 s->window, s->gc, s->slice.x, s->slice.y,
2647 XRectangle clip_rect, image_rect, r; 2650 s->slice.width, s->slice.height, x, y);
2648
2649 get_glyph_string_clip_rect (s, &nr);
2650 CONVERT_TO_XRECT (clip_rect, nr);
2651 image_rect.x = x;
2652 image_rect.y = y;
2653 image_rect.width = s->slice.width;
2654 image_rect.height = s->slice.height;
2655 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2656 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
2657 s->window, s->gc,
2658 s->slice.x + r.x - x, s->slice.y + r.y - y,
2659 r.width, r.height, r.x, r.y);
2660 }
2661 else 2651 else
2662 { 2652 {
2663 Rect nr; 2653 mac_copy_area (s->display, s->img->pixmap,
2664 XRectangle clip_rect, image_rect, r; 2654 s->window, s->gc, s->slice.x, s->slice.y,
2665 2655 s->slice.width, s->slice.height, x, y);
2666 get_glyph_string_clip_rect (s, &nr);
2667 CONVERT_TO_XRECT (clip_rect, nr);
2668 image_rect.x = x;
2669 image_rect.y = y;
2670 image_rect.width = s->slice.width;
2671 image_rect.height = s->slice.height;
2672 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2673 mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,
2674 s->slice.x + r.x - x, s->slice.y + r.y - y,
2675 r.width, r.height, r.x, r.y);
2676 2656
2677 /* When the image has a mask, we can expect that at 2657 /* When the image has a mask, we can expect that at
2678 least part of a mouse highlight or a block cursor will 2658 least part of a mouse highlight or a block cursor will
@@ -2751,6 +2731,7 @@ x_draw_image_relief (s)
2751} 2731}
2752 2732
2753 2733
2734#if 0 /* TODO: figure out if we need to do this on Mac. */
2754/* Draw the foreground of image glyph string S to PIXMAP. */ 2735/* Draw the foreground of image glyph string S to PIXMAP. */
2755 2736
2756static void 2737static void
@@ -2811,6 +2792,7 @@ x_draw_image_foreground_1 (s, pixmap)
2811 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y, 2792 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
2812 s->slice.width - 1, s->slice.height - 1); 2793 s->slice.width - 1, s->slice.height - 1);
2813} 2794}
2795#endif
2814 2796
2815 2797
2816/* Draw part of the background of glyph string S. X, Y, W, and H 2798/* Draw part of the background of glyph string S. X, Y, W, and H
@@ -2882,6 +2864,7 @@ x_draw_image_glyph_string (s)
2882 if (s->slice.y == 0) 2864 if (s->slice.y == 0)
2883 y += box_line_vwidth; 2865 y += box_line_vwidth;
2884 2866
2867#if 0 /* TODO: figure out if we need to do this on Mac. */
2885 if (s->img->mask) 2868 if (s->img->mask)
2886 { 2869 {
2887 /* Create a pixmap as large as the glyph string. Fill it 2870 /* Create a pixmap as large as the glyph string. Fill it
@@ -2918,12 +2901,14 @@ x_draw_image_glyph_string (s)
2918 } 2901 }
2919 } 2902 }
2920 else 2903 else
2904#endif
2921 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height); 2905 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
2922 2906
2923 s->background_filled_p = 1; 2907 s->background_filled_p = 1;
2924 } 2908 }
2925 2909
2926 /* Draw the foreground. */ 2910 /* Draw the foreground. */
2911#if 0 /* TODO: figure out if we need to do this on Mac. */
2927 if (pixmap != 0) 2912 if (pixmap != 0)
2928 { 2913 {
2929 x_draw_image_foreground_1 (s, pixmap); 2914 x_draw_image_foreground_1 (s, pixmap);
@@ -2934,6 +2919,7 @@ x_draw_image_glyph_string (s)
2934 XFreePixmap (s->display, pixmap); 2919 XFreePixmap (s->display, pixmap);
2935 } 2920 }
2936 else 2921 else
2922#endif
2937 x_draw_image_foreground (s); 2923 x_draw_image_foreground (s);
2938 2924
2939 /* If we must draw a relief around the image, do it. */ 2925 /* If we must draw a relief around the image, do it. */
@@ -4621,18 +4607,19 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4621 mode lines must be clipped to the whole window. */ 4607 mode lines must be clipped to the whole window. */
4622 4608
4623static void 4609static void
4624x_clip_to_row (w, row, gc) 4610x_clip_to_row (w, row, area, gc)
4625 struct window *w; 4611 struct window *w;
4626 struct glyph_row *row; 4612 struct glyph_row *row;
4613 int area;
4627 GC gc; 4614 GC gc;
4628{ 4615{
4629 struct frame *f = XFRAME (WINDOW_FRAME (w)); 4616 struct frame *f = XFRAME (WINDOW_FRAME (w));
4630 Rect clip_rect; 4617 Rect clip_rect;
4631 int window_y, window_width; 4618 int window_x, window_y, window_width;
4632 4619
4633 window_box (w, -1, 0, &window_y, &window_width, 0); 4620 window_box (w, area, &window_x, &window_y, &window_width, 0);
4634 4621
4635 clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0); 4622 clip_rect.left = window_x;
4636 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 4623 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
4637 clip_rect.top = max (clip_rect.top, window_y); 4624 clip_rect.top = max (clip_rect.top, window_y);
4638 clip_rect.right = clip_rect.left + window_width; 4625 clip_rect.right = clip_rect.left + window_width;
@@ -4698,7 +4685,7 @@ x_draw_hollow_cursor (w, row)
4698 gc = dpyinfo->scratch_cursor_gc; 4685 gc = dpyinfo->scratch_cursor_gc;
4699 4686
4700 /* Set clipping, draw the rectangle, and reset clipping again. */ 4687 /* Set clipping, draw the rectangle, and reset clipping again. */
4701 x_clip_to_row (w, row, gc); 4688 x_clip_to_row (w, row, TEXT_AREA, gc);
4702 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); 4689 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
4703 mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f)); 4690 mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f));
4704} 4691}
@@ -4769,7 +4756,7 @@ x_draw_bar_cursor (w, row, width, kind)
4769 width = min (cursor_glyph->pixel_width, width); 4756 width = min (cursor_glyph->pixel_width, width);
4770 4757
4771 w->phys_cursor_width = width; 4758 w->phys_cursor_width = width;
4772 x_clip_to_row (w, row, gc); 4759 x_clip_to_row (w, row, TEXT_AREA, gc);
4773 4760
4774 if (kind == BAR_CURSOR) 4761 if (kind == BAR_CURSOR)
4775 XFillRectangle (dpy, window, gc, 4762 XFillRectangle (dpy, window, gc,
@@ -5915,7 +5902,14 @@ mac_font_match (char *mf, char *xf)
5915static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr; 5902static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
5916 5903
5917static void 5904static void
5918decode_mac_font_name (char *name, int size, short scriptcode) 5905decode_mac_font_name (name, size, scriptcode)
5906 char *name;
5907 int size;
5908#if TARGET_API_MAC_CARBON
5909 int scriptcode;
5910#else
5911 short scriptcode;
5912#endif
5919{ 5913{
5920 Lisp_Object coding_system; 5914 Lisp_Object coding_system;
5921 struct coding_system coding; 5915 struct coding_system coding;
@@ -5957,7 +5951,15 @@ decode_mac_font_name (char *name, int size, short scriptcode)
5957 5951
5958 5952
5959static char * 5953static char *
5960mac_to_x_fontname (char *name, int size, Style style, short scriptcode) 5954mac_to_x_fontname (name, size, style, scriptcode, encoding_base)
5955 char *name;
5956 int size;
5957 Style style;
5958#if TARGET_API_MAC_CARBON
5959 int scriptcode;
5960#else
5961 short scriptcode;
5962#endif
5961{ 5963{
5962 char foundry[32], family[32], cs[32]; 5964 char foundry[32], family[32], cs[32];
5963 char xf[256], *result, *p; 5965 char xf[256], *result, *p;
@@ -5969,13 +5971,13 @@ mac_to_x_fontname (char *name, int size, Style style, short scriptcode)
5969 5971
5970 switch (scriptcode) 5972 switch (scriptcode)
5971 { 5973 {
5972 case smTradChinese: 5974 case smTradChinese: /* == kTextEncodingMacChineseTrad */
5973 strcpy(cs, "big5-0"); 5975 strcpy(cs, "big5-0");
5974 break; 5976 break;
5975 case smSimpChinese: 5977 case smSimpChinese: /* == kTextEncodingMacChineseSimp */
5976 strcpy(cs, "gb2312.1980-0"); 5978 strcpy(cs, "gb2312.1980-0");
5977 break; 5979 break;
5978 case smJapanese: 5980 case smJapanese: /* == kTextEncodingMacJapanese */
5979 strcpy(cs, "jisx0208.1983-sjis"); 5981 strcpy(cs, "jisx0208.1983-sjis");
5980 break; 5982 break;
5981 case -smJapanese: 5983 case -smJapanese:
@@ -5987,12 +5989,24 @@ mac_to_x_fontname (char *name, int size, Style style, short scriptcode)
5987 font is being built. */ 5989 font is being built. */
5988 strcpy(cs, "jisx0201.1976-0"); 5990 strcpy(cs, "jisx0201.1976-0");
5989 break; 5991 break;
5990 case smKorean: 5992 case smKorean: /* == kTextEncodingMacKorean */
5991 strcpy(cs, "ksc5601.1989-0"); 5993 strcpy(cs, "ksc5601.1989-0");
5992 break; 5994 break;
5995#if TARGET_API_MAC_CARBON
5996 case kTextEncodingMacCyrillic:
5997 strcpy(cs, "mac-cyrillic");
5998 break;
5999 case kTextEncodingMacCentralEurRoman:
6000 strcpy(cs, "mac-centraleuropean");
6001 break;
6002 case kTextEncodingMacSymbol:
6003 case kTextEncodingMacDingbats:
6004 strcpy(cs, "adobe-fontspecific");
6005 break;
6006#endif
5993 default: 6007 default:
5994 strcpy(cs, "mac-roman"); 6008 strcpy(cs, "mac-roman");
5995 break; 6009 break;
5996 } 6010 }
5997 } 6011 }
5998 6012
@@ -6039,7 +6053,10 @@ x_font_name_to_mac_font_name (char *xf, char *mf)
6039 coding_system = Qsjis; 6053 coding_system = Qsjis;
6040 else if (strcmp (cs, "ksc5601.1989-0") == 0) 6054 else if (strcmp (cs, "ksc5601.1989-0") == 0)
6041 coding_system = Qeuc_kr; 6055 coding_system = Qeuc_kr;
6042 else if (strcmp (cs, "mac-roman") == 0) 6056 else if (strcmp (cs, "mac-roman") == 0
6057 || strcmp (cs, "mac-cyrillic") == 0
6058 || strcmp (cs, "mac-centraleuropean") == 0
6059 || strcmp (cs, "adobe-fontspecific") == 0)
6043 strcpy (mf, family); 6060 strcpy (mf, family);
6044 else 6061 else
6045 sprintf (mf, "%s-%s-%s", foundry, family, cs); 6062 sprintf (mf, "%s-%s-%s", foundry, family, cs);
@@ -6114,7 +6131,8 @@ init_font_name_table ()
6114 FMFont font; 6131 FMFont font;
6115 FMFontStyle style; 6132 FMFontStyle style;
6116 FMFontSize size; 6133 FMFontSize size;
6117 SInt16 sc; 6134 TextEncoding encoding;
6135 TextEncodingBase sc;
6118 6136
6119 if (FMGetFontFamilyName (ff, name) != noErr) 6137 if (FMGetFontFamilyName (ff, name) != noErr)
6120 break; 6138 break;
@@ -6122,9 +6140,11 @@ init_font_name_table ()
6122 if (*name == '.') 6140 if (*name == '.')
6123 continue; 6141 continue;
6124 6142
6125 sc = FontToScript (ff); 6143 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
6144 break;
6145 sc = GetTextEncodingBase (encoding);
6126 decode_mac_font_name (name, sizeof (name), sc); 6146 decode_mac_font_name (name, sizeof (name), sc);
6127 6147
6128 /* Point the instance iterator at the current font family. */ 6148 /* Point the instance iterator at the current font family. */
6129 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 6149 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
6130 break; 6150 break;
@@ -8644,17 +8664,30 @@ XTread_socket (sd, expected, hold_quit)
8644 { 8664 {
8645 unsigned char ch = inev.code; 8665 unsigned char ch = inev.code;
8646 ByteCount actual_input_length, actual_output_length; 8666 ByteCount actual_input_length, actual_output_length;
8647 unsigned char outch; 8667 unsigned char outbuf[32];
8648 8668
8649 convert_status = TECConvertText (converter, &ch, 1, 8669 convert_status = TECConvertText (converter, &ch, 1,
8650 &actual_input_length, 8670 &actual_input_length,
8651 &outch, 1, 8671 outbuf, 1,
8652 &actual_output_length); 8672 &actual_output_length);
8653 if (convert_status == noErr 8673 if (convert_status == noErr
8654 && actual_input_length == 1 8674 && actual_input_length == 1
8655 && actual_output_length == 1) 8675 && actual_output_length == 1)
8656 inev.code = outch; 8676 inev.code = *outbuf;
8657 } 8677
8678 /* Reset internal states of the converter object.
8679 If it fails, create another one. */
8680 convert_status = TECFlushText (converter, outbuf,
8681 sizeof (outbuf),
8682 &actual_output_length);
8683 if (convert_status != noErr)
8684 {
8685 TECDisposeConverter (converter);
8686 TECCreateConverter (&converter,
8687 kTextEncodingMacRoman,
8688 mac_keyboard_text_encoding);
8689 }
8690 }
8658 } 8691 }
8659 8692
8660#if USE_CARBON_EVENTS 8693#if USE_CARBON_EVENTS
@@ -9173,7 +9206,7 @@ static struct redisplay_interface x_redisplay_interface =
9173 x_update_window_end, 9206 x_update_window_end,
9174 x_cursor_to, 9207 x_cursor_to,
9175 x_flush, 9208 x_flush,
9176 x_flush, 9209 0, /* flush_display_optional */
9177 x_clear_window_mouse_face, 9210 x_clear_window_mouse_face,
9178 x_get_glyph_overhangs, 9211 x_get_glyph_overhangs,
9179 x_fix_overlapping_area, 9212 x_fix_overlapping_area,
diff --git a/src/macterm.h b/src/macterm.h
index f9bde772fcd..ff7110828b1 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -600,5 +600,9 @@ extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
600#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 600#define FONT_TYPE_FOR_UNIBYTE(font, ch) 0
601#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 601#define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0
602 602
603#if TARGET_API_MAC_CARBON
604extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
605#endif
606
603/* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79 607/* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79
604 (do not change this comment) */ 608 (do not change this comment) */
diff --git a/src/minibuf.c b/src/minibuf.c
index 7aeb0283f2c..109b1fc1df0 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -218,7 +218,7 @@ static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object,
218 Lisp_Object, Lisp_Object, 218 Lisp_Object, Lisp_Object,
219 int, Lisp_Object, 219 int, Lisp_Object,
220 Lisp_Object, Lisp_Object, 220 Lisp_Object, Lisp_Object,
221 int, int)); 221 int, int, int));
222static Lisp_Object read_minibuf_noninteractive P_ ((Lisp_Object, Lisp_Object, 222static Lisp_Object read_minibuf_noninteractive P_ ((Lisp_Object, Lisp_Object,
223 Lisp_Object, Lisp_Object, 223 Lisp_Object, Lisp_Object,
224 int, Lisp_Object, 224 int, Lisp_Object,
@@ -437,7 +437,8 @@ minibuffer_completion_contents ()
437 437
438static Lisp_Object 438static Lisp_Object
439read_minibuf (map, initial, prompt, backup_n, expflag, 439read_minibuf (map, initial, prompt, backup_n, expflag,
440 histvar, histpos, defalt, allow_props, inherit_input_method) 440 histvar, histpos, defalt, allow_props, inherit_input_method,
441 keep_all)
441 Lisp_Object map; 442 Lisp_Object map;
442 Lisp_Object initial; 443 Lisp_Object initial;
443 Lisp_Object prompt; 444 Lisp_Object prompt;
@@ -448,6 +449,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
448 Lisp_Object defalt; 449 Lisp_Object defalt;
449 int allow_props; 450 int allow_props;
450 int inherit_input_method; 451 int inherit_input_method;
452 int keep_all;
451{ 453{
452 Lisp_Object val; 454 Lisp_Object val;
453 int count = SPECPDL_INDEX (); 455 int count = SPECPDL_INDEX ();
@@ -722,7 +724,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
722 last_minibuf_string = val; 724 last_minibuf_string = val;
723 725
724 /* Choose the string to add to the history. */ 726 /* Choose the string to add to the history. */
725 if (SCHARS (val) != 0) 727 if (SCHARS (val) != 0 || keep_all)
726 histstring = val; 728 histstring = val;
727 else if (STRINGP (defalt)) 729 else if (STRINGP (defalt))
728 histstring = defalt; 730 histstring = defalt;
@@ -749,7 +751,8 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
749 if (NILP (histval) 751 if (NILP (histval)
750 || (CONSP (histval) 752 || (CONSP (histval)
751 /* Don't duplicate the most recent entry in the history. */ 753 /* Don't duplicate the most recent entry in the history. */
752 && NILP (Fequal (histstring, Fcar (histval))))) 754 && (keep_all
755 || NILP (Fequal (histstring, Fcar (histval))))))
753 { 756 {
754 Lisp_Object length; 757 Lisp_Object length;
755 758
@@ -911,7 +914,7 @@ read_minibuf_unwind (data)
911} 914}
912 915
913 916
914DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 7, 0, 917DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 8, 0,
915 doc: /* Read a string from the minibuffer, prompting with string PROMPT. 918 doc: /* Read a string from the minibuffer, prompting with string PROMPT.
916The optional second arg INITIAL-CONTENTS is an obsolete alternative to 919The optional second arg INITIAL-CONTENTS is an obsolete alternative to
917 DEFAULT-VALUE. It normally should be nil in new code, except when 920 DEFAULT-VALUE. It normally should be nil in new code, except when
@@ -935,6 +938,8 @@ Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is available
935 the empty string. 938 the empty string.
936Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits 939Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
937 the current input method and the setting of `enable-multibyte-characters'. 940 the current input method and the setting of `enable-multibyte-characters'.
941Eight arg KEEP-ALL, if non-nil, says to put all inputs in the history list,
942 even empty or duplicate inputs.
938If the variable `minibuffer-allow-text-properties' is non-nil, 943If the variable `minibuffer-allow-text-properties' is non-nil,
939 then the string which is returned includes whatever text properties 944 then the string which is returned includes whatever text properties
940 were present in the minibuffer. Otherwise the value has no text properties. 945 were present in the minibuffer. Otherwise the value has no text properties.
@@ -950,9 +955,9 @@ POSITION in the minibuffer. Any integer value less than or equal to
950one puts point at the beginning of the string. *Note* that this 955one puts point at the beginning of the string. *Note* that this
951behavior differs from the way such arguments are used in `completing-read' 956behavior differs from the way such arguments are used in `completing-read'
952and some related functions, which use zero-indexing for POSITION. */) 957and some related functions, which use zero-indexing for POSITION. */)
953 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method) 958 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method, keep_all)
954 Lisp_Object prompt, initial_contents, keymap, read, hist, default_value; 959 Lisp_Object prompt, initial_contents, keymap, read, hist, default_value;
955 Lisp_Object inherit_input_method; 960 Lisp_Object inherit_input_method, keep_all;
956{ 961{
957 Lisp_Object histvar, histpos, val; 962 Lisp_Object histvar, histpos, val;
958 struct gcpro gcpro1; 963 struct gcpro gcpro1;
@@ -983,7 +988,8 @@ and some related functions, which use zero-indexing for POSITION. */)
983 Qnil, !NILP (read), 988 Qnil, !NILP (read),
984 histvar, histpos, default_value, 989 histvar, histpos, default_value,
985 minibuffer_allow_text_properties, 990 minibuffer_allow_text_properties,
986 !NILP (inherit_input_method)); 991 !NILP (inherit_input_method),
992 !NILP (keep_all));
987 UNGCPRO; 993 UNGCPRO;
988 return val; 994 return val;
989} 995}
@@ -1000,7 +1006,7 @@ arguments are used as in `read-from-minibuffer') */)
1000 CHECK_STRING (prompt); 1006 CHECK_STRING (prompt);
1001 return read_minibuf (Vminibuffer_local_map, initial_contents, 1007 return read_minibuf (Vminibuffer_local_map, initial_contents,
1002 prompt, Qnil, 1, Qminibuffer_history, 1008 prompt, Qnil, 1, Qminibuffer_history,
1003 make_number (0), Qnil, 0, 0); 1009 make_number (0), Qnil, 0, 0, 0);
1004} 1010}
1005 1011
1006DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0, 1012DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0,
@@ -1038,7 +1044,7 @@ Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
1038 Lisp_Object val; 1044 Lisp_Object val;
1039 val = Fread_from_minibuffer (prompt, initial_input, Qnil, 1045 val = Fread_from_minibuffer (prompt, initial_input, Qnil,
1040 Qnil, history, default_value, 1046 Qnil, history, default_value,
1041 inherit_input_method); 1047 inherit_input_method, Qnil);
1042 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value)) 1048 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value))
1043 val = default_value; 1049 val = default_value;
1044 return val; 1050 return val;
@@ -1060,7 +1066,7 @@ the current input method and the setting of`enable-multibyte-characters'. */)
1060 CHECK_STRING (prompt); 1066 CHECK_STRING (prompt);
1061 return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, Qnil, 1067 return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, Qnil,
1062 0, Qminibuffer_history, make_number (0), Qnil, 0, 1068 0, Qminibuffer_history, make_number (0), Qnil, 0,
1063 !NILP (inherit_input_method)); 1069 !NILP (inherit_input_method), 0);
1064} 1070}
1065 1071
1066DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0, 1072DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0,
@@ -1711,7 +1717,7 @@ Completion ignores case if the ambient value of
1711 : Vminibuffer_local_must_match_map, 1717 : Vminibuffer_local_must_match_map,
1712 init, prompt, make_number (pos), 0, 1718 init, prompt, make_number (pos), 0,
1713 histvar, histpos, def, 0, 1719 histvar, histpos, def, 0,
1714 !NILP (inherit_input_method)); 1720 !NILP (inherit_input_method), 0);
1715 1721
1716 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def)) 1722 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (def))
1717 val = def; 1723 val = def;
@@ -2076,10 +2082,28 @@ a repetition of this command will exit. */)
2076 if (XINT (Fminibuffer_prompt_end ()) == ZV) 2082 if (XINT (Fminibuffer_prompt_end ()) == ZV)
2077 goto exit; 2083 goto exit;
2078 2084
2079 if (!NILP (Ftest_completion (Fminibuffer_contents (), 2085 val = Fminibuffer_contents ();
2086 if (!NILP (Ftest_completion (val,
2080 Vminibuffer_completion_table, 2087 Vminibuffer_completion_table,
2081 Vminibuffer_completion_predicate))) 2088 Vminibuffer_completion_predicate)))
2082 goto exit; 2089 {
2090 if (completion_ignore_case)
2091 { /* Fixup case of the field, if necessary. */
2092 Lisp_Object compl
2093 = Ftry_completion (val,
2094 Vminibuffer_completion_table,
2095 Vminibuffer_completion_predicate);
2096 if (STRINGP (compl)
2097 /* If it weren't for this piece of paranoia, I'd replace
2098 the whole thing with a call to do_completion. */
2099 && EQ (Flength (val), Flength (compl)))
2100 {
2101 del_range (XINT (Fminibuffer_prompt_end ()), ZV);
2102 Finsert (1, &compl);
2103 }
2104 }
2105 goto exit;
2106 }
2083 2107
2084 /* Call do_completion, but ignore errors. */ 2108 /* Call do_completion, but ignore errors. */
2085 SET_PT (ZV); 2109 SET_PT (ZV);
diff --git a/src/regex.c b/src/regex.c
index 71a450f9b23..f21955a3c0e 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1275,7 +1275,7 @@ reg_syntax_t re_syntax_options;
1275 1275
1276reg_syntax_t 1276reg_syntax_t
1277re_set_syntax (syntax) 1277re_set_syntax (syntax)
1278 reg_syntax_t syntax; 1278 reg_syntax_t syntax;
1279{ 1279{
1280 reg_syntax_t ret = re_syntax_options; 1280 reg_syntax_t ret = re_syntax_options;
1281 1281
@@ -1283,6 +1283,17 @@ re_set_syntax (syntax)
1283 return ret; 1283 return ret;
1284} 1284}
1285WEAK_ALIAS (__re_set_syntax, re_set_syntax) 1285WEAK_ALIAS (__re_set_syntax, re_set_syntax)
1286
1287/* Regexp to use to replace spaces, or NULL meaning don't. */
1288static re_char *whitespace_regexp;
1289
1290void
1291re_set_whitespace_regexp (regexp)
1292 re_char *regexp;
1293{
1294 whitespace_regexp = regexp;
1295}
1296WEAK_ALIAS (__re_set_syntax, re_set_syntax)
1286 1297
1287/* This table gives an error message for each of the error codes listed 1298/* This table gives an error message for each of the error codes listed
1288 in regex.h. Obviously the order here has to be same as there. 1299 in regex.h. Obviously the order here has to be same as there.
@@ -1993,28 +2004,27 @@ struct range_table_work_area
1993 2004
1994/* Get the next unsigned number in the uncompiled pattern. */ 2005/* Get the next unsigned number in the uncompiled pattern. */
1995#define GET_UNSIGNED_NUMBER(num) \ 2006#define GET_UNSIGNED_NUMBER(num) \
1996 do { if (p != pend) \ 2007 do { \
1997 { \ 2008 if (p == pend) \
1998 PATFETCH (c); \ 2009 FREE_STACK_RETURN (REG_EBRACE); \
1999 if (c == ' ') \ 2010 else \
2000 FREE_STACK_RETURN (REG_BADBR); \ 2011 { \
2001 while ('0' <= c && c <= '9') \ 2012 PATFETCH (c); \
2002 { \ 2013 while ('0' <= c && c <= '9') \
2003 int prev; \ 2014 { \
2004 if (num < 0) \ 2015 int prev; \
2005 num = 0; \ 2016 if (num < 0) \
2006 prev = num; \ 2017 num = 0; \
2007 num = num * 10 + c - '0'; \ 2018 prev = num; \
2008 if (num / 10 != prev) \ 2019 num = num * 10 + c - '0'; \
2009 FREE_STACK_RETURN (REG_BADBR); \ 2020 if (num / 10 != prev) \
2010 if (p == pend) \ 2021 FREE_STACK_RETURN (REG_BADBR); \
2011 break; \ 2022 if (p == pend) \
2012 PATFETCH (c); \ 2023 FREE_STACK_RETURN (REG_EBRACE); \
2013 } \ 2024 PATFETCH (c); \
2014 if (c == ' ') \ 2025 } \
2015 FREE_STACK_RETURN (REG_BADBR); \ 2026 } \
2016 } \ 2027 } while (0)
2017 } while (0)
2018 2028
2019#if ! WIDE_CHAR_SUPPORT 2029#if ! WIDE_CHAR_SUPPORT
2020 2030
@@ -2495,6 +2505,15 @@ regex_compile (pattern, size, syntax, bufp)
2495 /* If a target of matching can contain multibyte characters. */ 2505 /* If a target of matching can contain multibyte characters. */
2496 const boolean target_multibyte = RE_TARGET_MULTIBYTE_P (bufp); 2506 const boolean target_multibyte = RE_TARGET_MULTIBYTE_P (bufp);
2497 2507
2508 /* Nonzero if we have pushed down into a subpattern. */
2509 int in_subpattern = 0;
2510
2511 /* These hold the values of p, pattern, and pend from the main
2512 pattern when we have pushed into a subpattern. */
2513 re_char *main_p;
2514 re_char *main_pattern;
2515 re_char *main_pend;
2516
2498#ifdef DEBUG 2517#ifdef DEBUG
2499 debug++; 2518 debug++;
2500 DEBUG_PRINT1 ("\nCompiling pattern: "); 2519 DEBUG_PRINT1 ("\nCompiling pattern: ");
@@ -2557,12 +2576,61 @@ regex_compile (pattern, size, syntax, bufp)
2557 begalt = b = bufp->buffer; 2576 begalt = b = bufp->buffer;
2558 2577
2559 /* Loop through the uncompiled pattern until we're at the end. */ 2578 /* Loop through the uncompiled pattern until we're at the end. */
2560 while (p != pend) 2579 while (1)
2561 { 2580 {
2581 if (p == pend)
2582 {
2583 /* If this is the end of an included regexp,
2584 pop back to the main regexp and try again. */
2585 if (in_subpattern)
2586 {
2587 in_subpattern = 0;
2588 pattern = main_pattern;
2589 p = main_p;
2590 pend = main_pend;
2591 continue;
2592 }
2593 /* If this is the end of the main regexp, we are done. */
2594 break;
2595 }
2596
2562 PATFETCH (c); 2597 PATFETCH (c);
2563 2598
2564 switch (c) 2599 switch (c)
2565 { 2600 {
2601 case ' ':
2602 {
2603 re_char *p1 = p;
2604
2605 /* If there's no special whitespace regexp, treat
2606 spaces normally. And don't try to do this recursively. */
2607 if (!whitespace_regexp || in_subpattern)
2608 goto normal_char;
2609
2610 /* Peek past following spaces. */
2611 while (p1 != pend)
2612 {
2613 if (*p1 != ' ')
2614 break;
2615 p1++;
2616 }
2617 /* If the spaces are followed by a repetition op,
2618 treat them normally. */
2619 if (p1 != pend
2620 && (*p1 == '*' || *p1 == '+' || *p1 == '?'
2621 || (*p1 == '\\' && p1 + 1 != pend && p1[1] == '{')))
2622 goto normal_char;
2623
2624 /* Replace the spaces with the whitespace regexp. */
2625 in_subpattern = 1;
2626 main_p = p1;
2627 main_pend = pend;
2628 main_pattern = pattern;
2629 p = pattern = whitespace_regexp;
2630 pend = p + strlen (p);
2631 break;
2632 }
2633
2566 case '^': 2634 case '^':
2567 { 2635 {
2568 if ( /* If at start of pattern, it's an operator. */ 2636 if ( /* If at start of pattern, it's an operator. */
@@ -3231,9 +3299,6 @@ regex_compile (pattern, size, syntax, bufp)
3231 3299
3232 beg_interval = p; 3300 beg_interval = p;
3233 3301
3234 if (p == pend)
3235 FREE_STACK_RETURN (REG_EBRACE);
3236
3237 GET_UNSIGNED_NUMBER (lower_bound); 3302 GET_UNSIGNED_NUMBER (lower_bound);
3238 3303
3239 if (c == ',') 3304 if (c == ',')
@@ -3250,7 +3315,8 @@ regex_compile (pattern, size, syntax, bufp)
3250 { 3315 {
3251 if (c != '\\') 3316 if (c != '\\')
3252 FREE_STACK_RETURN (REG_BADBR); 3317 FREE_STACK_RETURN (REG_BADBR);
3253 3318 if (p == pend)
3319 FREE_STACK_RETURN (REG_EESCAPE);
3254 PATFETCH (c); 3320 PATFETCH (c);
3255 } 3321 }
3256 3322
diff --git a/src/s/darwin.h b/src/s/darwin.h
index f854ed9380b..9f78405a43c 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -217,6 +217,13 @@ Boston, MA 02111-1307, USA. */
217/* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ 217/* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */
218#define HAVE_SOCKETS 218#define HAVE_SOCKETS
219 219
220/* In Carbon, asynchronous I/O (using SIGIO) can't be used for window
221 events because they don't come from sockets, even though it works
222 fine on tty's. */
223#ifdef HAVE_CARBON
224#define NO_SOCK_SIGIO
225#endif
226
220/* Extra initialization calls in main for Mac OS X system type. */ 227/* Extra initialization calls in main for Mac OS X system type. */
221#ifdef HAVE_CARBON 228#ifdef HAVE_CARBON
222#define SYMS_SYSTEM syms_of_mac() 229#define SYMS_SYSTEM syms_of_mac()
@@ -314,6 +321,10 @@ struct kboard;
314#define free unexec_free 321#define free unexec_free
315#endif 322#endif
316 323
324/* This makes create_process in process.c save and restore signal
325 handlers correctly. Suggested by Nozomu Ando.*/
326#define POSIX_SIGNALS
327
317/* Reroute calls to SELECT to the version defined in mac.c to fix the 328/* Reroute calls to SELECT to the version defined in mac.c to fix the
318 problem of Emacs requiring an extra return to be typed to start 329 problem of Emacs requiring an extra return to be typed to start
319 working when started from the command line. */ 330 working when started from the command line. */
diff --git a/src/s/gnu-linux.h b/src/s/gnu-linux.h
index 033ce49293a..3cf21756d7d 100644
--- a/src/s/gnu-linux.h
+++ b/src/s/gnu-linux.h
@@ -1,5 +1,5 @@
1/* This file is the configuration file for Linux-based GNU systems 1/* This file is the configuration file for Linux-based GNU systems
2 Copyright (C) 1985, 86, 92, 94, 96, 1999, 2002 Free Software Foundation, Inc. 2 Copyright (C) 1985, 86, 92, 94, 96, 1999, 2002, 2004 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -355,12 +355,22 @@ Boston, MA 02111-1307, USA. */
355 355
356#if defined __i386__ || defined __sparc__ || defined __mc68000__ \ 356#if defined __i386__ || defined __sparc__ || defined __mc68000__ \
357 || defined __alpha__ || defined __mips__ || defined __s390__ \ 357 || defined __alpha__ || defined __mips__ || defined __s390__ \
358 || defined __arm__ || defined __powerpc__ || defined __amd64__ 358 || defined __arm__ || defined __powerpc__ || defined __amd64__ \
359 || defined __ia64__
359#define GC_SETJMP_WORKS 1 360#define GC_SETJMP_WORKS 1
360#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS 361#define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS
361#ifdef __mc68000__ 362#ifdef __mc68000__
362#define GC_LISP_OBJECT_ALIGNMENT 2 363#define GC_LISP_OBJECT_ALIGNMENT 2
363#endif 364#endif
365#ifdef __ia64__
366#define GC_MARK_SECONDARY_STACK() \
367 do { \
368 extern void *__libc_ia64_register_backing_store_base; \
369 __builtin_ia64_flushrs (); \
370 mark_memory (__libc_ia64_register_backing_store_base, \
371 __builtin_ia64_bsp ()); \
372 } while (0)
373#endif
364#endif 374#endif
365 375
366/* arch-tag: 6244ea2a-abd0-44ec-abec-ff3dcc9afea9 376/* arch-tag: 6244ea2a-abd0-44ec-abec-ff3dcc9afea9
diff --git a/src/search.c b/src/search.c
index 59539de8768..41b71934e9f 100644
--- a/src/search.c
+++ b/src/search.c
@@ -41,7 +41,7 @@ Boston, MA 02111-1307, USA. */
41struct regexp_cache 41struct regexp_cache
42{ 42{
43 struct regexp_cache *next; 43 struct regexp_cache *next;
44 Lisp_Object regexp; 44 Lisp_Object regexp, whitespace_regexp;
45 struct re_pattern_buffer buf; 45 struct re_pattern_buffer buf;
46 char fastmap[0400]; 46 char fastmap[0400];
47 /* Nonzero means regexp was compiled to do full POSIX backtracking. */ 47 /* Nonzero means regexp was compiled to do full POSIX backtracking. */
@@ -83,6 +83,8 @@ static Lisp_Object last_thing_searched;
83 83
84Lisp_Object Qinvalid_regexp; 84Lisp_Object Qinvalid_regexp;
85 85
86Lisp_Object Vsearch_spaces_regexp;
87
86static void set_search_regs (); 88static void set_search_regs ();
87static void save_search_regs (); 89static void save_search_regs ();
88static int simple_search (); 90static int simple_search ();
@@ -1018,7 +1020,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1018 return pos; 1020 return pos;
1019 } 1021 }
1020 1022
1021 if (RE && !trivial_regexp_p (string)) 1023 if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
1022 { 1024 {
1023 unsigned char *p1, *p2; 1025 unsigned char *p1, *p2;
1024 int s1, s2; 1026 int s1, s2;
@@ -2801,7 +2803,7 @@ LIST should have been created by calling `match-data' previously. */)
2801 else 2803 else
2802 { 2804 {
2803 int from; 2805 int from;
2804 2806
2805 if (MARKERP (marker)) 2807 if (MARKERP (marker))
2806 { 2808 {
2807 if (XMARKER (marker)->buffer == 0) 2809 if (XMARKER (marker)->buffer == 0)
@@ -2809,15 +2811,15 @@ LIST should have been created by calling `match-data' previously. */)
2809 else 2811 else
2810 XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer); 2812 XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer);
2811 } 2813 }
2812 2814
2813 CHECK_NUMBER_COERCE_MARKER (marker); 2815 CHECK_NUMBER_COERCE_MARKER (marker);
2814 from = XINT (marker); 2816 from = XINT (marker);
2815 list = Fcdr (list); 2817 list = Fcdr (list);
2816 2818
2817 marker = Fcar (list); 2819 marker = Fcar (list);
2818 if (MARKERP (marker) && XMARKER (marker)->buffer == 0) 2820 if (MARKERP (marker) && XMARKER (marker)->buffer == 0)
2819 XSETFASTINT (marker, 0); 2821 XSETFASTINT (marker, 0);
2820 2822
2821 CHECK_NUMBER_COERCE_MARKER (marker); 2823 CHECK_NUMBER_COERCE_MARKER (marker);
2822 search_regs.start[i] = from; 2824 search_regs.start[i] = from;
2823 search_regs.end[i] = XINT (marker); 2825 search_regs.end[i] = XINT (marker);
@@ -2926,6 +2928,7 @@ syms_of_search ()
2926 searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100); 2928 searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100);
2927 searchbufs[i].buf.fastmap = searchbufs[i].fastmap; 2929 searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
2928 searchbufs[i].regexp = Qnil; 2930 searchbufs[i].regexp = Qnil;
2931 searchbufs[i].whitespace_regexp = Qnil;
2929 staticpro (&searchbufs[i].regexp); 2932 staticpro (&searchbufs[i].regexp);
2930 searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]); 2933 searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]);
2931 } 2934 }
@@ -2952,6 +2955,14 @@ syms_of_search ()
2952 saved_last_thing_searched = Qnil; 2955 saved_last_thing_searched = Qnil;
2953 staticpro (&saved_last_thing_searched); 2956 staticpro (&saved_last_thing_searched);
2954 2957
2958 DEFVAR_LISP ("search-spaces-regexp", &Vsearch_spaces_regexp,
2959 doc: /* Regexp to substitute for bunches of spaces in regexp search.
2960Some commands use this for user-specified regexps.
2961Spaces that occur inside character classes or repetition operators
2962or other such regexp constructs are not replaced with this.
2963A value of nil (which is the normal value) means treat spaces literally. */);
2964 Vsearch_spaces_regexp = Qnil;
2965
2955 defsubr (&Slooking_at); 2966 defsubr (&Slooking_at);
2956 defsubr (&Sposix_looking_at); 2967 defsubr (&Sposix_looking_at);
2957 defsubr (&Sstring_match); 2968 defsubr (&Sstring_match);
diff --git a/src/sysdep.c b/src/sysdep.c
index b120dcd950d..6284774d092 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1,6 +1,6 @@
1/* Interfaces to system-dependent kernel and library entries. 1/* Interfaces to system-dependent kernel and library entries.
2 Copyright (C) 1985, 86,87,88,93,94,95,1999,2000,01,2003 2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001,
3 Free Software Foundation, Inc. 3 2003, 2004 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -2768,12 +2768,16 @@ sys_signal (int signal_number, signal_handler_t action)
2768 struct sigaction new_action, old_action; 2768 struct sigaction new_action, old_action;
2769 sigemptyset (&new_action.sa_mask); 2769 sigemptyset (&new_action.sa_mask);
2770 new_action.sa_handler = action; 2770 new_action.sa_handler = action;
2771#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) 2771#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) && !defined(SYNC_INPUT)
2772 /* Emacs mostly works better with restartable system services. If this 2772 /* Emacs mostly works better with restartable system services. If this
2773 flag exists, we probably want to turn it on here. 2773 flag exists, we probably want to turn it on here.
2774 However, on some systems this resets the timeout of `select' 2774 However, on some systems this resets the timeout of `select'
2775 which means that `select' never finishes if it keeps getting signals. 2775 which means that `select' never finishes if it keeps getting signals.
2776 BROKEN_SA_RESTART is defined on those systems. */ 2776 BROKEN_SA_RESTART is defined on those systems. */
2777 /* It's not clear why the comment above says "mostly works better". --Stef
2778 When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll
2779 for pending input so we need long-running syscalls to be interrupted
2780 after a signal that sets the interrupt_input_pending flag. */
2777 new_action.sa_flags = SA_RESTART; 2781 new_action.sa_flags = SA_RESTART;
2778#else 2782#else
2779 new_action.sa_flags = 0; 2783 new_action.sa_flags = 0;
@@ -3225,7 +3229,8 @@ emacs_open (path, oflag, mode)
3225#endif 3229#endif
3226 3230
3227 while ((rtnval = open (path, oflag, mode)) == -1 3231 while ((rtnval = open (path, oflag, mode)) == -1
3228 && (errno == EINTR)); 3232 && (errno == EINTR))
3233 QUIT;
3229 return (rtnval); 3234 return (rtnval);
3230} 3235}
3231 3236
@@ -3258,7 +3263,8 @@ emacs_read (fildes, buf, nbyte)
3258 register int rtnval; 3263 register int rtnval;
3259 3264
3260 while ((rtnval = read (fildes, buf, nbyte)) == -1 3265 while ((rtnval = read (fildes, buf, nbyte)) == -1
3261 && (errno == EINTR)); 3266 && (errno == EINTR))
3267 QUIT;
3262 return (rtnval); 3268 return (rtnval);
3263} 3269}
3264 3270
@@ -3279,7 +3285,15 @@ emacs_write (fildes, buf, nbyte)
3279 if (rtnval == -1) 3285 if (rtnval == -1)
3280 { 3286 {
3281 if (errno == EINTR) 3287 if (errno == EINTR)
3282 continue; 3288 {
3289#ifdef SYNC_INPUT
3290 /* I originally used `QUIT' but that might causes files to
3291 be truncated if you hit C-g in the middle of it. --Stef */
3292 if (interrupt_input_pending)
3293 handle_async_input ();
3294#endif
3295 continue;
3296 }
3283 else 3297 else
3284 return (bytes_written ? bytes_written : -1); 3298 return (bytes_written ? bytes_written : -1);
3285 } 3299 }
diff --git a/src/term.c b/src/term.c
index 609efcb8439..1520a96babd 100644
--- a/src/term.c
+++ b/src/term.c
@@ -954,9 +954,14 @@ write_glyphs (string, len)
954 954
955 cmplus (len); 955 cmplus (len);
956 956
957 /* If terminal_coding does any conversion, use it, otherwise use
958 safe_terminal_coding. We can't use CODING_REQUIRE_ENCODING here
959 because it always return 1 if the member src_multibyte is 1. */
960 coding = (terminal_coding.common_flags & CODING_REQUIRE_ENCODING_MASK
961 ? &terminal_coding : &safe_terminal_coding);
957 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at 962 /* The mode bit CODING_MODE_LAST_BLOCK should be set to 1 only at
958 the tail. */ 963 the tail. */
959 terminal_coding.mode &= ~CODING_MODE_LAST_BLOCK; 964 coding->mode &= ~CODING_MODE_LAST_BLOCK;
960 965
961 while (len > 0) 966 while (len > 0)
962 { 967 {
@@ -1006,6 +1011,9 @@ insert_glyphs (start, len)
1006 char *buf; 1011 char *buf;
1007 struct glyph *glyph = NULL; 1012 struct glyph *glyph = NULL;
1008 struct frame *f, *sf; 1013 struct frame *f, *sf;
1014 unsigned char *conversion_buffer;
1015 unsigned char space[1];
1016 struct coding_system *coding;
1009 1017
1010 if (len <= 0) 1018 if (len <= 0)
1011 return; 1019 return;
@@ -2239,6 +2247,8 @@ term_init (terminal_type)
2239 int status; 2247 int status;
2240 struct frame *sf = XFRAME (selected_frame); 2248 struct frame *sf = XFRAME (selected_frame);
2241 2249
2250 encode_terminal_bufsize = 0;
2251
2242#ifdef WINDOWSNT 2252#ifdef WINDOWSNT
2243 initialize_w32_display (); 2253 initialize_w32_display ();
2244 2254
diff --git a/src/w32console.c b/src/w32console.c
index cd71f0ba6ad..170ce5508be 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -296,6 +296,9 @@ w32con_insert_glyphs (register struct glyph *start, register int len)
296 296
297extern unsigned char *terminal_encode_buffer; 297extern unsigned char *terminal_encode_buffer;
298 298
299extern unsigned char *encode_terminal_code P_ ((struct glyph *, int,
300 struct coding_system *));
301
299static void 302static void
300w32con_write_glyphs (register struct glyph *string, register int len) 303w32con_write_glyphs (register struct glyph *string, register int len)
301{ 304{
diff --git a/src/w32term.c b/src/w32term.c
index f50f5a49e8a..da24d2051ea 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -287,7 +287,7 @@ static void x_frame_rehighlight P_ ((struct w32_display_info *));
287static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 287static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
288static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 288static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
289 enum text_cursor_kinds)); 289 enum text_cursor_kinds));
290static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, HDC)); 290static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, int, HDC));
291 291
292static Lisp_Object Qvendor_specific_keysyms; 292static Lisp_Object Qvendor_specific_keysyms;
293 293
@@ -718,12 +718,12 @@ w32_draw_fringe_bitmap (w, row, p)
718 int oldVH = row->visible_height; 718 int oldVH = row->visible_height;
719 row->visible_height = p->h; 719 row->visible_height = p->h;
720 row->y -= rowY - p->y; 720 row->y -= rowY - p->y;
721 w32_clip_to_row (w, row, hdc); 721 w32_clip_to_row (w, row, -1, hdc);
722 row->y = oldY; 722 row->y = oldY;
723 row->visible_height = oldVH; 723 row->visible_height = oldVH;
724 } 724 }
725 else 725 else
726 w32_clip_to_row (w, row, hdc); 726 w32_clip_to_row (w, row, -1, hdc);
727 727
728 if (p->bx >= 0 && !p->overlay_p) 728 if (p->bx >= 0 && !p->overlay_p)
729 { 729 {
@@ -5063,18 +5063,19 @@ w32_read_socket (sd, expected, hold_quit)
5063 mode lines must be clipped to the whole window. */ 5063 mode lines must be clipped to the whole window. */
5064 5064
5065static void 5065static void
5066w32_clip_to_row (w, row, hdc) 5066w32_clip_to_row (w, row, area, hdc)
5067 struct window *w; 5067 struct window *w;
5068 struct glyph_row *row; 5068 struct glyph_row *row;
5069 int area;
5069 HDC hdc; 5070 HDC hdc;
5070{ 5071{
5071 struct frame *f = XFRAME (WINDOW_FRAME (w)); 5072 struct frame *f = XFRAME (WINDOW_FRAME (w));
5072 RECT clip_rect; 5073 RECT clip_rect;
5073 int window_y, window_width; 5074 int window_x, window_y, window_width;
5074 5075
5075 window_box (w, -1, 0, &window_y, &window_width, 0); 5076 window_box (w, area, &window_x, &window_y, &window_width, 0);
5076 5077
5077 clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0); 5078 clip_rect.left = window_x;
5078 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 5079 clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
5079 clip_rect.top = max (clip_rect.top, window_y); 5080 clip_rect.top = max (clip_rect.top, window_y);
5080 clip_rect.right = clip_rect.left + window_width; 5081 clip_rect.right = clip_rect.left + window_width;
@@ -5134,7 +5135,7 @@ x_draw_hollow_cursor (w, row)
5134 rect.right = rect.left + wd; 5135 rect.right = rect.left + wd;
5135 hdc = get_frame_dc (f); 5136 hdc = get_frame_dc (f);
5136 /* Set clipping, draw the rectangle, and reset clipping again. */ 5137 /* Set clipping, draw the rectangle, and reset clipping again. */
5137 w32_clip_to_row (w, row, hdc); 5138 w32_clip_to_row (w, row, TEXT_AREA, hdc);
5138 FrameRect (hdc, &rect, hb); 5139 FrameRect (hdc, &rect, hb);
5139 DeleteObject (hb); 5140 DeleteObject (hb);
5140 w32_set_clip_rectangle (hdc, NULL); 5141 w32_set_clip_rectangle (hdc, NULL);
@@ -5200,7 +5201,7 @@ x_draw_bar_cursor (w, row, width, kind)
5200 5201
5201 5202
5202 hdc = get_frame_dc (f); 5203 hdc = get_frame_dc (f);
5203 w32_clip_to_row (w, row, hdc); 5204 w32_clip_to_row (w, row, TEXT_AREA, hdc);
5204 5205
5205 if (kind == BAR_CURSOR) 5206 if (kind == BAR_CURSOR)
5206 { 5207 {
diff --git a/src/window.c b/src/window.c
index 3f8fa513619..a07bd437faa 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1611,7 +1611,7 @@ decode_next_window_args (window, minibuf, all_frames)
1611 : Qnil); 1611 : Qnil);
1612 else if (EQ (*all_frames, Qvisible)) 1612 else if (EQ (*all_frames, Qvisible))
1613 ; 1613 ;
1614 else if (XFASTINT (*all_frames) == 0) 1614 else if (EQ (*all_frames, make_number (0)))
1615 ; 1615 ;
1616 else if (FRAMEP (*all_frames)) 1616 else if (FRAMEP (*all_frames))
1617 ; 1617 ;
@@ -1885,7 +1885,7 @@ window_loop (type, obj, mini, frames)
1885 1885
1886 if (f) 1886 if (f)
1887 frame_arg = Qlambda; 1887 frame_arg = Qlambda;
1888 else if (XFASTINT (frames) == 0) 1888 else if (EQ (frames, make_number (0)))
1889 frame_arg = frames; 1889 frame_arg = frames;
1890 else if (EQ (frames, Qvisible)) 1890 else if (EQ (frames, Qvisible))
1891 frame_arg = frames; 1891 frame_arg = frames;
@@ -2097,6 +2097,8 @@ DEFUN ("get-lru-window", Fget_lru_window, Sget_lru_window, 0, 1, 0,
2097 doc: /* Return the window least recently selected or used for display. 2097 doc: /* Return the window least recently selected or used for display.
2098Return a full-width window if possible. 2098Return a full-width window if possible.
2099A minibuffer window is never a candidate. 2099A minibuffer window is never a candidate.
2100A dedicated window is never a candidate, so if all windows are dedicated,
2101the value is nil.
2100If optional argument FRAME is `visible', search all visible frames. 2102If optional argument FRAME is `visible', search all visible frames.
2101If FRAME is 0, search all visible and iconified frames. 2103If FRAME is 0, search all visible and iconified frames.
2102If FRAME is t, search all frames. 2104If FRAME is t, search all frames.
@@ -2117,6 +2119,8 @@ If FRAME is a frame, search only that frame. */)
2117DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0, 2119DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0,
2118 doc: /* Return the largest window in area. 2120 doc: /* Return the largest window in area.
2119A minibuffer window is never a candidate. 2121A minibuffer window is never a candidate.
2122A dedicated window is never a candidate, so if all windows are dedicated,
2123the value is nil.
2120If optional argument FRAME is `visible', search all visible frames. 2124If optional argument FRAME is `visible', search all visible frames.
2121If FRAME is 0, search all visible and iconified frames. 2125If FRAME is 0, search all visible and iconified frames.
2122If FRAME is t, search all frames. 2126If FRAME is t, search all frames.
@@ -2694,7 +2698,7 @@ shrink_windows (total, size, nchildren, shrinkable,
2694 ++nonzero_sizes; 2698 ++nonzero_sizes;
2695 nonzero_idx = i; 2699 nonzero_idx = i;
2696 } 2700 }
2697 2701
2698 for (i = 0; i < nchildren; ++i) 2702 for (i = 0; i < nchildren; ++i)
2699 if (new_sizes[i] > min_size) 2703 if (new_sizes[i] > min_size)
2700 { 2704 {
@@ -3012,6 +3016,9 @@ set_window_buffer (window, buffer, run_hooks_p, keep_margins_p)
3012 if (EQ (window, selected_window)) 3016 if (EQ (window, selected_window))
3013 b->last_selected_window = window; 3017 b->last_selected_window = window;
3014 3018
3019 /* Let redisplay errors through. */
3020 b->display_error_modiff = 0;
3021
3015 /* Update time stamps of buffer display. */ 3022 /* Update time stamps of buffer display. */
3016 if (INTEGERP (b->display_count)) 3023 if (INTEGERP (b->display_count))
3017 XSETINT (b->display_count, XINT (b->display_count) + 1); 3024 XSETINT (b->display_count, XINT (b->display_count) + 1);
@@ -6178,10 +6185,12 @@ If TYPE is t, use the frame's scroll-bar type. */)
6178 struct window *w = decode_window (window); 6185 struct window *w = decode_window (window);
6179 6186
6180 if (!NILP (width)) 6187 if (!NILP (width))
6181 CHECK_NATNUM (width); 6188 {
6189 CHECK_NATNUM (width);
6182 6190
6183 if (XINT (width) == 0) 6191 if (XINT (width) == 0)
6184 vertical_type = Qnil; 6192 vertical_type = Qnil;
6193 }
6185 6194
6186 if (!(EQ (vertical_type, Qnil) 6195 if (!(EQ (vertical_type, Qnil)
6187 || EQ (vertical_type, Qleft) 6196 || EQ (vertical_type, Qleft)
diff --git a/src/xdisp.c b/src/xdisp.c
index d4445cfec1a..c50edb98561 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -810,7 +810,7 @@ static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
810 810
811/* Function prototypes. */ 811/* Function prototypes. */
812 812
813static void setup_for_ellipsis P_ ((struct it *)); 813static void setup_for_ellipsis P_ ((struct it *, int));
814static void mark_window_display_accurate_1 P_ ((struct window *, int)); 814static void mark_window_display_accurate_1 P_ ((struct window *, int));
815static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object)); 815static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
816static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object)); 816static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
@@ -3230,7 +3230,7 @@ handle_invisible_prop (it)
3230 it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p; 3230 it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
3231 } 3231 }
3232 else if (display_ellipsis_p) 3232 else if (display_ellipsis_p)
3233 setup_for_ellipsis (it); 3233 setup_for_ellipsis (it, 0);
3234 } 3234 }
3235 } 3235 }
3236 3236
@@ -3238,14 +3238,17 @@ handle_invisible_prop (it)
3238} 3238}
3239 3239
3240 3240
3241/* Make iterator IT return `...' next. */ 3241/* Make iterator IT return `...' next.
3242 Replaces LEN characters from buffer. */
3242 3243
3243static void 3244static void
3244setup_for_ellipsis (it) 3245setup_for_ellipsis (it, len)
3245 struct it *it; 3246 struct it *it;
3247 int len;
3246{ 3248{
3247 if (it->dp 3249 /* Use the display table definition for `...'. Invalid glyphs
3248 && VECTORP (DISP_INVIS_VECTOR (it->dp))) 3250 will be handled by the method returning elements from dpvec. */
3251 if (it->dp && VECTORP (DISP_INVIS_VECTOR (it->dp)))
3249 { 3252 {
3250 struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp)); 3253 struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
3251 it->dpvec = v->contents; 3254 it->dpvec = v->contents;
@@ -3258,12 +3261,12 @@ setup_for_ellipsis (it)
3258 it->dpend = default_invis_vector + 3; 3261 it->dpend = default_invis_vector + 3;
3259 } 3262 }
3260 3263
3261 /* The ellipsis display does not replace the display of the 3264 it->dpvec_char_len = len;
3262 character at the new position. Indicate this by setting
3263 IT->dpvec_char_len to zero. */
3264 it->dpvec_char_len = 0;
3265
3266 it->current.dpvec_index = 0; 3265 it->current.dpvec_index = 0;
3266
3267 /* Remember the current face id in case glyphs specify faces.
3268 IT's face is restored in set_iterator_to_next. */
3269 it->saved_face_id = it->face_id;
3267 it->method = next_element_from_display_vector; 3270 it->method = next_element_from_display_vector;
3268} 3271}
3269 3272
@@ -3578,7 +3581,7 @@ handle_single_display_prop (it, prop, object, position,
3578 || EQ (XCAR (prop), Qright_fringe)) 3581 || EQ (XCAR (prop), Qright_fringe))
3579 && CONSP (XCDR (prop))) 3582 && CONSP (XCDR (prop)))
3580 { 3583 {
3581 unsigned face_id = DEFAULT_FACE_ID; 3584 int face_id = DEFAULT_FACE_ID;
3582 int fringe_bitmap; 3585 int fringe_bitmap;
3583 3586
3584 /* Save current settings of IT so that we can restore them 3587 /* Save current settings of IT so that we can restore them
@@ -3597,10 +3600,9 @@ handle_single_display_prop (it, prop, object, position,
3597 if (CONSP (XCDR (XCDR (prop)))) 3600 if (CONSP (XCDR (XCDR (prop))))
3598 { 3601 {
3599 Lisp_Object face_name = XCAR (XCDR (XCDR (prop))); 3602 Lisp_Object face_name = XCAR (XCDR (XCDR (prop)));
3600 3603 int face_id2 = lookup_named_face (it->f, face_name, 0);
3601 face_id = lookup_named_face (it->f, face_name); 3604 if (face_id2 >= 0)
3602 if (face_id < 0) 3605 face_id = face_id2;
3603 return 0;
3604 } 3606 }
3605 3607
3606 push_it (it); 3608 push_it (it);
@@ -4145,7 +4147,7 @@ next_overlay_string (it)
4145 /* If we have to display `...' for invisible text, set 4147 /* If we have to display `...' for invisible text, set
4146 the iterator up for that. */ 4148 the iterator up for that. */
4147 if (display_ellipsis_p) 4149 if (display_ellipsis_p)
4148 setup_for_ellipsis (it); 4150 setup_for_ellipsis (it, 0);
4149 } 4151 }
4150 else 4152 else
4151 { 4153 {
@@ -4937,7 +4939,10 @@ get_next_display_element (it)
4937 we hit the end of what we iterate over. Performance note: the 4939 we hit the end of what we iterate over. Performance note: the
4938 function pointer `method' used here turns out to be faster than 4940 function pointer `method' used here turns out to be faster than
4939 using a sequence of if-statements. */ 4941 using a sequence of if-statements. */
4940 int success_p = (*it->method) (it); 4942 int success_p;
4943
4944 get_next:
4945 success_p = (*it->method) (it);
4941 4946
4942 if (it->what == IT_CHARACTER) 4947 if (it->what == IT_CHARACTER)
4943 { 4948 {
@@ -4969,14 +4974,14 @@ get_next_display_element (it)
4969 it->dpvec = v->contents; 4974 it->dpvec = v->contents;
4970 it->dpend = v->contents + v->size; 4975 it->dpend = v->contents + v->size;
4971 it->current.dpvec_index = 0; 4976 it->current.dpvec_index = 0;
4977 it->saved_face_id = it->face_id;
4972 it->method = next_element_from_display_vector; 4978 it->method = next_element_from_display_vector;
4973 success_p = get_next_display_element (it);
4974 } 4979 }
4975 else 4980 else
4976 { 4981 {
4977 set_iterator_to_next (it, 0); 4982 set_iterator_to_next (it, 0);
4978 success_p = get_next_display_element (it);
4979 } 4983 }
4984 goto get_next;
4980 } 4985 }
4981 4986
4982 /* Translate control characters into `\003' or `^C' form. 4987 /* Translate control characters into `\003' or `^C' form.
@@ -5008,6 +5013,7 @@ get_next_display_element (it)
5008 IT->ctl_chars with glyphs for what we have to 5013 IT->ctl_chars with glyphs for what we have to
5009 display. Then, set IT->dpvec to these glyphs. */ 5014 display. Then, set IT->dpvec to these glyphs. */
5010 GLYPH g; 5015 GLYPH g;
5016 int ctl_len;
5011 5017
5012 if (it->c < 128 && it->ctl_arrow_p) 5018 if (it->c < 128 && it->ctl_arrow_p)
5013 { 5019 {
@@ -5022,14 +5028,7 @@ get_next_display_element (it)
5022 5028
5023 g = FAST_MAKE_GLYPH (it->c ^ 0100, 0); 5029 g = FAST_MAKE_GLYPH (it->c ^ 0100, 0);
5024 XSETINT (it->ctl_chars[1], g); 5030 XSETINT (it->ctl_chars[1], g);
5025 5031 ctl_len = 2;
5026 /* Set up IT->dpvec and return first character from it. */
5027 it->dpvec_char_len = it->len;
5028 it->dpvec = it->ctl_chars;
5029 it->dpend = it->dpvec + 2;
5030 it->current.dpvec_index = 0;
5031 it->method = next_element_from_display_vector;
5032 get_next_display_element (it);
5033 } 5032 }
5034 else 5033 else
5035 { 5034 {
@@ -5082,16 +5081,17 @@ get_next_display_element (it)
5082 g = FAST_MAKE_GLYPH ((str[i] & 7) + '0', 0); 5081 g = FAST_MAKE_GLYPH ((str[i] & 7) + '0', 0);
5083 XSETINT (it->ctl_chars[i * 4 + 3], g); 5082 XSETINT (it->ctl_chars[i * 4 + 3], g);
5084 } 5083 }
5085 5084 ctl_len = len * 4;
5086 /* Set up IT->dpvec and return the first character
5087 from it. */
5088 it->dpvec_char_len = it->len;
5089 it->dpvec = it->ctl_chars;
5090 it->dpend = it->dpvec + len * 4;
5091 it->current.dpvec_index = 0;
5092 it->method = next_element_from_display_vector;
5093 get_next_display_element (it);
5094 } 5085 }
5086
5087 /* Set up IT->dpvec and return first character from it. */
5088 it->dpvec_char_len = it->len;
5089 it->dpvec = it->ctl_chars;
5090 it->dpend = it->dpvec + ctl_len;
5091 it->current.dpvec_index = 0;
5092 it->saved_face_id = it->face_id;
5093 it->method = next_element_from_display_vector;
5094 goto get_next;
5095 } 5095 }
5096 } 5096 }
5097 5097
@@ -5285,11 +5285,14 @@ set_iterator_to_next (it, reseat_p)
5285 && IT_STRING_CHARPOS (*it) >= 0)); 5285 && IT_STRING_CHARPOS (*it) >= 0));
5286} 5286}
5287 5287
5288
5289/* Load IT's display element fields with information about the next 5288/* Load IT's display element fields with information about the next
5290 display element which comes from a display table entry or from the 5289 display element which comes from a display table entry or from the
5291 result of translating a control character to one of the forms `^C' 5290 result of translating a control character to one of the forms `^C'
5292 or `\003'. IT->dpvec holds the glyphs to return as characters. */ 5291 or `\003'.
5292
5293 IT->dpvec holds the glyphs to return as characters.
5294 IT->saved_face_id holds the face id before the display vector--
5295 it is restored into IT->face_idin set_iterator_to_next. */
5293 5296
5294static int 5297static int
5295next_element_from_display_vector (it) 5298next_element_from_display_vector (it)
@@ -5298,10 +5301,6 @@ next_element_from_display_vector (it)
5298 /* Precondition. */ 5301 /* Precondition. */
5299 xassert (it->dpvec && it->current.dpvec_index >= 0); 5302 xassert (it->dpvec && it->current.dpvec_index >= 0);
5300 5303
5301 /* Remember the current face id in case glyphs specify faces.
5302 IT's face is restored in set_iterator_to_next. */
5303 it->saved_face_id = it->face_id;
5304
5305 if (INTEGERP (*it->dpvec) 5304 if (INTEGERP (*it->dpvec)
5306 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec))) 5305 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
5307 { 5306 {
@@ -5485,28 +5484,7 @@ next_element_from_ellipsis (it)
5485 struct it *it; 5484 struct it *it;
5486{ 5485{
5487 if (it->selective_display_ellipsis_p) 5486 if (it->selective_display_ellipsis_p)
5488 { 5487 setup_for_ellipsis (it, it->len);
5489 if (it->dp && VECTORP (DISP_INVIS_VECTOR (it->dp)))
5490 {
5491 /* Use the display table definition for `...'. Invalid glyphs
5492 will be handled by the method returning elements from dpvec. */
5493 struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
5494 it->dpvec_char_len = it->len;
5495 it->dpvec = v->contents;
5496 it->dpend = v->contents + v->size;
5497 it->current.dpvec_index = 0;
5498 it->method = next_element_from_display_vector;
5499 }
5500 else
5501 {
5502 /* Use default `...' which is stored in default_invis_vector. */
5503 it->dpvec_char_len = it->len;
5504 it->dpvec = default_invis_vector;
5505 it->dpend = default_invis_vector + 3;
5506 it->current.dpvec_index = 0;
5507 it->method = next_element_from_display_vector;
5508 }
5509 }
5510 else 5488 else
5511 { 5489 {
5512 /* The face at the current position may be different from the 5490 /* The face at the current position may be different from the
@@ -14633,7 +14611,9 @@ highlight_trailing_whitespace (f, row)
14633 && glyph->u.ch == ' ')) 14611 && glyph->u.ch == ' '))
14634 && trailing_whitespace_p (glyph->charpos)) 14612 && trailing_whitespace_p (glyph->charpos))
14635 { 14613 {
14636 int face_id = lookup_named_face (f, Qtrailing_whitespace); 14614 int face_id = lookup_named_face (f, Qtrailing_whitespace, 0);
14615 if (face_id < 0)
14616 return;
14637 14617
14638 while (glyph >= start 14618 while (glyph >= start
14639 && BUFFERP (glyph->object) 14619 && BUFFERP (glyph->object)
@@ -14726,8 +14706,10 @@ display_line (it)
14726 hscrolled. This may stop at an x-position < IT->first_visible_x 14706 hscrolled. This may stop at an x-position < IT->first_visible_x
14727 if the first glyph is partially visible or if we hit a line end. */ 14707 if the first glyph is partially visible or if we hit a line end. */
14728 if (it->current_x < it->first_visible_x) 14708 if (it->current_x < it->first_visible_x)
14729 move_it_in_display_line_to (it, ZV, it->first_visible_x, 14709 {
14730 MOVE_TO_POS | MOVE_TO_X); 14710 move_it_in_display_line_to (it, ZV, it->first_visible_x,
14711 MOVE_TO_POS | MOVE_TO_X);
14712 }
14731 14713
14732 /* Get the initial row height. This is either the height of the 14714 /* Get the initial row height. This is either the height of the
14733 text hscrolled, if there is any, or zero. */ 14715 text hscrolled, if there is any, or zero. */
@@ -15056,12 +15038,10 @@ display_line (it)
15056 { 15038 {
15057 if (!get_next_display_element (it)) 15039 if (!get_next_display_element (it))
15058 { 15040 {
15059#ifdef HAVE_WINDOW_SYSTEM
15060 it->continuation_lines_width = 0; 15041 it->continuation_lines_width = 0;
15061 row->ends_at_zv_p = 1; 15042 row->ends_at_zv_p = 1;
15062 row->exact_window_width_line_p = 1; 15043 row->exact_window_width_line_p = 1;
15063 break; 15044 break;
15064#endif /* HAVE_WINDOW_SYSTEM */
15065 } 15045 }
15066 if (ITERATOR_AT_END_OF_LINE_P (it)) 15046 if (ITERATOR_AT_END_OF_LINE_P (it))
15067 { 15047 {
@@ -18376,6 +18356,19 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
18376 return x_reached; 18356 return x_reached;
18377} 18357}
18378 18358
18359/* Expand row matrix if too narrow. Don't expand if area
18360 is not present. */
18361
18362#define IT_EXPAND_MATRIX_WIDTH(it, area) \
18363 { \
18364 if (!fonts_changed_p \
18365 && (it->glyph_row->glyphs[area] \
18366 < it->glyph_row->glyphs[area + 1])) \
18367 { \
18368 it->w->ncols_scale_factor++; \
18369 fonts_changed_p = 1; \
18370 } \
18371 }
18379 18372
18380/* Store one glyph for IT->char_to_display in IT->glyph_row. 18373/* Store one glyph for IT->char_to_display in IT->glyph_row.
18381 Called from x_produce_glyphs when IT->glyph_row is non-null. */ 18374 Called from x_produce_glyphs when IT->glyph_row is non-null. */
@@ -18413,11 +18406,8 @@ append_glyph (it)
18413 glyph->font_type = FONT_TYPE_UNKNOWN; 18406 glyph->font_type = FONT_TYPE_UNKNOWN;
18414 ++it->glyph_row->used[area]; 18407 ++it->glyph_row->used[area];
18415 } 18408 }
18416 else if (!fonts_changed_p) 18409 else
18417 { 18410 IT_EXPAND_MATRIX_WIDTH (it, area);
18418 it->w->ncols_scale_factor++;
18419 fonts_changed_p = 1;
18420 }
18421} 18411}
18422 18412
18423/* Store one glyph for the composition IT->cmp_id in IT->glyph_row. 18413/* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
@@ -18455,11 +18445,8 @@ append_composite_glyph (it)
18455 glyph->font_type = FONT_TYPE_UNKNOWN; 18445 glyph->font_type = FONT_TYPE_UNKNOWN;
18456 ++it->glyph_row->used[area]; 18446 ++it->glyph_row->used[area];
18457 } 18447 }
18458 else if (!fonts_changed_p) 18448 else
18459 { 18449 IT_EXPAND_MATRIX_WIDTH (it, area);
18460 it->w->ncols_scale_factor++;
18461 fonts_changed_p = 1;
18462 }
18463} 18450}
18464 18451
18465 18452
@@ -18629,11 +18616,8 @@ produce_image_glyph (it)
18629 glyph->font_type = FONT_TYPE_UNKNOWN; 18616 glyph->font_type = FONT_TYPE_UNKNOWN;
18630 ++it->glyph_row->used[area]; 18617 ++it->glyph_row->used[area];
18631 } 18618 }
18632 else if (!fonts_changed_p) 18619 else
18633 { 18620 IT_EXPAND_MATRIX_WIDTH (it, area);
18634 it->w->ncols_scale_factor++;
18635 fonts_changed_p = 1;
18636 }
18637 } 18621 }
18638} 18622}
18639 18623
@@ -18677,11 +18661,8 @@ append_stretch_glyph (it, object, width, height, ascent)
18677 glyph->font_type = FONT_TYPE_UNKNOWN; 18661 glyph->font_type = FONT_TYPE_UNKNOWN;
18678 ++it->glyph_row->used[area]; 18662 ++it->glyph_row->used[area];
18679 } 18663 }
18680 else if (!fonts_changed_p) 18664 else
18681 { 18665 IT_EXPAND_MATRIX_WIDTH (it, area);
18682 it->w->ncols_scale_factor++;
18683 fonts_changed_p = 1;
18684 }
18685} 18666}
18686 18667
18687 18668
@@ -18912,7 +18893,7 @@ calc_line_height_property (it, prop, font, boff, total)
18912 struct face *face; 18893 struct face *face;
18913 struct font_info *font_info; 18894 struct font_info *font_info;
18914 18895
18915 face_id = lookup_named_face (it->f, face_name); 18896 face_id = lookup_named_face (it->f, face_name, 0);
18916 if (face_id < 0) 18897 if (face_id < 0)
18917 return make_number (-1); 18898 return make_number (-1);
18918 18899
@@ -20264,6 +20245,7 @@ erase_phys_cursor (w)
20264 { 20245 {
20265 int x, y; 20246 int x, y;
20266 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w); 20247 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
20248 int width;
20267 20249
20268 cursor_glyph = get_phys_cursor_glyph (w); 20250 cursor_glyph = get_phys_cursor_glyph (w);
20269 if (cursor_glyph == NULL) 20251 if (cursor_glyph == NULL)
@@ -20271,9 +20253,10 @@ erase_phys_cursor (w)
20271 20253
20272 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 20254 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
20273 y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y)); 20255 y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y));
20256 width = min (cursor_glyph->pixel_width,
20257 window_box_width (w, TEXT_AREA) - w->phys_cursor.x);
20274 20258
20275 rif->clear_frame_area (f, x, y, 20259 rif->clear_frame_area (f, x, y, width, cursor_row->visible_height);
20276 cursor_glyph->pixel_width, cursor_row->visible_height);
20277 } 20260 }
20278 20261
20279 /* Erase the cursor by redrawing the character underneath it. */ 20262 /* Erase the cursor by redrawing the character underneath it. */
@@ -21094,13 +21077,16 @@ note_mode_line_or_margin_highlight (w, x, y, area)
21094 /* If we're on a string with `help-echo' text property, arrange 21077 /* If we're on a string with `help-echo' text property, arrange
21095 for the help to be displayed. This is done by setting the 21078 for the help to be displayed. This is done by setting the
21096 global variable help_echo_string to the help string. */ 21079 global variable help_echo_string to the help string. */
21097 help = Fget_text_property (pos, Qhelp_echo, string); 21080 if (NILP (help))
21098 if (!NILP (help))
21099 { 21081 {
21100 help_echo_string = help; 21082 help = Fget_text_property (pos, Qhelp_echo, string);
21101 XSETWINDOW (help_echo_window, w); 21083 if (!NILP (help))
21102 help_echo_object = string; 21084 {
21103 help_echo_pos = charpos; 21085 help_echo_string = help;
21086 XSETWINDOW (help_echo_window, w);
21087 help_echo_object = string;
21088 help_echo_pos = charpos;
21089 }
21104 } 21090 }
21105 21091
21106 if (NILP (pointer)) 21092 if (NILP (pointer))
diff --git a/src/xfaces.c b/src/xfaces.c
index fc2cd6b0af4..1d20cc62a98 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3069,7 +3069,7 @@ the WIDTH times as wide as FACE on FRAME. */)
3069 { 3069 {
3070 /* This is of limited utility since it works with character 3070 /* This is of limited utility since it works with character
3071 widths. Keep it for compatibility. --gerd. */ 3071 widths. Keep it for compatibility. --gerd. */
3072 int face_id = lookup_named_face (f, face); 3072 int face_id = lookup_named_face (f, face, 0);
3073 struct face *face = (face_id < 0 3073 struct face *face = (face_id < 0
3074 ? NULL 3074 ? NULL
3075 : FACE_FROM_ID (f, face_id)); 3075 : FACE_FROM_ID (f, face_id));
@@ -5015,7 +5015,7 @@ return the font name used for CHARACTER. */)
5015 else 5015 else
5016 { 5016 {
5017 struct frame *f = frame_or_selected_frame (frame, 1); 5017 struct frame *f = frame_or_selected_frame (frame, 1);
5018 int face_id = lookup_named_face (f, face); 5018 int face_id = lookup_named_face (f, face, 1);
5019 struct face *face = FACE_FROM_ID (f, face_id); 5019 struct face *face = FACE_FROM_ID (f, face_id);
5020 5020
5021 if (! face) 5021 if (! face)
@@ -5753,9 +5753,10 @@ lookup_non_ascii_face (f, font_id, base_face)
5753 face isn't realized and cannot be realized. */ 5753 face isn't realized and cannot be realized. */
5754 5754
5755int 5755int
5756lookup_named_face (f, symbol) 5756lookup_named_face (f, symbol, signal_p)
5757 struct frame *f; 5757 struct frame *f;
5758 Lisp_Object symbol; 5758 Lisp_Object symbol;
5759 int signal_p;
5759{ 5760{
5760 Lisp_Object attrs[LFACE_VECTOR_SIZE]; 5761 Lisp_Object attrs[LFACE_VECTOR_SIZE];
5761 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; 5762 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
@@ -5768,7 +5769,9 @@ lookup_named_face (f, symbol)
5768 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); 5769 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
5769 } 5770 }
5770 5771
5771 get_lface_attributes (f, symbol, symbol_attrs, 1); 5772 if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p))
5773 return -1;
5774
5772 bcopy (default_face->lface, attrs, sizeof attrs); 5775 bcopy (default_face->lface, attrs, sizeof attrs);
5773 merge_face_vectors (f, symbol_attrs, attrs, 0); 5776 merge_face_vectors (f, symbol_attrs, attrs, 0);
5774 5777
@@ -5789,7 +5792,7 @@ ascii_face_of_lisp_face (f, lface_id)
5789 if (lface_id >= 0 && lface_id < lface_id_to_name_size) 5792 if (lface_id >= 0 && lface_id < lface_id_to_name_size)
5790 { 5793 {
5791 Lisp_Object face_name = lface_id_to_name[lface_id]; 5794 Lisp_Object face_name = lface_id_to_name[lface_id];
5792 face_id = lookup_named_face (f, face_name); 5795 face_id = lookup_named_face (f, face_name, 1);
5793 } 5796 }
5794 else 5797 else
5795 face_id = -1; 5798 face_id = -1;
diff --git a/src/xfns.c b/src/xfns.c
index 1f9098b2d24..36ef3a76bcf 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -152,6 +152,10 @@ char *gray_bitmap_bits = gray_bits;
152 152
153int display_hourglass_p; 153int display_hourglass_p;
154 154
155/* Non-zero means prompt with the old GTK file selection dialog. */
156
157int x_use_old_gtk_file_dialog;
158
155/* The background and shape of the mouse pointer, and shape when not 159/* The background and shape of the mouse pointer, and shape when not
156 over text or in the modeline. */ 160 over text or in the modeline. */
157 161
@@ -5558,6 +5562,14 @@ such a font. This is especially effective for such large fonts as
5558Chinese, Japanese, and Korean. */); 5562Chinese, Japanese, and Korean. */);
5559 Vx_pixel_size_width_font_regexp = Qnil; 5563 Vx_pixel_size_width_font_regexp = Qnil;
5560 5564
5565/* This is not ifdef:ed, so other builds than GTK can customize it. */
5566 DEFVAR_BOOL ("x-use-old-gtk-file-dialog", &x_use_old_gtk_file_dialog,
5567 doc: /* *Non-nil means prompt with the old GTK file selection dialog.
5568If nil or if the file selection dialog is not available, the new GTK file
5569chooser is used instead. To turn off all file dialogs set the
5570variable `use-file-dialog'. */);
5571 x_use_old_gtk_file_dialog = 0;
5572
5561#ifdef USE_X_TOOLKIT 5573#ifdef USE_X_TOOLKIT
5562 Fprovide (intern ("x-toolkit"), Qnil); 5574 Fprovide (intern ("x-toolkit"), Qnil);
5563#ifdef USE_MOTIF 5575#ifdef USE_MOTIF
@@ -5577,14 +5589,6 @@ Chinese, Japanese, and Korean. */);
5577 Fprovide (intern ("x-toolkit"), Qnil); 5589 Fprovide (intern ("x-toolkit"), Qnil);
5578 Fprovide (intern ("gtk"), Qnil); 5590 Fprovide (intern ("gtk"), Qnil);
5579 5591
5580#ifdef HAVE_GTK_FILE_BOTH
5581 DEFVAR_BOOL ("use-old-gtk-file-dialog", &use_old_gtk_file_dialog,
5582 doc: /* *Non-nil means that the old GTK file selection dialog is used.
5583If nil the new GTK file chooser is used instead. To turn off
5584all file dialogs set the variable `use-file-dialog'. */);
5585 use_old_gtk_file_dialog = 0;
5586#endif
5587
5588 DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string, 5592 DEFVAR_LISP ("gtk-version-string", &Vgtk_version_string,
5589 doc: /* Version info for GTK+. */); 5593 doc: /* Version info for GTK+. */);
5590 { 5594 {
diff --git a/src/xmenu.c b/src/xmenu.c
index 6899b91ebd7..e803680c6ec 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -741,8 +741,7 @@ POSITION is a position specification. This is either a mouse button event
741or a list ((XOFFSET YOFFSET) WINDOW) 741or a list ((XOFFSET YOFFSET) WINDOW)
742where XOFFSET and YOFFSET are positions in pixels from the top left 742where XOFFSET and YOFFSET are positions in pixels from the top left
743corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.) 743corner of WINDOW's frame. (WINDOW may be a frame object instead of a window.)
744This controls the position of the center of the first line 744This controls the position of the top left of the menu as a whole.
745in the first pane of the menu, not the top left of the menu as a whole.
746If POSITION is t, it means to use the current mouse position. 745If POSITION is t, it means to use the current mouse position.
747 746
748MENU is a specifier for a menu. For the simplest case, MENU is a keymap. 747MENU is a specifier for a menu. For the simplest case, MENU is a keymap.
@@ -3256,7 +3255,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3256 char *datap; 3255 char *datap;
3257 int ulx, uly, width, height; 3256 int ulx, uly, width, height;
3258 int dispwidth, dispheight; 3257 int dispwidth, dispheight;
3259 int i, j; 3258 int i, j, lines, maxlines;
3260 int maxwidth; 3259 int maxwidth;
3261 int dummy_int; 3260 int dummy_int;
3262 unsigned int dummy_uint; 3261 unsigned int dummy_uint;
@@ -3287,31 +3286,8 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3287 3286
3288#ifdef HAVE_X_WINDOWS 3287#ifdef HAVE_X_WINDOWS
3289 /* Adjust coordinates to relative to the outer (window manager) window. */ 3288 /* Adjust coordinates to relative to the outer (window manager) window. */
3290 { 3289 x += FRAME_OUTER_TO_INNER_DIFF_X (f);
3291 Window child; 3290 y += FRAME_OUTER_TO_INNER_DIFF_Y (f);
3292 int win_x = 0, win_y = 0;
3293
3294 /* Find the position of the outside upper-left corner of
3295 the inner window, with respect to the outer window. */
3296 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window)
3297 {
3298 BLOCK_INPUT;
3299 XTranslateCoordinates (FRAME_X_DISPLAY (f),
3300
3301 /* From-window, to-window. */
3302 f->output_data.x->window_desc,
3303 f->output_data.x->parent_desc,
3304
3305 /* From-position, to-position. */
3306 0, 0, &win_x, &win_y,
3307
3308 /* Child of window. */
3309 &child);
3310 UNBLOCK_INPUT;
3311 x += win_x;
3312 y += win_y;
3313 }
3314 }
3315#endif /* HAVE_X_WINDOWS */ 3291#endif /* HAVE_X_WINDOWS */
3316 3292
3317 /* Adjust coordinates to be root-window-relative. */ 3293 /* Adjust coordinates to be root-window-relative. */
@@ -3319,7 +3295,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3319 y += f->top_pos; 3295 y += f->top_pos;
3320 3296
3321 /* Create all the necessary panes and their items. */ 3297 /* Create all the necessary panes and their items. */
3322 i = 0; 3298 maxlines = lines = i = 0;
3323 while (i < menu_items_used) 3299 while (i < menu_items_used)
3324 { 3300 {
3325 if (EQ (XVECTOR (menu_items)->contents[i], Qt)) 3301 if (EQ (XVECTOR (menu_items)->contents[i], Qt))
@@ -3328,6 +3304,8 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3328 Lisp_Object pane_name, prefix; 3304 Lisp_Object pane_name, prefix;
3329 char *pane_string; 3305 char *pane_string;
3330 3306
3307 maxlines = max (maxlines, lines);
3308 lines = 0;
3331 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 3309 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
3332 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 3310 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
3333 pane_string = (NILP (pane_name) 3311 pane_string = (NILP (pane_name)
@@ -3420,9 +3398,12 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3420 return Qnil; 3398 return Qnil;
3421 } 3399 }
3422 i += MENU_ITEMS_ITEM_LENGTH; 3400 i += MENU_ITEMS_ITEM_LENGTH;
3401 lines++;
3423 } 3402 }
3424 } 3403 }
3425 3404
3405 maxlines = max (maxlines, lines);
3406
3426 /* All set and ready to fly. */ 3407 /* All set and ready to fly. */
3427 XMenuRecompute (FRAME_X_DISPLAY (f), menu); 3408 XMenuRecompute (FRAME_X_DISPLAY (f), menu);
3428 dispwidth = DisplayWidth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)); 3409 dispwidth = DisplayWidth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f));
@@ -3446,6 +3427,15 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3446 if (ulx < 0) x -= ulx; 3427 if (ulx < 0) x -= ulx;
3447 if (uly < 0) y -= uly; 3428 if (uly < 0) y -= uly;
3448 3429
3430 if (! for_click)
3431 {
3432 /* If position was not given by a mouse click, adjust so upper left
3433 corner of the menu as a whole ends up at given coordinates. This
3434 is what x-popup-menu says in its documentation. */
3435 x += width/2;
3436 y += 1.5*height/(maxlines+2);
3437 }
3438
3449 XMenuSetAEQ (menu, TRUE); 3439 XMenuSetAEQ (menu, TRUE);
3450 XMenuSetFreeze (menu, TRUE); 3440 XMenuSetFreeze (menu, TRUE);
3451 pane = selidx = 0; 3441 pane = selidx = 0;
diff --git a/src/xterm.c b/src/xterm.c
index c8c5d6e95c4..1f2b54272cc 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -358,7 +358,7 @@ static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
358static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int, 358static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
359 enum text_cursor_kinds)); 359 enum text_cursor_kinds));
360 360
361static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC)); 361static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC));
362static void x_flush P_ ((struct frame *f)); 362static void x_flush P_ ((struct frame *f));
363static void x_update_begin P_ ((struct frame *)); 363static void x_update_begin P_ ((struct frame *));
364static void x_update_window_begin P_ ((struct window *)); 364static void x_update_window_begin P_ ((struct window *));
@@ -710,12 +710,12 @@ x_draw_fringe_bitmap (w, row, p)
710 int oldVH = row->visible_height; 710 int oldVH = row->visible_height;
711 row->visible_height = p->h; 711 row->visible_height = p->h;
712 row->y -= rowY - p->y; 712 row->y -= rowY - p->y;
713 x_clip_to_row (w, row, gc); 713 x_clip_to_row (w, row, -1, gc);
714 row->y = oldY; 714 row->y = oldY;
715 row->visible_height = oldVH; 715 row->visible_height = oldVH;
716 } 716 }
717 else 717 else
718 x_clip_to_row (w, row, gc); 718 x_clip_to_row (w, row, -1, gc);
719 719
720 if (p->bx >= 0 && !p->overlay_p) 720 if (p->bx >= 0 && !p->overlay_p)
721 { 721 {
@@ -7142,18 +7142,19 @@ XTread_socket (sd, expected, hold_quit)
7142 mode lines must be clipped to the whole window. */ 7142 mode lines must be clipped to the whole window. */
7143 7143
7144static void 7144static void
7145x_clip_to_row (w, row, gc) 7145x_clip_to_row (w, row, area, gc)
7146 struct window *w; 7146 struct window *w;
7147 struct glyph_row *row; 7147 struct glyph_row *row;
7148 int area;
7148 GC gc; 7149 GC gc;
7149{ 7150{
7150 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7151 struct frame *f = XFRAME (WINDOW_FRAME (w));
7151 XRectangle clip_rect; 7152 XRectangle clip_rect;
7152 int window_y, window_width; 7153 int window_x, window_y, window_width;
7153 7154
7154 window_box (w, -1, 0, &window_y, &window_width, 0); 7155 window_box (w, area, &window_x, &window_y, &window_width, 0);
7155 7156
7156 clip_rect.x = WINDOW_TO_FRAME_PIXEL_X (w, 0); 7157 clip_rect.x = window_x;
7157 clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y); 7158 clip_rect.y = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
7158 clip_rect.y = max (clip_rect.y, window_y); 7159 clip_rect.y = max (clip_rect.y, window_y);
7159 clip_rect.width = window_width; 7160 clip_rect.width = window_width;
@@ -7219,7 +7220,7 @@ x_draw_hollow_cursor (w, row)
7219 gc = dpyinfo->scratch_cursor_gc; 7220 gc = dpyinfo->scratch_cursor_gc;
7220 7221
7221 /* Set clipping, draw the rectangle, and reset clipping again. */ 7222 /* Set clipping, draw the rectangle, and reset clipping again. */
7222 x_clip_to_row (w, row, gc); 7223 x_clip_to_row (w, row, TEXT_AREA, gc);
7223 XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h); 7224 XDrawRectangle (dpy, FRAME_X_WINDOW (f), gc, x, y, wd, h);
7224 XSetClipMask (dpy, gc, None); 7225 XSetClipMask (dpy, gc, None);
7225} 7226}
@@ -7291,7 +7292,7 @@ x_draw_bar_cursor (w, row, width, kind)
7291 width = min (cursor_glyph->pixel_width, width); 7292 width = min (cursor_glyph->pixel_width, width);
7292 7293
7293 w->phys_cursor_width = width; 7294 w->phys_cursor_width = width;
7294 x_clip_to_row (w, row, gc); 7295 x_clip_to_row (w, row, TEXT_AREA, gc);
7295 7296
7296 if (kind == BAR_CURSOR) 7297 if (kind == BAR_CURSOR)
7297 XFillRectangle (dpy, window, gc, 7298 XFillRectangle (dpy, window, gc,