NEVER EVER use sprintf together with _(...) !

--Sven
This commit is contained in:
Sven Neumann 1999-12-29 18:07:43 +00:00
parent 0b58c9c94b
commit 9498c29dfc
15 changed files with 118 additions and 171 deletions

View File

@ -1,3 +1,20 @@
Wed Dec 29 19:05:11 CET 1999 Sven Neumann <sven@gimp.org>
* plug-ins/common/CEL.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/despeckle.c
* plug-ins/common/gbr.c
* plug-ins/common/gifload.c
* plug-ins/common/gtm.c
* plug-ins/common/hrz.c
* plug-ins/common/iwarp.c
* plug-ins/common/png.c
* plug-ins/common/sunras.c
* plug-ins/common/warp.c
* plug-ins/common/xbm.c
* plug-ins/common/xpm.c
* plug-ins/common/xwd.c: NEVER EVER use sprintf together with _(...) !
Wed Dec 29 17:47:05 CET 1999 Sven Neumann <sven@gimp.org>
* app/fileops.c

View File

@ -212,9 +212,9 @@ static gint32 load_image(char *file, char *brief) {
gimp_quit();
}
progress= g_malloc(strlen(brief) + 10);
sprintf(progress, _("Loading %s:"), brief);
gimp_progress_init(progress);
progress = g_strdup_printf (_("Loading %s:"), brief);
gimp_progress_init (progress);
g_free (progress);
/* Get the image dimensions and create the image... */
@ -413,9 +413,9 @@ static gint save_image(char *file, char *brief, gint32 image, gint32 layer) {
gimp_quit();
}
progress= g_malloc(strlen(brief) + 9);
sprintf(progress, _("Saving %s:"), brief);
gimp_progress_init(progress);
progress = g_strdup_printf (_("Loading %s:"), brief);
gimp_progress_init (progress);
g_free (progress);
/* Headers */
memset(header, 0, 32);

View File

@ -153,8 +153,6 @@ static GtkWidget *gtkW_dialog_new (gchar *name,
GtkSignalFunc close_callback);
static GtkWidget *gtkW_frame_new (GtkWidget *parent, gchar *name);
static GtkWidget *gtkW_hbox_new (GtkWidget *parent);
static void gtkW_message_dialog (gint gtk_was_initialized, gchar *message);
static GtkWidget *gtkW_message_dialog_new (gchar * name);
static GtkWidget *gtkW_table_add_button (GtkWidget *table,
gchar *name,
gint x0,
@ -1921,7 +1919,7 @@ CML_copy_parameters_callback (GtkWidget *widget, gpointer data)
if (copy_source == copy_destination)
{
gtkW_message_dialog (TRUE, _("Warning: the source and the destination are the same channel."));
gimp_message (_("Warning: the source and the destination are the same channel."));
gdk_flush ();
return;
}
@ -2105,10 +2103,11 @@ CML_execute_save_to_file (GtkWidget *widget, gpointer client_data)
}
if ((err != 0) && (file == NULL))
{
gchar buffer[CML_LINE_SIZE];
gchar *buffer;
sprintf (buffer, _("Error: could not open \"%s\""), filename);
gtkW_message_dialog (TRUE, buffer);
buffer = g_strdup_printf (_("Error: could not open \"%s\""), filename);
gimp_message (buffer);
g_free (buffer);
return;
}
else
@ -2150,10 +2149,12 @@ CML_execute_save_to_file (GtkWidget *widget, gpointer client_data)
fclose(file);
#ifdef VERBOSE_DIALOGS
{
gchar buffer[CML_LINE_SIZE];
gchar *buffer;
sprintf (buffer, "Parameters were saved to \"%s\"", filename);
gtkW_message_dialog (TRUE, buffer);
buffer = g_strdup_printf (_("Parameters were saved to \"%s\""),
filename);
gimp_message (buffer);
g_free (buffer);
}
#endif
if ( sizeof (VALS.last_file_name) <= strlen (filename))
@ -2169,7 +2170,7 @@ force_overwrite (char *filename)
GtkWidget *dlg;
GtkWidget *label;
GtkWidget *table;
gchar buffer[CML_LINE_SIZE];
gchar *buffer;
gint tmp;
dlg = gtkW_dialog_new (_("CML file operation warning"),
@ -2179,8 +2180,9 @@ force_overwrite (char *filename)
table = gtkW_table_new (NULL, 1, 1);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
sprintf (buffer, _("%s exists, overwrite?"), filename);
buffer = g_strdup_printf (_("%s exists, overwrite?"), filename);
label = gtk_label_new (buffer);
g_free (buffer);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL|GTK_EXPAND,
0, 0, 0);
gtk_widget_show (label);
@ -2296,12 +2298,13 @@ CML_load_parameter_file (gchar *filename, gint interactive_mode)
if (!file)
{
gchar buffer[CML_LINE_SIZE];
gchar *buffer;
if (interactive_mode)
{
sprintf (buffer, _("Error: could not open \"%s\""), filename);
gtkW_message_dialog (TRUE, buffer);
buffer = g_strdup_printf (_("Error: could not open \"%s\""), filename);
gimp_message (buffer);
g_free (buffer);
}
return FALSE;
}
@ -2323,16 +2326,16 @@ CML_load_parameter_file (gchar *filename, gint interactive_mode)
if (version == 0)
{
if (interactive_mode)
gtkW_message_dialog (TRUE, _("Error: it's not CML parameter file."));
gimp_message (_("Error: it's not CML parameter file."));
fclose(file);
return FALSE;
}
if (interactive_mode)
{
if (version < PARAM_FILE_FORMAT_VERSION)
gtkW_message_dialog (TRUE, _("Warning: it's an old format file."));
gimp_message (_("Warning: it's an old format file."));
if (PARAM_FILE_FORMAT_VERSION < version)
gtkW_message_dialog (TRUE, _("Warning: Hmmm, it's a parameter file for newer CML_explorer than me."));
gimp_message (_("Warning: Hmmm, it's a parameter file for newer CML_explorer than me."));
}
for (channel_id = 0; flag && (channel_id < 3); channel_id++)
{
@ -2393,7 +2396,7 @@ CML_load_parameter_file (gchar *filename, gint interactive_mode)
if (flag == FALSE)
{
if (interactive_mode)
gtkW_message_dialog (TRUE, "Error: failed to load paramters");
gimp_message (_("Error: failed to load parameters"));
}
else
{
@ -2739,64 +2742,6 @@ gtkW_hbox_new (GtkWidget *parent)
return hbox;
}
static void
gtkW_message_dialog (gint gtk_was_initialized, gchar *message)
{
GtkWidget *dlg;
GtkWidget *table;
GtkWidget *label;
gchar **argv;
gint argc;
if (! gtk_was_initialized)
{
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup (PLUG_IN_NAME);
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
dlg = gtkW_message_dialog_new (PLUG_IN_NAME);
table = gtkW_table_new (GTK_DIALOG (dlg)->vbox, 1, 1);
label = gtk_label_new (message);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL|GTK_EXPAND,
0, 0, 0);
gtk_widget_show (label);
gtk_widget_show (dlg);
gtk_main ();
gdk_flush ();
}
static GtkWidget *
gtkW_message_dialog_new (gchar * name)
{
GtkWidget *dlg, *button;
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), name);
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) gtkW_close_callback, NULL);
/* Action Area */
button = gtk_button_new_with_label (_("OK"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT (dlg));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button,
TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
return dlg;
}
static GtkWidget *
gtkW_table_add_button (GtkWidget *table,
gchar *name,

View File

@ -43,6 +43,12 @@
* Revision History:
*
* $Log$
* Revision 1.21 1999/12/29 18:07:43 neo
* NEVER EVER use sprintf together with _(...) !
*
*
* --Sven
*
* Revision 1.20 1999/12/27 18:43:09 neo
* small dialog changes and german translation update
*
@ -754,9 +760,7 @@ despeckle_dialog(void)
*/
dialog = gtk_dialog_new();
plugin_name = g_new(gchar,
strlen( _("Despeckle "))+strlen(PLUG_IN_VERSION)+1);
sprintf(plugin_name, "%s%s", _("Despeckle "), PLUG_IN_VERSION);
plugin_name = g_strdup_printf ("%s%s", _("Despeckle "), PLUG_IN_VERSION);
gtk_window_set_title(GTK_WINDOW(dialog), plugin_name);
g_free(plugin_name);
gtk_window_set_wmclass(GTK_WINDOW(dialog), "despeckle", "Gimp");

View File

@ -260,9 +260,8 @@ load_image (char *filename)
GPixelRgn pixel_rgn;
int version_extra;
temp = g_malloc(strlen (filename) + 11);
sprintf(temp, _("Loading %s:"), filename);
gimp_progress_init(temp);
temp = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
fd = open(filename, O_RDONLY | _O_BINARY);
@ -366,10 +365,9 @@ save_image (char *filename,
if (gimp_drawable_type(drawable_ID) != GRAY_IMAGE)
return FALSE;
temp = g_malloc(strlen (filename) + 10);
sprintf(temp, _("Saving %s:"), filename);
gimp_progress_init(temp);
g_free(temp);
temp = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
drawable = gimp_drawable_get(drawable_ID);
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width,

View File

@ -292,11 +292,9 @@ load_image (char *filename)
return -1;
}
name_buf = g_malloc (strlen (filename) + 11);
if (run_mode != RUN_NONINTERACTIVE)
{
sprintf (name_buf, _("Loading %s:"), filename);
name_buf = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (name_buf);
g_free (name_buf);
}
@ -802,7 +800,8 @@ ReadImage (FILE *fd,
gint cur_progress, max_progress;
gint v;
gint i, j;
gchar framename[200]; /* FIXME */
gchar *framename;
gchar *framenamedisp = NULL;
gboolean alpha_frame = FALSE;
int nreturn_vals;
static int previous_disposal;
@ -839,9 +838,9 @@ ReadImage (FILE *fd,
gimp_image_set_cmap (image_ID, gimp_cmap, ncols);
if (Gif89.delayTime < 0)
strcpy(framename, _("Background"));
framename = g_strdup (_("Background"));
else
sprintf(framename, _("Background (%dms)"), 10*Gif89.delayTime);
framename = g_strdup_printf (_("Background (%dms)"), 10*Gif89.delayTime);
previous_disposal = Gif89.disposal;
@ -858,6 +857,8 @@ ReadImage (FILE *fd,
INDEXEDA_IMAGE, 100, NORMAL_MODE);
alpha_frame=TRUE;
}
g_free (framename);
}
else /* NOT FIRST FRAME */
{
@ -888,35 +889,38 @@ ReadImage (FILE *fd,
}
if (Gif89.delayTime < 0)
sprintf(framename, _("Frame %d"), frame_number);
framename = g_strdup_printf (_("Frame %d"), frame_number);
else
sprintf(framename, _("Frame %d (%dms)"),
frame_number, 10*Gif89.delayTime);
framename = g_strdup_printf (_("Frame %d (%dms)"), frame_number, 10*Gif89.delayTime);
switch (previous_disposal)
{
case 0x00: break; /* 'don't care' */
case 0x01: strcat(framename,_(" (combine)")); break;
case 0x02: strcat(framename,_(" (replace)")); break;
case 0x03: strcat(framename,_(" (combine)")); break;
case 0x01: framenamedisp = g_strconcat (framename, _(" (combine)"), NULL); break;
case 0x02: framenamedisp = g_strconcat (framename, _(" (replace)"), NULL); break;
case 0x03: framenamedisp = g_strconcat (framename, _(" (combine)"), NULL); break;
case 0x04:
case 0x05:
case 0x06:
case 0x07:
strcat(framename,_(" (unknown disposal)"));
framenamedisp = g_strconcat (framename, _(" (unknown disposal)"), NULL);
g_message ("GIF: Hmm... please forward this GIF to the "
"GIF plugin author!\n (adam@foxbox.org)\n");
break;
default: g_message ("GIF: Something got corrupted.\n"); break;
default:
g_message ("GIF: Something got corrupted.\n");
framenamedisp = g_strdup (framename);
break;
}
previous_disposal = Gif89.disposal;
g_free (framename);
layer_ID = gimp_layer_new (image_ID, framename,
layer_ID = gimp_layer_new (image_ID, framenamedisp,
len, height,
promote_to_rgb ? RGBA_IMAGE : INDEXEDA_IMAGE,
100, NORMAL_MODE);
alpha_frame = TRUE;
g_free (framenamedisp);
}
frame_number++;

View File

@ -222,8 +222,7 @@ save_image (char *filename,
if (gtmvals.caption)
fprintf (fp,"<CAPTION>%s</CAPTION>\n",gtmvals.captiontxt);
name = g_malloc (strlen (filename) + 11);
sprintf (name, _("Saving %s:"), filename);
name = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (name);
g_free (name);

View File

@ -321,8 +321,7 @@ load_image (char *filename)
void *mapped; /* memory mapped file data */
struct stat statbuf; /* must check file size */
temp = g_malloc (strlen (filename) + 11);
sprintf (temp, _("Loading %s:"), filename);
temp = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
@ -459,8 +458,7 @@ save_image (char *filename,
return FALSE;
}
temp = g_malloc (strlen (filename) + 11);
sprintf (temp, _("Saving %s:"), filename);
temp = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (temp);
g_free (temp);

View File

@ -603,7 +603,7 @@ static void iwarp()
int i;
gint32 layerID;
gint32 *animlayers;
char st[100];
gchar *st;
gfloat delta;
@ -621,25 +621,29 @@ static void iwarp()
if (image_bpp == 1 || image_bpp == 3) layer_alpha = TRUE; else layer_alpha = FALSE;
frame_number = 0;
for (i=0; i< animate_num_frames; i++) {
sprintf(st,"Frame %d",i);
st = g_strdup_printf (_("Frame %d"),i);
animlayers[i] = iwarp_layer_copy(layerID);
gimp_layer_set_name(animlayers[i],st);
g_free (st);
destdrawable = gimp_drawable_get(animlayers[i]);
sprintf(st, _("Warping Frame Nr %d ..."),frame_number);
st = g_strdup_printf (_("Warping Frame Nr %d ..."),frame_number);
gimp_progress_init(st);
g_free (st);
if (animate_deform_value >0.0) iwarp_frame();
gimp_image_add_layer(imageID,animlayers[i],0);
animate_deform_value = animate_deform_value + delta;
frame_number++;
}
if (do_animate_ping_pong) {
sprintf(st, _("Warping Frame Nr %d ..."),frame_number);
st = g_strdup_printf (_("Warping Frame Nr %d ..."),frame_number);
gimp_progress_init( _("Ping Pong"));
g_free (st);
for (i=0; i < animate_num_frames; i++) {
gimp_progress_update((double)i / (animate_num_frames-1));
layerID = iwarp_layer_copy(animlayers[animate_num_frames-i-1]);
sprintf(st,"Frame %d",i+animate_num_frames);
st = g_strdup_printf (_("Frame %d"),i+animate_num_frames);
gimp_layer_set_name(layerID,st);
g_free (st);
gimp_image_add_layer(imageID,layerID,0);
}
}

View File

@ -341,7 +341,7 @@ load_image (char *filename) /* I - File to load */
png_infop info; /* PNG info pointers */
guchar **pixels, /* Pixel rows */
*pixel; /* Pixel data */
char progress[255]; /* Title for progress display... */
gchar *progress; /* Title for progress display... */
guchar alpha[256], /* Index -> Alpha */
*alpha_ptr; /* Temporary pointer */
@ -388,11 +388,12 @@ load_image (char *filename) /* I - File to load */
png_init_io(pp, fp);
if (strrchr(filename, '/') != NULL)
sprintf (progress, _("Loading %s:"), strrchr(filename, '/') + 1);
progress = g_strdup_printf (_("Loading %s:"), strrchr(filename, '/') + 1);
else
sprintf (progress, _("Loading %s:"), filename);
progress = g_strdup_printf (progress, _("Loading %s:"), filename);
gimp_progress_init(progress);
g_free (progress);
/*
* Get the image dimensions and create the image...
@ -653,7 +654,7 @@ save_image (char *filename, /* I - File to save to */
gint offx, offy; /* Drawable offsets from origin */
guchar **pixels, /* Pixel rows */
*pixel; /* Pixel data */
char progress[255]; /* Title for progress display... */
gchar *progress; /* Title for progress display... */
gdouble xres, yres; /* GIMP resolution (dpi) */
gdouble gamma;
guchar red, green, blue; /* For palette background */
@ -694,11 +695,12 @@ save_image (char *filename, /* I - File to save to */
png_init_io(pp, fp);
if (strrchr(filename, '/') != NULL)
sprintf(progress, _("Saving %s:"), strrchr(filename, '/') + 1);
progress = g_strdup_printf (_("Saving %s:"), strrchr(filename, '/') + 1);
else
sprintf(progress, _("Saving %s:"), filename);
progress = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init(progress);
g_free (progress);
/*
* Get the drawable for the current image...

View File

@ -437,8 +437,7 @@ load_image (char *filename)
if (l_run_mode != RUN_NONINTERACTIVE)
{
temp = g_malloc (strlen (filename) + 64);
sprintf (temp, _("Loading %s:"), filename);
temp = g_strdup_printf (temp, _("Loading %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
}
@ -522,8 +521,7 @@ save_image (char *filename,
if (l_run_mode != RUN_NONINTERACTIVE)
{
temp = g_malloc (strlen (filename) + 64);
sprintf (temp, _("Saving %s:"), filename);
temp = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
}

View File

@ -1344,7 +1344,7 @@ warp (GDrawable *orig_draw,
GDrawable *disp_map; /* Displacement map, ie, control array */
GDrawable *mag_draw; /* Magnitude multiplier factor map */
gchar string[80]; /* string to hold title of progress bar window */
gchar *string; /* string to hold title of progress bar window */
gint first_time = TRUE;
gint width;
@ -1391,20 +1391,14 @@ warp (GDrawable *orig_draw,
for (warp_iter = 0; warp_iter < dvals.iter; warp_iter++)
{
if (run_mode != RUN_NONINTERACTIVE) {
sprintf(string, _("Flow Step %d..."),warp_iter+1);
string = g_strdup_printf (_("Flow Step %d..."), warp_iter+1);
gimp_progress_init (string);
progress = 0;
g_free (string);
progress = 0;
gimp_progress_update (0);
}
warp_one(orig_draw, orig_draw, *map_x, *map_y, mag_draw, first_time, warp_iter);
/*
sprintf(string,"Background Step %d...",warp_iter+1);
gimp_progress_init (string);
progress = 0;
warp_one(new_image, orig_draw, *map_x, *map_y, mag_draw, FALSE, warp_iter);
*/
gimp_drawable_update (orig_draw->id, x1, y1, (x2 - x1), (y2 - y1));
if (run_mode != RUN_NONINTERACTIVE)

View File

@ -541,8 +541,7 @@ load_image (char *filename)
return -1;
}
name_buf = g_malloc (strlen (filename) + 11);
sprintf (name_buf, _("Loading %s:"), filename);
name_buf = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (name_buf);
g_free (name_buf);
@ -799,8 +798,7 @@ save_image (char *filename,
return FALSE;
}
name_buf = (guchar *) g_malloc (strlen (filename) + 11);
sprintf (name_buf, _("Saving %s:"), filename);
name_buf = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (name_buf);
g_free (name_buf);

View File

@ -306,15 +306,12 @@ load_image (char *filename)
XpmImage xpm_image;
guchar *cmap;
gint32 image_ID;
char *name;
gchar *name;
/* put up a progress bar */
name = malloc (strlen (filename) + 12);
if (!name)
gimp_quit();
sprintf (name, _("Loading %s:"), filename);
name = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (name);
free (name);
g_free (name);
/* read the raw file */
XpmReadFileToXpmImage (filename, &xpm_image, NULL);
@ -629,12 +626,11 @@ save_image (char *filename,
/* put up a progress bar */
{
char *name = g_new (char, strlen (filename) + 12);
if (!name)
gimp_quit();
sprintf (name, _("Saving %s:"), filename);
gchar *name;
name = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (name);
free (name);
g_free (name);
}

View File

@ -367,7 +367,7 @@ load_image (char *filename)
{
FILE *ifp;
int depth, bpp;
char *temp;
gchar *temp;
gint32 image_ID;
L_XWDFILEHEADER xwdhdr;
L_XWDCOLOR *xwdcolmap = NULL;
@ -433,8 +433,7 @@ load_image (char *filename)
if (l_run_mode != RUN_NONINTERACTIVE)
{
temp = g_malloc (strlen (filename) + 11);
sprintf (temp, "Loading %s:", filename);
temp = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
}
@ -485,19 +484,11 @@ load_image (char *filename)
if (image_ID == -1)
{
temp = g_malloc (strlen (filename)+256);
if (temp == NULL)
{
show_message (_("this image depth/format is not supported"));
}
else
{
sprintf (temp, _("load_image (xwd): XWD-file %s has format %d, depth %d\n\
temp = g_strdup_printf (_("load_image (xwd): XWD-file %s has format %d, depth %d\n\
and bits per pixel %d.\nCurrently this is not supported.\n"),
filename, (int)xwdhdr.l_pixmap_format, depth, bpp);
show_message (temp);
g_free (temp);
}
filename, (int)xwdhdr.l_pixmap_format, depth, bpp);
show_message (temp);
g_free (temp);
return (-1);
}
@ -546,8 +537,7 @@ save_image (char *filename,
if (l_run_mode != RUN_NONINTERACTIVE)
{
temp = g_malloc (strlen (filename) + 11);
sprintf (temp, _("Saving %s:"), filename);
temp = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
}