all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Blandy <jimb@red-bean.com>
To: 10765@debbugs.gnu.org
Subject: bug#10765: Patch to fix this bug
Date: Wed, 8 Feb 2012 13:04:36 -0800	[thread overview]
Message-ID: <CAHgb+0n98r17u-mqe6kVooOur4jiJ9tdy5P7aA2jaq7dfEPdKw@mail.gmail.com> (raw)
In-Reply-To: <CAHgb+0=O75aaUBTOzaXUB66xr=dfOGzE1AEALNtfbE8m+fGGvQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 37 bytes --]

Attached is a patch to fix this bug.

[-- Attachment #2: gdb-mi-quotes.patch --]
[-- Type: text/x-patch, Size: 2257 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index be12a73..00cd7db 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -156,6 +156,13 @@
 
 	* ido.el (ido-find-file): Doc fix (ido-toggle-vc not on any key).
 
+2012-02-04  Jim Blandy  <jimb@red-bean.com>
+
+	* 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.
+
 2012-02-03  Glenn Morris  <rgm@gnu.org>
 
 	* image.el (image-animated-p): Doc fix.  Use image-animated-types.
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 301714e..6ffb67e 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1672,8 +1672,6 @@ static char *magick[] = {
   (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,23 @@ static char *magick[] = {
     (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 are replaced with \"\\\"\".
+All embedded newlines are replaced with \"\\n\"."
+  (let* ((quotes (replace-regexp-in-string "\"" "\\\"" string t t))
+         (newlines (replace-regexp-in-string "\n" "\\n" quotes t t)))
+    (concat "\"" newlines "\"")))
+
 (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	other threads:[~2012-02-08 21:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 20:56 bug#10765: 24.0.93; gdb-mi cannot transmit commands containing double quotes Jim Blandy
2012-02-08 21:04 ` Jim Blandy [this message]
2012-02-08 21:32   ` bug#10765: Patch to fix this bug Andreas Schwab
2012-02-09 19:14     ` Jim Blandy
2012-02-26  9:39       ` Chong Yidong
2012-02-27 19:05         ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHgb+0n98r17u-mqe6kVooOur4jiJ9tdy5P7aA2jaq7dfEPdKw@mail.gmail.com \
    --to=jimb@red-bean.com \
    --cc=10765@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.