Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: fix macro expansion bug
Date: Thu, 11 Dec 2008 23:41:00 -0000	[thread overview]
Message-ID: <m3ljumb7v8.fsf@fleche.redhat.com> (raw)
In-Reply-To: <200812112304.39302.pedro@codesourcery.com> (Pedro Alves's message of "Thu\, 11 Dec 2008 23\:04\:38 +0000")

>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:

>> +gdb_test "macro expand siginfo.si_addr" \
>> +  "expands to: siginfo. fields.fault.si_addr" \

Pedro> Just curious, as it's just a visual annoyance: do you know where
Pedro> this space comes from?  Do we store the definition with the space for
Pedro> some reason?  We don't get that extra space if the define came
Pedro> from the code, instead of from a 'macro define'.

Here's a patch to fix it.

This requires a minor tweak to the previous patch's test case, but
otherwise nothing.

As with the previous, I'm sending this through the regression tester,
but I don't expect problems.  Ok if it passes?

Tom

2008-12-11  Tom Tromey  <tromey@redhat.com>

	* macrocmd.c (macro_define_command): Skip whitespace after
	macro name.
	(print_one_macro): Print space after macro name.

diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 56e9a48..fa639d1 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -315,13 +315,17 @@ macro_define_command (char *exp, int from_tty)
 	}
       /* Skip the closing paren.  */
       ++exp;
+      skip_ws (&exp);
 
       macro_define_function (macro_main (macro_user_macros), -1, name,
 			     new_macro.argc, (const char **) new_macro.argv,
 			     exp);
     }
   else
-    macro_define_object (macro_main (macro_user_macros), -1, name, exp);
+    {
+      skip_ws (&exp);
+      macro_define_object (macro_main (macro_user_macros), -1, name, exp);
+    }
 
   do_cleanups (cleanup_chain);
 }
@@ -358,9 +362,7 @@ print_one_macro (const char *name, const struct macro_definition *macro,
 			  macro->argv[i]);
       fprintf_filtered (gdb_stdout, ")");
     }
-  /* Note that we don't need a leading space here -- "macro define"
-     provided it.  */
-  fprintf_filtered (gdb_stdout, "%s\n", macro->replacement);
+  fprintf_filtered (gdb_stdout, " %s\n", macro->replacement);
 }
 
 


  parent reply	other threads:[~2008-12-11 23:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11 21:37 Tom Tromey
2008-12-11 23:05 ` Pedro Alves
2008-12-11 23:28   ` Tom Tromey
2008-12-11 23:35     ` Pedro Alves
2008-12-12 17:07       ` Tom Tromey
2008-12-11 23:31   ` Andreas Schwab
2008-12-11 23:41   ` Tom Tromey [this message]
2008-12-11 23:51     ` Pedro Alves
2008-12-11 23:58       ` Tom Tromey
2008-12-12 17:02       ` Tom Tromey

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=m3ljumb7v8.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox