[Bond-users] Papyrus makelabels

Colin Close itchka at compuserve.com
Sun Dec 11 18:30:42 EST 2011


On Monday 12 Dec 2011 10:51:08 Jasen Betts wrote:
> On Sat, Dec 10, 2011 at 01:00:53PM +0000, Colin Close wrote:
> > On Saturday 10 Dec 2011 02:14:47 Colin Close wrote:
> > > On Friday 09 Dec 2011 15:13:00 Colin Close wrote:
> > > > On Friday 09 Dec 2011 13:37:25 Jasen Betts wrote:
> > > > > --- 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
> 
> remove that "else" -  should be near line 114
> 
> > > > > +               {
> > > > > +                 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;
> > > > >         
> > > > >         }
> > 
> > Hi Jasen,
> > Please forgive this continued blather it seems that the extra space is not
> > required. I confused myself by making more than one change at a time. It
> > is
> > just the  "ensure_variable(char *name)" thing  that is causing the
> > problem.
> > Best,
> 
> do the edit described above: remove the else.
> 
> when you get it working I'll submit a tidier version
Hey Jasen,
That's a real cheat (very smart though but no one would guess how it worked 
without a debugger) and I was just about to submit my own bit of code for 
approval. Here's what I came up with:-
------------------------------ backend/convert.c 
------------------------------
index 557dcaa..f187d97 100644
@@ -1971,13 +1971,20 @@ convert_ifresult(xmlNodePtr report, FILE * output, 
xmlNodePtr ifresult)
 static int
 ensure_variable(char *name)
 {
-	if (variable_get(name) == NULL)
-	{
-		errormsg("Required argument %s not defined", name);
-		return -1;
-	}
-
-	return 0;
+	gchar *hyph;	/*Disable the error check if variable "name" has a leading 
hyphen*/
+	hyph = strstr(name, "-");	/*since a program option is being passed i.e. --
option parameter*/
+	if (!hyph)
+	{
+	  if (variable_get(name) == NULL)
+	  {
+		  errormsg("Required argument %s not defined", name);
+		  return -1;
+	  }
+	 }
+	 else
+	  {
+	    return 0;
+	  }
 }
 
 /*
Tested and works.
Will the changes go into the git tree? If so I'll do a bit of work on 
documenting it if you like. BTW I did try also with a non-existant label and 
it didn't break. An error message was returned from makelabels to the terminal 
from which I ran the gui but no error message was returned to the gui. Looking 
at the papyrus script there is an independent check on the existance of the 
label type. On error it seems to call the fail function in the script which in 
it's turn calls xerror but for some reason it doesn't seem to be working.
Thanks for your help with this I've learn't some stuff.
Best
Colin



More information about the Bond-users mailing list