Patchwork small patch to accept = inside plugin arguments

login
register
mail settings
Submitter Basile Starynkevitch
Date Aug. 7, 2013, 5:15 p.m.
Message ID <1375895717.14832.7.camel@glinka.lesours>
Download mbox | patch
Permalink /patch/265573/
State New
Headers show

Comments

Basile Starynkevitch - Aug. 7, 2013, 5:15 p.m.
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
David Malcolm - Aug. 7, 2013, 5:33 p.m.
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)

Patch

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