[Bond-users] Papyrus makelabels
Colin Close
itchka at compuserve.com
Fri Dec 9 10:13:00 EST 2011
On Friday 09 Dec 2011 13:37:25 Jasen Betts wrote:
> On Thu, Dec 08, 2011 at 11:53:50PM +0000, Colin Close wrote:
> > which is almost certainly not going to work for the label option.
> > What is needed if the ability with papyrus_gui to optionally disable the
> > -a
> > flag generation to allow user option to be passed to papyrus.
> > I have looked at the source code for the section that does this work and
> > it
> > seems to me from my limited understanding of C coding that if the variable
> > name defined in the requires section of the xml began with a '-' or '--'
> > an
> > extra 'if' statement in this section of code could then overrride the -a
> > %=% stuff and simply output the option with its parameter.
>
> that's a good idea, <reuires> parameters have arbitrary names that are only
> used internally to the xml document. it's unlikely that anyone would
> have chosesn a name starting with --, and if they have they can
> probably change it to something else easily enough.
>
> > I've pasted the code from report.c here so you can see how simple the
> > change could be. I have put in some pseudo code 'cus alas I have yet to
> > grasp C. Its not elegant but I think it would work. What do you think?
>
> papyrus doesn't like "--name=value" , it only works with "--name value"
>
> I haven't allowed names starting with a single -, all papyrus options
> have a long version which should be preferred.
>
> --- a/gui/src/report.c
> +++ b/gui/src/report.c
> @@ -104,8 +104,18 @@ run_report ()
> param = (require_parameter *) walk->data;
> if (param->value)
> {
> - args=g_list_append(args,mem_strdup("-a"));
> - args=g_list_append(args, mem_strdup_printf ("%s=%s",
> param->ident, + if( param->ident[0] == '-' && param->ident[1]
> == '-' ) + { /* if param ident begins "--" emit it and the
> value without '-a' preamble + * and without "=" joining
> them */
> + if( param->ident[2] ) /* suppress '--' with nothing after,
> only emit value */ +
> args=g_list_append(args,mem_strdup(param->ident)); +
> args=g_list_append(args, mem_strdup(param->value)); + }
> + else
> + {
> + args=g_list_append(args,mem_strdup("-a"));
> + args=g_list_append(args, mem_strdup_printf ("%s=%s",
> param->idnt, param->value)); + }
> }
> walk = walk->next;
> }
Thank you Jasen, that's great! I'll patch it in and try it.
I'll also study what you have done and try to improve my C coding
comprehension some more.
Best
Colin
More information about the Bond-users
mailing list