commit 5d2ac7435de679559aae0ede1d8b6f1750c09e68 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Tue Sep 6 17:27:24 2016 -0700 Use DEV_TTY more consistently * src/conf_post.h (DEV_TTY): Move from here ... * src/keyboard.c, src/keyboard.h: ... to here, as it doesn’t need to be visible everywhere. Make it a constant. * src/keyboard.c (handle_interrupt, Fset_quit_char): * src/process.c (create_process): Prefer DEV_TTY to "/dev/tty". diff --git a/src/conf_post.h b/src/conf_post.h index bc8b096..865d018 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -140,10 +140,6 @@ typedef bool bool_bf; #undef HAVE_RINT #endif /* HPUX */ -#ifdef WINDOWSNT -# define DEV_TTY "CONOUT$" -#endif - #ifdef MSDOS #ifndef __DJGPP__ You lose; /* Emacs for DOS must be compiled with DJGPP */ @@ -246,11 +242,6 @@ extern int emacs_setenv_TZ (char const *); #include #include -#ifndef DEV_TTY -# define DEV_TTY "/dev/tty" -#endif - - #if __GNUC__ >= 3 /* On GCC 3.0 we might get a warning. */ #define NO_INLINE __attribute__((noinline)) #else diff --git a/src/keyboard.c b/src/keyboard.c index 3ef797c..b8bc361 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -75,6 +75,12 @@ along with GNU Emacs. If not, see . */ # pragma GCC diagnostic ignored "-Wclobbered" #endif +#ifdef WINDOWSNT +char const DEV_TTY[] = "CONOUT$"; +#else +char const DEV_TTY[] = "/dev/tty"; +#endif + /* Variables for blockinput.h: */ /* Positive if interrupt input is blocked right now. */ @@ -10310,7 +10316,7 @@ handle_interrupt (bool in_signal_handler) cancel_echoing (); /* XXX This code needs to be revised for multi-tty support. */ - if (!NILP (Vquit_flag) && get_named_terminal ("/dev/tty")) + if (!NILP (Vquit_flag) && get_named_terminal (DEV_TTY)) { if (! in_signal_handler) { @@ -10609,7 +10615,7 @@ process. See also `current-input-mode'. */) (Lisp_Object quit) { - struct terminal *t = get_named_terminal ("/dev/tty"); + struct terminal *t = get_named_terminal (DEV_TTY); struct tty_display_info *tty; if (!t) diff --git a/src/keyboard.h b/src/keyboard.h index 3873787..a5ed5e1 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -496,6 +496,8 @@ extern void mark_kboards (void); extern const char *const lispy_function_keys[]; #endif +extern char const DEV_TTY[]; + INLINE_HEADER_END #endif /* EMACS_KEYBOARD_H */ diff --git a/src/process.c b/src/process.c index 344a886..9895119 100644 --- a/src/process.c +++ b/src/process.c @@ -1917,7 +1917,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) { /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? I can't test it since I don't have 4.3. */ - int j = emacs_open ("/dev/tty", O_RDWR, 0); + int j = emacs_open (DEV_TTY, O_RDWR, 0); if (j >= 0) { ioctl (j, TIOCNOTTY, 0); diff --git a/src/term.c b/src/term.c index cb684b3..54a97e9 100644 --- a/src/term.c +++ b/src/term.c @@ -3905,7 +3905,7 @@ dissociate_if_controlling_tty (int fd) /* Create a termcap display on the tty device with the given name and type. - If NAME is NULL, then use the controlling tty, i.e., "/dev/tty". + If NAME is NULL, then use the controlling tty, i.e., DEV_TTY. Otherwise NAME should be a path to the tty device file, e.g. "/dev/pts/7". commit 644f77b517180c5f75a9eaac4d76b12a1f334ce6 Author: Eli Zaretskii Date: Tue Sep 6 19:46:06 2016 +0300 Avoid assertion violations when using marker positions * src/intervals.c (set_point_from_marker): If MARKER comes from another buffer, recalculate its byte position before using it to set point. * src/marker.c (set_marker_internal): If POSITION is a marker from another buffer, recalculate its byte position before using it. (Bug#24368) diff --git a/src/intervals.c b/src/intervals.c index 8451069..e797e25 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -1821,11 +1821,16 @@ set_point (ptrdiff_t charpos) void set_point_from_marker (Lisp_Object marker) { + ptrdiff_t charpos = clip_to_bounds (BEGV, marker_position (marker), ZV); + ptrdiff_t bytepos = marker_byte_position (marker); + + /* Don't trust the byte position if the marker belongs to a + different buffer. */ if (XMARKER (marker)->buffer != current_buffer) - signal_error ("Marker points into wrong buffer", marker); - set_point_both - (clip_to_bounds (BEGV, marker_position (marker), ZV), - clip_to_bounds (BEGV_BYTE, marker_byte_position (marker), ZV_BYTE)); + bytepos = buf_charpos_to_bytepos (current_buffer, charpos); + else + bytepos = clip_to_bounds (BEGV_BYTE, bytepos, ZV_BYTE); + set_point_both (charpos, bytepos); } /* If there's an invisible character at position POS + TEST_OFFS in the diff --git a/src/marker.c b/src/marker.c index febdb17..05e5bb8 100644 --- a/src/marker.c +++ b/src/marker.c @@ -507,7 +507,11 @@ set_marker_internal (Lisp_Object marker, Lisp_Object position, charpos = clip_to_bounds (restricted ? BUF_BEGV (b) : BUF_BEG (b), charpos, restricted ? BUF_ZV (b) : BUF_Z (b)); - if (bytepos == -1) + /* Don't believe BYTEPOS if it comes from a different buffer, + since that buffer might have a very different correspondence + between character and byte positions. */ + if (bytepos == -1 + || !(MARKERP (position) && XMARKER (position)->buffer == b)) bytepos = buf_charpos_to_bytepos (b, charpos); else bytepos = clip_to_bounds commit dcfcc595339f8bd503dedf95976b8a3633382f4f Author: Alan Mackenzie Date: Tue Sep 6 12:40:41 2016 +0000 * lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): Fix coding bug diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index d4cb192..259f8a0 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -4516,11 +4516,12 @@ comment at the start of cc-engine.el for more info." ((not (memq noerror '(before-literal after-literal))) (goto-char bound)) (t (setq state (parse-partial-sexp state-pos bound nil nil state)) - (when (or (elt state 3) (elt state 4)) - (if (eq noerror 'before-literal) - (goto-char (elt state 8)) - (parse-partial-sexp bound (point-max) nil nil - state 'syntax-table))))) + (if (or (elt state 3) (elt state 4)) + (if (eq noerror 'before-literal) + (goto-char (elt state 8)) + (parse-partial-sexp bound (point-max) nil nil + state 'syntax-table)) + (goto-char bound)))) nil))) commit 96a80239e7711c5f5d1f9cca5e18b6491b352ca5 Author: Alan Mackenzie Date: Tue Sep 6 11:47:16 2016 +0000 New options for handling of literals in c-syntactic-re-search-forward * lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): `noerror' can be given the values `before-literal' and `after-literal', so that when a search fails, and the `bound' is inside a literal, point is left respectively before or after that literal. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 2cad2d0..d4cb192 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -4278,6 +4278,15 @@ or string literals are ignored. The start point is assumed to be outside any comment, macro or string literal, or else the content of that region is taken as syntactically significant text. +NOERROR, in addition to the values nil, t, and +used in `re-search-forward' can also take the values +'before-literal and 'after-literal. In these cases, when BOUND +is also given and is inside a literal, and a search fails, point +will be left, respectively before or after the literal. Be aware +that with 'after-literal, if a string or comment is unclosed at +the end of the buffer, point may be left there, even though it is +inside a literal there. + If PAREN-LEVEL is non-nil, an additional restriction is added to ignore matches in nested paren sexps. The search will also not go outside the current list sexp, which has the effect that if the point @@ -4343,7 +4352,7 @@ comment at the start of cc-engine.el for more info." (setq search-pos (point)) (if (re-search-forward regexp bound noerror) t - ;; Without the following, when PAREN-LEVEL it non-nil, and + ;; Without the following, when PAREN-LEVEL is non-nil, and ;; NOERROR is not nil or t, and the very first search above ;; has just failed, point would end up at BOUND rather than ;; just before the next close paren. @@ -4501,9 +4510,18 @@ comment at the start of cc-engine.el for more info." (match-end 0)) ;; Search failed. Set point as appropriate. - (if (eq noerror t) - (goto-char start) + (cond + ((eq noerror t) + (goto-char start)) + ((not (memq noerror '(before-literal after-literal))) (goto-char bound)) + (t (setq state (parse-partial-sexp state-pos bound nil nil state)) + (when (or (elt state 3) (elt state 4)) + (if (eq noerror 'before-literal) + (goto-char (elt state 8)) + (parse-partial-sexp bound (point-max) nil nil + state 'syntax-table))))) + nil))) (defvar safe-pos-list) ; bound in c-syntactic-skip-backward