aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2004-10-25 18:17:28 +0000
committerKaroly Lorentey2004-10-25 18:17:28 +0000
commitf158167a84475d5fc41931531406821e6413afd7 (patch)
treefe3a54762ecb2b49c5e51d34e13b7a49dada8efe /src
parent90b404757b24ea0c88d6ec3ed9c1ccce07bbd19f (diff)
parentfc1062f54140bedbaf27f8938325543d3ecc8aa8 (diff)
downloademacs-f158167a84475d5fc41931531406821e6413afd7.tar.gz
emacs-f158167a84475d5fc41931531406821e6413afd7.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-626 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-627 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-629 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-630 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-631 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-632 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-633 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-634 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-635 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-636 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-637 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-638 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-54 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-55 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-56 Update from CVS: Add lisp/legacy-gnus-agent.el * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-57 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-58 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-262
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog103
-rw-r--r--src/Makefile.in5
-rw-r--r--src/config.in12
-rw-r--r--src/data.c6
-rw-r--r--src/editfns.c79
-rw-r--r--src/emacs.c65
-rw-r--r--src/fontset.c26
-rw-r--r--src/gtkutil.c160
-rw-r--r--src/gtkutil.h5
-rw-r--r--src/lastfile.c2
-rw-r--r--src/regex.c3
-rw-r--r--src/regex.h3
-rw-r--r--src/w32.c26
-rw-r--r--src/w32term.c2
-rw-r--r--src/xdisp.c14
-rw-r--r--src/xfns.c84
-rw-r--r--src/xterm.c36
-rw-r--r--src/xterm.h7
18 files changed, 406 insertions, 232 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7b22f043009..1490b34b4a9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,103 @@
12004-10-25 Kenichi Handa <handa@m17n.org>
2
3 * fontset.c (fontset_pattern_regexp): Optimize for the case that
4 PATTERN is full XLFD.
5
62004-10-24 Kenichi Handa <handa@m17n.org>
7
8 * regex.h (enum reg_errcode_t): New value REG_ERANGEX.
9
10 * regex.c (re_error_msgid): Add an entry for REG_ERANGEX.
11 (regex_compile): Return REG_ERANGEX if appropriate.
12
132004-10-22 Kenichi Handa <handa@m17n.org>
14
15 * editfns.c (Ftranslate_region_internal): New function.
16 (syms_of_editfns): Defsubr it.
17
182004-10-22 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
19
20 * xfns.c (xic_create_xfontset): Initialize missing_list to NULL.
21
222004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu>
23
24 * xterm.h (x_output): New member `xic_base_fontname'.
25 (FRAME_XIC_BASE_FONTNAME): New macro.
26 (xic_free_xfontset): Declare.
27
28 * xfns.c (xic_create_xfontset): Share fontsets between frames
29 based on base_fontname.
30 (xic_free_xfontset): New function.
31 (free_frame_xic): Use it.
32 (xic_set_xfontset): Ditto.
33
34 * xterm.c (xim_destroy_callback): Ditto.
35
36
372004-10-20 B. Anyos <banyos@freemail.hu> (tiny change)
38
39 * w32term.c (x_draw_glyph_string): Use overline_color for overlines.
40
412004-10-20 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
42
43 * xterm.h (XSync): If USE_GTK, define XSync as process_all and then
44 XSync.
45
46 * emacs.c (my_heap_start, heap_bss_diff, MAX_HEAP_BSS_DIFF):
47 New variables and constant.
48 (main): Calculate heap_bss_diff. If we are dumping and the
49 heap_bss_diff is greater than MAX_HEAP_BSS_DIFF, set PER_LINUX32
50 and exec ourself again.
51 (Fdump_emacs): If heap_bss_diff is greater than MAX_HEAP_BSS_DIFF
52 print a warning.
53
54 * lastfile.c: Make my_endbss and my_endbss_static available on all
55 platforms.
56
57 * Makefile.in (RUN_TEMACS): Remove @SETARCH@.
58 * config.in (HAVE_PERSONALITY_LINUX32): Regenerate.
59
602004-10-19 Luc Teirlinck <teirllm@auburn.edu>
61
62 * data.c (Flocal_variable_if_set_p): Doc fix.
63
642004-10-19 Jason Rumney <jasonr@gnu.org>
65
66 * w32.c (init_environment): Set emacs_dir correctly when running
67 emacs from the build directory.
68
692004-10-19 Richard M. Stallman <rms@gnu.org>
70
71 * editfns.c (Fdelete_and_extract_region):
72 If region is empty, return null string.
73
742004-10-19 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
75
76 * gtkutil.h (xg_update_scrollbar_pos): Remove arguments real_left
77 and canon_width.
78 (xg_frame_cleared): Removed.
79
80 * gtkutil.c (xg_frame_cleared, xg_fixed_handle_expose,
81 xg_find_top_left_in_fixed): Removed.
82 (xg_create_scroll_bar): Put an event box widget between
83 the scroll bar widget and the edit widget.
84 (xg_show_scroll_bar): Show the parent widget (the event box).
85 (xg_remove_scroll_bar): Destroy parent (the event box) also.
86 (xg_update_scrollbar_pos): Remove arguments real_left and canon_width.
87 Move the parent (the event box) widget inside the fixed widget.
88 Move window clear to xterm.c.
89
90 * gtkutil.h (xg_frame_cleared): Removed.
91
92 * xterm.c (x_clear_frame): Remove call to xg_frame_cleared
93 (x_scroll_bar_create, XTset_vertical_scroll_bar): Remove
94 arguments left and width to xg_update_scrollbar_pos.
95 (XTset_vertical_scroll_bar): Do x_clear_area for USE_GTK also.
96
972004-10-19 Kenichi Handa <handa@m17n.org>
98
99 * xdisp.c (display_mode_element): Fix display of wide chars.
100
12004-10-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 1012004-10-18 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 102
3 * gtkutil.c (xg_update_scrollbar_pos): Change XClearWindow to 103 * gtkutil.c (xg_update_scrollbar_pos): Change XClearWindow to
@@ -8,8 +108,7 @@
8 108
9 * fontset.c (fs_load_font): Use fast_string_match_ignore_case for 109 * fontset.c (fs_load_font): Use fast_string_match_ignore_case for
10 comparing font names. 110 comparing font names.
11 (fs_query_fontset): Use fast_string_match for comparing fontset 111 (fs_query_fontset): Use fast_string_match for comparing fontset names.
12 names.
13 (list_fontsets): Likewise. 112 (list_fontsets): Likewise.
14 113
15 * search.c (fast_string_match_ignore_case): New function. 114 * search.c (fast_string_match_ignore_case): New function.
diff --git a/src/Makefile.in b/src/Makefile.in
index f85811c970a..9d169cd4bdc 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -909,12 +909,7 @@ LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) \
909#define OBJECTS_MACHINE 909#define OBJECTS_MACHINE
910#endif 910#endif
911 911
912#ifdef HAVE_RANDOM_HEAPSTART
913#undef i386
914RUN_TEMACS = @SETARCH@ i386 ./temacs
915#else
916RUN_TEMACS = ./temacs 912RUN_TEMACS = ./temacs
917#endif
918 913
919all: emacs${EXEEXT} OTHER_FILES 914all: emacs${EXEEXT} OTHER_FILES
920 915
diff --git a/src/config.in b/src/config.in
index f2cf822b6ff..a559a35885f 100644
--- a/src/config.in
+++ b/src/config.in
@@ -414,6 +414,9 @@ Boston, MA 02111-1307, USA. */
414/* Define to 1 if you have the <nlist.h> header file. */ 414/* Define to 1 if you have the <nlist.h> header file. */
415#undef HAVE_NLIST_H 415#undef HAVE_NLIST_H
416 416
417/* Define to 1 if personality LINUX32 can be set. */
418#undef HAVE_PERSONALITY_LINUX32
419
417/* Define to 1 if you have the png library (-lpng). */ 420/* Define to 1 if you have the png library (-lpng). */
418#undef HAVE_PNG 421#undef HAVE_PNG
419 422
@@ -432,9 +435,6 @@ Boston, MA 02111-1307, USA. */
432/* Define to 1 if you have the `random' function. */ 435/* Define to 1 if you have the `random' function. */
433#undef HAVE_RANDOM 436#undef HAVE_RANDOM
434 437
435/* Define to 1 if this OS randomizes the start address of the heap. */
436#undef HAVE_RANDOM_HEAPSTART
437
438/* Define to 1 if you have the `recvfrom' function. */ 438/* Define to 1 if you have the `recvfrom' function. */
439#undef HAVE_RECVFROM 439#undef HAVE_RECVFROM
440 440
@@ -757,9 +757,9 @@ Boston, MA 02111-1307, USA. */
757/* If using the C implementation of alloca, define if you know the 757/* If using the C implementation of alloca, define if you know the
758 direction of stack growth for your system; otherwise it will be 758 direction of stack growth for your system; otherwise it will be
759 automatically deduced at run-time. 759 automatically deduced at run-time.
760 STACK_DIRECTION > 0 => grows toward higher addresses 760 STACK_DIRECTION > 0 => grows toward higher addresses
761 STACK_DIRECTION < 0 => grows toward lower addresses 761 STACK_DIRECTION < 0 => grows toward lower addresses
762 STACK_DIRECTION = 0 => direction of growth unknown */ 762 STACK_DIRECTION = 0 => direction of growth unknown */
763#undef STACK_DIRECTION 763#undef STACK_DIRECTION
764 764
765/* Define to 1 if you have the ANSI C header files. */ 765/* Define to 1 if you have the ANSI C header files. */
diff --git a/src/data.c b/src/data.c
index 616e91c2d62..33b37376a49 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1794,7 +1794,11 @@ BUFFER defaults to the current buffer. */)
1794 1794
1795DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, 1795DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p,
1796 1, 2, 0, 1796 1, 2, 0,
1797 doc: /* Non-nil if VARIABLE will be local in buffer BUFFER if it is set there. 1797 doc: /* Non-nil if VARIABLE will be local in buffer BUFFER when set there.
1798More precisely, this means that setting the variable \(with `set' or`setq'),
1799while it does not have a `let'-style binding that was made in BUFFER,
1800will produce a buffer local binding. See Info node
1801`(elisp)Creating Buffer-Local'.
1798BUFFER defaults to the current buffer. */) 1802BUFFER defaults to the current buffer. */)
1799 (variable, buffer) 1803 (variable, buffer)
1800 register Lisp_Object variable, buffer; 1804 register Lisp_Object variable, buffer;
diff --git a/src/editfns.c b/src/editfns.c
index 51f8a71d531..5b129a18a62 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2736,8 +2736,10 @@ Both characters must have the same length of multi-byte form. */)
2736 return Qnil; 2736 return Qnil;
2737} 2737}
2738 2738
2739DEFUN ("translate-region", Ftranslate_region, Stranslate_region, 3, 3, 0, 2739DEFUN ("translate-region-internal", Ftranslate_region_internal,
2740 doc: /* From START to END, translate characters according to TABLE. 2740 Stranslate_region_internal, 3, 3, 0,
2741 doc: /* Internal use only.
2742From START to END, translate characters according to TABLE.
2741TABLE is a string; the Nth character in it is the mapping 2743TABLE is a string; the Nth character in it is the mapping
2742for the character with code N. 2744for the character with code N.
2743It returns the number of characters changed. */) 2745It returns the number of characters changed. */)
@@ -2750,31 +2752,37 @@ It returns the number of characters changed. */)
2750 register int nc; /* New character. */ 2752 register int nc; /* New character. */
2751 int cnt; /* Number of changes made. */ 2753 int cnt; /* Number of changes made. */
2752 int size; /* Size of translate table. */ 2754 int size; /* Size of translate table. */
2753 int pos, pos_byte; 2755 int pos, pos_byte, end_pos;
2754 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 2756 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
2755 int string_multibyte; 2757 int string_multibyte;
2756 2758
2757 validate_region (&start, &end); 2759 validate_region (&start, &end);
2758 CHECK_STRING (table); 2760 if (CHAR_TABLE_P (table))
2759 2761 {
2760 if (multibyte != (SCHARS (table) < SBYTES (table))) 2762 size = MAX_CHAR;
2761 table = (multibyte 2763 tt = NULL;
2762 ? string_make_multibyte (table) 2764 }
2763 : string_make_unibyte (table)); 2765 else
2764 string_multibyte = SCHARS (table) < SBYTES (table); 2766 {
2767 CHECK_STRING (table);
2765 2768
2766 size = SCHARS (table); 2769 if (! multibyte && (SCHARS (table) < SBYTES (table)))
2767 tt = SDATA (table); 2770 table = string_make_unibyte (table);
2771 string_multibyte = SCHARS (table) < SBYTES (table);
2772 size = SCHARS (table);
2773 tt = SDATA (table);
2774 }
2768 2775
2769 pos = XINT (start); 2776 pos = XINT (start);
2770 pos_byte = CHAR_TO_BYTE (pos); 2777 pos_byte = CHAR_TO_BYTE (pos);
2778 end_pos = XINT (end);
2771 modify_region (current_buffer, pos, XINT (end)); 2779 modify_region (current_buffer, pos, XINT (end));
2772 2780
2773 cnt = 0; 2781 cnt = 0;
2774 for (; pos < XINT (end); ) 2782 for (; pos < end_pos; )
2775 { 2783 {
2776 register unsigned char *p = BYTE_POS_ADDR (pos_byte); 2784 register unsigned char *p = BYTE_POS_ADDR (pos_byte);
2777 unsigned char *str; 2785 unsigned char *str, buf[MAX_MULTIBYTE_LENGTH];
2778 int len, str_len; 2786 int len, str_len;
2779 int oc; 2787 int oc;
2780 2788
@@ -2784,16 +2792,45 @@ It returns the number of characters changed. */)
2784 oc = *p, len = 1; 2792 oc = *p, len = 1;
2785 if (oc < size) 2793 if (oc < size)
2786 { 2794 {
2787 if (string_multibyte) 2795 if (tt)
2788 { 2796 {
2789 str = tt + string_char_to_byte (table, oc); 2797 if (string_multibyte)
2790 nc = STRING_CHAR_AND_LENGTH (str, MAX_MULTIBYTE_LENGTH, str_len); 2798 {
2799 str = tt + string_char_to_byte (table, oc);
2800 nc = STRING_CHAR_AND_LENGTH (str, MAX_MULTIBYTE_LENGTH,
2801 str_len);
2802 }
2803 else
2804 {
2805 nc = tt[oc];
2806 if (! ASCII_BYTE_P (nc) && multibyte)
2807 {
2808 str_len = CHAR_STRING (nc, buf);
2809 str = buf;
2810 }
2811 else
2812 {
2813 str_len = 1;
2814 str = tt + oc;
2815 }
2816 }
2791 } 2817 }
2792 else 2818 else
2793 { 2819 {
2794 str = tt + oc; 2820 Lisp_Object val;
2795 nc = tt[oc], str_len = 1; 2821 int c;
2822
2823 nc = oc;
2824 val = CHAR_TABLE_REF (table, oc);
2825 if (INTEGERP (val)
2826 && (c = XINT (val), CHAR_VALID_P (c, 0)))
2827 {
2828 nc = c;
2829 str_len = CHAR_STRING (nc, buf);
2830 str = buf;
2831 }
2796 } 2832 }
2833
2797 if (nc != oc) 2834 if (nc != oc)
2798 { 2835 {
2799 if (len != str_len) 2836 if (len != str_len)
@@ -2844,6 +2881,8 @@ DEFUN ("delete-and-extract-region", Fdelete_and_extract_region,
2844 Lisp_Object start, end; 2881 Lisp_Object start, end;
2845{ 2882{
2846 validate_region (&start, &end); 2883 validate_region (&start, &end);
2884 if (XINT (start) == XINT (end))
2885 return build_string ("");
2847 return del_range_1 (XINT (start), XINT (end), 1, 1); 2886 return del_range_1 (XINT (start), XINT (end), 1, 1);
2848} 2887}
2849 2888
@@ -4288,7 +4327,7 @@ functions if all the text being accessed has this property. */);
4288 defsubr (&Sinsert_buffer_substring); 4327 defsubr (&Sinsert_buffer_substring);
4289 defsubr (&Scompare_buffer_substrings); 4328 defsubr (&Scompare_buffer_substrings);
4290 defsubr (&Ssubst_char_in_region); 4329 defsubr (&Ssubst_char_in_region);
4291 defsubr (&Stranslate_region); 4330 defsubr (&Stranslate_region_internal);
4292 defsubr (&Sdelete_region); 4331 defsubr (&Sdelete_region);
4293 defsubr (&Sdelete_and_extract_region); 4332 defsubr (&Sdelete_and_extract_region);
4294 defsubr (&Swiden); 4333 defsubr (&Swiden);
diff --git a/src/emacs.c b/src/emacs.c
index bdca7aa3944..96e858d943a 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -68,6 +68,10 @@ Boston, MA 02111-1307, USA. */
68#include <sys/resource.h> 68#include <sys/resource.h>
69#endif 69#endif
70 70
71#ifdef HAVE_PERSONALITY_LINUX32
72#include <sys/personality.h>
73#endif
74
71#ifndef O_RDWR 75#ifndef O_RDWR
72#define O_RDWR 2 76#define O_RDWR 2
73#endif 77#endif
@@ -193,6 +197,17 @@ int display_arg;
193 Tells GC how to save a copy of the stack. */ 197 Tells GC how to save a copy of the stack. */
194char *stack_bottom; 198char *stack_bottom;
195 199
200/* The address where the heap starts (from the first sbrk (0) call). */
201static void *my_heap_start;
202
203/* The gap between BSS end and heap start as far as we can tell. */
204static unsigned long heap_bss_diff;
205
206/* If the gap between BSS end and heap start is larger than this we try to
207 work around it, and if that fails, output a warning in dump-emacs. */
208#define MAX_HEAP_BSS_DIFF (1024*1024)
209
210
196#ifdef HAVE_WINDOW_SYSTEM 211#ifdef HAVE_WINDOW_SYSTEM
197extern Lisp_Object Vinitial_window_system; 212extern Lisp_Object Vinitial_window_system;
198#endif /* HAVE_WINDOW_SYSTEM */ 213#endif /* HAVE_WINDOW_SYSTEM */
@@ -734,7 +749,11 @@ malloc_initialize_hook ()
734 free (malloc_state_ptr); 749 free (malloc_state_ptr);
735 } 750 }
736 else 751 else
737 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; 752 {
753 if (my_heap_start == 0)
754 my_heap_start = sbrk (0);
755 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
756 }
738} 757}
739 758
740void (*__malloc_initialize_hook) () = malloc_initialize_hook; 759void (*__malloc_initialize_hook) () = malloc_initialize_hook;
@@ -810,6 +829,17 @@ main (argc, argv
810 stack_base = &dummy; 829 stack_base = &dummy;
811#endif 830#endif
812 831
832 if (!initialized)
833 {
834 extern char my_endbss[];
835 extern char *my_endbss_static;
836
837 if (my_heap_start == 0)
838 my_heap_start = sbrk (0);
839
840 heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static);
841 }
842
813#ifdef LINUX_SBRK_BUG 843#ifdef LINUX_SBRK_BUG
814 __sbrk (1); 844 __sbrk (1);
815#endif 845#endif
@@ -853,6 +883,28 @@ main (argc, argv
853 } 883 }
854 } 884 }
855 885
886#ifdef HAVE_PERSONALITY_LINUX32
887 /* See if there is a gap between the end of BSS and the heap.
888 In that case, set personality and exec ourself again. */
889 if (!initialized
890 && (strcmp (argv[argc-1], "dump") == 0
891 || strcmp (argv[argc-1], "bootstrap") == 0)
892 && heap_bss_diff > MAX_HEAP_BSS_DIFF)
893 {
894 if (! getenv ("EMACS_HEAP_EXEC"))
895 {
896 /* Set this so we only do this once. */
897 putenv("EMACS_HEAP_EXEC=true");
898 personality (PER_LINUX32);
899 execvp (argv[0], argv);
900
901 /* If the exec fails, try to dump anyway. */
902 perror ("execvp");
903 }
904 }
905#endif /* HAVE_PERSONALITY_LINUX32 */
906
907
856/* Map in shared memory, if we are using that. */ 908/* Map in shared memory, if we are using that. */
857#ifdef HAVE_SHM 909#ifdef HAVE_SHM
858 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) 910 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
@@ -2129,6 +2181,17 @@ You must run Emacs in batch mode in order to dump it. */)
2129 if (! noninteractive) 2181 if (! noninteractive)
2130 error ("Dumping Emacs works only in batch mode"); 2182 error ("Dumping Emacs works only in batch mode");
2131 2183
2184 if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
2185 {
2186 fprintf (stderr, "**************************************************\n");
2187 fprintf (stderr, "Warning: Your system has a gap between BSS and the\n");
2188 fprintf (stderr, "heap. This usually means that exec-shield or\n");
2189 fprintf (stderr, "something similar is in effect. The dump may fail\n");
2190 fprintf (stderr, "because of this. See the section about exec-shield\n");
2191 fprintf (stderr, "in etc/PROBLEMS for more information.\n");
2192 fprintf (stderr, "**************************************************\n");
2193 }
2194
2132 /* Bind `command-line-processed' to nil before dumping, 2195 /* Bind `command-line-processed' to nil before dumping,
2133 so that the dumped Emacs will process its command line 2196 so that the dumped Emacs will process its command line
2134 and set up to work with X windows if appropriate. */ 2197 and set up to work with X windows if appropriate. */
diff --git a/src/fontset.c b/src/fontset.c
index 7fbaee3c216..0c50be2d21e 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -790,16 +790,34 @@ fontset_pattern_regexp (pattern)
790 || strcmp (SDATA (pattern), CACHED_FONTSET_NAME)) 790 || strcmp (SDATA (pattern), CACHED_FONTSET_NAME))
791 { 791 {
792 /* We must at first update the cached data. */ 792 /* We must at first update the cached data. */
793 char *regex = (char *) alloca (SCHARS (pattern) * 2 + 3); 793 char *regex, *p0, *p1;
794 char *p0, *p1 = regex; 794 int ndashes = 0, nstars = 0;
795
796 for (p0 = SDATA (pattern); *p0; p0++)
797 {
798 if (*p0 == '-')
799 ndashes++;
800 else if (*p0 == '*')
801 nstars++;
802 }
803
804 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise
805 we convert "*" to "[^-]*" which is much faster in regular
806 expression matching. */
807 if (ndashes < 14)
808 p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1);
809 else
810 p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1);
795 811
796 /* Convert "*" to ".*", "?" to ".". */
797 *p1++ = '^'; 812 *p1++ = '^';
798 for (p0 = (char *) SDATA (pattern); *p0; p0++) 813 for (p0 = (char *) SDATA (pattern); *p0; p0++)
799 { 814 {
800 if (*p0 == '*') 815 if (*p0 == '*')
801 { 816 {
802 *p1++ = '.'; 817 if (ndashes < 14)
818 *p1++ = '.';
819 else
820 *p1++ = '[', *p1++ = '^', *p1++ = '-', *p1++ = ']';
803 *p1++ = '*'; 821 *p1++ = '*';
804 } 822 }
805 else if (*p0 == '?') 823 else if (*p0 == '?')
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 4d166a4d01e..8182ff45766 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -550,24 +550,6 @@ xg_resize_outer_widget (f, columns, rows)
550 gdk_window_process_all_updates (); 550 gdk_window_process_all_updates ();
551} 551}
552 552
553/* This gets called after the frame F has been cleared. Since that is
554 done with X calls, we need to redraw GTK widget (scroll bars). */
555void
556xg_frame_cleared (f)
557 FRAME_PTR f;
558{
559 GtkWidget *w = f->output_data.x->widget;
560
561 if (w)
562 {
563 gtk_container_set_reallocate_redraws (GTK_CONTAINER (w), TRUE);
564 gtk_container_foreach (GTK_CONTAINER (w),
565 (GtkCallback) gtk_widget_queue_draw,
566 0);
567 gdk_window_process_all_updates ();
568 }
569}
570
571/* Function to handle resize of our widgets. Since Emacs has some layouts 553/* Function to handle resize of our widgets. Since Emacs has some layouts
572 that does not fit well with GTK standard containers, we do most layout 554 that does not fit well with GTK standard containers, we do most layout
573 manually. 555 manually.
@@ -585,8 +567,10 @@ xg_resize_widgets (f, pixelwidth, pixelheight)
585 int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth); 567 int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth);
586 568
587 if (FRAME_GTK_WIDGET (f) 569 if (FRAME_GTK_WIDGET (f)
588 && (columns != FRAME_COLS (f) || rows != FRAME_LINES (f) 570 && (columns != FRAME_COLS (f)
589 || pixelwidth != FRAME_PIXEL_WIDTH (f) || pixelheight != FRAME_PIXEL_HEIGHT (f))) 571 || rows != FRAME_LINES (f)
572 || pixelwidth != FRAME_PIXEL_WIDTH (f)
573 || pixelheight != FRAME_PIXEL_HEIGHT (f)))
590 { 574 {
591 struct x_output *x = f->output_data.x; 575 struct x_output *x = f->output_data.x;
592 GtkAllocation all; 576 GtkAllocation all;
@@ -681,54 +665,6 @@ xg_pix_to_gcolor (w, pixel, c)
681 gdk_colormap_query_color (map, pixel, c); 665 gdk_colormap_query_color (map, pixel, c);
682} 666}
683 667
684/* Turning off double buffering for our GtkFixed widget has the side
685 effect of turning it off also for its children (scroll bars).
686 But we want those to be double buffered to not flicker so handle
687 expose manually here.
688 WIDGET is the GtkFixed widget that gets exposed.
689 EVENT is the expose event.
690 USER_DATA is unused.
691
692 Return TRUE to tell GTK that this expose event has been fully handeled
693 and that GTK shall do nothing more with it. */
694static gboolean
695xg_fixed_handle_expose (GtkWidget *widget,
696 GdkEventExpose *event,
697 gpointer user_data)
698{
699 GList *iter;
700
701 for (iter = GTK_FIXED (widget)->children; iter; iter = g_list_next (iter))
702 {
703 GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
704 GtkWidget *child = child_data->widget;
705 GdkWindow *window = child->window;
706 GdkRegion *region = gtk_widget_region_intersect (child, event->region);
707
708 if (! gdk_region_empty (region))
709 {
710 GdkEvent child_event;
711 child_event.expose = *event;
712 child_event.expose.region = region;
713
714 /* Turn on double buffering, i.e. draw to an off screen area. */
715 gdk_window_begin_paint_region (window, region);
716
717 /* Tell child to redraw itself. */
718 gdk_region_get_clipbox (region, &child_event.expose.area);
719 gtk_widget_send_expose (child, &child_event);
720 gdk_window_process_updates (window, TRUE);
721
722 /* Copy off screen area to the window. */
723 gdk_window_end_paint (window);
724 }
725
726 gdk_region_destroy (region);
727 }
728
729 return TRUE;
730}
731
732/* Create and set up the GTK widgets for frame F. 668/* Create and set up the GTK widgets for frame F.
733 Return 0 if creation failed, non-zero otherwise. */ 669 Return 0 if creation failed, non-zero otherwise. */
734int 670int
@@ -804,12 +740,6 @@ xg_create_frame_widgets (f)
804 a lot, so we turn off double buffering. */ 740 a lot, so we turn off double buffering. */
805 gtk_widget_set_double_buffered (wfixed, FALSE); 741 gtk_widget_set_double_buffered (wfixed, FALSE);
806 742
807 /* Turning off double buffering above has the side effect of turning
808 it off also for its children (scroll bars). But we want those
809 to be double buffered to not flicker so handle expose manually. */
810 g_signal_connect (G_OBJECT (wfixed), "expose-event",
811 G_CALLBACK (xg_fixed_handle_expose), 0);
812
813 /* GTK documents says use gtk_window_set_resizable. But then a user 743 /* GTK documents says use gtk_window_set_resizable. But then a user
814 can't shrink the window from its starting size. */ 744 can't shrink the window from its starting size. */
815 gtk_window_set_policy (GTK_WINDOW (wtop), TRUE, TRUE, TRUE); 745 gtk_window_set_policy (GTK_WINDOW (wtop), TRUE, TRUE, TRUE);
@@ -2770,6 +2700,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2770 char *scroll_bar_name; 2700 char *scroll_bar_name;
2771{ 2701{
2772 GtkWidget *wscroll; 2702 GtkWidget *wscroll;
2703 GtkWidget *webox;
2773 GtkObject *vadj; 2704 GtkObject *vadj;
2774 int scroll_id; 2705 int scroll_id;
2775 2706
@@ -2779,6 +2710,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2779 0.1, 0.1, 0.1); 2710 0.1, 0.1, 0.1);
2780 2711
2781 wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj)); 2712 wscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (vadj));
2713 webox = gtk_event_box_new ();
2782 gtk_widget_set_name (wscroll, scroll_bar_name); 2714 gtk_widget_set_name (wscroll, scroll_bar_name);
2783 gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS); 2715 gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS);
2784 2716
@@ -2804,11 +2736,18 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2804 G_CALLBACK (scroll_bar_button_cb), 2736 G_CALLBACK (scroll_bar_button_cb),
2805 (gpointer) bar); 2737 (gpointer) bar);
2806 2738
2807 gtk_fixed_put (GTK_FIXED (f->output_data.x->edit_widget), 2739 /* The scroll bar widget does not draw on a window of its own. Instead
2808 wscroll, -1, -1); 2740 it draws on the parent window, in this case the edit widget. So
2741 whenever the edit widget is cleared, the scroll bar needs to redraw
2742 also, which causes flicker. Put an event box between the edit widget
2743 and the scroll bar, so the scroll bar instead draws itself on the
2744 event box window. */
2745 gtk_fixed_put (GTK_FIXED (f->output_data.x->edit_widget), webox, -1, -1);
2746 gtk_container_add (GTK_CONTAINER (webox), wscroll);
2747
2809 2748
2810 /* Set the cursor to an arrow. */ 2749 /* Set the cursor to an arrow. */
2811 xg_set_cursor (wscroll, FRAME_X_DISPLAY_INFO (f)->xg_cursor); 2750 xg_set_cursor (webox, FRAME_X_DISPLAY_INFO (f)->xg_cursor);
2812 2751
2813 SET_SCROLL_BAR_X_WINDOW (bar, scroll_id); 2752 SET_SCROLL_BAR_X_WINDOW (bar, scroll_id);
2814} 2753}
@@ -2820,7 +2759,7 @@ xg_show_scroll_bar (scrollbar_id)
2820{ 2759{
2821 GtkWidget *w = xg_get_widget_from_map (scrollbar_id); 2760 GtkWidget *w = xg_get_widget_from_map (scrollbar_id);
2822 if (w) 2761 if (w)
2823 gtk_widget_show (w); 2762 gtk_widget_show_all (gtk_widget_get_parent (w));
2824} 2763}
2825 2764
2826/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ 2765/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */
@@ -2832,42 +2771,19 @@ xg_remove_scroll_bar (f, scrollbar_id)
2832 GtkWidget *w = xg_get_widget_from_map (scrollbar_id); 2771 GtkWidget *w = xg_get_widget_from_map (scrollbar_id);
2833 if (w) 2772 if (w)
2834 { 2773 {
2774 GtkWidget *wparent = gtk_widget_get_parent (w);
2835 gtk_widget_destroy (w); 2775 gtk_widget_destroy (w);
2776 gtk_widget_destroy (wparent);
2836 SET_FRAME_GARBAGED (f); 2777 SET_FRAME_GARBAGED (f);
2837 } 2778 }
2838} 2779}
2839 2780
2840/* Find left/top for widget W in GtkFixed widget WFIXED. */
2841static void
2842xg_find_top_left_in_fixed (w, wfixed, left, top)
2843 GtkWidget *w, *wfixed;
2844 int *left, *top;
2845{
2846 GList *iter;
2847
2848 for (iter = GTK_FIXED (wfixed)->children; iter; iter = g_list_next (iter))
2849 {
2850 GtkFixedChild *child = (GtkFixedChild *) iter->data;
2851
2852 if (child->widget == w)
2853 {
2854 *left = child->x;
2855 *top = child->y;
2856 return;
2857 }
2858 }
2859
2860 /* Shall never end up here. */
2861 abort ();
2862}
2863
2864/* Update the position of the vertical scroll bar represented by SCROLLBAR_ID 2781/* Update the position of the vertical scroll bar represented by SCROLLBAR_ID
2865 in frame F. 2782 in frame F.
2866 TOP/LEFT are the new pixel positions where the bar shall appear. 2783 TOP/LEFT are the new pixel positions where the bar shall appear.
2867 WIDTH, HEIGHT is the size in pixels the bar shall have. */ 2784 WIDTH, HEIGHT is the size in pixels the bar shall have. */
2868void 2785void
2869xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height, 2786xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height)
2870 real_left, canon_width)
2871 FRAME_PTR f; 2787 FRAME_PTR f;
2872 int scrollbar_id; 2788 int scrollbar_id;
2873 int top; 2789 int top;
@@ -2881,44 +2797,12 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height,
2881 if (wscroll) 2797 if (wscroll)
2882 { 2798 {
2883 GtkWidget *wfixed = f->output_data.x->edit_widget; 2799 GtkWidget *wfixed = f->output_data.x->edit_widget;
2884 2800 GtkWidget *wparent = gtk_widget_get_parent (wscroll);
2885 gtk_container_set_reallocate_redraws (GTK_CONTAINER (wfixed), TRUE);
2886 2801
2887 /* Move and resize to new values. */ 2802 /* Move and resize to new values. */
2888 gtk_fixed_move (GTK_FIXED (wfixed), wscroll, left, top);
2889 gtk_widget_set_size_request (wscroll, width, height); 2803 gtk_widget_set_size_request (wscroll, width, height);
2804 gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top);
2890 2805
2891 /* Scroll bars in GTK has a fixed width, so if we say width 16, it
2892 will only be its fixed width (14 is default) anyway, the rest is
2893 blank. We are drawing the mode line across scroll bars when
2894 the frame is split:
2895 |bar| |fringe|
2896 ----------------
2897 mode line
2898 ----------------
2899 |bar| |fringe|
2900
2901 When we "unsplit" the frame:
2902
2903 |bar| |fringe|
2904 -| |-| |
2905 m¦ |i| |
2906 -| |-| |
2907 | | | |
2908
2909
2910 the remains of the mode line can be seen in these blank spaces.
2911 So we must clear them explicitly.
2912 GTK scroll bars should do that, but they don't.
2913 Also, the canonical width may be wider than the width for the
2914 scroll bar so that there is some space (typically 1 pixel) between
2915 the scroll bar and the edge of the window and between the scroll
2916 bar and the fringe. */
2917 gdk_window_clear (wscroll->window);
2918
2919 /* Must force out update so changed scroll bars gets redrawn. */
2920 gdk_window_process_all_updates ();
2921
2922 SET_FRAME_GARBAGED (f); 2806 SET_FRAME_GARBAGED (f);
2923 cancel_mouse_face (f); 2807 cancel_mouse_face (f);
2924 } 2808 }
diff --git a/src/gtkutil.h b/src/gtkutil.h
index b35ab94b2cb..c0055f361cc 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -168,9 +168,7 @@ extern void xg_update_scrollbar_pos P_ ((FRAME_PTR f,
168 int top, 168 int top,
169 int left, 169 int left,
170 int width, 170 int width,
171 int height, 171 int height));
172 int real_left,
173 int canon_width));
174 172
175extern void xg_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *bar, 173extern void xg_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *bar,
176 int portion, 174 int portion,
@@ -184,7 +182,6 @@ extern void free_frame_tool_bar P_ ((FRAME_PTR f));
184extern void xg_resize_widgets P_ ((FRAME_PTR f, 182extern void xg_resize_widgets P_ ((FRAME_PTR f,
185 int pixelwidth, 183 int pixelwidth,
186 int pixelheight)); 184 int pixelheight));
187extern void xg_frame_cleared P_ ((FRAME_PTR f));
188extern void xg_frame_set_char_size P_ ((FRAME_PTR f, int cols, int rows)); 185extern void xg_frame_set_char_size P_ ((FRAME_PTR f, int cols, int rows));
189extern GtkWidget * xg_win_to_widget P_ ((Display *dpy, Window wdesc)); 186extern GtkWidget * xg_win_to_widget P_ ((Display *dpy, Window wdesc));
190 187
diff --git a/src/lastfile.c b/src/lastfile.c
index df678b42876..d6292e30040 100644
--- a/src/lastfile.c
+++ b/src/lastfile.c
@@ -40,7 +40,6 @@ Boston, MA 02111-1307, USA. */
40 40
41char my_edata[] = "End of Emacs initialized data"; 41char my_edata[] = "End of Emacs initialized data";
42 42
43#if defined(WINDOWSNT) || defined(CYGWIN)
44/* Help unexec locate the end of the .bss area used by Emacs (which 43/* Help unexec locate the end of the .bss area used by Emacs (which
45 isn't always a separate section in NT executables). */ 44 isn't always a separate section in NT executables). */
46char my_endbss[1]; 45char my_endbss[1];
@@ -50,7 +49,6 @@ char my_endbss[1];
50 of the bss area used by Emacs. */ 49 of the bss area used by Emacs. */
51static char _my_endbss[1]; 50static char _my_endbss[1];
52char * my_endbss_static = _my_endbss; 51char * my_endbss_static = _my_endbss;
53#endif
54 52
55/* arch-tag: 67e81ab4-e14f-44b2-8875-c0c12252223e 53/* arch-tag: 67e81ab4-e14f-44b2-8875-c0c12252223e
56 (do not change this comment) */ 54 (do not change this comment) */
diff --git a/src/regex.c b/src/regex.c
index 31a10ee92e0..36787238a32 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1283,6 +1283,7 @@ static const char *re_error_msgid[] =
1283 gettext_noop ("Premature end of regular expression"), /* REG_EEND */ 1283 gettext_noop ("Premature end of regular expression"), /* REG_EEND */
1284 gettext_noop ("Regular expression too big"), /* REG_ESIZE */ 1284 gettext_noop ("Regular expression too big"), /* REG_ESIZE */
1285 gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */ 1285 gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */
1286 gettext_noop ("Range striding over charsets") /* REG_ERANGEX */
1286 }; 1287 };
1287 1288
1288/* Avoiding alloca during matching, to placate r_alloc. */ 1289/* Avoiding alloca during matching, to placate r_alloc. */
@@ -2871,7 +2872,7 @@ regex_compile (pattern, size, syntax, bufp)
2871 } 2872 }
2872 } 2873 }
2873 else if (!SAME_CHARSET_P (c, c1)) 2874 else if (!SAME_CHARSET_P (c, c1))
2874 FREE_STACK_RETURN (REG_ERANGE); 2875 FREE_STACK_RETURN (REG_ERANGEX);
2875 } 2876 }
2876 else 2877 else
2877 /* Range from C to C. */ 2878 /* Range from C to C. */
diff --git a/src/regex.h b/src/regex.h
index f969c9c5e74..2cdb02993b1 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -316,7 +316,8 @@ typedef enum
316 /* Error codes we've added. */ 316 /* Error codes we've added. */
317 REG_EEND, /* Premature end. */ 317 REG_EEND, /* Premature end. */
318 REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ 318 REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
319 REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ 319 REG_ERPAREN, /* Unmatched ) or \); not returned from regcomp. */
320 REG_ERANGEX /* Range striding over charsets. */
320} reg_errcode_t; 321} reg_errcode_t;
321 322
322/* This data structure represents a compiled pattern. Before calling 323/* This data structure represents a compiled pattern. Before calling
diff --git a/src/w32.c b/src/w32.c
index 12d1f21b091..7b54924d736 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1005,6 +1005,32 @@ init_environment (char ** argv)
1005 _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname); 1005 _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname);
1006 _putenv (strdup (buf)); 1006 _putenv (strdup (buf));
1007 } 1007 }
1008 /* Handle running emacs from the build directory: src/oo-spd/i386/ */
1009
1010 /* FIXME: should use substring of get_emacs_configuration ().
1011 But I don't think the Windows build supports alpha, mips etc
1012 anymore, so have taken the easy option for now. */
1013 else if (p && stricmp (p, "\\i386") == 0)
1014 {
1015 *p = 0;
1016 p = strrchr (modname, '\\');
1017 if (p != NULL)
1018 {
1019 *p = 0;
1020 p = strrchr (modname, '\\');
1021 if (p && stricmp (p, "\\src") == 0)
1022 {
1023 char buf[SET_ENV_BUF_SIZE];
1024
1025 *p = 0;
1026 for (p = modname; *p; p++)
1027 if (*p == '\\') *p = '/';
1028
1029 _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname);
1030 _putenv (strdup (buf));
1031 }
1032 }
1033 }
1008 } 1034 }
1009 1035
1010 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 1036 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
diff --git a/src/w32term.c b/src/w32term.c
index 9238b7959d5..8db94ceb759 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2516,7 +2516,7 @@ x_draw_glyph_string (s)
2516 } 2516 }
2517 else 2517 else
2518 { 2518 {
2519 w32_fill_area (s->f, s->hdc, s->face->underline_color, s->x, 2519 w32_fill_area (s->f, s->hdc, s->face->overline_color, s->x,
2520 s->y + dy, s->width, h); 2520 s->y + dy, s->width, h);
2521 } 2521 }
2522 } 2522 }
diff --git a/src/xdisp.c b/src/xdisp.c
index 81a535f6b0e..47b4bc1f06d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7974,7 +7974,7 @@ store_frame_title (str, field_width, precision)
7974 7974
7975 /* Copy at most PRECISION chars from STR. */ 7975 /* Copy at most PRECISION chars from STR. */
7976 nbytes = strlen (str); 7976 nbytes = strlen (str);
7977 n+= c_string_width (str, nbytes, precision, &dummy, &nbytes); 7977 n += c_string_width (str, nbytes, precision, &dummy, &nbytes);
7978 while (nbytes--) 7978 while (nbytes--)
7979 store_frame_title_char (*str++); 7979 store_frame_title_char (*str++);
7980 7980
@@ -15459,14 +15459,15 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
15459 15459
15460 if (this - 1 != last) 15460 if (this - 1 != last)
15461 { 15461 {
15462 int nchars, nbytes;
15463
15462 /* Output to end of string or up to '%'. Field width 15464 /* Output to end of string or up to '%'. Field width
15463 is length of string. Don't output more than 15465 is length of string. Don't output more than
15464 PRECISION allows us. */ 15466 PRECISION allows us. */
15465 --this; 15467 --this;
15466 15468
15467 prec = chars_in_text (last, this - last); 15469 prec = c_string_width (last, this - last, precision - n,
15468 if (precision > 0 && prec > precision - n) 15470 &nchars, &nbytes);
15469 prec = precision - n;
15470 15471
15471 if (frame_title_ptr) 15472 if (frame_title_ptr)
15472 n += store_frame_title (last, 0, prec); 15473 n += store_frame_title (last, 0, prec);
@@ -15474,9 +15475,12 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
15474 { 15475 {
15475 int bytepos = last - lisp_string; 15476 int bytepos = last - lisp_string;
15476 int charpos = string_byte_to_char (elt, bytepos); 15477 int charpos = string_byte_to_char (elt, bytepos);
15478 int endpos = (precision <= 0 ? SCHARS (elt)
15479 : charpos + nchars);
15480
15477 n += store_mode_line_string (NULL, 15481 n += store_mode_line_string (NULL,
15478 Fsubstring (elt, make_number (charpos), 15482 Fsubstring (elt, make_number (charpos),
15479 make_number (charpos + prec)), 15483 make_number (endpos)),
15480 0, 0, 0, Qnil); 15484 0, 0, 0, Qnil);
15481 } 15485 }
15482 else 15486 else
diff --git a/src/xfns.c b/src/xfns.c
index 115a5aeb3c5..97a55869a05 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1951,29 +1951,85 @@ static XIMStyle supported_xim_styles[] =
1951}; 1951};
1952 1952
1953 1953
1954/* Create an X fontset on frame F with base font name 1954/* Create an X fontset on frame F with base font name BASE_FONTNAME. */
1955 BASE_FONTNAME.. */
1956 1955
1957static XFontSet 1956static XFontSet
1958xic_create_xfontset (f, base_fontname) 1957xic_create_xfontset (f, base_fontname)
1959 struct frame *f; 1958 struct frame *f;
1960 char *base_fontname; 1959 char *base_fontname;
1961{ 1960{
1962 XFontSet xfs; 1961 XFontSet xfs = NULL;
1963 char **missing_list; 1962 char **missing_list = NULL;
1964 int missing_count; 1963 int missing_count;
1965 char *def_string; 1964 char *def_string;
1965 Lisp_Object rest, frame;
1966
1967 /* See if there is another frame already using same fontset. */
1968 FOR_EACH_FRAME (rest, frame)
1969 {
1970 struct frame *cf = XFRAME (frame);
1971 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
1972 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
1973 && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
1974 {
1975 xfs = FRAME_XIC_FONTSET (cf);
1976 break;
1977 }
1978 }
1979
1980 if (!xfs)
1981 {
1982 /* New fontset. */
1983 xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
1984 base_fontname, &missing_list,
1985 &missing_count, &def_string);
1986 if (missing_list)
1987 XFreeStringList (missing_list);
1988 }
1966 1989
1967 xfs = XCreateFontSet (FRAME_X_DISPLAY (f), 1990 if (FRAME_XIC_BASE_FONTNAME (f))
1968 base_fontname, &missing_list, 1991 xfree (FRAME_XIC_BASE_FONTNAME (f));
1969 &missing_count, &def_string); 1992 FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname);
1970 if (missing_list)
1971 XFreeStringList (missing_list);
1972 1993
1973 /* No need to free def_string. */ 1994 /* No need to free def_string. */
1974 return xfs; 1995 return xfs;
1975} 1996}
1976 1997
1998/* Free the X fontset of frame F if it is the last frame using it. */
1999
2000void
2001xic_free_xfontset (f)
2002 struct frame *f;
2003{
2004 Lisp_Object rest, frame;
2005 int shared_p = 0;
2006
2007 if (!FRAME_XIC_FONTSET (f))
2008 return;
2009
2010 /* See if there is another frame sharing the same fontset. */
2011 FOR_EACH_FRAME (rest, frame)
2012 {
2013 struct frame *cf = XFRAME (frame);
2014 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
2015 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
2016 && FRAME_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f))
2017 {
2018 shared_p = 1;
2019 break;
2020 }
2021 }
2022
2023 if (!shared_p)
2024 /* The fontset is not used anymore. It is safe to free it. */
2025 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2026
2027 if (FRAME_XIC_BASE_FONTNAME (f))
2028 xfree (FRAME_XIC_BASE_FONTNAME (f));
2029 FRAME_XIC_BASE_FONTNAME (f) = NULL;
2030 FRAME_XIC_FONTSET (f) = NULL;
2031}
2032
1977 2033
1978/* Value is the best input style, given user preferences USER (already 2034/* Value is the best input style, given user preferences USER (already
1979 checked to be supported by Emacs), and styles supported by the 2035 checked to be supported by Emacs), and styles supported by the
@@ -2124,11 +2180,9 @@ free_frame_xic (f)
2124 return; 2180 return;
2125 2181
2126 XDestroyIC (FRAME_XIC (f)); 2182 XDestroyIC (FRAME_XIC (f));
2127 if (FRAME_XIC_FONTSET (f)) 2183 xic_free_xfontset (f);
2128 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2129 2184
2130 FRAME_XIC (f) = NULL; 2185 FRAME_XIC (f) = NULL;
2131 FRAME_XIC_FONTSET (f) = NULL;
2132} 2186}
2133 2187
2134 2188
@@ -2207,6 +2261,8 @@ xic_set_xfontset (f, base_fontname)
2207 XVaNestedList attr; 2261 XVaNestedList attr;
2208 XFontSet xfs; 2262 XFontSet xfs;
2209 2263
2264 xic_free_xfontset (f);
2265
2210 xfs = xic_create_xfontset (f, base_fontname); 2266 xfs = xic_create_xfontset (f, base_fontname);
2211 2267
2212 attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL); 2268 attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL);
@@ -2216,8 +2272,6 @@ xic_set_xfontset (f, base_fontname)
2216 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL); 2272 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
2217 XFree (attr); 2273 XFree (attr);
2218 2274
2219 if (FRAME_XIC_FONTSET (f))
2220 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2221 FRAME_XIC_FONTSET (f) = xfs; 2275 FRAME_XIC_FONTSET (f) = xfs;
2222} 2276}
2223 2277
diff --git a/src/xterm.c b/src/xterm.c
index 2ce8b7d7759..492e8d00b52 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2819,10 +2819,6 @@ x_clear_frame (struct frame *f)
2819 2819
2820 XFlush (FRAME_X_DISPLAY (f)); 2820 XFlush (FRAME_X_DISPLAY (f));
2821 2821
2822#ifdef USE_GTK
2823 xg_frame_cleared (f);
2824#endif
2825
2826 UNBLOCK_INPUT; 2822 UNBLOCK_INPUT;
2827} 2823}
2828 2824
@@ -4865,9 +4861,7 @@ x_scroll_bar_create (w, top, left, width, height)
4865 top, 4861 top,
4866 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 4862 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
4867 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 4863 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
4868 max (height, 1), 4864 max (height, 1));
4869 left,
4870 width);
4871 xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar)); 4865 xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar));
4872#else /* not USE_GTK */ 4866#else /* not USE_GTK */
4873 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 4867 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
@@ -5111,18 +5105,6 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5111 5105
5112#ifdef USE_TOOLKIT_SCROLL_BARS 5106#ifdef USE_TOOLKIT_SCROLL_BARS
5113 5107
5114#ifdef USE_GTK
5115 if (mask)
5116 xg_update_scrollbar_pos (f,
5117 SCROLL_BAR_X_WINDOW (bar),
5118 top,
5119 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5120 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
5121 max (height, 1),
5122 left,
5123 width);
5124#else /* not USE_GTK */
5125
5126 /* Move/size the scroll bar widget. */ 5108 /* Move/size the scroll bar widget. */
5127 if (mask) 5109 if (mask)
5128 { 5110 {
@@ -5131,13 +5113,21 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5131 if (width > 0 && height > 0) 5113 if (width > 0 && height > 0)
5132 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5114 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5133 left, top, width, height, False); 5115 left, top, width, height, False);
5116#ifdef USE_GTK
5117 xg_update_scrollbar_pos (f,
5118 SCROLL_BAR_X_WINDOW (bar),
5119 top,
5120 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5121 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2,
5122 max (height, 1));
5123#else /* not USE_GTK */
5134 XtConfigureWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar), 5124 XtConfigureWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar),
5135 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5125 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5136 top, 5126 top,
5137 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 5127 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
5138 max (height, 1), 0); 5128 max (height, 1), 0);
5139 }
5140#endif /* not USE_GTK */ 5129#endif /* not USE_GTK */
5130 }
5141#else /* not USE_TOOLKIT_SCROLL_BARS */ 5131#else /* not USE_TOOLKIT_SCROLL_BARS */
5142 5132
5143 /* Clear areas not covered by the scroll bar because of 5133 /* Clear areas not covered by the scroll bar because of
@@ -8031,11 +8021,7 @@ xim_destroy_callback (xim, client_data, call_data)
8031 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) 8021 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
8032 { 8022 {
8033 FRAME_XIC (f) = NULL; 8023 FRAME_XIC (f) = NULL;
8034 if (FRAME_XIC_FONTSET (f)) 8024 xic_free_xfontset (f);
8035 {
8036 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
8037 FRAME_XIC_FONTSET (f) = NULL;
8038 }
8039 } 8025 }
8040 } 8026 }
8041 8027
diff --git a/src/xterm.h b/src/xterm.h
index bb1fe9ddc4c..eebe4f10878 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -50,7 +50,9 @@ typedef Widget xt_or_gtk_widget;
50typedef GtkWidget *xt_or_gtk_widget; 50typedef GtkWidget *xt_or_gtk_widget;
51#define XtParent(x) (gtk_widget_get_parent (x)) 51#define XtParent(x) (gtk_widget_get_parent (x))
52#undef XSync 52#undef XSync
53#define XSync(d, b) gdk_window_process_all_updates () 53#define XSync(d, b) do { gdk_window_process_all_updates (); \
54 XSync (d, b); } while (0)
55
54 56
55#endif /* USE_GTK */ 57#endif /* USE_GTK */
56 58
@@ -601,6 +603,7 @@ struct x_output
601 XIC xic; 603 XIC xic;
602 XIMStyle xic_style; 604 XIMStyle xic_style;
603 XFontSet xic_xfs; 605 XFontSet xic_xfs;
606 char *xic_base_fontname;
604#endif 607#endif
605 608
606 /* Relief GCs, colors etc. */ 609 /* Relief GCs, colors etc. */
@@ -735,6 +738,7 @@ enum
735#define FRAME_X_XIM_STYLES(f) (FRAME_X_DISPLAY_INFO (f)->xim_styles) 738#define FRAME_X_XIM_STYLES(f) (FRAME_X_DISPLAY_INFO (f)->xim_styles)
736#define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style) 739#define FRAME_XIC_STYLE(f) ((f)->output_data.x->xic_style)
737#define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs) 740#define FRAME_XIC_FONTSET(f) ((f)->output_data.x->xic_xfs)
741#define FRAME_XIC_BASE_FONTNAME(f) ((f)->output_data.x->xic_base_fontname)
738 742
739/* Value is the smallest width of any character in any font on frame F. */ 743/* Value is the smallest width of any character in any font on frame F. */
740 744
@@ -1044,6 +1048,7 @@ extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object))
1044extern unsigned char * x_encode_text P_ ((Lisp_Object, Lisp_Object, int, 1048extern unsigned char * x_encode_text P_ ((Lisp_Object, Lisp_Object, int,
1045 int *, int *)); 1049 int *, int *));
1046extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); 1050extern void x_implicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
1051extern void xic_free_xfontset P_ ((struct frame *));
1047extern void create_frame_xic P_ ((struct frame *)); 1052extern void create_frame_xic P_ ((struct frame *));
1048extern void destroy_frame_xic P_ ((struct frame *)); 1053extern void destroy_frame_xic P_ ((struct frame *));
1049extern void xic_set_preeditarea P_ ((struct window *, int, int)); 1054extern void xic_set_preeditarea P_ ((struct window *, int, int));