[GRASS-SVN] r29853 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jan 27 04:52:06 EST 2008
Author: neteler
Date: 2008-01-27 04:52:06 -0500 (Sun, 27 Jan 2008)
New Revision: 29853
Modified:
grass/trunk/lib/gis/error.c
Log:
Ivan Shmakov <ivan theory asu.ru>: code polishing
Modified: grass/trunk/lib/gis/error.c
===================================================================
--- grass/trunk/lib/gis/error.c 2008-01-27 08:24:05 UTC (rev 29852)
+++ grass/trunk/lib/gis/error.c 2008-01-27 09:52:06 UTC (rev 29853)
@@ -93,7 +93,17 @@
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);
+
+ /* . */
+ return print_error (buffer, type);
+}
+
/*!
* \fn void G_message (const char *msg,...)
*
@@ -105,15 +115,11 @@
*/
void G_message (const char *msg,...)
{
- char buffer[2000]; /* G_asprintf does not work */
- va_list ap;
-
if( G_verbose() >= G_verbose_std() ) {
+ va_list ap;
va_start(ap, msg);
- vsprintf(buffer,msg,ap);
+ vfprint_error (MSG, msg, ap);
va_end(ap);
-
- print_error (buffer,MSG);
}
}
@@ -130,15 +136,11 @@
*/
void G_verbose_message (const char *msg, ...)
{
- char buffer[2000]; /* G_asprintf does not work */
- va_list ap;
-
if( G_verbose() > G_verbose_std() ) {
+ va_list ap;
va_start(ap, msg);
- vsprintf(buffer,msg,ap);
+ vfprint_error (MSG, msg, ap);
va_end(ap);
-
- G_message(buffer);
}
}
@@ -158,15 +160,11 @@
*/
void G_important_message(const char *msg, ...)
{
- char buffer[2000]; /* G_asprintf does not work */
- va_list ap;
-
if( G_verbose() > G_verbose_min() ) {
+ va_list ap;
va_start(ap, msg);
- vsprintf(buffer,msg,ap);
+ vfprint_error (MSG, msg, ap);
va_end(ap);
-
- print_error (buffer,MSG);
}
}
@@ -194,14 +192,11 @@
*/
int G_fatal_error (const char *msg,...)
{
- char buffer[2000]; /* No novels to the error logs, OK? */
va_list ap;
va_start(ap,msg);
- vsprintf(buffer,msg,ap);
+ vfprint_error (ERR, msg, ap);
va_end(ap);
-
- print_error (buffer,ERR);
exit (EXIT_FAILURE);
}
@@ -221,15 +216,13 @@
*/
int G_warning (const char *msg, ...)
{
- char buffer[2000];
va_list ap;
if (no_warn) return 0;
va_start(ap,msg);
- vsprintf(buffer,msg,ap);
+ vfprint_error (WARN, msg, ap);
va_end(ap);
- print_error (buffer,WARN);
return 0;
}
More information about the grass-commit
mailing list