[GRASS5] filenames in GRASS database/r.mask

Hi,

i noticed two minor problems:
some modules (at least r.mapcalc) do not allow dashes (-) in filenames
or at least need different quoting/treatment. I noticed this with
shade.rel.sh and shade.clr.sh, which choked on my raster files with
dashes. I changed both scripts to exit with an error message with files
with dashes in, i know of no solution.
This should be put into the TODO to revise this for 5.1. Every module
should work with allowed filenames.

Second i am missing a commandline version of r.mask. This should be
really simple, only a reclassified raster map of name "MASK" must be
created or deleted. But the code of r.mask is mixed up with the code for
r.reclass, so i have not done it.

cu,

Andreas
--
Andreas Lange, 65187 Wiesbaden, Germany, Tel. +49 611 807850
Andreas.Lange@Rhein-Main.de - A.C.Lange@GMX.net

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Thu, May 10, 2001 at 12:45:38PM +0200, Andreas Lange wrote:

Hi,

i noticed two minor problems:
some modules (at least r.mapcalc) do not allow dashes (-) in filenames
or at least need different quoting/treatment. I noticed this with
shade.rel.sh and shade.clr.sh, which choked on my raster files with
dashes. I changed both scripts to exit with an error message with files
with dashes in, i know of no solution.
This should be put into the TODO to revise this for 5.1. Every module
should work with allowed filenames.

Hi Andreas,

please feed this into the RT, area "wish" (you can select that)
when directly posting in RT.

Second i am missing a commandline version of r.mask. This should be
really simple, only a reclassified raster map of name "MASK" must be
created or deleted. But the code of r.mask is mixed up with the code for
r.reclass, so i have not done it.

Yes, parser functionality would be nice. However, you could simply

r.mapcalc MASK="some formula"
or
g.rename mymap,MASK

(I guess you know that, so I am telling this to some others here :-).

However, please add the r.mask issue to RT, too.

Thanks,

Markus

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Thu, May 10, 2001 at 12:45:38PM +0200, Andreas Lange wrote:

Hi,

i noticed two minor problems:
some modules (at least r.mapcalc) do not allow dashes (-) in filenames
or at least need different quoting/treatment. I noticed this with
shade.rel.sh and shade.clr.sh, which choked on my raster files with
dashes. I changed both scripts to exit with an error message with files
with dashes in, i know of no solution.
This should be put into the TODO to revise this for 5.1. Every module
should work with allowed filenames.

I was recently looking at r.mapcalc and I'm not sure it would be
possible to differentiate between:
  foo = a<minus>b
    and
      foo = a<hyphen>b

as both <minus> and <hyphen> are generally represented by the same
character '-' which is really longer than a hyphen '­'.

Whitespace is ignored for tokenization by the parser. So,
  "foo + if(bar, bar, baz)" = "foo+if(bar,bar,baz)"

Perhaps there is a way to have the parser first try to match "foo-bar"
to a raster, and failing that subdivide the token to {foo,-,bar}?

Or, perhaps, we should disallow hyphens in GRASS database files?

--
Eric G. Miller <egm2@jps.net>

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

"Eric G. Miller" wrote:

Or, perhaps, we should disallow hyphens in GRASS database files?

Probably the best solution... in ascii, there is no difference
between hyphen and minus. Grass has a function for verifying
the validity of database's file names G_legal_filename() which
may be updated. It looks actually :

int G_legal_filename (char *s)
{
    if (*s == '.' || *s == 0) {
  fprintf(stderr, "Illegal filename. Cannot be '.' or 'NULL'\n");
  return -1;
    }

    for ( ; *s; s++)
  if (*s == '/' || *s == '"' || *s == '\'' || *s <= ' ' || *s > 0176) {
    fprintf(stderr, "Illegal filename. character <%c> not allowed.", *s);
      return -1;
  }

    return 1;
}
--
Michel WURTZ - DIG - Maison de la télédétection
               500, rue J.F. Breton
               34093 MONTPELLIER Cedex 5

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Fri, May 11, 2001 at 08:54:40AM +0000, Michel Wurtz wrote:

"Eric G. Miller" wrote:

> Or, perhaps, we should disallow hyphens in GRASS database files?

Probably the best solution... in ascii, there is no difference
between hyphen and minus. Grass has a function for verifying
the validity of database's file names G_legal_filename() which
may be updated. It looks actually :

int G_legal_filename (char *s)
{
    if (*s == '.' || *s == 0) {
  fprintf(stderr, "Illegal filename. Cannot be '.' or 'NULL'\n");
  return -1;
    }

    for ( ; *s; s++)
  if (*s == '/' || *s == '"' || *s == '\'' || *s <= ' ' || *s > 0176) {
    fprintf(stderr, "Illegal filename. character <%c> not allowed.", *s);
      return -1;
  }

    return 1;
}

An addition: I feel that "=" is even no allowed character. It can
be specified (on command line), later you run into troubles when
trying to use the map (on command line).

Just my experience,

Markus

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

Markus Neteler wrote:

> > Or, perhaps, we should disallow hyphens in GRASS database files?
>
> Probably the best solution... in ascii, there is no difference
> between hyphen and minus. Grass has a function for verifying
> the validity of database's file names G_legal_filename() which
> may be updated. It looks actually :

[snip]

An addition: I feel that "=" is even no allowed character. It can
be specified (on command line), later you run into troubles when
trying to use the map (on command line).

Given the frequent usage of system(), I suspect that many of the
non-alphanumeric characters will cause problems with many commands.

For 5.1, we should seriously consider eradicating the use of system()
altogether.

Even for 5.0, it might be worth systematically inserting quotes into
command strings, e.g. changing

  sprintf(buf, "r.foo %s", filename);
to
  sprintf(buf, "r.foo '%s'", filename);

This should handle any filename which doesn't contain a single quote
character.

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

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'