diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2017-10-06 09:50:54 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2017-10-06 09:50:54 -0400 |
commit | 11f9cb522fed9aa6552f6315340ca7352661a1e8 (patch) | |
tree | 39facc48471c67b321c045e47d70ef030adbea44 /src | |
parent | 92045f4546b9708dc9f69954799d211c1f56ff1e (diff) | |
parent | 9655937da4a339300c624addd97674c038a01bc9 (diff) | |
download | emacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.tar.gz emacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.tar.bz2 emacs-11f9cb522fed9aa6552f6315340ca7352661a1e8.zip |
Merge emacs-26
Diffstat (limited to 'src')
-rw-r--r-- | src/callint.c | 4 | ||||
-rw-r--r-- | src/dbusbind.c | 3 | ||||
-rw-r--r-- | src/editfns.c | 28 | ||||
-rw-r--r-- | src/frame.c | 2 | ||||
-rw-r--r-- | src/gtkutil.c | 17 | ||||
-rw-r--r-- | src/keyboard.c | 14 | ||||
-rw-r--r-- | src/lisp.h | 40 | ||||
-rw-r--r-- | src/sysdep.c | 13 | ||||
-rw-r--r-- | src/thread.c | 16 | ||||
-rw-r--r-- | src/thread.h | 7 | ||||
-rw-r--r-- | src/xdisp.c | 4 | ||||
-rw-r--r-- | src/xrdb.c | 7 |
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 { /* `args' will contain the array of arguments to pass to the function. `visargs' will contain the same list but in a nicer form, so that if we - pass it to styled_format it will be understandable to a human. */ + pass it to Fformat_message it will be understandable to a human. */ Lisp_Object *args, *visargs; Lisp_Object specs; Lisp_Object filter_specs; @@ -502,7 +502,7 @@ invoke it. If KEYS is omitted or nil, the return value of for (i = 2; *tem; i++) { visargs[1] = make_string (tem + 1, strcspn (tem + 1, "\n")); - callint_message = styled_format (i - 1, visargs + 1, true, false); + callint_message = Fformat_message (i - 1, visargs + 1); switch (*tem) { 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 * XD_OBJECT_TO_STRING (Lisp_Object object) { AUTO_STRING (format, "%s"); - Lisp_Object args[] = { format, object }; - return SSDATA (styled_format (ARRAYELTS (args), args, false, false)); + return SSDATA (CALLN (Fformat, format, object)); } #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, static long int tm_gmtoff (struct tm *); static int tm_diff (struct tm *, struct tm *); static void update_buffer_properties (ptrdiff_t, ptrdiff_t); +static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); #ifndef HAVE_TM_GMTOFF # define HAVE_TM_GMTOFF false @@ -3958,7 +3959,7 @@ usage: (message FORMAT-STRING &rest ARGS) */) } else { - Lisp_Object val = styled_format (nargs, args, true, false); + Lisp_Object val = Fformat_message (nargs, args); message3 (val); return val; } @@ -3984,7 +3985,7 @@ usage: (message-box FORMAT-STRING &rest ARGS) */) } else { - Lisp_Object val = styled_format (nargs, args, true, false); + Lisp_Object val = Fformat_message (nargs, args); Lisp_Object pane, menu; pane = list1 (Fcons (build_string ("OK"), Qt)); @@ -4140,7 +4141,7 @@ produced text. usage: (format STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { - return styled_format (nargs, args, false, true); + return styled_format (nargs, args, false); } DEFUN ("format-message", Fformat_message, Sformat_message, 1, MANY, 0, @@ -4156,16 +4157,13 @@ and right quote replacement characters are specified by usage: (format-message STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { - return styled_format (nargs, args, true, true); + return styled_format (nargs, args, true); } -/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. - If NEW_RESULT, the result is a new string; otherwise, the result - may be one of the arguments. */ +/* Implement ‘format-message’ if MESSAGE is true, ‘format’ otherwise. */ -Lisp_Object -styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, - bool new_result) +static Lisp_Object +styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) { ptrdiff_t n; /* The number of the next arg to substitute. */ char initial_buffer[4000]; @@ -4195,9 +4193,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, /* The start and end bytepos in the output string. */ ptrdiff_t start, end; - /* Whether the argument is a newly created string. */ - bool_bf new_string : 1; - /* Whether the argument is a string with intervals. */ bool_bf intervals : 1; } *info; @@ -4241,6 +4236,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, ptrdiff_t ispec; ptrdiff_t nspec = 0; + /* True if a string needs to be allocated to hold the result. */ + bool new_result = false; + /* If we start out planning a unibyte result, then discover it has to be multibyte, we jump back to retry. */ retry: @@ -4360,7 +4358,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, if (nspec < ispec) { spec->argument = args[n]; - spec->new_string = false; spec->intervals = false; nspec = ispec; } @@ -4378,7 +4375,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, { Lisp_Object noescape = conversion == 'S' ? Qnil : Qt; spec->argument = arg = Fprin1_to_string (arg, noescape); - spec->new_string = true; if (STRING_MULTIBYTE (arg) && ! multibyte) { multibyte = true; @@ -4397,7 +4393,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, goto retry; } spec->argument = arg = Fchar_to_string (arg); - spec->new_string = true; } if (!EQ (arg, args[n])) @@ -4421,7 +4416,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message, if (conversion == 's') { if (format == end && format - format_start == 2 - && (!new_result || spec->new_string) && ! string_intervals (args[0])) return arg; 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. */) (Lisp_Object frame) { struct frame *f = decode_live_frame (frame); +#ifdef HAVE_WINDOW_SYSTEM Lisp_Object parent = f->parent_frame; if (!NILP (parent)) @@ -2562,6 +2563,7 @@ for how to proceed. */) return Qnil; } } +#endif /* HAVE_WINDOW_SYSTEM */ /* Don't allow minibuf_window to remain on an iconified frame. */ 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, if (get_fg) gtk_style_context_get_color (gsty, state, &col); else - /* FIXME: gtk_style_context_get_background_color is deprecated - in GTK+ 3.16. New versions of GTK+ don’t use the concept of - a single background color any more, so we shouldn’t query for - it. */ - gtk_style_context_get_background_color (gsty, state, &col); + { + GdkRGBA *c; + /* FIXME: Retrieving the background color is deprecated in + GTK+ 3.16. New versions of GTK+ don’t use the concept of a + single background color any more, so we shouldn’t query for + it. */ + gtk_style_context_get (gsty, state, + GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &c, + NULL); + col = *c; + gdk_rgba_free (c); + } unsigned short 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; /* Message normally displayed by Vtop_level. */ static Lisp_Object regular_top_level_message; -/* For longjmp to where kbd input is being done. */ - -static sys_jmp_buf getcjmp; - /* True while displaying for echoing. Delays C-g throwing. */ static bool echoing; @@ -2570,9 +2566,6 @@ read_char (int commandflag, Lisp_Object map, so restore it now. */ restore_getcjmp (save_jump); pthread_sigmask (SIG_SETMASK, &empty_mask, 0); -#if THREADS_ENABLED - maybe_reacquire_global_lock (); -#endif unbind_to (jmpcount, Qnil); XSETINT (c, quit_char); internal_last_event_frame = selected_frame; @@ -10508,6 +10501,13 @@ handle_interrupt (bool in_signal_handler) outside of polling since we don't get SIGIO like X and we don't have a separate event loop thread like W32. */ #ifndef HAVE_NS +#ifdef THREADS_ENABLED + /* If we were called from a signal handler, we must be in the main + thread, see deliver_process_signal. So we must make sure the + main thread holds the global lock. */ + if (in_signal_handler) + maybe_reacquire_global_lock (); +#endif if (waiting_for_input && !echoing) quit_throw_to_read_char (in_signal_handler); #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) == (offsetof (struct Lisp_Vector, contents) + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object))); + +/* Save and restore the instruction and environment pointers, + without affecting the signal mask. */ + +#ifdef HAVE__SETJMP +typedef jmp_buf sys_jmp_buf; +# define sys_setjmp(j) _setjmp (j) +# define sys_longjmp(j, v) _longjmp (j, v) +#elif defined HAVE_SIGSETJMP +typedef sigjmp_buf sys_jmp_buf; +# define sys_setjmp(j) sigsetjmp (j, 0) +# define sys_longjmp(j, v) siglongjmp (j, v) +#else +/* A platform that uses neither _longjmp nor siglongjmp; assume + longjmp does not affect the sigmask. */ +typedef jmp_buf sys_jmp_buf; +# define sys_setjmp(j) setjmp (j) +# define sys_longjmp(j, v) longjmp (j, v) +#endif + #include "thread.h" /*********************************************************************** @@ -3003,25 +3023,6 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); static struct Lisp_Kboard_Objfwd ko_fwd; \ defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \ } while (false) - -/* Save and restore the instruction and environment pointers, - without affecting the signal mask. */ - -#ifdef HAVE__SETJMP -typedef jmp_buf sys_jmp_buf; -# define sys_setjmp(j) _setjmp (j) -# define sys_longjmp(j, v) _longjmp (j, v) -#elif defined HAVE_SIGSETJMP -typedef sigjmp_buf sys_jmp_buf; -# define sys_setjmp(j) sigsetjmp (j, 0) -# define sys_longjmp(j, v) siglongjmp (j, v) -#else -/* A platform that uses neither _longjmp nor siglongjmp; assume - longjmp does not affect the sigmask. */ -typedef jmp_buf sys_jmp_buf; -# define sys_setjmp(j) setjmp (j) -# define sys_longjmp(j, v) longjmp (j, v) -#endif /* Elisp uses several stacks: @@ -3969,7 +3970,6 @@ extern _Noreturn void time_overflow (void); extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool); -extern Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool, bool); extern void init_editfns (bool); extern void syms_of_editfns (void); 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) bool use_libc = true; # endif if (use_libc) - return get_current_dir_name (); + { + /* GNU/Linux get_current_dir_name can return a string starting + with "(unreachable)" (Bug#27871). */ + char *wd = get_current_dir_name (); + if (wd && ! (IS_DIRECTORY_SEP (*wd) || (*wd && IS_DEVICE_SEP (wd[1])))) + { + free (wd); + errno = ENOENT; + return NULL; + } + return wd; + } # endif 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) post_acquire_global_lock (self); } -/* This is called from keyboard.c when it detects that SIGINT - interrupted thread_select before the current thread could acquire - the lock. We must acquire the lock to prevent a thread from - running without holding the global lock, and to avoid repeated - calls to sys_mutex_unlock, which invokes undefined behavior. */ +/* This is called from keyboard.c when it detects that SIGINT was + delivered to the main thread and interrupted thread_select before + the main thread could acquire the lock. We must acquire the lock + to prevent a thread from running without holding the global lock, + and to avoid repeated calls to sys_mutex_unlock, which invokes + undefined behavior. */ void maybe_reacquire_global_lock (void) { + /* SIGINT handler is always run on the main thread, see + deliver_process_signal, so reflect that in our thread-tracking + variables. */ + current_thread = &main_thread; + if (current_thread->not_holding_lock) { 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 bool m_waiting_for_input; #define waiting_for_input (current_thread->m_waiting_for_input) + /* For longjmp to where kbd input is being done. This is per-thread + so that if more than one thread calls read_char, they don't + clobber each other's getcjmp, which will cause + quit_throw_to_read_char crash due to using a wrong stack. */ + sys_jmp_buf m_getcjmp; +#define getcjmp (current_thread->m_getcjmp) + /* The OS identifier for this thread. */ sys_thread_t thread_id; 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) for (ptrdiff_t i = 1; i <= nargs; i++) args[i] = va_arg (ap, Lisp_Object); Lisp_Object msg = Qnil; - msg = styled_format (nargs, args, true, false); + msg = Fformat_message (nargs, args); ptrdiff_t len = SBYTES (msg) + 1; USE_SAFE_ALLOCA; @@ -19525,7 +19525,7 @@ DEFUN ("trace-to-stderr", Ftrace_to_stderr, Strace_to_stderr, 1, MANY, "", usage: (trace-to-stderr STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { - Lisp_Object s = styled_format (nargs, args, false, false); + Lisp_Object s = Fformat (nargs, args); fwrite (SDATA (s), 1, SBYTES (s), stderr); return Qnil; } 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) db = XrmGetStringDatabase (xdefs); else { + /* Use ~/.Xdefaults. */ char *home = gethomedir (); ptrdiff_t homelen = strlen (home); char *filename = xrealloc (home, homelen + sizeof xdefaults); @@ -375,13 +376,15 @@ get_environ_db (void) if (!p) { + /* Use ~/.Xdefaults-HOSTNAME. */ char *home = gethomedir (); ptrdiff_t homelen = strlen (home); Lisp_Object system_name = Fsystem_name (); ptrdiff_t filenamesize = (homelen + sizeof xdefaults - + SBYTES (system_name)); + + 1 + SBYTES (system_name)); p = filename = xrealloc (home, filenamesize); - lispstpcpy (stpcpy (filename + homelen, xdefaults), system_name); + lispstpcpy (stpcpy (stpcpy (filename + homelen, xdefaults), "-"), + system_name); } db = XrmGetFileDatabase (p); |