emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master f8eecb1 4/6: Merge from origin/emacs-25


From: Paul Eggert
Subject: [Emacs-diffs] master f8eecb1 4/6: Merge from origin/emacs-25
Date: Tue, 25 Oct 2016 19:52:28 +0000 (UTC)

branch: master
commit f8eecb1c6c8a3646d65112843c7f813fe639d57f
Merge: 43645b4 96ac0c3
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Merge from origin/emacs-25
    
    96ac0c3 Yet another fix for using pointers into buffer text
    1047496 Another fix for using pointer to buffer text
    3121992 Fix Bug#24478
---
 lisp/net/tramp-sh.el |   32 +++++++++++++++++++++-----------
 src/search.c         |   18 +++++++++++++++---
 2 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 0e21a81..6a190b0 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -69,19 +69,18 @@ files conditionalize this setup based on the TERM 
environment variable."
   :require 'tramp)
 
 ;;;###tramp-autoload
-(defcustom tramp-histfile-override ".tramp_history"
+(defcustom tramp-histfile-override "~/.tramp_history"
   "When invoking a shell, override the HISTFILE with this value.
 When setting to a string, it redirects the shell history to that
 file.  Be careful when setting to \"/dev/null\"; this might
 result in undesired results when using \"bash\" as shell.
 
-The value t, the default value, unsets any setting of HISTFILE,
-and sets both HISTFILESIZE and HISTSIZE to 0.  If you set this
-variable to nil, however, the *override* is disabled, so the
-history will go to the default storage location,
-e.g. \"$HOME/.sh_history\"."
+The value t unsets any setting of HISTFILE, and sets both
+HISTFILESIZE and HISTSIZE to 0.  If you set this variable to nil,
+however, the *override* is disabled, so the history will go to
+the default storage location, e.g. \"$HOME/.sh_history\"."
   :group 'tramp
-  :version "25.1"
+  :version "25.2"
   :type '(choice (const :tag "Do not override HISTFILE" nil)
                  (const :tag "Unset HISTFILE" t)
                  (string :tag "Redirect to a file"))
@@ -3977,7 +3976,19 @@ file exists and nonzero exit status otherwise."
                ""))
            (tramp-shell-quote-argument tramp-end-of-output)
            shell (or extra-args ""))
-       t))
+       t)
+      ;; Check proper HISTFILE setting.  We give up when not working.
+      (when (and (stringp tramp-histfile-override)
+                (file-name-directory tramp-histfile-override))
+       (tramp-barf-unless-okay
+        vec
+        (format
+         "(cd %s)"
+         (tramp-shell-quote-argument
+          (file-name-directory tramp-histfile-override)))
+        "`tramp-histfile-override' uses invalid file `%s'"
+        tramp-histfile-override)))
+
     (tramp-set-connection-property
      (tramp-get-connection-process vec) "remote-shell" shell)))
 
@@ -4913,10 +4924,9 @@ connection if a previous connection has died for some 
reason."
                ;; Mark it as connected.
                (tramp-set-connection-property p "connected" t)))))
 
-      ;; When the user did interrupt, we must cleanup.
-      (quit
+      ;; Cleanup, and propagate the signal.
+      ((error quit)
        (tramp-cleanup-connection vec t)
-       ;; Propagate the quit signal.
        (signal (car err) (cdr err))))))
 
 (defun tramp-send-command (vec command &optional neveropen nooutput)
diff --git a/src/search.c b/src/search.c
index 127a57a..92bfa88 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2007,13 +2007,20 @@ boyer_moore (EMACS_INT n, unsigned char *base_pat,
              cursor += dirlen - i - direction; /* fix cursor */
              if (i + direction == 0)
                {
-                 ptrdiff_t position, start, end;
+                 ptrdiff_t position, start, end, cursor_off;
 
                  cursor -= direction;
 
                  position = pos_byte + cursor - p2 + ((direction > 0)
                                                       ? 1 - len_byte : 0);
+                 /* set_search_regs might call malloc, which could
+                    cause ralloc.c relocate buffer text.  We need to
+                    update pointers into buffer text due to that.  */
+                 cursor_off = cursor - p2;
                  set_search_regs (position, len_byte);
+                 p_limit = BYTE_POS_ADDR (limit);
+                 p2 = BYTE_POS_ADDR (pos_byte);
+                 cursor = p2 + cursor_off;
 
                  if (NILP (Vinhibit_changing_match_data))
                    {
@@ -2633,6 +2640,7 @@ since only regular expressions have distinguished 
subexpressions.  */)
          const unsigned char *add_stuff = NULL;
          ptrdiff_t add_len = 0;
          ptrdiff_t idx = -1;
+         ptrdiff_t begbyte;
 
          if (str_multibyte)
            {
@@ -2695,11 +2703,10 @@ since only regular expressions have distinguished 
subexpressions.  */)
             set up ADD_STUFF and ADD_LEN to point to it.  */
          if (idx >= 0)
            {
-             ptrdiff_t begbyte = CHAR_TO_BYTE (search_regs.start[idx]);
+             begbyte = CHAR_TO_BYTE (search_regs.start[idx]);
              add_len = CHAR_TO_BYTE (search_regs.end[idx]) - begbyte;
              if (search_regs.start[idx] < GPT && GPT < search_regs.end[idx])
                move_gap_both (search_regs.start[idx], begbyte);
-             add_stuff = BYTE_POS_ADDR (begbyte);
            }
 
          /* Now the stuff we want to add to SUBSTED
@@ -2712,6 +2719,11 @@ since only regular expressions have distinguished 
subexpressions.  */)
                       add_len - (substed_alloc_size - substed_len),
                       STRING_BYTES_BOUND, 1);
 
+         /* We compute this after the call to xpalloc, because that
+            could cause buffer text be relocated when ralloc.c is used.  */
+         if (idx >= 0)
+           add_stuff = BYTE_POS_ADDR (begbyte);
+
          /* Now add to the end of SUBSTED.  */
          if (add_stuff)
            {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]