[GRASS-dev] g.mlist as C implementation?
Glynn Clements
glynn at gclements.plus.com
Wed Sep 12 23:58:40 EDT 2007
Hamish wrote:
> > I had overlooked the part where loop which adds the separator was
> > replaced with a call to "tr".
> >
> > Technically, this corresponds to a reduction in functionality, as the
> > previous version would accept any string as a separator, but using
> > "tr" restricts it to a single character (which is probably all that's
> > required).
>
> is it possible to use sed instead of tr?
> sed -e "s/\n/$sep/" # doesn't work
Yes, but you can't do it with a single "s" command. You would need to
collect all of the input into the pattern space with the N command.
This could be a problem for non-GNU versions of sed which may have a
limit on the maximum length of the pattern space.
OTOH, tr acts as a filter, writing out data as it processes it, so
there is no limit on the amount of data.
> I will have a look at merging Martin, Markus and Glynn's suggestions for
> a flat output g.list flag. As the feature is needed for parsing, I'd
> rather do it as a flag vs. a ncols= option which retains the text and
> fancy format mapset underlines. I've never really known what the "g"
> stands for, but as we use it a lot for parsable output, the flag will
> be '-g' here too.
>
> so it would look like:
>
> G63> g.list -g rast
> map1 at user1
> map2 at user1
> map3 at user1
> map_a at PERMANENT
> map_b at PERMANENT
> map_c at PERMANENT
>
> G63> g.list -gf rast
> map1 at user1:
> map2 at user1:This map has a title
> map3 at user1:
> map_a at PERMANENT:Raw x,y,z data binned into a raster grid by cell min
> map_b at PERMANENT:Land Use
> map_c at PERMANENT:
According to G_legal_filename(), ":" is legal in map names (that won't
work on Windows):
if (*s == '/' || *s == '"' || *s == '\'' || *s <= ' ' ||
*s == '@' || *s == ',' || *s == '=' || *s == '*' || *s > 0176) {
fprintf(stderr, _("Illegal filename. Character <%c> not allowed.\n"), *s);
I'd suggest using a comma for the field separator.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list