aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2005-11-18 13:13:34 +0000
committerKaroly Lorentey2005-11-18 13:13:34 +0000
commitbffa514a8b8c947c655b463e8073e8e5ac061bc7 (patch)
tree0c51140f31c86667569ab1ddba534a16152cd13d /src
parentf5100f05486a36a443aa021b1a418e4b55988571 (diff)
parent1135363e9a6fd149e8f95bfa76421549697a0df0 (diff)
downloademacs-bffa514a8b8c947c655b463e8073e8e5ac061bc7.tar.gz
emacs-bffa514a8b8c947c655b463e8073e8e5ac061bc7.zip
Merged from miles@gnu.org--gnu-2005 (patch 152-156, 642-654)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-642 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-643 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-644 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-645 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-646 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-647 lisp/gnus/ChangeLog: Remove duplicate entry * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-648 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-649 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-650 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-651 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-652 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-653 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-654 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-152 Update from CVS: lisp/mml.el (mml-preview): Doc fix. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-153 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-154 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-155 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-156 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-440
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit57
-rw-r--r--src/ChangeLog151
-rw-r--r--src/Makefile.in2
-rw-r--r--src/alloc.c101
-rw-r--r--src/dispextern.h4
-rw-r--r--src/doc.c11
-rw-r--r--src/fileio.c6
-rw-r--r--src/gnu.h216
-rw-r--r--src/image.c46
-rw-r--r--src/keymap.c8
-rw-r--r--src/lisp.h31
-rw-r--r--src/lread.c6
-rw-r--r--src/mac.c95
-rw-r--r--src/macgui.h10
-rw-r--r--src/macterm.c479
-rw-r--r--src/print.c20
-rw-r--r--src/process.c63
-rw-r--r--src/s/darwin.h8
-rw-r--r--src/search.c2
-rw-r--r--src/unexmacosx.c68
-rw-r--r--src/xdisp.c9
-rw-r--r--src/xfns.c21
-rw-r--r--src/xterm.c28
23 files changed, 1236 insertions, 206 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index 462b6a86c5f..3f7755a3d8e 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -31,6 +31,9 @@ dir ../lwlib
31# However, C-z works just as well in that case. 31# However, C-z works just as well in that case.
32handle 2 noprint pass 32handle 2 noprint pass
33 33
34# Make it work like SIGINT normally does.
35handle SIGTSTP nopass
36
34# Don't pass SIGALRM to Emacs. This makes problems when 37# Don't pass SIGALRM to Emacs. This makes problems when
35# debugging. 38# debugging.
36handle SIGALRM ignore 39handle SIGALRM ignore
@@ -66,13 +69,53 @@ end
66# Print out s-expressions 69# Print out s-expressions
67define pp 70define pp
68 set $tmp = $arg0 71 set $tmp = $arg0
69 set debug_print ($tmp) 72 set safe_debug_print ($tmp)
70end 73end
71document pp 74document pp
72Print the argument as an emacs s-expression 75Print the argument as an emacs s-expression
73Works only when an inferior emacs is executing. 76Works only when an inferior emacs is executing.
74end 77end
75 78
79# Print out s-expressions from tool bar
80define pp1
81 set $tmp = $arg0
82 echo $arg0
83 printf " = "
84 set safe_debug_print ($tmp)
85end
86document pp1
87Print the argument as an emacs s-expression
88Works only when an inferior emacs is executing.
89For use on tool bar when debugging in Emacs
90where the variable name would not otherwise
91be recorded in the GUD buffer.
92end
93
94# Print value of lisp variable
95define pv
96 set $tmp = "$arg0"
97 set safe_debug_print ( find_symbol_value (intern ($tmp)))
98end
99document pv
100Print the value of the lisp variable given as argument.
101Works only when an inferior emacs is executing.
102end
103
104# Print value of lisp variable
105define pv1
106 set $tmp = "$arg0"
107 echo $arg0
108 printf " = "
109 set safe_debug_print (find_symbol_value (intern ($tmp)))
110end
111document pv1
112Print the value of the lisp variable given as argument.
113Works only when an inferior emacs is executing.
114For use on tool bar when debugging in Emacs
115where the variable name would not otherwise
116be recorded in the GUD buffer.
117end
118
76# Print out current buffer point and boundaries 119# Print out current buffer point and boundaries
77define ppt 120define ppt
78 set $b = current_buffer 121 set $b = current_buffer
@@ -122,7 +165,7 @@ define pitx
122 printf " HL" 165 printf " HL"
123 end 166 end
124 if ($it->n_overlay_strings > 0) 167 if ($it->n_overlay_strings > 0)
125 printf " nov=%d" 168 printf " nov=%d", $it->n_overlay_strings
126 end 169 end
127 if ($it->sp != 0) 170 if ($it->sp != 0)
128 printf " sp=%d", $it->sp 171 printf " sp=%d", $it->sp
@@ -672,6 +715,16 @@ document xbacktrace
672 an error was signaled. 715 an error was signaled.
673end 716end
674 717
718# Show Lisp backtrace after normal backtrace.
719define hookpost-backtrace
720 set $bt = backtrace_list
721 if $bt
722 echo \n
723 echo Lisp Backtrace:\n
724 xbacktrace
725 end
726end
727
675define xreload 728define xreload
676 set $tagmask = (((long)1 << gdb_gctypebits) - 1) 729 set $tagmask = (((long)1 << gdb_gctypebits) - 1)
677 set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1 730 set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
diff --git a/src/ChangeLog b/src/ChangeLog
index e2798ad1268..900db33db3d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,152 @@
12005-11-16 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * lread.c (readevalloop): Add missing GCPROs.
4
52005-11-16 Chong Yidong <cyd@stupidchicken.com>
6
7 * xfns.c (xg_set_icon_from_xpm_data): New function.
8
9 * gnu.h (gnu_xpm_bits): Rename from gnu_bits.
10 (gnu_xbm_bits): Rename from gnu_bits (xbm version).
11
12 * xterm.c (x_bitmap_icon): Use the xpm if available.
13
14 * image.c (x_create_bitmap_from_xpm_data): New function.
15 (x_create_bitmap_from_xpm_data): Initialize XpmAttributes.
16
172005-11-15 Luc Teirlinck <teirllm@auburn.edu>
18
19 * Makefile.in (lisp, shortlisp): Add rfn-eshadow.
20
212005-11-16 Nick Roberts <nickrob@snap.net.nz>
22
23 * .gdbinit: Make SIGTSTP work like SIGINT normally does.
24
252005-11-15 Andreas Schwab <schwab@suse.de>
26
27 * lisp.h (struct Lisp_Cons): Make cdr a union.
28 (XCDR_AS_LVALUE): Adjust.
29 (struct Lisp_Float): Make data a union.
30 (XFLOAT_DATA): Adjust.
31
32 * alloc.c (free_float): Make free list chaining aliasing-safe.
33 (make_float): Likewise.
34 (free_cons): Likewise.
35 (Fcons): Likewise.
36 (check_cons_list): Likewise.
37 (Fmake_symbol): Likewise.
38 (allocate_misc): Likewise.
39 (free_misc): Likewise.
40 (gc_sweep): Likewise.
41
422005-11-15 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
43
44 * mac.c (HASHKEY_QUERY_CACHE): New define.
45 (xrm_create_database, xrm_q_put_resource): Empty query cache.
46 (xrm_get_resource): Use query cache.
47
48 * image.c (init_image) [MAC_OS]: Don't call EnterMovies if
49 inhibit_window_system is set.
50
512005-11-13 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
52
53 * macgui.h (USE_CG_TEXT_DRAWING): New define.
54 (struct MacFontStruct) [USE_CG_TEXT_DRAWING]: New members cg_font
55 and cg_glyphs.
56
57 * macterm.c [USE_CG_TEXT_DRAWING] (mac_draw_string_cg): New function.
58 (x_draw_glyph_string_foreground) [USE_CG_TEXT_DRAWING]: Use it.
59 (XLoadQueryFont) [USE_CG_TEXT_DRAWING]: Set members cg_font and
60 cg_glyphs in struct MacFontStruct if synthesized bold or italic is
61 not used and font substitution never occurs for ASCII and Latin-1
62 characters.
63 (XLoadQueryFont): Maximum and minimum metrics are now those among
64 ASCII characters.
65 (XLoadQueryFont) [!MAC_OS8 || USE_ATSUI]: Apply WebKit-style
66 height adjustments for Courier, Helvetica, and Times.
67
68 * s/darwin.h (LIBS_CARBON) [!HAVE_CARBON]: Remove `-framework Carbon'.
69
702005-11-11 David Reitter <david.reitter@gmail.com>
71
72 * macterm.c (syms_of_macterm): Remove macCtrlKey, macShiftKey,
73 macMetaKey, macAltKey. Introduce Qctrl, Qmeta,
74 Vmac_control_modifier / mac-control-modifier,
75 Vmac_option_modifier / mac-option-modifier,
76 Vmac_command_modifier / mac-command-modifier.
77 (mac_to_emacs_modifiers): Use the new style modifier
78 variables. Return UInt32 (modifiers are longs now.)
79 (backtranslate_modified_keycode): New function (refactoring).
80 (XTread_socket): Use new modifier variables and refactored function.
81 (mac_determine_quit_char_modifiers): Remove macMetaKey (there is
82 no dedicated meta key. Not in use anyway.)
83 (convert_fn_keycode): Map Fn-keys to their original keycode
84 using a table (english keyboard only).
85
862005-11-11 Kim F. Storm <storm@cua.dk>
87
88 * .gdbinit (pitx): Fix output format if n_overlay_strings > 0.
89 Add post hook to "backtrace" to always dump lisp call stack to
90 increase chance of people sending it to us when reporting bugs.
91
92 * doc.c (Fsubstitute_command_keys): Doc fix.
93
94 * dispextern.h (struct it): New member ignore_overlay_strings_at_pos_p.
95
96 * xdisp.c (handle_stop): Skip overlay string handling if
97 ignore_overlay_strings_at_pos_p is set.
98 (set_iterator_to_next): At end of display vector, set
99 ignore_overlay_strings_at_pos_p if dpvec came from an overlay
100 string, so we skip those overlay strings at current pos.
101
1022005-11-10 Lars Hansen <larsh@soem.dk>
103
104 * fileio.c (file-regular-p): Doc fix.
105
1062005-11-10 Kim F. Storm <storm@cua.dk>
107
108 * alloc.c (valid_lisp_object_p): New function to validate that
109 an object is really a valid Lisp_Object.
110
111 * lisp.h (valid_lisp_object_p): Add prototype.
112
113 * print.c (safe_debug_print): New function to be called from gdb
114 to print Lisp objects; use valid_lisp_object_p to avoid crashing
115 if user tries to print something which is not a Lisp object.
116
117 * .gdbinit (pp, pp1): Use safe_debug_print.
118 (pv, pv1): New commands to print value of a lisp variable.
119
1202005-11-10 Nick Roberts <nickrob@snap.net.nz>
121
122 * .gdbinit (pp1): New user-defined function.
123
1242005-11-09 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
125
126 * image.c [MAC_OSX] (image_load_quartz2d): Fix memory leak.
127
128 * mac.c [MAC_OSX] (init_mac_osx_environment): Reinitialize locale
129 related variables for dumped executable.
130
131 * unexmacosx.c (unexec_write_zero): New function.
132 (copy_data_segment): Clear uninitialized local variables in
133 statically linked libraries.
134
135 * s/darwin.h (C_SWITCH_SYSTEM): Remove -fno-common.
136
1372005-11-09 Juri Linkov <juri@jurta.org>
138
139 * keymap.c (shadow_lookup): If Flookup_key returns a number,
140 call it again with a sub-key-sequence, and if its return value
141 is non-nil (sub-key is bound), return nil.
142
1432005-11-08 Kim F. Storm <storm@cua.dk>
144
145 * process.c (Fsignal_process): Recognize signal names with and
146 without SIG prefix, e.g. SIGHUP and HUP.
147
148 * search.c (search_buffer): No need to initialize base_pat.
149
12005-11-04 Stefan Monnier <monnier@iro.umontreal.ca> 1502005-11-04 Stefan Monnier <monnier@iro.umontreal.ca>
2 151
3 * window.c (Fget_lru_window, Fget_largest_window, window_loop): 152 * window.c (Fget_lru_window, Fget_largest_window, window_loop):
@@ -179,7 +328,7 @@
179 from last_mouse_glyph_frame, and update last_mouse_glyph_frame. 328 from last_mouse_glyph_frame, and update last_mouse_glyph_frame.
180 (XTmouse_position): Set last_mouse_glyph_frame. 329 (XTmouse_position): Set last_mouse_glyph_frame.
181 (XTread_socket): Clear last_mouse_glyph_frame on mouse up/down event. 330 (XTread_socket): Clear last_mouse_glyph_frame on mouse up/down event.
182 (mac_draw_string_common) [MAC_OSX && WORDS_BIG_ENDIAN]: Fix typo. 331 (mac_draw_string_common) [USE_ATSUI && WORDS_BIG_ENDIAN]: Fix typo.
183 Use EndianU16_BtoN. 332 Use EndianU16_BtoN.
184 (mac_draw_string_common) [MAC_OSX]: Don't use ATSUClearLayoutControls. 333 (mac_draw_string_common) [MAC_OSX]: Don't use ATSUClearLayoutControls.
185 (x_per_char_metric, XLoadQueryFont) 334 (x_per_char_metric, XLoadQueryFont)
diff --git a/src/Makefile.in b/src/Makefile.in
index 30dc5ab030d..7c9203d11ff 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -725,6 +725,7 @@ lisp= \
725 ${lispsource}help.elc \ 725 ${lispsource}help.elc \
726 ${lispsource}indent.elc \ 726 ${lispsource}indent.elc \
727 ${lispsource}isearch.elc \ 727 ${lispsource}isearch.elc \
728 ${lispsource}rfn-eshadow.elc \
728 ${lispsource}loadup.el \ 729 ${lispsource}loadup.el \
729 ${lispsource}loaddefs.el \ 730 ${lispsource}loaddefs.el \
730 ${lispsource}bindings.elc \ 731 ${lispsource}bindings.elc \
@@ -821,6 +822,7 @@ shortlisp= \
821 ../lisp/help.elc \ 822 ../lisp/help.elc \
822 ../lisp/indent.elc \ 823 ../lisp/indent.elc \
823 ../lisp/isearch.elc \ 824 ../lisp/isearch.elc \
825 ../lisp/rfn-eshadow.elc \
824 ../lisp/loadup.el \ 826 ../lisp/loadup.el \
825 ../lisp/loaddefs.el \ 827 ../lisp/loaddefs.el \
826 ../lisp/bindings.elc \ 828 ../lisp/bindings.elc \
diff --git a/src/alloc.c b/src/alloc.c
index 1e95447549b..bc48f7bb3b4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2532,7 +2532,7 @@ void
2532free_float (ptr) 2532free_float (ptr)
2533 struct Lisp_Float *ptr; 2533 struct Lisp_Float *ptr;
2534{ 2534{
2535 *(struct Lisp_Float **)&ptr->data = float_free_list; 2535 ptr->u.chain = float_free_list;
2536 float_free_list = ptr; 2536 float_free_list = ptr;
2537} 2537}
2538 2538
@@ -2550,7 +2550,7 @@ make_float (float_value)
2550 /* We use the data field for chaining the free list 2550 /* We use the data field for chaining the free list
2551 so that we won't use the same field that has the mark bit. */ 2551 so that we won't use the same field that has the mark bit. */
2552 XSETFLOAT (val, float_free_list); 2552 XSETFLOAT (val, float_free_list);
2553 float_free_list = *(struct Lisp_Float **)&float_free_list->data; 2553 float_free_list = float_free_list->u.chain;
2554 } 2554 }
2555 else 2555 else
2556 { 2556 {
@@ -2650,7 +2650,7 @@ void
2650free_cons (ptr) 2650free_cons (ptr)
2651 struct Lisp_Cons *ptr; 2651 struct Lisp_Cons *ptr;
2652{ 2652{
2653 *(struct Lisp_Cons **)&ptr->cdr = cons_free_list; 2653 ptr->u.chain = cons_free_list;
2654#if GC_MARK_STACK 2654#if GC_MARK_STACK
2655 ptr->car = Vdead; 2655 ptr->car = Vdead;
2656#endif 2656#endif
@@ -2669,7 +2669,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
2669 /* We use the cdr for chaining the free list 2669 /* We use the cdr for chaining the free list
2670 so that we won't use the same field that has the mark bit. */ 2670 so that we won't use the same field that has the mark bit. */
2671 XSETCONS (val, cons_free_list); 2671 XSETCONS (val, cons_free_list);
2672 cons_free_list = *(struct Lisp_Cons **)&cons_free_list->cdr; 2672 cons_free_list = cons_free_list->u.chain;
2673 } 2673 }
2674 else 2674 else
2675 { 2675 {
@@ -2704,7 +2704,7 @@ check_cons_list ()
2704 struct Lisp_Cons *tail = cons_free_list; 2704 struct Lisp_Cons *tail = cons_free_list;
2705 2705
2706 while (tail) 2706 while (tail)
2707 tail = *(struct Lisp_Cons **)&tail->cdr; 2707 tail = tail->u.chain;
2708#endif 2708#endif
2709} 2709}
2710 2710
@@ -3141,7 +3141,7 @@ Its value and function definition are void, and its property list is nil. */)
3141 if (symbol_free_list) 3141 if (symbol_free_list)
3142 { 3142 {
3143 XSETSYMBOL (val, symbol_free_list); 3143 XSETSYMBOL (val, symbol_free_list);
3144 symbol_free_list = *(struct Lisp_Symbol **)&symbol_free_list->value; 3144 symbol_free_list = symbol_free_list->next;
3145 } 3145 }
3146 else 3146 else
3147 { 3147 {
@@ -4485,10 +4485,79 @@ mark_stack ()
4485#endif 4485#endif
4486} 4486}
4487 4487
4488
4489#endif /* GC_MARK_STACK != 0 */ 4488#endif /* GC_MARK_STACK != 0 */
4490 4489
4491 4490
4491
4492/* Return 1 if OBJ is a valid lisp object.
4493 Return 0 if OBJ is NOT a valid lisp object.
4494 Return -1 if we cannot validate OBJ.
4495*/
4496
4497int
4498valid_lisp_object_p (obj)
4499 Lisp_Object obj;
4500{
4501#if !GC_MARK_STACK
4502 /* Cannot determine this. */
4503 return -1;
4504#else
4505 void *p;
4506 struct mem_node *m;
4507
4508 if (INTEGERP (obj))
4509 return 1;
4510
4511 p = (void *) XPNTR (obj);
4512
4513 if (PURE_POINTER_P (p))
4514 return 1;
4515
4516 m = mem_find (p);
4517
4518 if (m == MEM_NIL)
4519 return 0;
4520
4521 switch (m->type)
4522 {
4523 case MEM_TYPE_NON_LISP:
4524 return 0;
4525
4526 case MEM_TYPE_BUFFER:
4527 return live_buffer_p (m, p);
4528
4529 case MEM_TYPE_CONS:
4530 return live_cons_p (m, p);
4531
4532 case MEM_TYPE_STRING:
4533 return live_string_p (m, p);
4534
4535 case MEM_TYPE_MISC:
4536 return live_misc_p (m, p);
4537
4538 case MEM_TYPE_SYMBOL:
4539 return live_symbol_p (m, p);
4540
4541 case MEM_TYPE_FLOAT:
4542 return live_float_p (m, p);
4543
4544 case MEM_TYPE_VECTOR:
4545 case MEM_TYPE_PROCESS:
4546 case MEM_TYPE_HASH_TABLE:
4547 case MEM_TYPE_FRAME:
4548 case MEM_TYPE_WINDOW:
4549 return live_vector_p (m, p);
4550
4551 default:
4552 break;
4553 }
4554
4555 return 0;
4556#endif
4557}
4558
4559
4560
4492 4561
4493/*********************************************************************** 4562/***********************************************************************
4494 Pure Storage Management 4563 Pure Storage Management
@@ -4969,7 +5038,7 @@ returns nil, because real GC can't be done. */)
4969 total += total_floats * sizeof (struct Lisp_Float); 5038 total += total_floats * sizeof (struct Lisp_Float);
4970 total += total_intervals * sizeof (struct interval); 5039 total += total_intervals * sizeof (struct interval);
4971 total += total_strings * sizeof (struct Lisp_String); 5040 total += total_strings * sizeof (struct Lisp_String);
4972 5041
4973 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage); 5042 gc_relative_threshold = total * XFLOAT_DATA (Vgc_cons_percentage);
4974 } 5043 }
4975 else 5044 else
@@ -5496,14 +5565,14 @@ mark_object (arg)
5496 CHECK_ALLOCATED_AND_LIVE (live_cons_p); 5565 CHECK_ALLOCATED_AND_LIVE (live_cons_p);
5497 CONS_MARK (ptr); 5566 CONS_MARK (ptr);
5498 /* If the cdr is nil, avoid recursion for the car. */ 5567 /* If the cdr is nil, avoid recursion for the car. */
5499 if (EQ (ptr->cdr, Qnil)) 5568 if (EQ (ptr->u.cdr, Qnil))
5500 { 5569 {
5501 obj = ptr->car; 5570 obj = ptr->car;
5502 cdr_count = 0; 5571 cdr_count = 0;
5503 goto loop; 5572 goto loop;
5504 } 5573 }
5505 mark_object (ptr->car); 5574 mark_object (ptr->car);
5506 obj = ptr->cdr; 5575 obj = ptr->u.cdr;
5507 cdr_count++; 5576 cdr_count++;
5508 if (cdr_count == mark_object_loop_halt) 5577 if (cdr_count == mark_object_loop_halt)
5509 abort (); 5578 abort ();
@@ -5650,7 +5719,7 @@ gc_sweep ()
5650 if (!CONS_MARKED_P (&cblk->conses[i])) 5719 if (!CONS_MARKED_P (&cblk->conses[i]))
5651 { 5720 {
5652 this_free++; 5721 this_free++;
5653 *(struct Lisp_Cons **)&cblk->conses[i].cdr = cons_free_list; 5722 cblk->conses[i].u.chain = cons_free_list;
5654 cons_free_list = &cblk->conses[i]; 5723 cons_free_list = &cblk->conses[i];
5655#if GC_MARK_STACK 5724#if GC_MARK_STACK
5656 cons_free_list->car = Vdead; 5725 cons_free_list->car = Vdead;
@@ -5669,7 +5738,7 @@ gc_sweep ()
5669 { 5738 {
5670 *cprev = cblk->next; 5739 *cprev = cblk->next;
5671 /* Unhook from the free list. */ 5740 /* Unhook from the free list. */
5672 cons_free_list = *(struct Lisp_Cons **) &cblk->conses[0].cdr; 5741 cons_free_list = cblk->conses[0].u.chain;
5673 lisp_align_free (cblk); 5742 lisp_align_free (cblk);
5674 n_cons_blocks--; 5743 n_cons_blocks--;
5675 } 5744 }
@@ -5700,7 +5769,7 @@ gc_sweep ()
5700 if (!FLOAT_MARKED_P (&fblk->floats[i])) 5769 if (!FLOAT_MARKED_P (&fblk->floats[i]))
5701 { 5770 {
5702 this_free++; 5771 this_free++;
5703 *(struct Lisp_Float **)&fblk->floats[i].data = float_free_list; 5772 fblk->floats[i].u.chain = float_free_list;
5704 float_free_list = &fblk->floats[i]; 5773 float_free_list = &fblk->floats[i];
5705 } 5774 }
5706 else 5775 else
@@ -5716,7 +5785,7 @@ gc_sweep ()
5716 { 5785 {
5717 *fprev = fblk->next; 5786 *fprev = fblk->next;
5718 /* Unhook from the free list. */ 5787 /* Unhook from the free list. */
5719 float_free_list = *(struct Lisp_Float **) &fblk->floats[0].data; 5788 float_free_list = fblk->floats[0].u.chain;
5720 lisp_align_free (fblk); 5789 lisp_align_free (fblk);
5721 n_float_blocks--; 5790 n_float_blocks--;
5722 } 5791 }
@@ -5804,7 +5873,7 @@ gc_sweep ()
5804 5873
5805 if (!sym->gcmarkbit && !pure_p) 5874 if (!sym->gcmarkbit && !pure_p)
5806 { 5875 {
5807 *(struct Lisp_Symbol **) &sym->value = symbol_free_list; 5876 sym->next = symbol_free_list;
5808 symbol_free_list = sym; 5877 symbol_free_list = sym;
5809#if GC_MARK_STACK 5878#if GC_MARK_STACK
5810 symbol_free_list->function = Vdead; 5879 symbol_free_list->function = Vdead;
@@ -5828,7 +5897,7 @@ gc_sweep ()
5828 { 5897 {
5829 *sprev = sblk->next; 5898 *sprev = sblk->next;
5830 /* Unhook from the free list. */ 5899 /* Unhook from the free list. */
5831 symbol_free_list = *(struct Lisp_Symbol **)&sblk->symbols[0].value; 5900 symbol_free_list = sblk->symbols[0].next;
5832 lisp_free (sblk); 5901 lisp_free (sblk);
5833 n_symbol_blocks--; 5902 n_symbol_blocks--;
5834 } 5903 }
diff --git a/src/dispextern.h b/src/dispextern.h
index 078726aa5c8..f5573efdcc4 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1974,6 +1974,10 @@ struct it
1974 /* 1 means overlay strings at end_charpos have been processed. */ 1974 /* 1 means overlay strings at end_charpos have been processed. */
1975 unsigned overlay_strings_at_end_processed_p : 1; 1975 unsigned overlay_strings_at_end_processed_p : 1;
1976 1976
1977 /* 1 means to ignore overlay strings at current pos, as they have
1978 already been processed. */
1979 unsigned ignore_overlay_strings_at_pos_p : 1;
1980
1977 /* 1 means the actual glyph is not available in the current 1981 /* 1 means the actual glyph is not available in the current
1978 system. */ 1982 system. */
1979 unsigned glyph_not_available_p : 1; 1983 unsigned glyph_not_available_p : 1;
diff --git a/src/doc.c b/src/doc.c
index a31c53d5b21..0566c5f9d06 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -735,15 +735,18 @@ the same file name is found in the `doc-directory'. */)
735DEFUN ("substitute-command-keys", Fsubstitute_command_keys, 735DEFUN ("substitute-command-keys", Fsubstitute_command_keys,
736 Ssubstitute_command_keys, 1, 1, 0, 736 Ssubstitute_command_keys, 1, 1, 0,
737 doc: /* Substitute key descriptions for command names in STRING. 737 doc: /* Substitute key descriptions for command names in STRING.
738Return a new string which is STRING with substrings of the form \\=\\[COMMAND] 738Substrings of the form \\=\\[COMMAND] replaced by either: a keystroke
739replaced by either: a keystroke sequence that will invoke COMMAND, 739sequence that will invoke COMMAND, or "M-x COMMAND" if COMMAND is not
740or "M-x COMMAND" if COMMAND is not on any keys. 740on any keys.
741Substrings of the form \\=\\{MAPVAR} are replaced by summaries 741Substrings of the form \\=\\{MAPVAR} are replaced by summaries
742\(made by describe-bindings) of the value of MAPVAR, taken as a keymap. 742\(made by describe-bindings) of the value of MAPVAR, taken as a keymap.
743Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR 743Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR
744as the keymap for future \\=\\[COMMAND] substrings. 744as the keymap for future \\=\\[COMMAND] substrings.
745\\=\\= quotes the following character and is discarded; 745\\=\\= quotes the following character and is discarded;
746thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output. */) 746thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.
747
748Returns original STRING if no substitutions were made. Othwerwise,
749a new string, without any text properties, is returned. */)
747 (string) 750 (string)
748 Lisp_Object string; 751 Lisp_Object string;
749{ 752{
diff --git a/src/fileio.c b/src/fileio.c
index 6806c7d025a..b7262b6c58b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3394,8 +3394,10 @@ searchable directory. */)
3394} 3394}
3395 3395
3396DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0, 3396DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0,
3397 doc: /* Return t if file FILENAME is the name of a regular file. 3397 doc: /* Return t if FILENAME names a regular file.
3398This is the sort of file that holds an ordinary stream of data bytes. */) 3398This is the sort of file that holds an ordinary stream of data bytes.
3399Symbolic links to regular files count as regular files.
3400See `file-symlink-p' to distinguish symlinks. */)
3399 (filename) 3401 (filename)
3400 Lisp_Object filename; 3402 Lisp_Object filename;
3401{ 3403{
diff --git a/src/gnu.h b/src/gnu.h
index 1d623431af8..dbf47317493 100644
--- a/src/gnu.h
+++ b/src/gnu.h
@@ -1,6 +1,216 @@
1#define gnu_width 50 1#if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
2#define gnu_height 50 2static char * gnu_xpm_bits[] = {
3static unsigned char gnu_bits[] = { 3"32 32 173 2",
4" c None",
5". c #67627D",
6"+ c #5F5A76",
7"@ c #78748C",
8"# c #DCDBE1",
9"$ c #CFCED7",
10"% c #B8B5C7",
11"& c #ADA9C1",
12"* c #A6A3B9",
13"= c #9995A9",
14"- c #878398",
15"; c #C2C0CD",
16"> c #9591AE",
17", c #9B97B3",
18"' c #BDBACC",
19") c #9C98B3",
20"! c #A9A6B9",
21"~ c #8D89A0",
22"{ c #A9A5BC",
23"] c #938FAB",
24"^ c #B4B2C5",
25"/ c #F8F8FA",
26"( c #E4E3EA",
27"_ c #BCB9CB",
28": c #9390A5",
29"< c #5E5A75",
30"[ c #8B87A1",
31"} c #918DA9",
32"| c #BAB7C9",
33"1 c #FFFFFF",
34"2 c #F1F1F4",
35"3 c #B4B1C4",
36"4 c #9D99AF",
37"5 c #5D5974",
38"6 c #8E8AA5",
39"7 c #A3A0B6",
40"8 c #F8F8F9",
41"9 c #9F9CB3",
42"0 c #8C88A3",
43"a c #938FA9",
44"b c #C6C4D1",
45"c c #B7B4C5",
46"d c #9D99B1",
47"e c #5C5873",
48"f c #8985A0",
49"g c #B5B3C4",
50"h c #F0F0F3",
51"i c #A6A3B7",
52"j c #9B98AE",
53"k c #5C5872",
54"l c #88849D",
55"m c #A6A3B6",
56"n c #F8F7F9",
57"o c #C3C1CE",
58"p c #9996AB",
59"q c #5B5772",
60"r c #85819A",
61"s c #9491A7",
62"t c #E0DFE6",
63"u c #C2C0CC",
64"v c #8C88A0",
65"w c #9894A9",
66"x c #5A5671",
67"y c #838097",
68"z c #B2B0BE",
69"A c #F7F7F8",
70"B c #D8D7DE",
71"C c #928FA4",
72"D c #9491A5",
73"E c #5A5670",
74"F c #817D95",
75"G c #A9A6B6",
76"H c #A8A5B6",
77"I c #928FA3",
78"J c #59556F",
79"K c #7E7B91",
80"L c #BEBDC8",
81"M c #AEACBA",
82"N c #908DA0",
83"O c #5B5771",
84"P c #58546D",
85"Q c #65617A",
86"R c #E0DFE4",
87"S c #8E8B9E",
88"T c #7A778D",
89"U c #5A566F",
90"V c #57536C",
91"W c #58546F",
92"X c #A19EAE",
93"Y c #EAEAED",
94"Z c #F5F4F6",
95"` c #A19FAE",
96" . c #625F78",
97".. c #77748A",
98"+. c #59556E",
99"@. c #56526B",
100"#. c #807D90",
101"$. c #D5D4DA",
102"%. c #9693A3",
103"&. c #767387",
104"*. c #55516A",
105"=. c #534F68",
106"-. c #9491A1",
107";. c #F4F4F6",
108">. c #9E9CAA",
109",. c #5D5971",
110"'. c #737084",
111"). c #545068",
112"!. c #504D64",
113"~. c #F4F4F5",
114"{. c #DEDDE2",
115"]. c #5A576D",
116"^. c #716F81",
117"/. c #56526A",
118"(. c #524F67",
119"_. c #4D4A61",
120":. c #9A99A6",
121"<. c #848292",
122"[. c #6F6C7F",
123"}. c #545169",
124"|. c #514E65",
125"1. c #4A475D",
126"2. c #6B697B",
127"3. c #D2D1D6",
128"4. c #F4F3F5",
129"5. c #9998A4",
130"6. c #6C6A7B",
131"7. c #535067",
132"8. c #504C64",
133"9. c #474459",
134"0. c #747282",
135"a. c #D1D0D5",
136"b. c #E8E8EA",
137"c. c #8C8A97",
138"d. c #676576",
139"e. c #4E4B62",
140"f. c #444156",
141"g. c #727080",
142"h. c #E8E7EA",
143"i. c #8A8996",
144"j. c #656374",
145"k. c #524F66",
146"l. c #423F53",
147"m. c #B8B7BE",
148"n. c #D0CFD4",
149"o. c #4E4B5E",
150"p. c #636171",
151"q. c #4C485E",
152"r. c #434054",
153"s. c #3F3C4F",
154"t. c #575465",
155"u. c #CFCED3",
156"v. c #646272",
157"w. c #504C62",
158"x. c #4B475D",
159"y. c #3D3A4C",
160"z. c #494657",
161"A. c #7A7884",
162"B. c #B7B6BC",
163"C. c #DADADD",
164"D. c #4F4B61",
165"E. c #49455B",
166"F. c #3A3748",
167"G. c #5E5C6A",
168"H. c #908E98",
169"I. c #C1C0C6",
170"J. c #F3F2F4",
171"K. c #777581",
172"L. c #474458",
173"M. c #434053",
174"N. c #3C3A4A",
175"O. c #373544",
176"P. c #454256",
177" ",
178" ",
179" . + + + + + + + + + + + + + + + + + + + + + + + ",
180" @ # $ % & & & & & & & & & & & & & & & & & & * = @ + ",
181" @ - ; > > > > > > > > > > , ' ' ) > > > > > > > > ! . + ",
182" @ ~ { ] ] ] ] ] ] ] ] ] ] ] ] ^ / ( _ ] ] ] ] ] ] ] : < ",
183" . [ } } } } } } } } } } } } } } | 1 1 2 3 } } } } } 4 < ",
184" 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 8 1 1 1 8 6 6 6 6 6 9 5 ",
185" 5 0 0 0 0 0 0 0 0 0 0 0 0 a b 8 1 1 1 1 c 0 0 0 0 0 d 5 ",
186" e f f f f f f f f f f f g h 1 1 1 1 h i f f f f f f j e ",
187" k l l l l l l l l l m h 1 1 1 1 n o l l l l l l l l p k ",
188" q r r r r r r r s t 1 1 1 1 1 u v r r r r r r r r r w q ",
189" x y y y y y y z A 1 1 1 1 B C y y y y y y y y y y y D e ",
190" E F F F F F G 1 1 1 1 A H F F F F F F F F F F F F F I k ",
191" J K K K K K L 1 1 1 1 M K K K K K K K K K K K K K K N O ",
192" P q q q q q Q R 1 1 1 S q q q q q q q q q q q q q q T U ",
193" V W W W W W W W X Y 1 Z ` .W W W W W W W W W W W W ..+. ",
194" @.@.@.@.@.@.@.#.$.1 1 1 1 1 %.@.@.@.@.@.@.@.@.@.@.@.&.P ",
195" *.=.=.=.=.=.-.1 1 1 1 ;.>.,.=.=.=.=.=.=.=.=.=.=.=.=.'.V ",
196" ).!.!.!.!.!.~.1 1 1 {.].!.!.!.!.!.!.!.!.!.!.!.!.!.!.^./. ",
197" (._._._._._.:.1 1 1 <._._._._._._._._._._._._._._._.[.}. ",
198" |.1.1.1.1.1.1.2.3.1 4.5.1.1.1.1.1.1.1.1.1.1.1.1.1.1.6.7. ",
199" 8.9.9.9.9.9.9.9.9.0.a.1 b.c.9.9.9.9.9.9.9.9.9.9.9.9.d.). ",
200" e.f.f.f.f.f.f.f.f.f.f.g.h.1 h.i.f.f.f.f.f.f.f.f.f.f.j.k. ",
201" _.l.l.l.l.l.l.l.l.l.l.l.l.m.1 1 n.o.l.l.l.l.l.l.l.l.p.|. ",
202" q.r.s.s.s.s.s.s.s.s.s.s.s.t.1 1 1 u.s.s.s.s.s.s.s.s.v.w. ",
203" x.9.y.y.y.y.y.y.y.y.z.A.B.1 1 1 1 C.y.y.y.y.y.y.y.y.d.D. ",
204" E.E.r.F.F.F.F.F.F.F.F.G.H.I.J.I.K.F.F.F.F.F.F.F.F.r.E.E. ",
205" L.L.M.N.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.N.M.L.L. ",
206" P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P.P. ",
207" ",
208" "};
209#endif /* defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) */
210
211#define gnu_xbm_width 50
212#define gnu_xbm_height 50
213static unsigned char gnu_xbm_bits[] = {
4 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
6 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 216 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00,
diff --git a/src/image.c b/src/image.c
index fb3cdecaa54..1ba1cd197ff 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2549,6 +2549,7 @@ image_load_quartz2d (f, img, png_p)
2549 2549
2550 if (!check_image_size (f, width, height)) 2550 if (!check_image_size (f, width, height))
2551 { 2551 {
2552 CGImageRelease (image);
2552 UNGCPRO; 2553 UNGCPRO;
2553 image_error ("Invalid image size", Qnil, Qnil); 2554 image_error ("Invalid image size", Qnil, Qnil);
2554 return 0; 2555 return 0;
@@ -3715,6 +3716,45 @@ xpm_image_p (object)
3715 3716
3716#endif /* HAVE_XPM || MAC_OS */ 3717#endif /* HAVE_XPM || MAC_OS */
3717 3718
3719#if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
3720int
3721x_create_bitmap_from_xpm_data (f, bits)
3722 struct frame *f;
3723 char **bits;
3724{
3725 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
3726 int id, rc;
3727 XpmAttributes attrs;
3728 Pixmap bitmap, mask;
3729
3730 bzero (&attrs, sizeof attrs);
3731
3732 attrs.visual = FRAME_X_VISUAL (f);
3733 attrs.colormap = FRAME_X_COLORMAP (f);
3734 attrs.valuemask |= XpmVisual;
3735 attrs.valuemask |= XpmColormap;
3736
3737 rc = XpmCreatePixmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3738 bits, &bitmap, &mask, &attrs);
3739 if (rc != XpmSuccess)
3740 return -1;
3741
3742 id = x_allocate_bitmap_record (f);
3743
3744 dpyinfo->bitmaps[id - 1].pixmap = bitmap;
3745 dpyinfo->bitmaps[id - 1].have_mask = 1;
3746 dpyinfo->bitmaps[id - 1].mask = mask;
3747 dpyinfo->bitmaps[id - 1].file = NULL;
3748 dpyinfo->bitmaps[id - 1].height = attrs.height;
3749 dpyinfo->bitmaps[id - 1].width = attrs.width;
3750 dpyinfo->bitmaps[id - 1].depth = attrs.depth;
3751 dpyinfo->bitmaps[id - 1].refcount = 1;
3752
3753 XpmFreeAttributes (&attrs);
3754 return id;
3755}
3756#endif /* HAVE_X_WINDOWS */
3757
3718/* Load image IMG which will be displayed on frame F. Value is 3758/* Load image IMG which will be displayed on frame F. Value is
3719 non-zero if successful. */ 3759 non-zero if successful. */
3720 3760
@@ -3762,6 +3802,9 @@ xpm_load (f, img)
3762 attrs.valuemask |= XpmCloseness; 3802 attrs.valuemask |= XpmCloseness;
3763#endif /* not XpmAllocCloseColors */ 3803#endif /* not XpmAllocCloseColors */
3764#endif /* ALLOC_XPM_COLORS */ 3804#endif /* ALLOC_XPM_COLORS */
3805#ifdef ALLOC_XPM_COLORS
3806 xpm_init_color_cache (f, &attrs);
3807#endif
3765 3808
3766 /* If image specification contains symbolic color definitions, add 3809 /* If image specification contains symbolic color definitions, add
3767 these to `attrs'. */ 3810 these to `attrs'. */
@@ -8457,7 +8500,8 @@ init_image ()
8457{ 8500{
8458#ifdef MAC_OS 8501#ifdef MAC_OS
8459 /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ 8502 /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */
8460 EnterMovies (); 8503 if (!inhibit_window_system)
8504 EnterMovies ();
8461#ifdef MAC_OSX 8505#ifdef MAC_OSX
8462 init_image_func_pointer (); 8506 init_image_func_pointer ();
8463#endif 8507#endif
diff --git a/src/keymap.c b/src/keymap.c
index 7e5b00bc771..a19b0102127 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -2370,7 +2370,13 @@ shadow_lookup (shadow, key, flag)
2370 for (tail = shadow; CONSP (tail); tail = XCDR (tail)) 2370 for (tail = shadow; CONSP (tail); tail = XCDR (tail))
2371 { 2371 {
2372 value = Flookup_key (XCAR (tail), key, flag); 2372 value = Flookup_key (XCAR (tail), key, flag);
2373 if (!NILP (value) && !NATNUMP (value)) 2373 if (NATNUMP (value))
2374 {
2375 value = Flookup_key (XCAR (tail), Fsubstring (key, 0, value), flag);
2376 if (!NILP (value))
2377 return Qnil;
2378 }
2379 else if (!NILP (value))
2374 return value; 2380 return value;
2375 } 2381 }
2376 return Qnil; 2382 return Qnil;
diff --git a/src/lisp.h b/src/lisp.h
index adf53035e98..767e97a94a6 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -600,9 +600,19 @@ struct Lisp_Cons
600 /* Please do not use the names of these elements in code other 600 /* Please do not use the names of these elements in code other
601 than the core lisp implementation. Use XCAR and XCDR below. */ 601 than the core lisp implementation. Use XCAR and XCDR below. */
602#ifdef HIDE_LISP_IMPLEMENTATION 602#ifdef HIDE_LISP_IMPLEMENTATION
603 Lisp_Object car_, cdr_; 603 Lisp_Object car_;
604 union
605 {
606 Lisp_Object cdr_;
607 struct Lisp_Cons *chain;
608 } u;
604#else 609#else
605 Lisp_Object car, cdr; 610 Lisp_Object car;
611 union
612 {
613 Lisp_Object cdr;
614 struct Lisp_Cons *chain;
615 } u;
606#endif 616#endif
607 }; 617 };
608 618
@@ -615,10 +625,10 @@ struct Lisp_Cons
615 invalidated at arbitrary points.) */ 625 invalidated at arbitrary points.) */
616#ifdef HIDE_LISP_IMPLEMENTATION 626#ifdef HIDE_LISP_IMPLEMENTATION
617#define XCAR_AS_LVALUE(c) (XCONS ((c))->car_) 627#define XCAR_AS_LVALUE(c) (XCONS ((c))->car_)
618#define XCDR_AS_LVALUE(c) (XCONS ((c))->cdr_) 628#define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr_)
619#else 629#else
620#define XCAR_AS_LVALUE(c) (XCONS ((c))->car) 630#define XCAR_AS_LVALUE(c) (XCONS ((c))->car)
621#define XCDR_AS_LVALUE(c) (XCONS ((c))->cdr) 631#define XCDR_AS_LVALUE(c) (XCONS ((c))->u.cdr)
622#endif 632#endif
623 633
624/* Use these from normal code. */ 634/* Use these from normal code. */
@@ -1275,17 +1285,21 @@ union Lisp_Misc
1275/* Lisp floating point type */ 1285/* Lisp floating point type */
1276struct Lisp_Float 1286struct Lisp_Float
1277 { 1287 {
1288 union
1289 {
1278#ifdef HIDE_LISP_IMPLEMENTATION 1290#ifdef HIDE_LISP_IMPLEMENTATION
1279 double data_; 1291 double data_;
1280#else 1292#else
1281 double data; 1293 double data;
1282#endif 1294#endif
1295 struct Lisp_Float *chain;
1296 } u;
1283 }; 1297 };
1284 1298
1285#ifdef HIDE_LISP_IMPLEMENTATION 1299#ifdef HIDE_LISP_IMPLEMENTATION
1286#define XFLOAT_DATA(f) (XFLOAT (f)->data_) 1300#define XFLOAT_DATA(f) (XFLOAT (f)->u.data_)
1287#else 1301#else
1288#define XFLOAT_DATA(f) (XFLOAT (f)->data) 1302#define XFLOAT_DATA(f) (XFLOAT (f)->u.data)
1289#endif 1303#endif
1290 1304
1291/* A character, declared with the following typedef, is a member 1305/* A character, declared with the following typedef, is a member
@@ -2549,6 +2563,7 @@ extern void init_alloc_once P_ ((void));
2549extern void init_alloc P_ ((void)); 2563extern void init_alloc P_ ((void));
2550extern void syms_of_alloc P_ ((void)); 2564extern void syms_of_alloc P_ ((void));
2551extern struct buffer * allocate_buffer P_ ((void)); 2565extern struct buffer * allocate_buffer P_ ((void));
2566extern int valid_lisp_object_p P_ ((Lisp_Object));
2552 2567
2553/* Defined in print.c */ 2568/* Defined in print.c */
2554extern Lisp_Object Vprin1_to_string_buffer; 2569extern Lisp_Object Vprin1_to_string_buffer;
diff --git a/src/lread.c b/src/lread.c
index 1bae0ea7ddd..234fbe6e395 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1317,7 +1317,7 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
1317 register int c; 1317 register int c;
1318 register Lisp_Object val; 1318 register Lisp_Object val;
1319 int count = SPECPDL_INDEX (); 1319 int count = SPECPDL_INDEX ();
1320 struct gcpro gcpro1; 1320 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1321 struct buffer *b = 0; 1321 struct buffer *b = 0;
1322 int continue_reading_p; 1322 int continue_reading_p;
1323 1323
@@ -1326,14 +1326,14 @@ readevalloop (readcharfun, stream, sourcename, evalfun,
1326 else if (MARKERP (readcharfun)) 1326 else if (MARKERP (readcharfun))
1327 b = XMARKER (readcharfun)->buffer; 1327 b = XMARKER (readcharfun)->buffer;
1328 1328
1329 specbind (Qstandard_input, readcharfun); 1329 specbind (Qstandard_input, readcharfun); /* GCPROs readcharfun. */
1330 specbind (Qcurrent_load_list, Qnil); 1330 specbind (Qcurrent_load_list, Qnil);
1331 record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil); 1331 record_unwind_protect (readevalloop_1, load_convert_to_unibyte ? Qt : Qnil);
1332 load_convert_to_unibyte = !NILP (unibyte); 1332 load_convert_to_unibyte = !NILP (unibyte);
1333 1333
1334 readchar_backlog = -1; 1334 readchar_backlog = -1;
1335 1335
1336 GCPRO1 (sourcename); 1336 GCPRO4 (sourcename, readfun, start, end);
1337 1337
1338 LOADHIST_ATTACH (sourcename); 1338 LOADHIST_ATTACH (sourcename);
1339 1339
diff --git a/src/mac.c b/src/mac.c
index 4c8e78ade25..2493945727d 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -854,9 +854,14 @@ parse_resource_line (p)
854 implemented as a hash table that maps a pair (SRC-NODE-ID . 854 implemented as a hash table that maps a pair (SRC-NODE-ID .
855 EDGE-LABEL) to DEST-NODE-ID. It also holds a maximum node id used 855 EDGE-LABEL) to DEST-NODE-ID. It also holds a maximum node id used
856 in the table as a value for HASHKEY_MAX_NID. A value associated to 856 in the table as a value for HASHKEY_MAX_NID. A value associated to
857 a node is recorded as a value for the node id. */ 857 a node is recorded as a value for the node id.
858
859 A database also has a cache for past queries as a value for
860 HASHKEY_QUERY_CACHE. It is another hash table that maps
861 "NAME-STRING\0CLASS-STRING" to the result of the query. */
858 862
859#define HASHKEY_MAX_NID (make_number (0)) 863#define HASHKEY_MAX_NID (make_number (0))
864#define HASHKEY_QUERY_CACHE (make_number (-1))
860 865
861static XrmDatabase 866static XrmDatabase
862xrm_create_database () 867xrm_create_database ()
@@ -868,6 +873,7 @@ xrm_create_database ()
868 make_float (DEFAULT_REHASH_THRESHOLD), 873 make_float (DEFAULT_REHASH_THRESHOLD),
869 Qnil, Qnil, Qnil); 874 Qnil, Qnil, Qnil);
870 Fputhash (HASHKEY_MAX_NID, make_number (0), database); 875 Fputhash (HASHKEY_MAX_NID, make_number (0), database);
876 Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
871 877
872 return database; 878 return database;
873} 879}
@@ -901,6 +907,7 @@ xrm_q_put_resource (database, quarks, value)
901 Fputhash (node_id, value, database); 907 Fputhash (node_id, value, database);
902 908
903 Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database); 909 Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database);
910 Fputhash (HASHKEY_QUERY_CACHE, Qnil, database);
904} 911}
905 912
906/* Merge multiple resource entries specified by DATA into a resource 913/* Merge multiple resource entries specified by DATA into a resource
@@ -989,8 +996,30 @@ xrm_get_resource (database, name, class)
989 XrmDatabase database; 996 XrmDatabase database;
990 char *name, *class; 997 char *name, *class;
991{ 998{
992 Lisp_Object quark_name, quark_class, tmp; 999 Lisp_Object key, query_cache, quark_name, quark_class, tmp;
993 int nn, nc; 1000 int i, nn, nc;
1001 struct Lisp_Hash_Table *h;
1002 unsigned hash_code;
1003
1004 nn = strlen (name);
1005 nc = strlen (class);
1006 key = make_uninit_string (nn + nc + 1);
1007 strcpy (SDATA (key), name);
1008 strncpy (SDATA (key) + nn + 1, class, nc);
1009
1010 query_cache = Fgethash (HASHKEY_QUERY_CACHE, database, Qnil);
1011 if (NILP (query_cache))
1012 {
1013 query_cache = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
1014 make_float (DEFAULT_REHASH_SIZE),
1015 make_float (DEFAULT_REHASH_THRESHOLD),
1016 Qnil, Qnil, Qnil);
1017 Fputhash (HASHKEY_QUERY_CACHE, query_cache, database);
1018 }
1019 h = XHASH_TABLE (query_cache);
1020 i = hash_lookup (h, key, &hash_code);
1021 if (i >= 0)
1022 return HASH_VALUE (h, i);
994 1023
995 quark_name = parse_resource_name (&name); 1024 quark_name = parse_resource_name (&name);
996 if (*name != '\0') 1025 if (*name != '\0')
@@ -1009,7 +1038,11 @@ xrm_get_resource (database, name, class)
1009 if (nn != nc) 1038 if (nn != nc)
1010 return Qnil; 1039 return Qnil;
1011 else 1040 else
1012 return xrm_q_get_resource (database, quark_name, quark_class); 1041 {
1042 tmp = xrm_q_get_resource (database, quark_name, quark_class);
1043 hash_put (h, key, tmp, hash_code);
1044 return tmp;
1045 }
1013} 1046}
1014 1047
1015#if TARGET_API_MAC_CARBON 1048#if TARGET_API_MAC_CARBON
@@ -4119,7 +4152,7 @@ DEFUN ("mac-code-convert-string", Fmac_code_convert_string, Smac_code_convert_st
4119The conversion is performed using the converter provided by the system. 4152The conversion is performed using the converter provided by the system.
4120Each encoding is specified by either a coding system symbol, a mime 4153Each encoding is specified by either a coding system symbol, a mime
4121charset string, or an integer as a CFStringEncoding value. Nil for 4154charset string, or an integer as a CFStringEncoding value. Nil for
4122encoding means UTF-16 in native byte order, no byte order marker. 4155encoding means UTF-16 in native byte order, no byte order mark.
4123On Mac OS X 10.2 and later, you can do Unicode Normalization by 4156On Mac OS X 10.2 and later, you can do Unicode Normalization by
4124specifying the optional argument NORMALIZATION-FORM with a symbol NFD, 4157specifying the optional argument NORMALIZATION-FORM with a symbol NFD,
4125NFKD, NFC, NFKC, HFS+D, or HFS+C. 4158NFKD, NFC, NFKC, HFS+D, or HFS+C.
@@ -4192,6 +4225,29 @@ DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_
4192 return Qnil; 4225 return Qnil;
4193} 4226}
4194 4227
4228
4229static Lisp_Object
4230mac_get_system_locale ()
4231{
4232 OSErr err;
4233 LangCode lang;
4234 RegionCode region;
4235 LocaleRef locale;
4236 Str255 str;
4237
4238 lang = GetScriptVariable (smSystemScript, smScriptLang);
4239 region = GetScriptManagerVariable (smRegionCode);
4240 err = LocaleRefFromLangOrRegionCode (lang, region, &locale);
4241 if (err == noErr)
4242 err = LocaleRefGetPartString (locale, kLocaleAllPartsMask,
4243 sizeof (str), str);
4244 if (err == noErr)
4245 return build_string (str);
4246 else
4247 return Qnil;
4248}
4249
4250
4195#ifdef MAC_OSX 4251#ifdef MAC_OSX
4196#undef select 4252#undef select
4197 4253
@@ -4213,7 +4269,7 @@ extern int noninteractive;
4213 involved, and timeout is not too short (greater than 4269 involved, and timeout is not too short (greater than
4214 SELECT_TIMEOUT_THRESHHOLD_RUNLOOP seconds). 4270 SELECT_TIMEOUT_THRESHHOLD_RUNLOOP seconds).
4215 -> Create CFSocket for each socket and add it into the current 4271 -> Create CFSocket for each socket and add it into the current
4216 event RunLoop so that an `ready-to-read' event can be posted 4272 event RunLoop so that a `ready-to-read' event can be posted
4217 to the event queue that is also used for window events. Then 4273 to the event queue that is also used for window events. Then
4218 ReceiveNextEvent can wait for both kinds of inputs. 4274 ReceiveNextEvent can wait for both kinds of inputs.
4219 4. Otherwise. 4275 4. Otherwise.
@@ -4481,6 +4537,11 @@ init_mac_osx_environment ()
4481 char *p, *q; 4537 char *p, *q;
4482 struct stat st; 4538 struct stat st;
4483 4539
4540 /* Initialize locale related variables. */
4541 mac_system_script_code =
4542 (ScriptCode) GetScriptManagerVariable (smSysScript);
4543 Vmac_system_locale = mac_get_system_locale ();
4544
4484 /* Fetch the pathname of the application bundle as a C string into 4545 /* Fetch the pathname of the application bundle as a C string into
4485 app_bundle_pathname. */ 4546 app_bundle_pathname. */
4486 4547
@@ -4600,28 +4661,6 @@ init_mac_osx_environment ()
4600#endif /* MAC_OSX */ 4661#endif /* MAC_OSX */
4601 4662
4602 4663
4603static Lisp_Object
4604mac_get_system_locale ()
4605{
4606 OSErr err;
4607 LangCode lang;
4608 RegionCode region;
4609 LocaleRef locale;
4610 Str255 str;
4611
4612 lang = GetScriptVariable (smSystemScript, smScriptLang);
4613 region = GetScriptManagerVariable (smRegionCode);
4614 err = LocaleRefFromLangOrRegionCode (lang, region, &locale);
4615 if (err == noErr)
4616 err = LocaleRefGetPartString (locale, kLocaleAllPartsMask,
4617 sizeof (str), str);
4618 if (err == noErr)
4619 return build_string (str);
4620 else
4621 return Qnil;
4622}
4623
4624
4625void 4664void
4626syms_of_mac () 4665syms_of_mac ()
4627{ 4666{
diff --git a/src/macgui.h b/src/macgui.h
index 6e2adb092c6..40244dbc7c6 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -92,6 +92,12 @@ typedef GWorldPtr Pixmap;
92#endif 92#endif
93 93
94 94
95#ifndef USE_CG_TEXT_DRAWING
96#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
97#define USE_CG_TEXT_DRAWING 1
98#endif
99#endif
100
95/* Emulate XCharStruct. */ 101/* Emulate XCharStruct. */
96typedef struct _XCharStruct 102typedef struct _XCharStruct
97{ 103{
@@ -127,6 +133,10 @@ struct MacFontStruct {
127#endif 133#endif
128#if USE_ATSUI 134#if USE_ATSUI
129 ATSUStyle mac_style; /* NULL if QuickDraw Text is used */ 135 ATSUStyle mac_style; /* NULL if QuickDraw Text is used */
136#if USE_CG_TEXT_DRAWING
137 CGFontRef cg_font; /* NULL if ATSUI text drawing is used */
138 CGGlyph *cg_glyphs; /* Likewise */
139#endif
130#endif 140#endif
131 141
132/* from Xlib.h */ 142/* from Xlib.h */
diff --git a/src/macterm.c b/src/macterm.c
index 70120bdf59d..169e3d60855 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -87,14 +87,6 @@ Boston, MA 02110-1301, USA. */
87#include "atimer.h" 87#include "atimer.h"
88#include "keymap.h" 88#include "keymap.h"
89 89
90/* Set of macros that handle mapping of Mac modifier keys to emacs. */
91#define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \
92 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey))
93#define macShiftKey (shiftKey)
94#define macMetaKey (NILP (Vmac_reverse_ctrl_meta) ? \
95 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \
96 : controlKey)
97#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
98 90
99 91
100/* Non-nil means Emacs uses toolkit scroll bars. */ 92/* Non-nil means Emacs uses toolkit scroll bars. */
@@ -207,7 +199,8 @@ extern EMACS_INT extra_keyboard_modifiers;
207 199
208/* The keysyms to use for the various modifiers. */ 200/* The keysyms to use for the various modifiers. */
209 201
210static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; 202static Lisp_Object Qalt, Qhyper, Qsuper, Qctrl,
203 Qmeta, Qmodifier_value;
211 204
212extern int inhibit_window_system; 205extern int inhibit_window_system;
213 206
@@ -778,7 +771,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
778 QDEndCGContext (port, &context); 771 QDEndCGContext (port, &context);
779#if 0 772#if 0
780 /* This doesn't work on Mac OS X 10.1. */ 773 /* This doesn't work on Mac OS X 10.1. */
781 ATSUClearLayoutControls (text_layout, 774 ATSUClearLayoutControls (text_layout,
782 sizeof (tags) / sizeof (tags[0]), 775 sizeof (tags) / sizeof (tags[0]),
783 tags); 776 tags);
784#else 777#else
@@ -871,6 +864,77 @@ mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
871} 864}
872 865
873 866
867#if USE_CG_TEXT_DRAWING
868static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *));
869
870static int
871mac_draw_string_cg (f, gc, x, y, buf, nchars)
872 struct frame *f;
873 GC gc;
874 int x, y;
875 XChar2b *buf;
876 int nchars;
877{
878 CGrafPtr port;
879 float port_height, gx, gy;
880 int i;
881 CGContextRef context;
882 CGGlyph *glyphs;
883 CGSize *advances;
884
885 if (NILP (Vmac_use_core_graphics) || GC_FONT (gc)->cg_font == NULL)
886 return 0;
887
888 port = GetWindowPort (FRAME_MAC_WINDOW (f));
889 port_height = FRAME_PIXEL_HEIGHT (f);
890 gx = x;
891 gy = port_height - y;
892 glyphs = (CGGlyph *)buf;
893 advances = xmalloc (sizeof (CGSize) * nchars);
894 for (i = 0; i < nchars; i++)
895 {
896 advances[i].width = x_per_char_metric (GC_FONT (gc), buf)->width;
897 advances[i].height = 0;
898 glyphs[i] = GC_FONT (gc)->cg_glyphs[buf->byte2];
899 buf++;
900 }
901
902 QDBeginCGContext (port, &context);
903 if (gc->n_clip_rects)
904 {
905 CGContextTranslateCTM (context, 0, port_height);
906 CGContextScaleCTM (context, 1, -1);
907 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
908 CGContextScaleCTM (context, 1, -1);
909 CGContextTranslateCTM (context, 0, -port_height);
910 }
911 CGContextSetRGBFillColor (context,
912 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
913 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0,
914 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0,
915 1.0);
916 CGContextSetFont (context, GC_FONT (gc)->cg_font);
917 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
918#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
919 CGContextSetTextPosition (context, gx, gy);
920 CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars);
921#else
922 for (i = 0; i < nchars; i++)
923 {
924 CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1);
925 gx += advances[i].width;
926 }
927#endif
928 CGContextSynchronize (context);
929 QDEndCGContext (port, &context);
930
931 xfree (advances);
932
933 return 1;
934}
935#endif
936
937
874/* Mac replacement for XCopyArea: dest must be window. */ 938/* Mac replacement for XCopyArea: dest must be window. */
875 939
876static void 940static void
@@ -2265,6 +2329,13 @@ x_draw_glyph_string_foreground (s)
2265 || GC_FONT (s->gc)->mac_style 2329 || GC_FONT (s->gc)->mac_style
2266#endif 2330#endif
2267 ) 2331 )
2332#if USE_CG_TEXT_DRAWING
2333 if (!s->two_byte_p
2334 && mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff,
2335 s->char2b, s->nchars))
2336 ;
2337 else
2338#endif
2268 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff, 2339 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
2269 s->char2b, s->nchars); 2340 s->char2b, s->nchars);
2270 else 2341 else
@@ -7288,6 +7359,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
7288 Str31 charset; 7359 Str31 charset;
7289 SInt16 fontnum; 7360 SInt16 fontnum;
7290#if USE_ATSUI 7361#if USE_ATSUI
7362 static ATSUFontID font_id;
7291 ATSUStyle mac_style = NULL; 7363 ATSUStyle mac_style = NULL;
7292#endif 7364#endif
7293 Style fontface; 7365 Style fontface;
@@ -7322,7 +7394,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
7322 kATSUQDBoldfaceTag, kATSUQDItalicTag}; 7394 kATSUQDBoldfaceTag, kATSUQDItalicTag};
7323 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), 7395 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed),
7324 sizeof (Boolean), sizeof (Boolean)}; 7396 sizeof (Boolean), sizeof (Boolean)};
7325 static ATSUFontID font_id;
7326 static Fixed size_fixed; 7397 static Fixed size_fixed;
7327 static Boolean bold_p, italic_p; 7398 static Boolean bold_p, italic_p;
7328 ATSUAttributeValuePtr values[] = {&font_id, &size_fixed, 7399 ATSUAttributeValuePtr values[] = {&font_id, &size_fixed,
@@ -7376,6 +7447,10 @@ XLoadQueryFont (Display *dpy, char *fontname)
7376 font->mac_scriptcode = scriptcode; 7447 font->mac_scriptcode = scriptcode;
7377#if USE_ATSUI 7448#if USE_ATSUI
7378 font->mac_style = mac_style; 7449 font->mac_style = mac_style;
7450#if USE_CG_TEXT_DRAWING
7451 font->cg_font = NULL;
7452 font->cg_glyphs = NULL;
7453#endif
7379#endif 7454#endif
7380 7455
7381 /* Apple Japanese (SJIS) font is listed as both 7456 /* Apple Japanese (SJIS) font is listed as both
@@ -7405,6 +7480,30 @@ XLoadQueryFont (Display *dpy, char *fontname)
7405 } 7480 }
7406 bzero (font->per_char, sizeof (XCharStruct) * 0x10000); 7481 bzero (font->per_char, sizeof (XCharStruct) * 0x10000);
7407 7482
7483#if USE_CG_TEXT_DRAWING
7484 {
7485 FMFontFamily font_family;
7486 FMFontStyle style;
7487 ATSFontRef ats_font;
7488
7489 err = FMGetFontFamilyInstanceFromFont (font_id, &font_family, &style);
7490 if (err == noErr)
7491 err = FMGetFontFromFontFamilyInstance (font_family, fontface,
7492 &font_id, &style);
7493 /* Use CG text drawing if italic/bold is not synthesized. */
7494 if (err == noErr && style == fontface)
7495 {
7496 ats_font = FMGetATSFontRefFromFont (font_id);
7497 font->cg_font = CGFontCreateWithPlatformFont (&ats_font);
7498 }
7499 }
7500
7501 if (font->cg_font)
7502 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
7503 if (font->cg_glyphs)
7504 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
7505#endif
7506
7408 err = atsu_get_text_layout_with_text_ptr (&c, 1, 7507 err = atsu_get_text_layout_with_text_ptr (&c, 1,
7409 font->mac_style, 7508 font->mac_style,
7410 &text_layout); 7509 &text_layout);
@@ -7414,8 +7513,19 @@ XLoadQueryFont (Display *dpy, char *fontname)
7414 return NULL; 7513 return NULL;
7415 } 7514 }
7416 7515
7417 for (c = 0x20; c <= 0x7e; c++) 7516 for (c = 0x20; c <= 0xff; c++)
7418 { 7517 {
7518 if (c == 0xad)
7519 /* Soft hyphen is not supported in ATSUI. */
7520 continue;
7521 else if (c == 0x7f)
7522 {
7523 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7524 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7525 c = 0x9f;
7526 continue;
7527 }
7528
7419 err = ATSUClearLayoutCache (text_layout, kATSUFromTextBeginning); 7529 err = ATSUClearLayoutCache (text_layout, kATSUFromTextBeginning);
7420 if (err == noErr) 7530 if (err == noErr)
7421 err = ATSUMeasureTextImage (text_layout, 7531 err = ATSUMeasureTextImage (text_layout,
@@ -7464,9 +7574,32 @@ XLoadQueryFont (Display *dpy, char *fontname)
7464 } 7574 }
7465 } 7575 }
7466 } 7576 }
7577#if USE_CG_TEXT_DRAWING
7578 if (err == noErr && char_width > 0 && font->cg_font)
7579 {
7580 ATSUGlyphInfoArray glyph_info_array;
7581 ByteCount count = sizeof (ATSUGlyphInfoArray);
7582
7583 err = ATSUMatchFontsToText (text_layout, kATSUFromTextBeginning,
7584 kATSUToTextEnd, NULL, NULL, NULL);
7585 if (err == noErr)
7586 err = ATSUGetGlyphInfo (text_layout, kATSUFromTextBeginning,
7587 kATSUToTextEnd, &count,
7588 &glyph_info_array);
7589 if (err == noErr)
7590 font->cg_glyphs[c] = glyph_info_array.glyphs[0].glyphID;
7591 else
7592 {
7593 /* Don't use CG text drawing if font substitution
7594 occurs in ASCII or Latin-1 characters. */
7595 CGFontRelease (font->cg_font);
7596 font->cg_font = NULL;
7597 xfree (font->cg_glyphs);
7598 font->cg_glyphs = NULL;
7599 }
7600 }
7601#endif
7467 } 7602 }
7468 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7469 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7470 7603
7471 font->min_byte1 = 0; 7604 font->min_byte1 = 0;
7472 font->max_byte1 = 0xff; 7605 font->max_byte1 = 0xff;
@@ -7579,6 +7712,13 @@ XLoadQueryFont (Display *dpy, char *fontname)
7579 SetRect (&max_bounds, 0, 0, 0, 0); 7712 SetRect (&max_bounds, 0, 0, 0, 0);
7580 for (c = 0x20; c <= 0xff; c++) 7713 for (c = 0x20; c <= 0xff; c++)
7581 { 7714 {
7715 if (c == 0x7f)
7716 {
7717 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7718 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7719 continue;
7720 }
7721
7582 ch = c; 7722 ch = c;
7583 char_width = CharWidth (ch); 7723 char_width = CharWidth (ch);
7584 QDTextBounds (1, &ch, &char_bounds); 7724 QDTextBounds (1, &ch, &char_bounds);
@@ -7601,8 +7741,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
7601 UnionRect (&max_bounds, &char_bounds, &max_bounds); 7741 UnionRect (&max_bounds, &char_bounds, &max_bounds);
7602 } 7742 }
7603 } 7743 }
7604 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7605 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7606 if (min_width == max_width 7744 if (min_width == max_width
7607 && max_bounds.left >= 0 && max_bounds.right <= max_width) 7745 && max_bounds.left >= 0 && max_bounds.right <= max_width)
7608 { 7746 {
@@ -7618,6 +7756,15 @@ XLoadQueryFont (Display *dpy, char *fontname)
7618 TextFace (old_fontface); 7756 TextFace (old_fontface);
7619 } 7757 }
7620 7758
7759#if !defined (MAC_OS8) || USE_ATSUI
7760 /* AppKit and WebKit do some adjustment to the heights of Courier,
7761 Helvetica, and Times. This only works on the environments where
7762 the XDrawImageString counterpart is never used. */
7763 if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
7764 || strcmp (family, "times") == 0)
7765 font->ascent += (font->ascent + font->descent) * .15 + 0.5;
7766#endif
7767
7621 return font; 7768 return font;
7622} 7769}
7623 7770
@@ -7633,6 +7780,12 @@ mac_unload_font (dpyinfo, font)
7633#if USE_ATSUI 7780#if USE_ATSUI
7634 if (font->mac_style) 7781 if (font->mac_style)
7635 ATSUDisposeStyle (font->mac_style); 7782 ATSUDisposeStyle (font->mac_style);
7783#if USE_CG_TEXT_DRAWING
7784 if (font->cg_font)
7785 CGFontRelease (font->cg_font);
7786 if (font->cg_glyphs)
7787 xfree (font->cg_glyphs);
7788#endif
7636#endif 7789#endif
7637 xfree (font); 7790 xfree (font);
7638} 7791}
@@ -7920,14 +8073,18 @@ x_find_ccl_program (fontp)
7920/* Contains the string "reverse", which is a constant for mouse button emu.*/ 8073/* Contains the string "reverse", which is a constant for mouse button emu.*/
7921Lisp_Object Qreverse; 8074Lisp_Object Qreverse;
7922 8075
7923/* True if using command key as meta key. */
7924Lisp_Object Vmac_command_key_is_meta;
7925 8076
7926/* Modifier associated with the option key, or nil for normal behavior. */ 8077/* Modifier associated with the control key, or nil to ignore. */
8078Lisp_Object Vmac_control_modifier;
8079
8080/* Modifier associated with the option key, or nil to ignore. */
7927Lisp_Object Vmac_option_modifier; 8081Lisp_Object Vmac_option_modifier;
7928 8082
7929/* True if the ctrl and meta keys should be reversed. */ 8083/* Modifier associated with the command key, or nil to ignore. */
7930Lisp_Object Vmac_reverse_ctrl_meta; 8084Lisp_Object Vmac_command_modifier;
8085
8086/* Modifier associated with the function key, or nil to ignore. */
8087Lisp_Object Vmac_function_modifier;
7931 8088
7932/* True if the option and command modifiers should be used to emulate 8089/* True if the option and command modifiers should be used to emulate
7933 a three button mouse */ 8090 a three button mouse */
@@ -8001,19 +8158,43 @@ mac_to_emacs_modifiers (EventModifiers mods)
8001#endif 8158#endif
8002{ 8159{
8003 unsigned int result = 0; 8160 unsigned int result = 0;
8004 if (mods & macShiftKey) 8161 if (mods & shiftKey)
8005 result |= shift_modifier; 8162 result |= shift_modifier;
8006 if (mods & macCtrlKey) 8163
8007 result |= ctrl_modifier; 8164
8008 if (mods & macMetaKey) 8165
8009 result |= meta_modifier; 8166 /* Deactivated to simplify configuration:
8010 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) 8167 if Vmac_option_modifier is non-NIL, we fully process the Option
8011 result |= alt_modifier; 8168 key. Otherwise, we only process it if an additional Ctrl or Command
8169 is pressed. That way the system may convert the character to a
8170 composed one.
8171 if ((mods & optionKey) &&
8172 (( !NILP(Vmac_option_modifier) ||
8173 ((mods & cmdKey) || (mods & controlKey))))) */
8174
8012 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) { 8175 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) {
8013 Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value); 8176 Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value);
8014 if (!NILP(val)) 8177 if (INTEGERP(val))
8015 result |= XUINT(val); 8178 result |= XUINT(val);
8016 } 8179 }
8180 if (!NILP (Vmac_command_modifier) && (mods & cmdKey)) {
8181 Lisp_Object val = Fget(Vmac_command_modifier, Qmodifier_value);
8182 if (INTEGERP(val))
8183 result |= XUINT(val);
8184 }
8185 if (!NILP (Vmac_control_modifier) && (mods & controlKey)) {
8186 Lisp_Object val = Fget(Vmac_control_modifier, Qmodifier_value);
8187 if (INTEGERP(val))
8188 result |= XUINT(val);
8189 }
8190
8191#ifdef MAC_OSX
8192 if (!NILP (Vmac_function_modifier) && (mods & kEventKeyModifierFnMask)) {
8193 Lisp_Object val = Fget(Vmac_function_modifier, Qmodifier_value);
8194 if (INTEGERP(val))
8195 result |= XUINT(val);
8196 }
8197#endif
8017 8198
8018 return result; 8199 return result;
8019} 8200}
@@ -8035,7 +8216,7 @@ mac_get_emulated_btn ( UInt32 modifiers )
8035#if USE_CARBON_EVENTS 8216#if USE_CARBON_EVENTS
8036/* Obtains the event modifiers from the event ref and then calls 8217/* Obtains the event modifiers from the event ref and then calls
8037 mac_to_emacs_modifiers. */ 8218 mac_to_emacs_modifiers. */
8038static int 8219static UInt32
8039mac_event_to_emacs_modifiers (EventRef eventRef) 8220mac_event_to_emacs_modifiers (EventRef eventRef)
8040{ 8221{
8041 UInt32 mods = 0; 8222 UInt32 mods = 0;
@@ -9385,6 +9566,7 @@ static unsigned char keycode_to_xkeysym_table[] = {
9385 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0 9566 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0
9386}; 9567};
9387 9568
9569
9388static int 9570static int
9389keycode_to_xkeysym (int keyCode, int *xKeySym) 9571keycode_to_xkeysym (int keyCode, int *xKeySym)
9390{ 9572{
@@ -9392,6 +9574,121 @@ keycode_to_xkeysym (int keyCode, int *xKeySym)
9392 return *xKeySym != 0; 9574 return *xKeySym != 0;
9393} 9575}
9394 9576
9577static unsigned char fn_keycode_to_xkeysym_table[] = {
9578 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9579 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9580 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9581
9582 /*0x30*/ 0, 0, 0, 0,
9583 /*0x34*/ 0, 0, 0, 0,
9584 /*0x38*/ 0, 0, 0, 0,
9585 /*0x3C*/ 0, 0, 0, 0,
9586
9587 /*0x40*/ 0, 0x2e /*kp-. = .*/, 0, 0x50 /*kp-* = 'p'*/,
9588 /*0x44*/ 0, '/' /*kp-+*/, 0, 0,
9589 /*0x48*/ 0, 0, 0, 0x30 /*kp-/ = '0'*/,
9590 /*0x4C*/ 0, 0, 0x3b /*kp-- = ';'*/, 0,
9591
9592 /*0x50*/ 0, 0x2d /*kp-= = '-'*/, 0x6d /*kp-0 = 'm'*/, 0x6a /*kp-1 = 'j'*/,
9593 /*0x54*/ 0x6b /*kp-2 = 'k'*/, 0x6c /*kp-3 = 'l'*/, 'u' /*kp-4*/, 'i' /*kp-5*/,
9594 /*0x58*/ 'o' /*kp-6*/, '7' /*kp-7*/, 0, '8' /*kp-8*/,
9595 /*0x5C*/ '9' /*kp-9*/, 0, 0, 0,
9596
9597 /*0x60*/ 0, 0, 0, 0,
9598 /*0x64*/ 0, 0, 0, 0,
9599 /*0x68*/ 0, 0, 0, 0,
9600 /*0x6C*/ 0, 0, 0, 0,
9601
9602 /*0x70*/ 0, 0, 0, 0,
9603 /*0x74*/ 0, 0, 0, 0,
9604 /*0x78*/ 0, 0, 0, 0,
9605 /*0x7C*/ 0, 0, 0, 0
9606};
9607static int
9608convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9609{
9610#ifdef MAC_OSX
9611 /* Use the special map to translate keys when function modifier is
9612 to be caught. KeyTranslate can't be used in that case.
9613 We can't detect the function key using the input_event.modifiers,
9614 because this uses the high word of an UInt32. Therefore,
9615 we'll just read it out of the original eventRef.
9616 */
9617
9618
9619 /* TODO / known issues
9620
9621 - Fn-Shift-j is regonized as Fn-j and not Fn-J.
9622 The above table always translates to lower characters. We need to use
9623 the KCHR keyboard resource (KeyTranslate() ) to map k->K and 8->*.
9624
9625 - The table is meant for English language keyboards, and it will work
9626 for many others with the exception of key combinations like Fn-ö on
9627 a German keyboard, which is currently mapped to Fn-;.
9628 How to solve this without keeping separate tables for all keyboards
9629 around? KeyTranslate isn't of much help here, as it only takes a 16-bit
9630 value for keycode with the modifiers in he high byte, i.e. no room for the
9631 Fn modifier. That's why we need the table.
9632
9633 */
9634
9635 UInt32 mods = 0;
9636 if (!NILP(Vmac_function_modifier))
9637 {
9638 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
9639 sizeof (UInt32), NULL, &mods);
9640 if (mods & kEventKeyModifierFnMask)
9641 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f];
9642
9643 return (*newCode != 0);
9644 }
9645 }
9646#endif
9647 return false;
9648}
9649
9650static int
9651backtranslate_modified_keycode(int mods, int keycode, int def)
9652{
9653 if (mods &
9654 (controlKey |
9655 (NILP (Vmac_option_modifier) ? 0 : optionKey) |
9656 cmdKey))
9657 {
9658 /* This code comes from Keyboard Resource,
9659 Appendix C of IM - Text. This is necessary
9660 since shift is ignored in KCHR table
9661 translation when option or command is pressed.
9662 It also does not translate correctly
9663 control-shift chars like C-% so mask off shift
9664 here also.
9665
9666 Not done for combinations with the option key (alt)
9667 unless it is to be caught by Emacs: this is
9668 to preserve key combinations translated by the OS
9669 such as Alt-3.
9670 */
9671 /* mask off option and command */
9672 int new_modifiers = mods & 0xe600;
9673 /* set high byte of keycode to modifier high byte*/
9674 int new_keycode = keycode | new_modifiers;
9675 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9676 unsigned long some_state = 0;
9677 return (int) KeyTranslate (kchr_ptr, new_keycode,
9678 &some_state) & 0xff;
9679 /* TO DO: Recognize two separate resulting characters, "for
9680 example, when the user presses Option-E followed by N, you
9681 can map this through the KeyTranslate function using the
9682 U.S. 'KCHR' resource to produce ´n, which KeyTranslate
9683 returns as two characters in the bytes labeled Character code
9684 1 and Character code 2." (from Carbon API doc) */
9685
9686 }
9687 else
9688 return def;
9689}
9690
9691
9395#if !USE_CARBON_EVENTS 9692#if !USE_CARBON_EVENTS
9396static RgnHandle mouse_region = NULL; 9693static RgnHandle mouse_region = NULL;
9397 9694
@@ -9936,8 +10233,7 @@ XTread_socket (sd, expected, hold_quit)
9936 || !(er.modifiers & cmdKey)) 10233 || !(er.modifiers & cmdKey))
9937 && (!NILP (Vmac_pass_control_to_system) 10234 && (!NILP (Vmac_pass_control_to_system)
9938 || !(er.modifiers & controlKey)) 10235 || !(er.modifiers & controlKey))
9939 && (!NILP (Vmac_command_key_is_meta) 10236 && (NILP (Vmac_option_modifier)
9940 && NILP (Vmac_option_modifier)
9941 || !(er.modifiers & optionKey))) 10237 || !(er.modifiers & optionKey)))
9942 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 10238 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
9943 != eventNotHandledErr) 10239 != eventNotHandledErr)
@@ -9981,49 +10277,36 @@ XTread_socket (sd, expected, hold_quit)
9981 dpyinfo->mouse_face_hidden = 1; 10277 dpyinfo->mouse_face_hidden = 1;
9982 } 10278 }
9983 10279
9984 if (keycode_to_xkeysym (keycode, &xkeysym)) 10280 /* translate the keycode back to determine the original key */
9985 { 10281 /* Convert key code if function key is pressed.
9986 inev.code = 0xff00 | xkeysym; 10282 Otherwise, if non-ASCII-event, take care of that
9987 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 10283 without re-translating the key code. */
9988 } 10284#if USE_CARBON_EVENTS
9989 else 10285 if (convert_fn_keycode (eventRef, keycode, &xkeysym))
9990 { 10286 {
9991 if (er.modifiers & (controlKey | 10287 inev.code = xkeysym;
9992 (NILP (Vmac_command_key_is_meta) ? optionKey 10288 /* this doesn't work - tried to add shift modifiers */
9993 : cmdKey))) 10289 inev.code =
9994 { 10290 backtranslate_modified_keycode(er.modifiers & (~0x2200),
9995 /* This code comes from Keyboard Resource, 10291 xkeysym | 0x80, xkeysym);
9996 Appendix C of IM - Text. This is necessary
9997 since shift is ignored in KCHR table
9998 translation when option or command is pressed.
9999 It also does not translate correctly
10000 control-shift chars like C-% so mask off shift
10001 here also */
10002 int new_modifiers = er.modifiers & 0xe600;
10003 /* mask off option and command */
10004 int new_keycode = keycode | new_modifiers;
10005 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
10006 unsigned long some_state = 0;
10007 inev.code = KeyTranslate (kchr_ptr, new_keycode,
10008 &some_state) & 0xff;
10009 }
10010 else if (!NILP (Vmac_option_modifier)
10011 && (er.modifiers & optionKey))
10012 {
10013 /* When using the option key as an emacs modifier,
10014 convert the pressed key code back to one
10015 without the Mac option modifier applied. */
10016 int new_modifiers = er.modifiers & ~optionKey;
10017 int new_keycode = keycode | new_modifiers;
10018 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
10019 unsigned long some_state = 0;
10020 inev.code = KeyTranslate (kchr_ptr, new_keycode,
10021 &some_state) & 0xff;
10022 }
10023 else
10024 inev.code = er.message & charCodeMask;
10025 inev.kind = ASCII_KEYSTROKE_EVENT; 10292 inev.kind = ASCII_KEYSTROKE_EVENT;
10026 } 10293 }
10294 else
10295#endif
10296 if (keycode_to_xkeysym (keycode, &xkeysym))
10297 {
10298 inev.code = 0xff00 | xkeysym;
10299 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
10300 }
10301 else
10302 {
10303
10304 inev.code =
10305 backtranslate_modified_keycode(er.modifiers, keycode,
10306 er.message & charCodeMask);
10307 inev.kind = ASCII_KEYSTROKE_EVENT;
10308
10309 }
10027 } 10310 }
10028 10311
10029#if USE_CARBON_EVENTS 10312#if USE_CARBON_EVENTS
@@ -10463,10 +10746,9 @@ mac_determine_quit_char_modifiers()
10463 10746
10464 /* Map modifiers */ 10747 /* Map modifiers */
10465 mac_quit_char_modifiers = 0; 10748 mac_quit_char_modifiers = 0;
10466 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= macCtrlKey; 10749 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= controlKey;
10467 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= macShiftKey; 10750 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= shiftKey;
10468 if (qc_modifiers & meta_modifier) mac_quit_char_modifiers |= macMetaKey; 10751 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= optionKey;
10469 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= macAltKey;
10470} 10752}
10471 10753
10472static void 10754static void
@@ -10624,6 +10906,10 @@ syms_of_macterm ()
10624#endif 10906#endif
10625 10907
10626 Qmodifier_value = intern ("modifier-value"); 10908 Qmodifier_value = intern ("modifier-value");
10909 Qctrl = intern ("ctrl");
10910 Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier));
10911 Qmeta = intern ("meta");
10912 Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
10627 Qalt = intern ("alt"); 10913 Qalt = intern ("alt");
10628 Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); 10914 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
10629 Qhyper = intern ("hyper"); 10915 Qhyper = intern ("hyper");
@@ -10676,21 +10962,36 @@ syms_of_macterm ()
10676 staticpro (&last_mouse_motion_frame); 10962 staticpro (&last_mouse_motion_frame);
10677 last_mouse_motion_frame = Qnil; 10963 last_mouse_motion_frame = Qnil;
10678 10964
10679 DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta, 10965
10680 doc: /* Non-nil means that the command key is used as the Emacs meta key. 10966
10681Otherwise the option key is used. */); 10967/* Variables to configure modifier key assignment. */
10682 Vmac_command_key_is_meta = Qt; 10968
10969 DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier,
10970 doc: /* Modifier key assumed when the Mac control key is pressed.
10971The value can be `alt', `ctrl', `hyper', or `super' for the respective
10972modifier. The default is `ctrl'. */);
10973 Vmac_control_modifier = Qctrl;
10683 10974
10684 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier, 10975 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
10685 doc: /* Modifier to use for the Mac alt/option key. The value can 10976 doc: /* Modifier key assumed when the Mac alt/option key is pressed.
10686be alt, hyper, or super for the respective modifier. If the value is 10977The value can be `alt', `ctrl', `hyper', or `super' for the respective
10687nil then the key will act as the normal Mac option modifier. */); 10978modifier. If the value is nil then the key will act as the normal
10979Mac control modifier, and the option key can be used to compose
10980characters depending on the chosen Mac keyboard setting. */);
10688 Vmac_option_modifier = Qnil; 10981 Vmac_option_modifier = Qnil;
10689 10982
10690 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, 10983 DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier,
10691 doc: /* Non-nil means that the control and meta keys are reversed. This is 10984 doc: /* Modifier key assumed when the Mac command key is pressed.
10692useful for non-standard keyboard layouts. */); 10985The value can be `alt', `ctrl', `hyper', or `super' for the respective
10693 Vmac_reverse_ctrl_meta = Qnil; 10986modifier. The default is `meta'. */);
10987 Vmac_command_modifier = Qmeta;
10988
10989 DEFVAR_LISP ("mac-function-modifier", &Vmac_function_modifier,
10990 doc: /* Modifier key assumed when the Mac function key is pressed.
10991The value can be `alt', `ctrl', `hyper', or `super' for the respective
10992modifier. Note that remapping the function key may lead to unexpected
10993results for some keys on non-US/GB keyboards. */);
10994 Vmac_function_modifier = Qnil;
10694 10995
10695 DEFVAR_LISP ("mac-emulate-three-button-mouse", 10996 DEFVAR_LISP ("mac-emulate-three-button-mouse",
10696 &Vmac_emulate_three_button_mouse, 10997 &Vmac_emulate_three_button_mouse,
diff --git a/src/print.c b/src/print.c
index 91642afd651..d563580ddd3 100644
--- a/src/print.c
+++ b/src/print.c
@@ -970,6 +970,26 @@ debug_print (arg)
970 Fprin1 (arg, Qexternal_debugging_output); 970 Fprin1 (arg, Qexternal_debugging_output);
971 fprintf (stderr, "\r\n"); 971 fprintf (stderr, "\r\n");
972} 972}
973
974void
975safe_debug_print (arg)
976 Lisp_Object arg;
977{
978 int valid = valid_lisp_object_p (arg);
979
980 if (valid > 0)
981 debug_print (arg);
982 else
983 fprintf (stderr, "#<%s_LISP_OBJECT 0x%08lx>\r\n",
984 !valid ? "INVALID" : "SOME",
985#ifdef NO_UNION_TYPE
986 (unsigned long) arg
987#else
988 (unsigned long) arg.i
989#endif
990 );
991}
992
973 993
974DEFUN ("error-message-string", Ferror_message_string, Serror_message_string, 994DEFUN ("error-message-string", Ferror_message_string, Serror_message_string,
975 1, 1, 0, 995 1, 1, 0,
diff --git a/src/process.c b/src/process.c
index dd892637726..752768a7bad 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5944,97 +5944,100 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
5944 CHECK_SYMBOL (sigcode); 5944 CHECK_SYMBOL (sigcode);
5945 name = SDATA (SYMBOL_NAME (sigcode)); 5945 name = SDATA (SYMBOL_NAME (sigcode));
5946 5946
5947 if (!strncmp(name, "SIG", 3))
5948 name += 3;
5949
5947 if (0) 5950 if (0)
5948 ; 5951 ;
5949#ifdef SIGHUP 5952#ifdef SIGHUP
5950 handle_signal ("SIGHUP", SIGHUP); 5953 handle_signal ("HUP", SIGHUP);
5951#endif 5954#endif
5952#ifdef SIGINT 5955#ifdef SIGINT
5953 handle_signal ("SIGINT", SIGINT); 5956 handle_signal ("INT", SIGINT);
5954#endif 5957#endif
5955#ifdef SIGQUIT 5958#ifdef SIGQUIT
5956 handle_signal ("SIGQUIT", SIGQUIT); 5959 handle_signal ("QUIT", SIGQUIT);
5957#endif 5960#endif
5958#ifdef SIGILL 5961#ifdef SIGILL
5959 handle_signal ("SIGILL", SIGILL); 5962 handle_signal ("ILL", SIGILL);
5960#endif 5963#endif
5961#ifdef SIGABRT 5964#ifdef SIGABRT
5962 handle_signal ("SIGABRT", SIGABRT); 5965 handle_signal ("ABRT", SIGABRT);
5963#endif 5966#endif
5964#ifdef SIGEMT 5967#ifdef SIGEMT
5965 handle_signal ("SIGEMT", SIGEMT); 5968 handle_signal ("EMT", SIGEMT);
5966#endif 5969#endif
5967#ifdef SIGKILL 5970#ifdef SIGKILL
5968 handle_signal ("SIGKILL", SIGKILL); 5971 handle_signal ("KILL", SIGKILL);
5969#endif 5972#endif
5970#ifdef SIGFPE 5973#ifdef SIGFPE
5971 handle_signal ("SIGFPE", SIGFPE); 5974 handle_signal ("FPE", SIGFPE);
5972#endif 5975#endif
5973#ifdef SIGBUS 5976#ifdef SIGBUS
5974 handle_signal ("SIGBUS", SIGBUS); 5977 handle_signal ("BUS", SIGBUS);
5975#endif 5978#endif
5976#ifdef SIGSEGV 5979#ifdef SIGSEGV
5977 handle_signal ("SIGSEGV", SIGSEGV); 5980 handle_signal ("SEGV", SIGSEGV);
5978#endif 5981#endif
5979#ifdef SIGSYS 5982#ifdef SIGSYS
5980 handle_signal ("SIGSYS", SIGSYS); 5983 handle_signal ("SYS", SIGSYS);
5981#endif 5984#endif
5982#ifdef SIGPIPE 5985#ifdef SIGPIPE
5983 handle_signal ("SIGPIPE", SIGPIPE); 5986 handle_signal ("PIPE", SIGPIPE);
5984#endif 5987#endif
5985#ifdef SIGALRM 5988#ifdef SIGALRM
5986 handle_signal ("SIGALRM", SIGALRM); 5989 handle_signal ("ALRM", SIGALRM);
5987#endif 5990#endif
5988#ifdef SIGTERM 5991#ifdef SIGTERM
5989 handle_signal ("SIGTERM", SIGTERM); 5992 handle_signal ("TERM", SIGTERM);
5990#endif 5993#endif
5991#ifdef SIGURG 5994#ifdef SIGURG
5992 handle_signal ("SIGURG", SIGURG); 5995 handle_signal ("URG", SIGURG);
5993#endif 5996#endif
5994#ifdef SIGSTOP 5997#ifdef SIGSTOP
5995 handle_signal ("SIGSTOP", SIGSTOP); 5998 handle_signal ("STOP", SIGSTOP);
5996#endif 5999#endif
5997#ifdef SIGTSTP 6000#ifdef SIGTSTP
5998 handle_signal ("SIGTSTP", SIGTSTP); 6001 handle_signal ("TSTP", SIGTSTP);
5999#endif 6002#endif
6000#ifdef SIGCONT 6003#ifdef SIGCONT
6001 handle_signal ("SIGCONT", SIGCONT); 6004 handle_signal ("CONT", SIGCONT);
6002#endif 6005#endif
6003#ifdef SIGCHLD 6006#ifdef SIGCHLD
6004 handle_signal ("SIGCHLD", SIGCHLD); 6007 handle_signal ("CHLD", SIGCHLD);
6005#endif 6008#endif
6006#ifdef SIGTTIN 6009#ifdef SIGTTIN
6007 handle_signal ("SIGTTIN", SIGTTIN); 6010 handle_signal ("TTIN", SIGTTIN);
6008#endif 6011#endif
6009#ifdef SIGTTOU 6012#ifdef SIGTTOU
6010 handle_signal ("SIGTTOU", SIGTTOU); 6013 handle_signal ("TTOU", SIGTTOU);
6011#endif 6014#endif
6012#ifdef SIGIO 6015#ifdef SIGIO
6013 handle_signal ("SIGIO", SIGIO); 6016 handle_signal ("IO", SIGIO);
6014#endif 6017#endif
6015#ifdef SIGXCPU 6018#ifdef SIGXCPU
6016 handle_signal ("SIGXCPU", SIGXCPU); 6019 handle_signal ("XCPU", SIGXCPU);
6017#endif 6020#endif
6018#ifdef SIGXFSZ 6021#ifdef SIGXFSZ
6019 handle_signal ("SIGXFSZ", SIGXFSZ); 6022 handle_signal ("XFSZ", SIGXFSZ);
6020#endif 6023#endif
6021#ifdef SIGVTALRM 6024#ifdef SIGVTALRM
6022 handle_signal ("SIGVTALRM", SIGVTALRM); 6025 handle_signal ("VTALRM", SIGVTALRM);
6023#endif 6026#endif
6024#ifdef SIGPROF 6027#ifdef SIGPROF
6025 handle_signal ("SIGPROF", SIGPROF); 6028 handle_signal ("PROF", SIGPROF);
6026#endif 6029#endif
6027#ifdef SIGWINCH 6030#ifdef SIGWINCH
6028 handle_signal ("SIGWINCH", SIGWINCH); 6031 handle_signal ("WINCH", SIGWINCH);
6029#endif 6032#endif
6030#ifdef SIGINFO 6033#ifdef SIGINFO
6031 handle_signal ("SIGINFO", SIGINFO); 6034 handle_signal ("INFO", SIGINFO);
6032#endif 6035#endif
6033#ifdef SIGUSR1 6036#ifdef SIGUSR1
6034 handle_signal ("SIGUSR1", SIGUSR1); 6037 handle_signal ("USR1", SIGUSR1);
6035#endif 6038#endif
6036#ifdef SIGUSR2 6039#ifdef SIGUSR2
6037 handle_signal ("SIGUSR2", SIGUSR2); 6040 handle_signal ("USR2", SIGUSR2);
6038#endif 6041#endif
6039 else 6042 else
6040 error ("Undefined signal name %s", name); 6043 error ("Undefined signal name %s", name);
diff --git a/src/s/darwin.h b/src/s/darwin.h
index fad445d7557..6227010e3ed 100644
--- a/src/s/darwin.h
+++ b/src/s/darwin.h
@@ -263,13 +263,13 @@ Boston, MA 02110-1301, USA. */
263 263
264/* Indicate that we are compiling for Mac OS X and where to find Mac 264/* Indicate that we are compiling for Mac OS X and where to find Mac
265 specific headers. */ 265 specific headers. */
266#define C_SWITCH_SYSTEM -fpascal-strings -fno-common -DMAC_OSX -I../mac/src 266#define C_SWITCH_SYSTEM -fpascal-strings -DMAC_OSX -I../mac/src
267 267
268/* Link in the Carbon lib. */ 268/* Link in the Carbon lib. */
269#ifdef HAVE_CARBON 269#ifdef HAVE_CARBON
270#define LIBS_CARBON -framework Carbon -framework QuickTime 270#define LIBS_CARBON -framework Carbon -framework QuickTime
271#else 271#else
272#define LIBS_CARBON -framework Carbon 272#define LIBS_CARBON
273#endif 273#endif
274 274
275/* The -headerpad option tells ld (see man page) to leave room at the 275/* The -headerpad option tells ld (see man page) to leave room at the
@@ -328,6 +328,10 @@ struct kboard;
328 does not exist. */ 328 does not exist. */
329#undef HAVE_WORKING_VFORK 329#undef HAVE_WORKING_VFORK
330#define vfork fork 330#define vfork fork
331
332/* Don't close pty in process.c to make it as controlling terminal.
333 It is already a controlling terminal of subprocess, because we did
334 ioctl TIOCSCTTY. */
331#define DONT_REOPEN_PTY 335#define DONT_REOPEN_PTY
332 336
333#ifdef temacs 337#ifdef temacs
diff --git a/src/search.c b/src/search.c
index d3a5bd838a9..ab4b2a0f519 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1174,7 +1174,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1174 int raw_pattern_size_byte; 1174 int raw_pattern_size_byte;
1175 unsigned char *patbuf; 1175 unsigned char *patbuf;
1176 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 1176 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
1177 unsigned char *base_pat = SDATA (string); 1177 unsigned char *base_pat;
1178 /* Set to positive if we find a non-ASCII char that need 1178 /* Set to positive if we find a non-ASCII char that need
1179 translation. Otherwise set to zero later. */ 1179 translation. Otherwise set to zero later. */
1180 int charset_base = -1; 1180 int charset_base = -1;
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index 9db9622f6f5..43e1f5e805c 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -174,7 +174,7 @@ off_t data_segment_old_fileoff;
174 174
175struct segment_command *data_segment_scp; 175struct segment_command *data_segment_scp;
176 176
177/* Read n bytes from infd into memory starting at address dest. 177/* Read N bytes from infd into memory starting at address DEST.
178 Return true if successful, false otherwise. */ 178 Return true if successful, false otherwise. */
179static int 179static int
180unexec_read (void *dest, size_t n) 180unexec_read (void *dest, size_t n)
@@ -182,8 +182,9 @@ unexec_read (void *dest, size_t n)
182 return n == read (infd, dest, n); 182 return n == read (infd, dest, n);
183} 183}
184 184
185/* Write n bytes from memory starting at address src to outfd starting 185/* Write COUNT bytes from memory starting at address SRC to outfd
186 at offset dest. Return true if successful, false otherwise. */ 186 starting at offset DEST. Return true if successful, false
187 otherwise. */
187static int 188static int
188unexec_write (off_t dest, const void *src, size_t count) 189unexec_write (off_t dest, const void *src, size_t count)
189{ 190{
@@ -193,8 +194,32 @@ unexec_write (off_t dest, const void *src, size_t count)
193 return write (outfd, src, count) == count; 194 return write (outfd, src, count) == count;
194} 195}
195 196
196/* Copy n bytes from starting offset src in infd to starting offset 197/* Write COUNT bytes of zeros to outfd starting at offset DEST.
197 dest in outfd. Return true if successful, false otherwise. */ 198 Return true if successful, false otherwise. */
199static int
200unexec_write_zero (off_t dest, size_t count)
201{
202 char buf[UNEXEC_COPY_BUFSZ];
203 ssize_t bytes;
204
205 bzero (buf, UNEXEC_COPY_BUFSZ);
206 if (lseek (outfd, dest, SEEK_SET) != dest)
207 return 0;
208
209 while (count > 0)
210 {
211 bytes = count > UNEXEC_COPY_BUFSZ ? UNEXEC_COPY_BUFSZ : count;
212 if (write (outfd, buf, bytes) != bytes)
213 return 0;
214 count -= bytes;
215 }
216
217 return 1;
218}
219
220/* Copy COUNT bytes from starting offset SRC in infd to starting
221 offset DEST in outfd. Return true if successful, false
222 otherwise. */
198static int 223static int
199unexec_copy (off_t dest, off_t src, ssize_t count) 224unexec_copy (off_t dest, off_t src, ssize_t count)
200{ 225{
@@ -684,14 +709,39 @@ copy_data_segment (struct load_command *lc)
684 if (!unexec_write (header_offset, sectp, sizeof (struct section))) 709 if (!unexec_write (header_offset, sectp, sizeof (struct section)))
685 unexec_error ("cannot write section %s's header", SECT_DATA); 710 unexec_error ("cannot write section %s's header", SECT_DATA);
686 } 711 }
687 else if (strncmp (sectp->sectname, SECT_BSS, 16) == 0 712 else if (strncmp (sectp->sectname, SECT_COMMON, 16) == 0)
688 || strncmp (sectp->sectname, SECT_COMMON, 16) == 0)
689 { 713 {
690 sectp->flags = S_REGULAR; 714 sectp->flags = S_REGULAR;
691 if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size)) 715 if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size))
692 unexec_error ("cannot write section %s", SECT_DATA); 716 unexec_error ("cannot write section %s", sectp->sectname);
693 if (!unexec_write (header_offset, sectp, sizeof (struct section))) 717 if (!unexec_write (header_offset, sectp, sizeof (struct section)))
694 unexec_error ("cannot write section %s's header", SECT_DATA); 718 unexec_error ("cannot write section %s's header", sectp->sectname);
719 }
720 else if (strncmp (sectp->sectname, SECT_BSS, 16) == 0)
721 {
722 extern char *my_endbss_static;
723 unsigned long my_size;
724
725 sectp->flags = S_REGULAR;
726
727 /* Clear uninitialized local variables in statically linked
728 libraries. In particular, function pointers stored by
729 libSystemStub.a, which is introduced in Mac OS X 10.4 for
730 binary compatibility with respect to long double, are
731 cleared so that they will be reinitialized when the
732 dumped binary is executed on other versions of OS. */
733 my_size = (unsigned long)my_endbss_static - sectp->addr;
734 if (!(sectp->addr <= (unsigned long)my_endbss_static
735 && my_size <= sectp->size))
736 unexec_error ("my_endbss_static is not in section %s",
737 sectp->sectname);
738 if (!unexec_write (sectp->offset, (void *) sectp->addr, my_size))
739 unexec_error ("cannot write section %s", sectp->sectname);
740 if (!unexec_write_zero (sectp->offset + my_size,
741 sectp->size - my_size))
742 unexec_error ("cannot write section %s", sectp->sectname);
743 if (!unexec_write (header_offset, sectp, sizeof (struct section)))
744 unexec_error ("cannot write section %s's header", sectp->sectname);
695 } 745 }
696 else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0 746 else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0
697 || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0 747 || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0
diff --git a/src/xdisp.c b/src/xdisp.c
index 4db562c2283..623a1b3a524 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2965,11 +2965,13 @@ handle_stop (it)
2965 struct it *it; 2965 struct it *it;
2966{ 2966{
2967 enum prop_handled handled; 2967 enum prop_handled handled;
2968 int handle_overlay_change_p = 1; 2968 int handle_overlay_change_p;
2969 struct props *p; 2969 struct props *p;
2970 2970
2971 it->dpvec = NULL; 2971 it->dpvec = NULL;
2972 it->current.dpvec_index = -1; 2972 it->current.dpvec_index = -1;
2973 handle_overlay_change_p = !it->ignore_overlay_strings_at_pos_p;
2974 it->ignore_overlay_strings_at_pos_p = 0;
2973 2975
2974 /* Use face of preceding text for ellipsis (if invisible) */ 2976 /* Use face of preceding text for ellipsis (if invisible) */
2975 if (it->selective_display_ellipsis_p) 2977 if (it->selective_display_ellipsis_p)
@@ -5673,6 +5675,9 @@ set_iterator_to_next (it, reseat_p)
5673 reseat_at_next_visible_line_start (it, 1); 5675 reseat_at_next_visible_line_start (it, 1);
5674 else if (it->dpvec_char_len > 0) 5676 else if (it->dpvec_char_len > 0)
5675 { 5677 {
5678 if (it->method == GET_FROM_STRING
5679 && it->n_overlay_strings > 0)
5680 it->ignore_overlay_strings_at_pos_p = 1;
5676 it->len = it->dpvec_char_len; 5681 it->len = it->dpvec_char_len;
5677 set_iterator_to_next (it, reseat_p); 5682 set_iterator_to_next (it, reseat_p);
5678 } 5683 }
@@ -20809,7 +20814,7 @@ get_window_cursor_type (w, glyph, width, active_cursor)
20809 /* Use cursor-in-non-selected-windows for non-selected window or frame. */ 20814 /* Use cursor-in-non-selected-windows for non-selected window or frame. */
20810 if (non_selected) 20815 if (non_selected)
20811 { 20816 {
20812 alt_cursor = XBUFFER (w->buffer)->cursor_in_non_selected_windows; 20817 alt_cursor = b->cursor_in_non_selected_windows;
20813 return get_specified_cursor_type (alt_cursor, width); 20818 return get_specified_cursor_type (alt_cursor, width);
20814 } 20819 }
20815 20820
diff --git a/src/xfns.c b/src/xfns.c
index d39616429ad..311bc5f1bd8 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -829,6 +829,27 @@ xg_set_icon (f, file)
829 UNGCPRO; 829 UNGCPRO;
830 return result; 830 return result;
831} 831}
832
833int
834xg_set_icon_from_xpm_data (f, data)
835 FRAME_PTR f;
836 char **data;
837{
838 int result = 0;
839 GError *err = NULL;
840 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (data);
841
842 if (!pixbuf)
843 {
844 g_error_free (err);
845 return 0;
846 }
847
848 gtk_window_set_icon (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
849 pixbuf);
850 g_object_unref (pixbuf);
851 return 1;
852}
832#endif /* USE_GTK */ 853#endif /* USE_GTK */
833 854
834 855
diff --git a/src/xterm.c b/src/xterm.c
index 1adcb4fb4d1..42c860b64c9 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7376,10 +7376,30 @@ x_bitmap_icon (f, file)
7376 /* Create the GNU bitmap and mask if necessary. */ 7376 /* Create the GNU bitmap and mask if necessary. */
7377 if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0) 7377 if (FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id < 0)
7378 { 7378 {
7379 FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id 7379 int rc = -1;
7380 = x_create_bitmap_from_data (f, gnu_bits, 7380
7381 gnu_width, gnu_height); 7381#if defined (HAVE_XPM) && defined (HAVE_X_WINDOWS)
7382 x_create_bitmap_mask (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id); 7382#ifdef USE_GTK
7383 if (xg_set_icon_from_xpm_data (f, gnu_xpm_bits))
7384 return 0;
7385#else
7386 rc = x_create_bitmap_from_xpm_data (f, gnu_xpm_bits);
7387 if (rc != -1)
7388 FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id = rc;
7389#endif /* USE_GTK */
7390#endif /* defined (HAVE_XPM) && defined (HAVE_X_WINDOWS) */
7391
7392 /* If all else fails, use the (black and white) xbm image. */
7393 if (rc == -1)
7394 {
7395 rc = x_create_bitmap_from_data (f, gnu_xbm_bits,
7396 gnu_xbm_width, gnu_xbm_height);
7397 if (rc == -1)
7398 return 1;
7399
7400 FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id = rc;
7401 x_create_bitmap_mask (f, FRAME_X_DISPLAY_INFO (f)->icon_bitmap_id);
7402 }
7383 } 7403 }
7384 7404
7385 /* The first time we create the GNU bitmap and mask, 7405 /* The first time we create the GNU bitmap and mask,