aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2017-10-06 09:50:54 -0400
committerStefan Monnier2017-10-06 09:50:54 -0400
commit11f9cb522fed9aa6552f6315340ca7352661a1e8 (patch)
tree39facc48471c67b321c045e47d70ef030adbea44 /src
parent92045f4546b9708dc9f69954799d211c1f56ff1e (diff)
parent9655937da4a339300c624addd97674c038a01bc9 (diff)
downloademacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.tar.gz
emacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.zip
Merge emacs-26
Diffstat (limited to 'src')
-rw-r--r--src/callint.c4
-rw-r--r--src/dbusbind.c3
-rw-r--r--src/editfns.c28
-rw-r--r--src/frame.c2
-rw-r--r--src/gtkutil.c17
-rw-r--r--src/keyboard.c14
-rw-r--r--src/lisp.h40
-rw-r--r--src/sysdep.c13
-rw-r--r--src/thread.c16
-rw-r--r--src/thread.h7
-rw-r--r--src/xdisp.c4
-rw-r--r--src/xrdb.c7
12 files changed, 92 insertions, 63 deletions
diff --git a/src/callint.c b/src/callint.c
index 469205cc380..5d88082e38d 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -272,7 +272,7 @@ invoke it. If KEYS is omitted or nil, the return value of
272{ 272{
273 /* `args' will contain the array of arguments to pass to the function. 273 /* `args' will contain the array of arguments to pass to the function.
274 `visargs' will contain the same list but in a nicer form, so that if we 274 `visargs' will contain the same list but in a nicer form, so that if we
275 pass it to styled_format it will be understandable to a human. */ 275 pass it to Fformat_message it will be understandable to a human. */
276 Lisp_Object *args, *visargs; 276 Lisp_Object *args, *visargs;
277 Lisp_Object specs; 277 Lisp_Object specs;
278 Lisp_Object filter_specs; 278 Lisp_Object filter_specs;
@@ -502,7 +502,7 @@ invoke it. If KEYS is omitted or nil, the return value of
502 for (i = 2; *tem; i++) 502 for (i = 2; *tem; i++)
503 { 503 {
504 visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); 504 visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n"));
505 callint_message = styled_format (i - 1, visargs + 1, true, false); 505 callint_message = Fformat_message (i - 1, visargs + 1);
506 506
507 switch (*tem) 507 switch (*tem)
508 { 508 {
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 789aa008611..4a7068416fe 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -237,8 +237,7 @@ static char *
237XD_OBJECT_TO_STRING (Lisp_Object object) 237XD_OBJECT_TO_STRING (Lisp_Object object)
238{ 238{
239 AUTO_STRING (format, "%s"); 239 AUTO_STRING (format, "%s");
240 Lisp_Object args[] = { format, object }; 240 return SSDATA (CALLN (Fformat, format, object));
241 return SSDATA (styled_format (ARRAYELTS (args), args, false, false));
242} 241}
243 242
244#define XD_DBUS_VALIDATE_BUS_ADDRESS(bus) \ 243#define XD_DBUS_VALIDATE_BUS_ADDRESS(bus) \
diff --git a/src/editfns.c b/src/editfns.c
index 4dcf7cbe6ef..4fe50ac31d7 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -74,6 +74,7 @@ static Lisp_Object format_time_string (char const *, ptrdiff_t, struct timespec,
74static long int tm_gmtoff (struct tm *); 74static long int tm_gmtoff (struct tm *);
75static int tm_diff (struct tm *, struct tm *); 75static int tm_diff (struct tm *, struct tm *);
76static void update_buffer_properties (ptrdiff_t, ptrdiff_t); 76static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
77static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool);
77 78
78#ifndef HAVE_TM_GMTOFF 79#ifndef HAVE_TM_GMTOFF
79# define HAVE_TM_GMTOFF false 80# define HAVE_TM_GMTOFF false
@@ -3958,7 +3959,7 @@ usage: (message FORMAT-STRING &rest ARGS) */)
3958 } 3959 }
3959 else 3960 else
3960 { 3961 {
3961 Lisp_Object val = styled_format (nargs, args, true, false); 3962 Lisp_Object val = Fformat_message (nargs, args);
3962 message3 (val); 3963 message3 (val);
3963 return val; 3964 return val;
3964 } 3965 }
@@ -3984,7 +3985,7 @@ usage: (message-box FORMAT-STRING &rest ARGS) */)
3984 } 3985 }
3985 else 3986 else
3986 { 3987 {
3987 Lisp_Object val = styled_format (nargs, args, true, false); 3988 Lisp_Object val = Fformat_message (nargs, args);
3988 Lisp_Object pane, menu; 3989 Lisp_Object pane, menu;
3989 3990
3990 pane = list1 (Fcons (build_string ("OK"), Qt)); 3991 pane = list1 (Fcons (build_string ("OK"), Qt));
@@ -4140,7 +4141,7 @@ produced text.
4140usage: (format STRING &rest OBJECTS) */) 4141usage: (format STRING &rest OBJECTS) */)
4141 (ptrdiff_t nargs, Lisp_Object *args) 4142 (ptrdiff_t nargs, Lisp_Object *args)
4142{ 4143{
4143 return styled_format (nargs, args, false, true); 4144 return styled_format (nargs, args, false);
4144} 4145}
4145 4146
4146DEFUN ("format-message", Fformat_message, Sformat_message, 1, MANY, 0, 4147DEFUN ("format-message", Fformat_message, Sformat_message, 1, MANY, 0,
@@ -4156,16 +4157,13 @@ and right quote replacement characters are specified by
4156usage: (format-message STRING &rest OBJECTS) */) 4157usage: (format-message STRING &rest OBJECTS) */)
4157 (ptrdiff_t nargs, Lisp_Object *args) 4158 (ptrdiff_t nargs, Lisp_Object *args)
4158{ 4159{
4159 return styled_format (nargs, args, true, true); 4160 return styled_format (nargs, args, true);
4160} 4161}
4161 4162
4162/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. 4163/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. */
4163 If NEW_RESULT, the result is a new string; otherwise, the result
4164 may be one of the arguments. */
4165 4164
4166Lisp_Object 4165static Lisp_Object
4167styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, 4166styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4168 bool new_result)
4169{ 4167{
4170 ptrdiff_t n; /* The number of the next arg to substitute. */ 4168 ptrdiff_t n; /* The number of the next arg to substitute. */
4171 char initial_buffer[4000]; 4169 char initial_buffer[4000];
@@ -4195,9 +4193,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message,
4195 /* The start and end bytepos in the output string. */ 4193 /* The start and end bytepos in the output string. */
4196 ptrdiff_t start, end; 4194 ptrdiff_t start, end;
4197 4195
4198 /* Whether the argument is a newly created string. */
4199 bool_bf new_string : 1;
4200
4201 /* Whether the argument is a string with intervals. */ 4196 /* Whether the argument is a string with intervals. */
4202 bool_bf intervals : 1; 4197 bool_bf intervals : 1;
4203 } *info; 4198 } *info;
@@ -4241,6 +4236,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message,
4241 ptrdiff_t ispec; 4236 ptrdiff_t ispec;
4242 ptrdiff_t nspec = 0; 4237 ptrdiff_t nspec = 0;
4243 4238
4239 /* True if a string needs to be allocated to hold the result. */
4240 bool new_result = false;
4241
4244 /* If we start out planning a unibyte result, 4242 /* If we start out planning a unibyte result,
4245 then discover it has to be multibyte, we jump back to retry. */ 4243 then discover it has to be multibyte, we jump back to retry. */
4246 retry: 4244 retry:
@@ -4360,7 +4358,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message,
4360 if (nspec < ispec) 4358 if (nspec < ispec)
4361 { 4359 {
4362 spec->argument = args[n]; 4360 spec->argument = args[n];
4363 spec->new_string = false;
4364 spec->intervals = false; 4361 spec->intervals = false;
4365 nspec = ispec; 4362 nspec = ispec;
4366 } 4363 }
@@ -4378,7 +4375,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message,
4378 { 4375 {
4379 Lisp_Object noescape = conversion == 'S' ? Qnil : Qt; 4376 Lisp_Object noescape = conversion == 'S' ? Qnil : Qt;
4380 spec->argument = arg = Fprin1_to_string (arg, noescape); 4377 spec->argument = arg = Fprin1_to_string (arg, noescape);
4381 spec->new_string = true;
4382 if (STRING_MULTIBYTE (arg) && ! multibyte) 4378 if (STRING_MULTIBYTE (arg) && ! multibyte)
4383 { 4379 {
4384 multibyte = true; 4380 multibyte = true;
@@ -4397,7 +4393,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message,
4397 goto retry; 4393 goto retry;
4398 } 4394 }
4399 spec->argument = arg = Fchar_to_string (arg); 4395 spec->argument = arg = Fchar_to_string (arg);
4400 spec->new_string = true;
4401 } 4396 }
4402 4397
4403 if (!EQ (arg, args[n])) 4398 if (!EQ (arg, args[n]))
@@ -4421,7 +4416,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message,
4421 if (conversion == 's') 4416 if (conversion == 's')
4422 { 4417 {
4423 if (format == end && format - format_start == 2 4418 if (format == end && format - format_start == 2
4424 && (!new_result || spec->new_string)
4425 && ! string_intervals (args[0])) 4419 && ! string_intervals (args[0]))
4426 return arg; 4420 return arg;
4427 4421
diff --git a/src/frame.c b/src/frame.c
index 1aff3a007ac..ab801eec9c7 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2542,6 +2542,7 @@ for how to proceed. */)
2542 (Lisp_Object frame) 2542 (Lisp_Object frame)
2543{ 2543{
2544 struct frame *f = decode_live_frame (frame); 2544 struct frame *f = decode_live_frame (frame);
2545#ifdef HAVE_WINDOW_SYSTEM
2545 Lisp_Object parent = f->parent_frame; 2546 Lisp_Object parent = f->parent_frame;
2546 2547
2547 if (!NILP (parent)) 2548 if (!NILP (parent))
@@ -2562,6 +2563,7 @@ for how to proceed. */)
2562 return Qnil; 2563 return Qnil;
2563 } 2564 }
2564 } 2565 }
2566#endif /* HAVE_WINDOW_SYSTEM */
2565 2567
2566 /* Don't allow minibuf_window to remain on an iconified frame. */ 2568 /* Don't allow minibuf_window to remain on an iconified frame. */
2567 check_minibuf_window (frame, EQ (minibuf_window, selected_window)); 2569 check_minibuf_window (frame, EQ (minibuf_window, selected_window));
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 8d565c19c9c..4aa2c9bb5e0 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -577,11 +577,18 @@ xg_check_special_colors (struct frame *f,
577 if (get_fg) 577 if (get_fg)
578 gtk_style_context_get_color (gsty, state, &col); 578 gtk_style_context_get_color (gsty, state, &col);
579 else 579 else
580 /* FIXME: gtk_style_context_get_background_color is deprecated 580 {
581 in GTK+ 3.16. New versions of GTK+ don’t use the concept of 581 GdkRGBA *c;
582 a single background color any more, so we shouldn’t query for 582 /* FIXME: Retrieving the background color is deprecated in
583 it. */ 583 GTK+ 3.16. New versions of GTK+ don’t use the concept of a
584 gtk_style_context_get_background_color (gsty, state, &col); 584 single background color any more, so we shouldn’t query for
585 it. */
586 gtk_style_context_get (gsty, state,
587 GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c,
588 NULL);
589 col = *c;
590 gdk_rgba_free (c);
591 }
585 592
586 unsigned short 593 unsigned short
587 r = col.red * 65535, 594 r = col.red * 65535,
diff --git a/src/keyboard.c b/src/keyboard.c
index e8701b88708..ee353d2b078 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -145,10 +145,6 @@ static Lisp_Object recover_top_level_message;
145/* Message normally displayed by Vtop_level. */ 145/* Message normally displayed by Vtop_level. */
146static Lisp_Object regular_top_level_message; 146static Lisp_Object regular_top_level_message;
147 147
148/* For longjmp to where kbd input is being done. */
149
150static sys_jmp_buf getcjmp;
151
152/* True while displaying for echoing. Delays C-g throwing. */ 148/* True while displaying for echoing. Delays C-g throwing. */
153 149
154static bool echoing; 150static bool echoing;
@@ -2570,9 +2566,6 @@ read_char (int commandflag, Lisp_Object map,
2570 so restore it now. */ 2566 so restore it now. */
2571 restore_getcjmp (save_jump); 2567 restore_getcjmp (save_jump);
2572 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 2568 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
2573#if THREADS_ENABLED
2574 maybe_reacquire_global_lock ();
2575#endif
2576 unbind_to (jmpcount, Qnil); 2569 unbind_to (jmpcount, Qnil);
2577 XSETINT (c, quit_char); 2570 XSETINT (c, quit_char);
2578 internal_last_event_frame = selected_frame; 2571 internal_last_event_frame = selected_frame;
@@ -10508,6 +10501,13 @@ handle_interrupt (bool in_signal_handler)
10508 outside of polling since we don't get SIGIO like X and we don't have a 10501 outside of polling since we don't get SIGIO like X and we don't have a
10509 separate event loop thread like W32. */ 10502 separate event loop thread like W32. */
10510#ifndef HAVE_NS 10503#ifndef HAVE_NS
10504#ifdef THREADS_ENABLED
10505 /* If we were called from a signal handler, we must be in the main
10506 thread, see deliver_process_signal. So we must make sure the
10507 main thread holds the global lock. */
10508 if (in_signal_handler)
10509 maybe_reacquire_global_lock ();
10510#endif
10511 if (waiting_for_input && !echoing) 10511 if (waiting_for_input && !echoing)
10512 quit_throw_to_read_char (in_signal_handler); 10512 quit_throw_to_read_char (in_signal_handler);
10513#endif 10513#endif
diff --git a/src/lisp.h b/src/lisp.h
index 680c25d4c49..266370333f5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1865,6 +1865,26 @@ verify (offsetof (struct Lisp_Sub_Char_Table, contents)
1865 == (offsetof (struct Lisp_Vector, contents) 1865 == (offsetof (struct Lisp_Vector, contents)
1866 + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object))); 1866 + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object)));
1867 1867
1868
1869/* Save and restore the instruction and environment pointers,
1870 without affecting the signal mask. */
1871
1872#ifdef HAVE__SETJMP
1873typedef jmp_buf sys_jmp_buf;
1874# define sys_setjmp(j) _setjmp (j)
1875# define sys_longjmp(j, v) _longjmp (j, v)
1876#elif defined HAVE_SIGSETJMP
1877typedef sigjmp_buf sys_jmp_buf;
1878# define sys_setjmp(j) sigsetjmp (j, 0)
1879# define sys_longjmp(j, v) siglongjmp (j, v)
1880#else
1881/* A platform that uses neither _longjmp nor siglongjmp; assume
1882 longjmp does not affect the sigmask. */
1883typedef jmp_buf sys_jmp_buf;
1884# define sys_setjmp(j) setjmp (j)
1885# define sys_longjmp(j, v) longjmp (j, v)
1886#endif
1887
1868#include "thread.h" 1888#include "thread.h"
1869 1889
1870/*********************************************************************** 1890/***********************************************************************
@@ -3003,25 +3023,6 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int);
3003 static struct Lisp_Kboard_Objfwd ko_fwd; \ 3023 static struct Lisp_Kboard_Objfwd ko_fwd; \
3004 defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \ 3024 defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \
3005 } while (false) 3025 } while (false)
3006
3007/* Save and restore the instruction and environment pointers,
3008 without affecting the signal mask. */
3009
3010#ifdef HAVE__SETJMP
3011typedef jmp_buf sys_jmp_buf;
3012# define sys_setjmp(j) _setjmp (j)
3013# define sys_longjmp(j, v) _longjmp (j, v)
3014#elif defined HAVE_SIGSETJMP
3015typedef sigjmp_buf sys_jmp_buf;
3016# define sys_setjmp(j) sigsetjmp (j, 0)
3017# define sys_longjmp(j, v) siglongjmp (j, v)
3018#else
3019/* A platform that uses neither _longjmp nor siglongjmp; assume
3020 longjmp does not affect the sigmask. */
3021typedef jmp_buf sys_jmp_buf;
3022# define sys_setjmp(j) setjmp (j)
3023# define sys_longjmp(j, v) longjmp (j, v)
3024#endif
3025 3026
3026 3027
3027/* Elisp uses several stacks: 3028/* Elisp uses several stacks:
@@ -3969,7 +3970,6 @@ extern _Noreturn void time_overflow (void);
3969extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); 3970extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
3970extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, 3971extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
3971 ptrdiff_t, bool); 3972 ptrdiff_t, bool);
3972extern Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool, bool);
3973extern void init_editfns (bool); 3973extern void init_editfns (bool);
3974extern void syms_of_editfns (void); 3974extern void syms_of_editfns (void);
3975 3975
diff --git a/src/sysdep.c b/src/sysdep.c
index 26d381f5796..8291a606bea 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -232,7 +232,18 @@ emacs_get_current_dir_name (void)
232 bool use_libc = true; 232 bool use_libc = true;
233# endif 233# endif
234 if (use_libc) 234 if (use_libc)
235 return get_current_dir_name (); 235 {
236 /* GNU/Linux get_current_dir_name can return a string starting
237 with "(unreachable)" (Bug#27871). */
238 char *wd = get_current_dir_name ();
239 if (wd && ! (IS_DIRECTORY_SEP (*wd) || (*wd && IS_DEVICE_SEP (wd[1]))))
240 {
241 free (wd);
242 errno = ENOENT;
243 return NULL;
244 }
245 return wd;
246 }
236# endif 247# endif
237 248
238 char *buf; 249 char *buf;
diff --git a/src/thread.c b/src/thread.c
index 42d7791ad0f..d075bdb3a13 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -101,14 +101,20 @@ acquire_global_lock (struct thread_state *self)
101 post_acquire_global_lock (self); 101 post_acquire_global_lock (self);
102} 102}
103 103
104/* This is called from keyboard.c when it detects that SIGINT 104/* This is called from keyboard.c when it detects that SIGINT was
105 interrupted thread_select before the current thread could acquire 105 delivered to the main thread and interrupted thread_select before
106 the lock. We must acquire the lock to prevent a thread from 106 the main thread could acquire the lock. We must acquire the lock
107 running without holding the global lock, and to avoid repeated 107 to prevent a thread from running without holding the global lock,
108 calls to sys_mutex_unlock, which invokes undefined behavior. */ 108 and to avoid repeated calls to sys_mutex_unlock, which invokes
109 undefined behavior. */
109void 110void
110maybe_reacquire_global_lock (void) 111maybe_reacquire_global_lock (void)
111{ 112{
113 /* SIGINT handler is always run on the main thread, see
114 deliver_process_signal, so reflect that in our thread-tracking
115 variables. */
116 current_thread = &main_thread;
117
112 if (current_thread->not_holding_lock) 118 if (current_thread->not_holding_lock)
113 { 119 {
114 struct thread_state *self = current_thread; 120 struct thread_state *self = current_thread;
diff --git a/src/thread.h b/src/thread.h
index 7fce8674f0e..cb2133d72d4 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -158,6 +158,13 @@ struct thread_state
158 bool m_waiting_for_input; 158 bool m_waiting_for_input;
159#define waiting_for_input (current_thread->m_waiting_for_input) 159#define waiting_for_input (current_thread->m_waiting_for_input)
160 160
161 /* For longjmp to where kbd input is being done. This is per-thread
162 so that if more than one thread calls read_char, they don't
163 clobber each other's getcjmp, which will cause
164 quit_throw_to_read_char crash due to using a wrong stack. */
165 sys_jmp_buf m_getcjmp;
166#define getcjmp (current_thread->m_getcjmp)
167
161 /* The OS identifier for this thread. */ 168 /* The OS identifier for this thread. */
162 sys_thread_t thread_id; 169 sys_thread_t thread_id;
163 170
diff --git a/src/xdisp.c b/src/xdisp.c
index 86164eb9f6f..141275f15a0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10194,7 +10194,7 @@ vadd_to_log (char const *format, va_list ap)
10194 for (ptrdiff_t i = 1; i <= nargs; i++) 10194 for (ptrdiff_t i = 1; i <= nargs; i++)
10195 args[i] = va_arg (ap, Lisp_Object); 10195 args[i] = va_arg (ap, Lisp_Object);
10196 Lisp_Object msg = Qnil; 10196 Lisp_Object msg = Qnil;
10197 msg = styled_format (nargs, args, true, false); 10197 msg = Fformat_message (nargs, args);
10198 10198
10199 ptrdiff_t len = SBYTES (msg) + 1; 10199 ptrdiff_t len = SBYTES (msg) + 1;
10200 USE_SAFE_ALLOCA; 10200 USE_SAFE_ALLOCA;
@@ -19525,7 +19525,7 @@ DEFUN ("trace-to-stderr", Ftrace_to_stderr, Strace_to_stderr, 1, MANY, "",
19525usage: (trace-to-stderr STRING &rest OBJECTS) */) 19525usage: (trace-to-stderr STRING &rest OBJECTS) */)
19526 (ptrdiff_t nargs, Lisp_Object *args) 19526 (ptrdiff_t nargs, Lisp_Object *args)
19527{ 19527{
19528 Lisp_Object s = styled_format (nargs, args, false, false); 19528 Lisp_Object s = Fformat (nargs, args);
19529 fwrite (SDATA (s), 1, SBYTES (s), stderr); 19529 fwrite (SDATA (s), 1, SBYTES (s), stderr);
19530 return Qnil; 19530 return Qnil;
19531} 19531}
diff --git a/src/xrdb.c b/src/xrdb.c
index 15a01475b7c..3c1bad1c735 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -345,6 +345,7 @@ get_user_db (Display *display)
345 db = XrmGetStringDatabase (xdefs); 345 db = XrmGetStringDatabase (xdefs);
346 else 346 else
347 { 347 {
348 /* Use ~/.Xdefaults. */
348 char *home = gethomedir (); 349 char *home = gethomedir ();
349 ptrdiff_t homelen = strlen (home); 350 ptrdiff_t homelen = strlen (home);
350 char *filename = xrealloc (home, homelen + sizeof xdefaults); 351 char *filename = xrealloc (home, homelen + sizeof xdefaults);
@@ -375,13 +376,15 @@ get_environ_db (void)
375 376
376 if (!p) 377 if (!p)
377 { 378 {
379 /* Use ~/.Xdefaults-HOSTNAME. */
378 char *home = gethomedir (); 380 char *home = gethomedir ();
379 ptrdiff_t homelen = strlen (home); 381 ptrdiff_t homelen = strlen (home);
380 Lisp_Object system_name = Fsystem_name (); 382 Lisp_Object system_name = Fsystem_name ();
381 ptrdiff_t filenamesize = (homelen + sizeof xdefaults 383 ptrdiff_t filenamesize = (homelen + sizeof xdefaults
382 + SBYTES (system_name)); 384 + 1 + SBYTES (system_name));
383 p = filename = xrealloc (home, filenamesize); 385 p = filename = xrealloc (home, filenamesize);
384 lispstpcpy (stpcpy (filename + homelen, xdefaults), system_name); 386 lispstpcpy (stpcpy (stpcpy (filename + homelen, xdefaults), "-"),
387 system_name);
385 } 388 }
386 389
387 db = XrmGetFileDatabase (p); 390 db = XrmGetFileDatabase (p);