[GRASS-dev] G_message () family of functions

Glynn Clements glynn at gclements.plus.com
Sun Jan 13 19:06:57 EST 2008


Ivan Shmakov wrote:

>  > BTW, the correct pattern for issuing a string message is:
> 
>  > G_message ("%s", string);
> 
>  > not:
> 
>  > G_message (string);
> 
>  > [...]
> 
> 	May I suggest the following patch?

Seems reasonable enough.

> --- lib/gis/error.c	2008-01-03 14:15:58.000000000 +0600
> +++ lib/gis/error.c	2008-01-12 23:14:50.000000000 +0600
> @@ -93,6 +93,16 @@
>                          time_t, const char *);
>  static int log_error (const char *, int);
>  
> +static int
> +vfprint_error (int type, const char *template, va_list ap)
> +{
> +    char buffer[2000];  /* G_asprintf does not work */
> +
> +    vsprintf (buffer, template, ap);

It would be nice to use vsnprintf(), but we would need to check that
it's available (it's not in C89).

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


More information about the grass-dev mailing list