[GRASS5] [bug #2488] (grass) GRASS 5.7 WISH - improve string reading ability in g.parser

Glynn Clements glynn.clements at virgin.net
Thu Jun 17 06:53:58 EDT 2004


Hamish wrote:

> > > this bug's URL: http://intevation.de/rt/webrt?serial_num=2488
> > > Subject: GRASS 5.7 WISH - improve string reading ability in g.parser
> ..
> > > g.parser has difficulties parsing strings with spaces in them. If
> > > you enter a string with spaces, it treats each word as a separate,
> > > illegal entry for that variable.
> > 
> > I can't reproduce this behaviour with 5.3, and g.parser itself is
> > unchanged in 5.7 (although G_parser() has some changes).
> 
> I believe this will be the long standing problem in the TclTk menus,
> which strips away all quotes from input fields.

Actually, the problem is deeper than that. You shouldn't *need* quotes
in input fields. And, unlike Bourne-shell, Tcl doesn't automatically
split variable values into words.

My guess is that something is flattening the argument list to a
string, then (implicitly) re-parsing it into a list, so embedded
spaces get treated as separators. E.g. doing:

	set list "$list $item"

(as you would in Bourne-shell), rather than using lappend.

Unlike Bourne-shell, Tcl has adequate support for preserving list
structure, by using braces where necessary. E.g.:

	set a "foo"
	set b "bar"
	set c "hello world"
	set list [list $a $b $c]
	puts $list
	
	=> foo bar {hello world}

In any case, I'm pretty certain that this has nothing to do with
g.parser, in the sense that it applies equally to every program which
uses G_parser(), which is almost everything.

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




More information about the grass-dev mailing list