[GRASS-dev] db.execute: ".execute" suffix missing in man page

Paul Kelly paul-grass at stjohnspoint.co.uk
Wed Oct 24 10:28:58 EDT 2007

On Wed, 10 Oct 2007, Glynn Clements wrote:

> Maciej Sieczka wrote:
>> In Firefox and Lynx browsers the ".execute" part of
>> "db.execute" is missing above the module description. It
>> also not there in "man db.execute" output.
> G_parser() does:
> 	G_basename(tmp_name, "exe");

Oops - that was an oversight on my part.

> G_basename() is described thus:
> * \fn char * G_basename (char *filename, const char *desired_ext)
> *
> * \brief Truncates filename to the base part (before the last '.')
> * if it matches the extension, otherwise leaves it unchanged.
> But it actually only checks if the specified extension is a prefix of
> the actual extension rather than a complete match.

The reason for that was so that e.g. "tif" can match .tif and .tiff and 
other usage cases like that. The original usage for G_basename() was 
checking the output filename for r.out.tiff so it could decide if it 
should add an extension or not.

> Suggested fix (untested):
> char * G_basename(char *filename, const char *desired_ext)
> {
>    /* Find the last . in the filename */
>    char *dot = strrchr(filename, '.');
>    if (dot && G_strcasecmp(dot + 1, desired_ext) == 0)
>       *dot = '\0';
>    return filename;
> }

That would break the way it is used in r.out.tiff in some circumstances. 
I'm thinking it might be easier to conditionalise its use in G_parser() 
and G_set_program_name() on __MINGW32__ as its only purpose there is to 
strip out the .exe executable extension on Windows?

Maybe there should be two functions though. Or maybe stripping out the 
.exe is quite simple and it doesn't need to use G_basename()?

If noone else has fixed this yet I'll try and get to it fairly soon.


More information about the grass-dev mailing list