emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107438: Fix handling of commands con


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107438: Fix handling of commands containing double quotes in gdb-mi
Date: Sun, 26 Feb 2012 17:38:45 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107438
fixes bug(s): http://debbugs.gnu.org/10765
author: Jim Blandy <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2012-02-26 17:38:45 +0800
message:
  Fix handling of commands containing double quotes in gdb-mi
  
  * lisp/progmodes/gdb-mi.el (gdb-mi-quote): New function.
  (gdb-send): Apply it to the operand of the '-interpreter-exec
  console' command, so that we can pass arguments with (say) quotes
  in them.  Store exact string sent in gdb-debug-log (Bug#10765).
modified:
  lisp/ChangeLog
  lisp/progmodes/gdb-mi.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-02-26 09:24:13 +0000
+++ b/lisp/ChangeLog    2012-02-26 09:38:45 +0000
@@ -1,3 +1,10 @@
+2012-02-26  Jim Blandy  <address@hidden>
+
+       * progmodes/gdb-mi.el (gdb-mi-quote): New function.
+       (gdb-send): Apply it to the operand of the '-interpreter-exec
+       console' command, so that we can pass arguments with (say) quotes
+       in them.  Store exact string sent in gdb-debug-log (Bug#10765).
+
 2012-02-26  Chong Yidong  <address@hidden>
 
        * help-fns.el (describe-function-1): Clarify description of

=== modified file 'lisp/progmodes/gdb-mi.el'
--- a/lisp/progmodes/gdb-mi.el  2012-02-05 08:06:37 +0000
+++ b/lisp/progmodes/gdb-mi.el  2012-02-26 09:38:45 +0000
@@ -1672,8 +1672,6 @@
   (if (not (string= "" string))
       (setq gdb-last-command string)
     (if gdb-last-command (setq string gdb-last-command)))
-  (if gdb-enable-debug
-      (push (cons 'mi-send (concat string "\n")) gdb-debug-log))
   (if (string-match "^-" string)
       ;; MI command
       (progn
@@ -1683,10 +1681,22 @@
     (if (string-match "\\\\$" string)
        (setq gdb-continuation (concat gdb-continuation string "\n"))
       (setq gdb-first-done-or-error t)
-      (process-send-string proc (concat "-interpreter-exec console \""
-                                       gdb-continuation string "\"\n"))
+      (let ((to-send (concat "-interpreter-exec console "
+                             (gdb-mi-quote string)
+                             "\n")))
+        (if gdb-enable-debug
+            (push (cons 'mi-send to-send) gdb-debug-log))
+        (process-send-string proc to-send))
       (setq gdb-continuation nil))))
 
+(defun gdb-mi-quote (string)
+  "Return STRING quoted properly as an MI argument.
+The string is enclosed in double quotes.
+All embedded quotes, newlines, and backslashes are preceded with a backslash."
+  (setq string (replace-regexp-in-string "\\([\"\\]\\)" "\\\\\\&" string))
+  (setq string (replace-regexp-in-string "\n" "\\n" string t t))
+  (concat "\"" string "\""))
+
 (defun gdb-input (command handler-function)
   "Send COMMAND to GDB via the MI interface.
 Run the function HANDLER-FUNCTION, with no arguments, once the command is


reply via email to

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