[GRASS-dev] G7: Definition problem in parser_standard_options.c

Hi,

I just discovered that local modifications of predefined
parser variables influence the help text/manual/etc:
Example:

http://grass.osgeo.org/grass70/manuals/r.resamp.interp.html
...
method=string
    Sampling interpolation method
    Options: nearest, linear, cubic, lanczos
    Default: linear
    nearest: Nearest-neighbor interpolation
    linear: Linear interpolation
    cubic: Cubic interpolation
    ... <<-- missing: lanczos

because of
lib/gis/parser_standard_options.c

   case G_OPT_R_INTERP_TYPE:
        Opt->key = "method";
        Opt->type = TYPE_STRING;
        Opt->required = NO;
        Opt->description = _("Sampling interpolation method");
        Opt->options = "nearest,linear,cubic";
        G_asprintf((char **) &(Opt->descriptions),
                   "nearest;%s;linear;%s;cubic;%s",
                   _("Nearest-neighbor interpolation"),
                   _("Linear interpolation"),
                   _("Cubic interpolation"));
        break;

Besides copying manually the G_asprintf() stuff into the module (no
good), is there a better way of implementing it?

Markus

Markus Neteler wrote:

Besides copying manually the G_asprintf() stuff into the module (no
good), is there a better way of implementing it?

If the module changes ->options, it needs to change ->descriptions to
match.

However, if it's only appending options, it can make use of the
existing descriptions, e.g.:

  char *desc = method->descriptions;
        G_asprintf((char **) &(method->descriptions),
                   "%s;lanczos;%s", desc,
                   _("Lanczos interpolation"));
  G_free(desc);

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