Commit bf334716 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

use g_strdup_vprintf() instead of guessing the string length. Also declare

2004-08-08  Sven Neumann  <sven@gimp.org>

	* plug-ins/script-fu/siod-wrapper.[ch] (siod_output_string): use
	g_strdup_vprintf() instead of guessing the string length. Also
	declare the function using G_GNUC_PRINTF().
parent 79d50e2a
2004-08-08 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/siod-wrapper.[ch] (siod_output_string): use
g_strdup_vprintf() instead of guessing the string length. Also
declare the function using G_GNUC_PRINTF().
2004-08-08 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* plug-ins/ifscompose/README.ifscompose: fix out of date info,
......
......@@ -112,31 +112,28 @@ siod_get_success_msg (void)
}
void
siod_output_string (FILE *fp, char *string, ...)
siod_output_string (FILE *fp,
const gchar *format,
...)
{
gint buff_len;
gchar *buff;
va_list args;
/* Ensure plenty of room in case string contains %-style format codes */
buff_len = strlen (string) * 2;
buff = g_malloc (buff_len);
if (buff == NULL)
return; /* Should "No memory" be output here? */
va_start (args, string);
g_vsnprintf (buff, buff_len, string, args);
gchar *buf;
va_list args;
va_start (args, format);
buf = g_strdup_vprintf (format, args);
va_end (args);
if (siod_console_mode && fp == stdout)
script_fu_output_to_console (buff);
{
script_fu_output_to_console (buf);
}
else
{
fprintf (fp, buff);
fflush (fp);
}
{
fprintf (fp, buf);
fflush (fp);
}
g_free (buff);
g_free (buf);
}
......
......@@ -35,7 +35,9 @@ void siod_print_welcome (void);
const gchar * siod_get_error_msg (void);
const gchar * siod_get_success_msg (void);
void siod_output_string (FILE *fp, char *string, ...);
void siod_output_string (FILE *fp,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
/* if the return value is 0, success. error otherwise. */
gint siod_interpret_string (const gchar *expr);
......
......@@ -112,31 +112,28 @@ siod_get_success_msg (void)
}
void
siod_output_string (FILE *fp, char *string, ...)
siod_output_string (FILE *fp,
const gchar *format,
...)
{
gint buff_len;
gchar *buff;
va_list args;
/* Ensure plenty of room in case string contains %-style format codes */
buff_len = strlen (string) * 2;
buff = g_malloc (buff_len);
if (buff == NULL)
return; /* Should "No memory" be output here? */
va_start (args, string);
g_vsnprintf (buff, buff_len, string, args);
gchar *buf;
va_list args;
va_start (args, format);
buf = g_strdup_vprintf (format, args);
va_end (args);
if (siod_console_mode && fp == stdout)
script_fu_output_to_console (buff);
{
script_fu_output_to_console (buf);
}
else
{
fprintf (fp, buff);
fflush (fp);
}
{
fprintf (fp, buf);
fflush (fp);
}
g_free (buff);
g_free (buf);
}
......
......@@ -35,7 +35,9 @@ void siod_print_welcome (void);
const gchar * siod_get_error_msg (void);
const gchar * siod_get_success_msg (void);
void siod_output_string (FILE *fp, char *string, ...);
void siod_output_string (FILE *fp,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
/* if the return value is 0, success. error otherwise. */
gint siod_interpret_string (const gchar *expr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment