[GRASS-dev] G7: parser - suppressing label in scripts

Hi,

we have a problem with the introduction of labels:
http://trac.osgeo.org/grass/changeset/39886/grass/trunk/lib/gis/parser_standard_options.c

because:

myscript.py help
        vector Name of input vector map(s) used by GRASS script
                  Data source(s) for direct OGR access

... but we don't want the second line.

It would be good to be able to suppress "label" with the a reserved word
like "None" or "NULL":

#%option G_OPT_V_INPUTS
#% key: vector
#% label: NULL
#% description: Name of input vector map(s) used by GRASS script
#% required: no
#%end

to eventually gain:

myscript.py help
        vector Name of input vector map(s) used by GRASS script

Any suggestions how to implement this suppressing "label" in the parser?

Markus

Markus Neteler wrote:

we have a problem with the introduction of labels:
http://trac.osgeo.org/grass/changeset/39886/grass/trunk/lib/gis/parser_standard_options.c

Actually, the problem only arose with the addition of standard options
in r47421.

It would be good to be able to suppress "label" with the a reserved word
like "None" or "NULL":

#%option G_OPT_V_INPUTS
#% key: vector
#% label: NULL
#% description: Name of input vector map(s) used by GRASS script
#% required: no
#%end

Any suggestions how to implement this suppressing "label" in the parser?

In parse.c, I suggest adding e.g.:

  static char *xstrdup(const char *arg) {
      return (strcmp(arg, "{NULL}") == 0)
          ? NULL
          : strdup(arg);
  }

and replacing all references to strdup() with xstrdup(). Also,
translate() will need a test for NULL pointers.

Hello Glynn,
thanks for your suggestions. But i think you are two steps ahead from
me, because i am not able to find any strdup() usage in parser*.c.

Are there any steps to do before replacing strdup with your suggested xstrdup?

Thanks and best regards
Soeren

2011/8/10 Glynn Clements <glynn@gclements.plus.com>:

Markus Neteler wrote:

we have a problem with the introduction of labels:
http://trac.osgeo.org/grass/changeset/39886/grass/trunk/lib/gis/parser_standard_options.c

Actually, the problem only arose with the addition of standard options
in r47421.

It would be good to be able to suppress "label" with the a reserved word
like "None" or "NULL":

#%option G_OPT_V_INPUTS
#% key: vector
#% label: NULL
#% description: Name of input vector map(s) used by GRASS script
#% required: no
#%end

Any suggestions how to implement this suppressing "label" in the parser?

In parse.c, I suggest adding e.g.:

   static char \*xstrdup\(const char \*arg\) \{
       return \(strcmp\(arg, &quot;\{NULL\}&quot;\) == 0\)
           ? NULL
           : strdup\(arg\);
   \}

and replacing all references to strdup() with xstrdup(). Also,
translate() will need a test for NULL pointers.
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Soeren Gebbert wrote:

> > Any suggestions how to implement this suppressing "label" in the parser?
>
> In parse.c, I suggest adding e.g.:

thanks for your suggestions. But i think you are two steps ahead from
me, because i am not able to find any strdup() usage in parser*.c.

I didn't say parser*.c, I said parse.c, i.e. general/g.parser/parse.c
(in 7.0; the standard option feature hasn't been back-ported to 6.x).

--
Glynn Clements <glynn@gclements.plus.com>

On Fri, Aug 12, 2011 at 8:58 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Soeren Gebbert wrote:

> > Any suggestions how to implement this suppressing "label" in the parser?
>
> In parse.c, I suggest adding e.g.:

thanks for your suggestions. But i think you are two steps ahead from
me, because i am not able to find any strdup() usage in parser*.c.

I didn't say parser*.c, I said parse.c, i.e. general/g.parser/parse.c
(in 7.0; the standard option feature hasn't been back-ported to 6.x).

Right.
Together with Sören we have implemented all in r47596.

This now works:

#%option G_OPT_V_INPUTS
#% key: vector
#% label: {NULL}
#% required: no
#%end

Markus