public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* small patch to accept = inside plugin arguments
@ 2013-08-07 17:15 Basile Starynkevitch
  2013-08-07 17:33 ` David Malcolm
  0 siblings, 1 reply; 2+ messages in thread
From: Basile Starynkevitch @ 2013-08-07 17:15 UTC (permalink / raw)
  To: gcc-patches

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

Hello All,

It should be perfectly possible for a plugin argument to contain the
equal sign.

For plugin with scripting or DSL behavior (like MELT, see
http://gcc-melt.org/ for more) it is useful to pass some commands 
or expressions to the plugin. For MELT we might want to run
 
     gcc -fplugin=melt -fplugin-arg-melt-mode=eval \
         -fplugin-arg-melt-arg='(== 1 2)' empty.c

for plugins accepting some shell command to be run by system or popen, 
passing -fplugin-arg-foo-command='env FOO=bar doit arg' would be
perfectly ok, but is not.

The small attached patch relative to trunk 201571 should solve the
issue.

##### gcc/ChangeLog entry
2013-08-07  Basile Starynkevitch  <basile@starynkevitch.net>

	* plugin.c (parse_plugin_arg_opt): Accept equal sign inside 
          plugin argument.
####

Comments are welcome. Ok for trunk?

Cheers

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


[-- Attachment #2: patch-plugin-equal-r201571.diff --]
[-- Type: text/x-patch, Size: 730 bytes --]

Index: gcc/plugin.c
===================================================================
--- gcc/plugin.c	(revision 201571)
+++ gcc/plugin.c	(working copy)
@@ -241,16 +241,13 @@ parse_plugin_arg_opt (const char *arg)
         }
       else if (*ptr == '=')
         {
-          if (key_parsed)
-            {
-              error ("malformed option -fplugin-arg-%s (multiple '=' signs)",
-		     arg);
-              return;
-            }
-          key_len = len;
-          len = 0;
-          value_start = ptr + 1;
-          key_parsed = true;
+	  if (!key_parsed) 
+	    {
+	      key_len = len;
+	      len = 0;
+	      value_start = ptr + 1;
+	      key_parsed = true;
+	    }
           continue;
         }
       else

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: small patch to accept = inside plugin arguments
  2013-08-07 17:15 small patch to accept = inside plugin arguments Basile Starynkevitch
@ 2013-08-07 17:33 ` David Malcolm
  0 siblings, 0 replies; 2+ messages in thread
From: David Malcolm @ 2013-08-07 17:33 UTC (permalink / raw)
  To: Basile Starynkevitch; +Cc: gcc-patches

On Wed, 2013-08-07 at 19:15 +0200, Basile Starynkevitch wrote:
> Hello All,
> 
> It should be perfectly possible for a plugin argument to contain the
> equal sign.
> 
> For plugin with scripting or DSL behavior (like MELT, see
> http://gcc-melt.org/ for more) it is useful to pass some commands 
> or expressions to the plugin. For MELT we might want to run
>  
>      gcc -fplugin=melt -fplugin-arg-melt-mode=eval \
>          -fplugin-arg-melt-arg='(== 1 2)' empty.c
> 
> for plugins accepting some shell command to be run by system or popen, 
> passing -fplugin-arg-foo-command='env FOO=bar doit arg' would be
> perfectly ok, but is not.

Thanks - fwiw I've also run into this issue a few times with the python
plugin.

(I'm not a reviewer)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-07 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-07 17:15 small patch to accept = inside plugin arguments Basile Starynkevitch
2013-08-07 17:33 ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).