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

Glynn Clements glynn at gclements.plus.com
Tue Oct 9 19:47:53 EDT 2007


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_basename

> Does anybody confirm?

Confirm:

	$ db.execute --help
	
	...
	
	Usage:
	 db [-i] [input=name] [driver=name] [database=name] [--verbose]
	   [--quiet]

G_parser() does:

	G_basename(tmp_name, "exe");

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.

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;
}

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list