[GRASS5] fixes for recent problems in tcltkgrass for GRASS 5.3

Due to changes in the GRASS input parsing system, a few tcltkgrass commands
no longer worked correctly. I *think* (and hope) that I found all the few
instances and have fixed them. I just committed these fixes to the CVS.

Besides s.to.vect (reported earlier), these are d.measure, r.colors.rules,
and v.support_option_build/v.support_option_edit.

For d.measure, the -s flag is now a user option (thought this should be the
default method of operation).

for r.colors, it now runs in an xterm and the colors=rules option is
available from the r.colors module (i.e., no separate r.colors for color
table rules).

For v.support, both the build and edit options are now user options.
Separate menu entries for rebuilding topology and editing vector categories
have been combined into a single entry.

Please let me know if anyone runs into a module I've missed.

This is an additional reason to separate the 5.3 build from 5.7. Because
both 5.3 and 5.7 share the same code for input parsing fix to make this work
much better under 5.7 broke input parsing for a few cases in 5.3 where it
had worked fine before.

Cheers,
Michael Barton
______________________________
Michael Barton, Professor of Anthropology
School of Human Diversity and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Michael Barton wrote:

Due to changes in the GRASS input parsing system, a few tcltkgrass commands
no longer worked correctly. I *think* (and hope) that I found all the few
instances and have fixed them. I just committed these fixes to the CVS.

The problems relate to changes in tcltkgrass, not libgis.

This is an additional reason to separate the 5.3 build from 5.7. Because
both 5.3 and 5.7 share the same code for input parsing fix to make this work
much better under 5.7 broke input parsing for a few cases in 5.3 where it
had worked fine before.

Nothing related to command-line parsing is shared between 5.3 and 5.7.
5.7 has its own version of d.m, tcltkgrass and parser.c.

--
Glynn Clements <glynn.clements@virgin.net>

Glynn Clements wrote:

> Due to changes in the GRASS input parsing system, a few tcltkgrass commands
> no longer worked correctly. I *think* (and hope) that I found all the few
> instances and have fixed them. I just committed these fixes to the CVS.

The problems relate to changes in tcltkgrass, not libgis.

More precisely, I suspect that it's due to this change to gui.tcl:

  revision 1.21
  date: 2004/08/04 00:55:26; author: hamish; state: Exp; lines: +3 -3
  fix text entries with whitespaces in Tcl menus

Specifically, this part:

  @@ -727,7 +727,7 @@
       switch [$path cget -text] {
           Run {
               if {$button == 1} {
  - set name [eval concat $cmd]
  + set name [concat $cmd]
                   set see [expr {[lindex $cmd 0] == "g.manual"} ? 0 : -1]
               } elseif {$button == 2} {
                   set name "g.manual [lindex $root 0]"

Using "eval concat $cmd" would split list items into multiple words,
while "concat $cmd" will preserve boundaries.

  % set cmd "foo bar {baz baz}"
  % foreach word $cmd {puts $word}
  foo
  bar
  baz baz
  % set name [eval concat $cmd]
  % foreach word $name {puts $word}
  foo
  bar
  baz
  baz
  % set name [concat $cmd]
  % foreach word $name {puts $word}
  foo
  bar
  baz baz

Actually, the existing version is equivalent to just "set name $cmd".

  % set name $cmd
  % foreach word $name {puts $word}
  foo
  bar
  baz baz

The change causes it to correctly interpret arguments which contain
spaces but, as a side-effect, it doesn't handle commands which contain
spaces.

It should probably be:

  set prog [lindex $cmd 0]
  set args [lrange $cmd 1 end]
  set name [eval concat $prog [list $args]]

This will split the command but not the arguments.

--
Glynn Clements <glynn.clements@virgin.net>

Sorry if I misstated this. I was working from memory, not finding the
original email that described what happened.

Prior to an update to (what I understood was) one of the parsing routines by
Hamish in late July or August, a command in a GRASS 5.3 tcltkgrass module
like {d.measure -s} would parse as a single string...

d.measure -s

After that update, this now parses seems to parse (incorrectly) as a list...

d.measure
-s

Possibly I misunderstood which update was the likely cause of this, but the
discussions I saw suggested that it was one of the updates that allowed
GRASS 5.7 to correctly parse strings that included spaces.

If this is not the case, then perhaps it is worthwhile to dig more to track
it down. Perhaps similar, but not quite equivalent changes were made to the
parsing routines of 5.3 and 5.7 at the same time???

Michael

On 10/4/04 1:36 PM, "Glynn Clements" <glynn.clements@virgin.net> wrote:

Michael Barton wrote:

Due to changes in the GRASS input parsing system, a few tcltkgrass commands
no longer worked correctly. I *think* (and hope) that I found all the few
instances and have fixed them. I just committed these fixes to the CVS.

The problems relate to changes in tcltkgrass, not libgis.

This is an additional reason to separate the 5.3 build from 5.7. Because
both 5.3 and 5.7 share the same code for input parsing fix to make this work
much better under 5.7 broke input parsing for a few cases in 5.3 where it
had worked fine before.

Nothing related to command-line parsing is shared between 5.3 and 5.7.
5.7 has its own version of d.m, tcltkgrass and parser.c.

______________________________
Michael Barton, Professor of Anthropology
School of Human Diversity and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Thanks.

I can try this out and see if it does the trick. If so, I'll go ahead and
update.

Michael

On 10/4/04 1:56 PM, "Glynn Clements" <glynn.clements@virgin.net> wrote:

It should probably be:

set prog [lindex $cmd 0]
set args [lrange $cmd 1 end]
set name [eval concat $prog [list $args]]

This will split the command but not the arguments.

______________________________
Michael Barton, Professor of Anthropology
School of Human Diversity and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Glynn,

This seems to fix the problem. Command lines in tcltkgrass can once again
include arguments.

I've committed this change to the CVS and made the slight related changes to
menu.tcl (restoring separate entries for building vector topology and
editing vector categories) and d.measure (making -s the default mode of
operation).

Thanks for suggesting this.

Michael

On 10/4/04 1:56 PM, "Glynn Clements" <glynn.clements@virgin.net> wrote:

The change causes it to correctly interpret arguments which contain
spaces but, as a side-effect, it doesn't handle commands which contain
spaces.

It should probably be:

set prog [lindex $cmd 0]
set args [lrange $cmd 1 end]
set name [eval concat $prog [list $args]]

This will split the command but not the arguments.

______________________________
Michael Barton, Professor of Anthropology
School of Human Diversity and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA

voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

This seems to fix the problem. Command lines in tcltkgrass can once
again include arguments.

I've committed this change to the CVS

...

> The change causes it to correctly interpret arguments which contain
> spaces but, as a side-effect, it doesn't handle commands which
> contain spaces.
>
> It should probably be:
>
> set prog [lindex $cmd 0]
> set args [lrange $cmd 1 end]
> set name [eval concat $prog [list $args]]
>
> This will split the command but not the arguments.

So the only remaining issue is displaying '' instead of {} in the
command preview? I notice the above fix leaves the preview as e.g.
{d.measure -s} other=options
but still runs correctly.

Minor item, but it would be nice to have that cut-and-pastable.

Anything else to keep 5.4 waiting?

Hamish

_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com