Hi all,
I realized a strange behaviour of r.buffer, e.g.
$ r.buffer in=e out=e d=1
No error, input and output is the same...
$ r.buffer in=e [EMAIL PROTECTED] d=1
Illegal filename. Character <@> not allowed.
ERROR: <[EMAIL PROTECTED]> is an illegal file name
Why so restrictive? The current mapset is 'user1'.
I modified library function G_check_input_output() to handle also this case.
If mapset defined for output map is not the current one:
ERROR: Mapset defined for output map <[EMAIL PROTECTED]> is not the current
mapset
Any objects to commit to CVS?
Martin
--
Martin Landa <[EMAIL PROTECTED]> * http://gama.fsv.cvut.cz/~landa *
Index: lib/gis/legal_name.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/gis/legal_name.c,v
retrieving revision 2.11
diff -u -r2.11 legal_name.c
--- lib/gis/legal_name.c 14 Apr 2007 23:01:59 -0000 2.11
+++ lib/gis/legal_name.c 29 Oct 2007 11:06:20 -0000
@@ -1,14 +1,14 @@
/**
* \file legal_name.c
*
- * \brief Functions to handle file name legality.
+ * \brief GIS Library - Handle file name legality.
*
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
* \author GRASS GIS Development Team
*
- * \date 1999-2006
+ * \date 1999-2007
*/
#include <stdio.h>
@@ -18,8 +18,6 @@
/**
- * \fn int G_legal_filename (char *s)
- *
* \brief Check for legal database file name.
*
* Legal file names will <b>not</b> begin with '.' or NULL and must
@@ -35,14 +33,14 @@
int G_legal_filename (const char *s)
{
if (*s == '.' || *s == 0) {
- fprintf(stderr, _("Illegal filename. Cannot be '.' or 'NULL'\n"));
+ G_warning(_("Illegal filename. Cannot be '.' or 'NULL'."));
return -1;
}
for (; *s; s++)
if (*s == '/' || *s == '"' || *s == '\'' || *s <= ' ' ||
*s == '@' || *s == ',' || *s == '=' || *s == '*' || *s > 0176) {
- fprintf(stderr, _("Illegal filename. Character <%c> not allowed.\n"), *s);
+ G_warning (_("Illegal filename. Character '%c' not allowed."), *s);
return -1;
}
@@ -51,8 +49,6 @@
/**
- * \fn int G_check_input_output_name (char * input, char * output, int error)
- *
* \brief Check input and output file names.
*
* Check: 1) output is legal map name, 2) if can find input map, and 3)
@@ -67,34 +63,59 @@
int G_check_input_output_name ( const char * input, const char * output, int error )
{
+ char output_name[1000], output_mapset[1000];
char *mapset;
- if ( output == NULL) return 0; /* don't die on undefined parameters */
- if ( G_legal_filename(output) == -1 ) {
+ /* output */
+ if ( output == NULL)
+ return 0; /* don't die on undefined parameters */
+
+ /* is output name fully qualified ? */
+ if (G__name_is_fully_qualified(output, output_name, output_mapset)) {
+ if (strcmp(G_mapset(), output_mapset)) {
+ if ( error == GR_FATAL_EXIT ) {
+ G_fatal_error ( _("Mapset defined for output map <%s> is "
+ "not the current mapset"), output );
+ } else if ( error == GR_FATAL_PRINT ) {
+ G_warning ( _("Mapset defined for output map <%s> is "
+ "not the current mapset"), output );
+ return 1;
+ } else { /* GR_FATAL_RETURN */
+ return 1;
+ }
+ }
+ }
+ else {
+ G_strcpy (output_name, output);
+ }
+
+ if ( G_legal_filename(output_name) == -1 ) {
if ( error == GR_FATAL_EXIT ) {
- G_fatal_error ( _("Output name '%s' is not valid rast name."), output );
+ G_fatal_error ( _("Output name <%s> is not valid raster map name"), output_name );
} else if ( error == GR_FATAL_PRINT ) {
- G_warning ( _("Output name '%s' is not valid rast name."), output );
+ G_warning ( _("Output name <%s> is not valid raster map name"), output_name );
return 1;
} else { /* GR_FATAL_RETURN */
return 1;
}
}
+ /* input */
mapset = G_find_cell2 (input, "");
if ( mapset == NULL ) {
if ( error == GR_FATAL_EXIT ) {
- G_fatal_error ( _("Cannot find input map '%s'"), input );
+ G_fatal_error ( _("Raster map <%s> not found"), input );
} else if ( error == GR_FATAL_PRINT ) {
- G_warning ( _("Cannot find input map '%s'"), input );
+ G_warning ( _("Raster map <%s> not found"), input );
return 1;
} else { /* GR_FATAL_RETURN */
return 1;
}
}
- if ( strcmp(mapset,G_mapset()) == 0 ) {
+ /* input <-> output */
+ if ( strcmp(mapset, G_mapset()) == 0 ) {
char nm[1000], ms[1000];
const char *in;
@@ -104,11 +125,11 @@
in = input;
}
- if ( strcmp(in,output) == 0 ) {
+ if ( strcmp(in, output_name) == 0 ) {
if ( error == GR_FATAL_EXIT ) {
- G_fatal_error ( _("Output map '%s' is used as input"), output );
+ G_fatal_error ( _("Output raster map <%s> is used as input"), output_name );
} else if ( error == GR_FATAL_PRINT ) {
- G_warning ( _("Output map '%s' is used as input"), output );
+ G_warning ( _("Output raster map <%s> is used as input"), output_name );
return 1;
} else { /* GR_FATAL_RETURN */
return 1;
_______________________________________________
grass-dev mailing list
[email protected]
http://grass.itc.it/mailman/listinfo/grass-dev