[GRASS-dev] v.digit startup error from -n position

Hi,

I found a problem starting v.digit from the tcltk GUI:

v.digit map=cities 'bgcmd=d.rast landcover.30m' -n
New empty map created.

Application initialization failed: "-n" option requires an additional argument
Error in startup script: couldn't read file "map=cities": no such file or directory

while
v.digit -n map=cities 'bgcmd=d.rast landcover.30m'

works (see -n position). Strange for me, since G_parser is used...

Any ideas? Is it related to bgcmd_opt parsing?

I think that the gtcltk code should in general put flags
first (which would resolve the problem here).

Markus

I thought that Glynn fixed this last week. I can't remember exactly, but it
had to do with the same kind of string/command parsing that has repeatedly
plagued us.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Markus Neteler <neteler@itc.it>
Date: Wed, 2 Aug 2006 17:15:58 +0200
To: GRASS developers list <grass-dev@grass.itc.it>
Subject: [GRASS-dev] v.digit startup error from -n position

Hi,

I found a problem starting v.digit from the tcltk GUI:

v.digit map=cities 'bgcmd=d.rast landcover.30m' -n
New empty map created.

Application initialization failed: "-n" option requires an additional argument
Error in startup script: couldn't read file "map=cities": no such file or
directory

while
v.digit -n map=cities 'bgcmd=d.rast landcover.30m'

works (see -n position). Strange for me, since G_parser is used...

Any ideas? Is it related to bgcmd_opt parsing?

I think that the gtcltk code should in general put flags
first (which would resolve the problem here).

Markus

Markus, Michael,

https://intevation.de/rt/webrt?serial_num=4604

Maciek

OK. Looking through to the very bottom of the thread, there appears to be
some confusion about what is meant by GUI.

If v.digit is having a problem with a new vector when run from the toolbar
button in gism, it is one thing. This SHOULD be OK. I've checked the code
and it is written...

  v.digit -n map=new_map

... as Glynn indicated. If this is where the problem lies, then, there is
some other kind of issue.

Glynn also noted, however, that in the auto-generated GUI dialogs, this is
being written as...

  v.digit map=new_map -n

This causes a problem because the -n is misinterpreted by TclTk as a flag in
the TclTk command. So if the problem arises when v.digit is run from a menu
or the dialog is started from the CLI by simply typing v.digit, then THIS is
where the problem lies.

Generically, the GRASS flags should come before any other arguments it
seems. I don't know where this is coded, but Cedric should know.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Maciej Sieczka <tutey@o2.pl>
Date: Wed, 02 Aug 2006 19:17:34 +0200
To: Michael Barton <michael.barton@asu.edu>
Cc: Markus Neteler <neteler@itc.it>, GRASS developers list
<grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] v.digit startup error from -n position

Markus, Michael,

https://intevation.de/rt/webrt?serial_num=4604

Maciek

Michael Barton wrote:

OK. Looking through to the very bottom of the thread, there appears to be
some confusion about what is meant by GUI.

If v.digit is having a problem with a new vector when run from the toolbar
button in gism, it is one thing. This SHOULD be OK. I've checked the code
and it is written...

  v.digit -n map=new_map

... as Glynn indicated. If this is where the problem lies, then, there is
some other kind of issue.

Contrary to the "resolved" status in the RT, the real bug remains.

v.digit is calling Tk_Main() as:

    Tk_Main(argc, argv, Tcl_AppInit);

where argc/argv are those passed to main.

It shouldn't be doing this; it should be passing a dummy argv, e.g.

    char *fake_argv[2];
  ...
    fake_argv[0] = argv[0];
    fake_argv[1] = NULL;
    Tk_Main(1, fake_argv, Tcl_AppInit);

Changing the order of v.digit's arguments is a workaround, not a fix.

Glynn also noted, however, that in the auto-generated GUI dialogs, this is
being written as...

  v.digit map=new_map -n

This causes a problem because the -n is misinterpreted by TclTk as a flag in
the TclTk command. So if the problem arises when v.digit is run from a menu
or the dialog is started from the CLI by simply typing v.digit, then THIS is
where the problem lies.

Generically, the GRASS flags should come before any other arguments it
seems. I don't know where this is coded, but Cedric should know.

The generate_tcl() function in lib/gis/parser.c writes out a list of
flags/options, with the flags last. gui.tcl passes the command-line
options to the module in their original order, i.e. with the flags
last.

This isn't a problem, as G_parser() doesn't care about the order. The
fact that putting the flags first happens to work around the bug in
v.digit is a coincidence, but not a particularly relevant one: v.digit
should still be fixed.

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

OK. I get it (I think). This is a problem in the v.digit code itself, not
with the TclTk wrappers that parse it for the GUI.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Glynn Clements <glynn@gclements.plus.com>
Date: Wed, 2 Aug 2006 23:28:25 +0100
To: Michael Barton <michael.barton@asu.edu>
Cc: Maciej Sieczka <tutey@o2.pl>, Markus Neteler <neteler@itc.it>, GRASS
developers list <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] v.digit startup error from -n position

Michael Barton wrote:

OK. Looking through to the very bottom of the thread, there appears to be
some confusion about what is meant by GUI.

If v.digit is having a problem with a new vector when run from the toolbar
button in gism, it is one thing. This SHOULD be OK. I've checked the code
and it is written...

  v.digit -n map=new_map

... as Glynn indicated. If this is where the problem lies, then, there is
some other kind of issue.

Contrary to the "resolved" status in the RT, the real bug remains.

v.digit is calling Tk_Main() as:

    Tk_Main(argc, argv, Tcl_AppInit);

where argc/argv are those passed to main.

It shouldn't be doing this; it should be passing a dummy argv, e.g.

    char *fake_argv[2];
...
    fake_argv[0] = argv[0];
    fake_argv[1] = NULL;
    Tk_Main(1, fake_argv, Tcl_AppInit);

Changing the order of v.digit's arguments is a workaround, not a fix.

Glynn also noted, however, that in the auto-generated GUI dialogs, this is
being written as...

  v.digit map=new_map -n

This causes a problem because the -n is misinterpreted by TclTk as a flag in
the TclTk command. So if the problem arises when v.digit is run from a menu
or the dialog is started from the CLI by simply typing v.digit, then THIS is
where the problem lies.

Generically, the GRASS flags should come before any other arguments it
seems. I don't know where this is coded, but Cedric should know.

The generate_tcl() function in lib/gis/parser.c writes out a list of
flags/options, with the flags last. gui.tcl passes the command-line
options to the module in their original order, i.e. with the flags
last.

This isn't a problem, as G_parser() doesn't care about the order. The
fact that putting the flags first happens to work around the bug in
v.digit is a coincidence, but not a particularly relevant one: v.digit
should still be fixed.

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

On Wed, Aug 02, 2006 at 11:28:25PM +0100, Glynn Clements wrote:

Michael Barton wrote:

> OK. Looking through to the very bottom of the thread, there appears to be
> some confusion about what is meant by GUI.
>
> If v.digit is having a problem with a new vector when run from the toolbar
> button in gism, it is one thing. This SHOULD be OK. I've checked the code
> and it is written...
>
> v.digit -n map=new_map
>
> ... as Glynn indicated. If this is where the problem lies, then, there is
> some other kind of issue.

Contrary to the "resolved" status in the RT, the real bug remains.

v.digit is calling Tk_Main() as:

    Tk_Main(argc, argv, Tcl_AppInit);

where argc/argv are those passed to main.

It shouldn't be doing this; it should be passing a dummy argv, e.g.

    char *fake_argv[2];
  ...
    fake_argv[0] = argv[0];
    fake_argv[1] = NULL;
    Tk_Main(1, fake_argv, Tcl_AppInit);

Changing the order of v.digit's arguments is a workaround, not a fix.

Now fixed as suggested.
Someone may close the report, cannot find it.

Markus

Markus Neteler napisa?(a):

Now fixed as suggested.
Someone may close the report, cannot find it.

Done.

Maciek