Commit 1c2b0228 authored by Sven Neumann's avatar Sven Neumann
Browse files

The way is now free for a new millenium without sprintf being used together with

gettext.


--Sven
parent f9b657fc
Thu Dec 30 19:45:13 CET 1999 Sven Neumann <sven@gimp.org>
* plug-ins/bmp/bmpread.c
* plug-ins/bmp/bmpwrite.c
* plug-ins/common/compose.c
* plug-ins/common/gifload.c
* plug-ins/common/normalize.c
* plug-ins/common/png.c
* plug-ins/common/sunras.c
* plug-ins/common/warp.c
* plug-ins/common/xbm.c
* plug-ins/common/zealouscrop.c
* plug-ins/fits/fits.c
* plug-ins/flame/flame.c
* plug-ins/gap/gap_arr_dialog.c
* plug-ins/gap/gap_filter_foreach.c
* plug-ins/gap/gap_lib.c
* plug-ins/gap/gap_mod_layer.c
* plug-ins/gap/gap_mov_dialog.c
* plug-ins/gap/gap_mpege.c
* plug-ins/gap/gap_range_ops.c
* plug-ins/gap/gap_split.c
* plug-ins/gdyntext/charmap.c
* plug-ins/gimpressionist/brush.c
* plug-ins/gimpressionist/color.c
* plug-ins/gimpressionist/general.c
* plug-ins/gimpressionist/gimp.c
* plug-ins/gimpressionist/orientation.c
* plug-ins/gimpressionist/paper.c
* plug-ins/gimpressionist/placement.c
* plug-ins/gimpressionist/ppmtool.c
* plug-ins/gimpressionist/ppmtool.h
* plug-ins/gimpressionist/presets.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/gimpressionist/size.c
* plug-ins/ifscompose/ifscompose.c
* plug-ins/imagemap/imap_cmd_guides.c
* plug-ins/imagemap/imap_edit_area_info.c
* plug-ins/imagemap/imap_menu.c
* plug-ins/print/print.c
* po-plug-ins/POTFILES.in
Got rid of all occurences of sprintf together with gettext and removed
translation tags from console output.
In a few places I also changed malloc to g_malloc and friends.
Thu Dec 30 15:21:29 GMT 1999 Adam D. Moss <adam@gimp.org>
 
* plug-ins/common/animoptimize.c: PDB interface patch
......
......@@ -45,8 +45,7 @@ ReadBMP (char *name)
if (interactive_bmp)
{
temp_buf = g_malloc (strlen (name) + 11);
sprintf (temp_buf, _("Loading %s:"), name);
temp_buf = g_strdup_printf (_("Loading %s:"), name);
gimp_progress_init (temp_buf);
g_free (temp_buf);
}
......
......@@ -168,8 +168,7 @@ WriteBMP (char *filename,
if (interactive_bmp)
{
temp_buf = g_malloc (strlen (filename) + 11);
sprintf (temp_buf, _("Saving %s:"), filename);
temp_buf = g_strdup_printf (_("Saving %s:"), filename);
gimp_progress_init (temp_buf);
g_free (temp_buf);
}
......
......@@ -273,7 +273,7 @@ run (char *name,
GStatusType status = STATUS_SUCCESS;
gint32 image_ID, drawable_ID;
int compose_by_drawable;
char msg[256];
gchar *msg;
INIT_I18N_UI ();
......@@ -302,9 +302,10 @@ run (char *name,
layer_list = gimp_image_get_layers (param[1].data.d_int32, &nlayers);
if ((layer_list == NULL) || (nlayers <= 0))
{
sprintf (msg, "compose: Could not get layers for image %d",
(int)param[1].data.d_int32);
msg = g_strdup_printf (_("compose: Could not get layers for image %d"),
(int)param[1].data.d_int32);
show_message (msg);
g_free (msg);
return;
}
drawable_ID = layer_list[0];
......@@ -418,7 +419,7 @@ compose (char *compose_type,
if ( (width != (int)gimp_drawable_width (compose_ID[j]))
|| (height != (int)gimp_drawable_height (compose_ID[j])))
{
show_message ("compose: drawables have different size");
show_message (_("Compose: Drawables have different size"));
return -1;
}
}
......@@ -435,7 +436,7 @@ compose (char *compose_type,
if ( (width != (int)gimp_image_width (compose_ID[j]))
|| (height != (int)gimp_image_height (compose_ID[j])))
{
show_message ("compose: images have different size");
show_message (_("Compose: Images have different size"));
return -1;
}
}
......@@ -448,7 +449,7 @@ compose (char *compose_type,
g32 = gimp_image_get_layers (compose_ID[j], &num_layers);
if ((g32 == NULL) || (num_layers <= 0))
{
show_message ("compose: error in getting layer IDs");
show_message (_("Compose: Error in getting layer IDs"));
return (-1);
}
......@@ -464,11 +465,13 @@ compose (char *compose_type,
/* Check bytes per pixel */
incr_src[j] = drawable_src[j]->bpp;
if ((incr_src[j] != 1) && (incr_src[j] != 2))
{char msg[256];
sprintf (msg, _("compose: image is not a gray image (bpp=%d)"),
incr_src[j]);
show_message (msg);
return (-1);
{
gchar *msg;
g_strdup_printf (_("Compose: Image is not a gray image (bpp=%d)"),
incr_src[j]);
show_message (msg);
g_free (msg);
return (-1);
}
/* Get pixel region */
......@@ -478,11 +481,6 @@ compose (char *compose_type,
/* Get memory for retrieving information */
src[j] = (unsigned char *)g_malloc (tile_height * width
* drawable_src[j]->bpp);
if (src[j] == NULL)
{
show_message (_("compose: not enough memory"));
return (-1);
}
}
/* Create new image */
......@@ -492,13 +490,6 @@ compose (char *compose_type,
width, height, gdtype_dst,
&layer_ID_dst, &drawable_dst, &pixel_rgn_dst);
dst = (unsigned char *)g_malloc (tile_height * width * drawable_dst->bpp);
if (dst == NULL)
{
for (j = 0; j < num_images; j++)
g_free (src[j]);
show_message (_("compose: not enough memory"));
return (-1);
}
/* Do the composition */
i = 0;
......
......@@ -801,6 +801,7 @@ ReadImage (FILE *fd,
gint v;
gint i, j;
gchar *framename;
gchar *framename_ptr;
gboolean alpha_frame = FALSE;
int nreturn_vals;
static int previous_disposal;
......@@ -894,15 +895,30 @@ ReadImage (FILE *fd,
switch (previous_disposal)
{
case 0x00: break; /* 'don't care' */
case 0x01: framename = g_strconcat (framename, _(" (combine)"), NULL); break;
case 0x02: framename = g_strconcat (framename, _(" (replace)"), NULL); break;
case 0x03: framename = g_strconcat (framename, _(" (combine)"), NULL); break;
case 0x00:
break; /* 'don't care' */
case 0x01:
framename_ptr = framename;
framename = g_strconcat (framename, " (combine)", NULL);
g_free (framename_ptr);
break;
case 0x02:
framename_ptr = framename;
framename = g_strconcat (framename, " (replace)", NULL);
g_free (framename_ptr);
break;
case 0x03:
framename_ptr = framename;
framename = g_strconcat (framename, " (combine)", NULL);
g_free (framename_ptr);
break;
case 0x04:
case 0x05:
case 0x06:
case 0x07:
framename = g_strconcat (framename, _(" (unknown disposal)"), NULL);
framename_ptr = framename;
framename = g_strconcat (framename, " (unknown disposal)", NULL);
g_free (framename_ptr);
g_message ("GIF: Hmm... please forward this GIF to the "
"GIF plugin author!\n (adam@foxbox.org)\n");
break;
......
......@@ -152,8 +152,8 @@ indexed_norma(gint32 image_ID) /* a.d.m. */
if (cmap==NULL)
{
printf(_("normalize: cmap was NULL! Quitting...\n"));
gimp_quit();
printf ("normalize: cmap was NULL! Quitting...\n");
return;
}
for (i=0;i<ncols;i++)
......
......@@ -390,7 +390,7 @@ load_image (char *filename) /* I - File to load */
if (strrchr(filename, '/') != NULL)
progress = g_strdup_printf (_("Loading %s:"), strrchr(filename, '/') + 1);
else
progress = g_strdup_printf (progress, _("Loading %s:"), filename);
progress = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init(progress);
g_free (progress);
......
......@@ -437,7 +437,7 @@ load_image (char *filename)
if (l_run_mode != RUN_NONINTERACTIVE)
{
temp = g_strdup_printf (temp, _("Loading %s:"), filename);
temp = g_strdup_printf (_("Loading %s:"), filename);
gimp_progress_init (temp);
g_free (temp);
}
......@@ -1727,7 +1727,7 @@ show_message (char *message)
if (l_run_mode == RUN_INTERACTIVE)
gimp_message (message);
else
fprintf (stderr, _("sunras: %s\n"), message);
fprintf (stderr, "sunras: %s\n", message);
}
static int
......
......@@ -1104,26 +1104,25 @@ diff (GDrawable *drawable,
/* allocate row buffers for source & dest. data */
/* P.S. Hey, what happens if malloc returns NULL, hmmm..? */
prev_row = (guchar *) malloc ((x2 - x1 + 2) * src_bytes);
cur_row = (guchar *) malloc ((x2 - x1 + 2) * src_bytes);
next_row = (guchar *) malloc ((x2 - x1 + 2) * src_bytes);
prev_row = g_new (guchar, (x2 - x1 + 2) * src_bytes);
cur_row = g_new (guchar, (x2 - x1 + 2) * src_bytes);
next_row = g_new (guchar, (x2 - x1 + 2) * src_bytes);
prev_row_g = (guchar *) malloc ((x2 - x1 + 2) * src_bytes);
cur_row_g = (guchar *) malloc ((x2 - x1 + 2) * src_bytes);
next_row_g = (guchar *) malloc ((x2 - x1 + 2) * src_bytes);
prev_row_g = g_new (guchar, (x2 - x1 + 2) * src_bytes);
cur_row_g = g_new (guchar, (x2 - x1 + 2) * src_bytes);
next_row_g = g_new (guchar, (x2 - x1 + 2) * src_bytes);
cur_row_v = (guchar *) malloc ((x2 - x1 + 2) * src_bytes); /* vector map */
cur_row_m = (guchar *) malloc ((x2 - x1 + 2) * src_bytes); /* magnitude map */
cur_row_v = g_new (guchar, (x2 - x1 + 2) * src_bytes); /* vector map */
cur_row_m = g_new (guchar, (x2 - x1 + 2) * src_bytes); /* magnitude map */
destx = (guchar *) malloc ((x2 - x1) * dest_bytes);
desty = (guchar *) malloc ((x2 - x1) * dest_bytes);
destx = g_new (guchar, (x2 - x1) * dest_bytes);
desty = g_new (guchar, (x2 - x1) * dest_bytes);
if ((desty==NULL) || (destx==NULL) || (cur_row_m==NULL) || (cur_row_v==NULL)
|| (next_row_g==NULL) || (cur_row_g==NULL) || (prev_row_g==NULL)
|| (next_row==NULL) || (cur_row==NULL) || (prev_row==NULL)) {
fprintf(stderr, _("Warp diff: error allocating memory.\n"));
fprintf(stderr, "Warp diff: error allocating memory.\n");
exit(1);
}
......@@ -1315,17 +1314,17 @@ diff (GDrawable *drawable,
gimp_progress_init ( _("Smoothing Y gradient..."));
blur16(draw_yd);
free (prev_row); /* row buffers allocated at top of fn. */
free (cur_row);
free (next_row);
free (prev_row_g); /* row buffers allocated at top of fn. */
free (cur_row_g);
free (next_row_g);
free (cur_row_v);
free (cur_row_m);
free (destx);
free (desty);
g_free (prev_row); /* row buffers allocated at top of fn. */
g_free (cur_row);
g_free (next_row);
g_free (prev_row_g); /* row buffers allocated at top of fn. */
g_free (cur_row_g);
g_free (next_row_g);
g_free (cur_row_v);
g_free (cur_row_m);
g_free (destx);
g_free (desty);
*xl_id = xlayer_id; /* pass back the X and Y layer ID numbers */
*yl_id = ylayer_id;
......
......@@ -710,7 +710,7 @@ not_bw_dialog (void)
if (!gtk_initialized)
{
fprintf (stderr, _("XBM: can only save two color indexed images\n"));
fprintf (stderr, "XBM: can only save two color indexed images\n");
return;
}
......
......@@ -206,7 +206,7 @@ static void do_zcrop(GDrawable *drawable, gint32 image_id)
if (((livingcols==0) || (livingrows==0)) ||
((livingcols==width) && (livingrows==height)))
{
printf(_("ZealousCrop(tm): Nothing to be done.\n"));
printf("ZealousCrop(tm): Nothing to be done.\n");
return;
}
......
......@@ -483,8 +483,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);
}
......
......@@ -277,7 +277,7 @@ doit (GDrawable * drawable)
bytes = drawable->bpp;
if (3 != bytes && 4 != bytes) {
fprintf(stderr, _("only works with three or four channels, not %d.\n"), bytes);
fprintf(stderr, "only works with three or four channels, not %d.\n", bytes);
return;
}
......
......@@ -672,7 +672,7 @@ pair_flt_create_value(t_pair *pair, char *title, GtkTable *table, int row, t_arr
if((*arr_ptr->flt_format != '%')
|| (arr_ptr->flt_format[strlen(arr_ptr->flt_format) -1] != 'f'))
{
printf( _("pair_flt_create_value: Bad FloatFormat ignored %s\n"), arr_ptr->flt_format);
printf( "pair_flt_create_value: Bad FloatFormat ignored %s\n", arr_ptr->flt_format);
arr_ptr->flt_format = "%0.2f";
}
}
......@@ -825,7 +825,7 @@ pair_int_create_value(t_pair *pair, char *title, GtkTable *table, int row, t_arr
if((*arr_ptr->int_format != '%')
|| (arr_ptr->int_format[strlen(arr_ptr->int_format) -1] != 'd'))
{
printf( _("pair_int_create_value: Bad IntFormat ignored %s\n"), arr_ptr->int_format);
printf ("pair_int_create_value: Bad IntFormat ignored %s\n", arr_ptr->int_format);
arr_ptr->int_format = "%d";
}
}
......@@ -1056,10 +1056,10 @@ gint p_array_std_dialog(char *title_txt,
label_create_value(l_label_txt, GTK_TABLE(table), (l_idx + 1), arr_ptr);
break;
case WGT_ACT_BUTTON:
printf( _("WGT_ACT_BUTTON not implemented yet, widget type ignored\n"));
printf ("WGT_ACT_BUTTON not implemented yet, widget type ignored\n");
break;
default: /* undefined widget type */
printf( _("Unknown widget type %d ignored\n"), arr_ptr->widget_type);
printf ("Unknown widget type %d ignored\n", arr_ptr->widget_type);
break;
} /* end switch */
......
......@@ -109,8 +109,8 @@ static gint p_pitstop(GRunModeType run_mode, char *plugin_name, gint text_flag,
char *step_backup_file, gint len_step_backup_file,
gint32 layer_idx)
{
char *l_env;
char l_msg[512];
gchar *l_env;
gchar *l_msg;
static t_but_arg l_but_argv[3];
gint l_but_argc;
gint l_argc;
......@@ -150,17 +150,19 @@ static gint p_pitstop(GRunModeType run_mode, char *plugin_name, gint text_flag,
}
if(text_flag == 0)
{
sprintf(l_msg, _("2.nd call of %s\n(define end-settings)"), plugin_name);
l_msg = g_strdup_printf (_("2.nd call of %s\n(define end-settings)"), plugin_name);
}
else
{
sprintf(l_msg, _("Non-Interactive call of %s\n(for all layers inbetween)"), plugin_name);
l_msg = g_strdup_printf (_("Non-Interactive call of %s\n(for all layers inbetween)"), plugin_name);
l_but_argc = 3;
l_argc = 1;
}
l_continue = p_array_std_dialog (_("Animated Filter apply"), l_msg,
l_argc, l_argv,
l_but_argc, l_but_argv, 0);
g_free (l_msg);
if(l_continue < 0) return -1;
else return l_continue;
......@@ -188,7 +190,7 @@ static void p_visibilty_restore(gint32 image_id, gint nlayers, int *visible_tab,
}
else
{
printf( _("Error: Plugin %s has changed Nr. of layers from %d to %d\ncould not restore Layer visibilty.\n"),
printf ("Error: Plugin %s has changed Nr. of layers from %d to %d\ncould not restore Layer visibilty.\n",
plugin_name, (int)nlayers, (int)l_nlayers2);
}
......@@ -204,12 +206,12 @@ static gint32 p_get_indexed_layerid(gint32 image_id, gint *nlayers, gint32 idx,
l_layers_list = gimp_image_get_layers(image_id, &l_nlayers2);
if(l_layers_list == NULL)
{
printf( _("Warning: cant get layers (maybe the image was closed)\n"));
printf ("Warning: cant get layers (maybe the image was closed)\n");
return -1;
}
if((l_nlayers2 != *nlayers) && (*nlayers > 0))
{
printf( _("Error: Plugin %s has changed Nr. of layers from %d to %d\nAnim Filter apply stopped.\n"),
printf ("Error: Plugin %s has changed Nr. of layers from %d to %d\nAnim Filter apply stopped.\n",
plugin_name, (int)*nlayers, (int)l_nlayers2);
return -1;
}
......@@ -260,7 +262,7 @@ int p_foreach_multilayer(GRunModeType run_mode, gint32 image_id,
l_rc = p_procedure_available(plugin_name, PTYP_CAN_OPERATE_ON_DRAWABLE);
if(l_rc < 0)
{
fprintf(stderr, _("ERROR: Plugin not available or wrong type %s\n"), plugin_name);
fprintf(stderr, "ERROR: Plugin not available or wrong type %s\n", plugin_name);
return -1;
}
......@@ -279,7 +281,7 @@ int p_foreach_multilayer(GRunModeType run_mode, gint32 image_id,
{
if(l_nlayers < 1)
{
fprintf(stderr, _("ERROR: need at 1 Layers to apply plugin !\n"));
fprintf(stderr, "ERROR: need at least 1 Layers to apply plugin !\n");
}
else
{
......@@ -309,7 +311,7 @@ int p_foreach_multilayer(GRunModeType run_mode, gint32 image_id,
l_child_pid = 0; /* fork(); */
if(l_child_pid < 0)
{
fprintf(stderr, _("ERROR: fork failed !\n"));
fprintf(stderr, "ERROR: fork failed !\n");
return -1;
}
......@@ -497,7 +499,7 @@ int p_foreach_multilayer(GRunModeType run_mode, gint32 image_id,
/* check if to save each step to backup file */
if((l_step_backup_file[0] != '\0') && (l_step_backup_file[0] != ' '))
{
printf( _("Saving image to backupfile:%s step = %d\n"),
printf ("Saving image to backupfile:%s step = %d\n",
l_step_backup_file, (int)l_idx);
p_save_xcf(image_id, l_step_backup_file);
}
......
......@@ -1790,9 +1790,9 @@ int gap_goto(GRunModeType run_mode, gint32 image_id, int nr)
int rc;
t_anim_info *ainfo_ptr;
long l_dest;
char l_hline[50];
char l_title[50];
long l_dest;
gchar *l_hline;
gchar *l_title;
rc = -1;
ainfo_ptr = p_alloc_ainfo(image_id, run_mode);
......@@ -1804,18 +1804,21 @@ int gap_goto(GRunModeType run_mode, gint32 image_id, int nr)
if(run_mode == RUN_INTERACTIVE)
{
sprintf(l_title, _("Goto Frame (%ld/%ld)")
, ainfo_ptr->curr_frame_nr
, ainfo_ptr->frame_cnt);
sprintf(l_hline, _("Destination Frame Number (%ld - %ld)")
, ainfo_ptr->first_frame_nr
, ainfo_ptr->last_frame_nr);
l_title = g_strdup_printf (_("Goto Frame (%ld/%ld)")
, ainfo_ptr->curr_frame_nr
, ainfo_ptr->frame_cnt);
l_hline = g_strdup_printf (_("Destination Frame Number (%ld - %ld)")
, ainfo_ptr->first_frame_nr
, ainfo_ptr->last_frame_nr);
l_dest = p_slider_dialog(l_title, l_hline, _("Number :"), NULL
, ainfo_ptr->first_frame_nr
, ainfo_ptr->last_frame_nr
, ainfo_ptr->curr_frame_nr
, TRUE);
g_free (l_title);
g_free (l_hline);
if(l_dest < 0)
{
......@@ -1856,8 +1859,8 @@ int gap_del(GRunModeType run_mode, gint32 image_id, int nr)
long l_cnt;
long l_max;
char l_hline[50];
char l_title[50];
gchar *l_hline;
gchar *l_title;
rc = -1;
ainfo_ptr = p_alloc_ainfo(image_id, run_mode);
......@@ -1869,11 +1872,11 @@ int gap_del(GRunModeType run_mode, gint32 image_id, int nr)
if(run_mode == RUN_INTERACTIVE)
{
sprintf(l_title, _("Delete Frames (%ld/%ld)")
, ainfo_ptr->curr_frame_nr
, ainfo_ptr->frame_cnt);
sprintf(l_hline, _("Delete Frames from %ld to (Number)")
, ainfo_ptr->curr_frame_nr);
l_title = g_strdup_printf (_("Delete Frames (%ld/%ld)")
, ainfo_ptr->curr_frame_nr
, ainfo_ptr->frame_cnt);
l_hline = g_strdup_printf (_("Delete Frames from %ld to (Number)")
, ainfo_ptr->curr_frame_nr);
l_max = ainfo_ptr->last_frame_nr;
if(l_max == ainfo_ptr->curr_frame_nr)
......@@ -1891,6 +1894,9 @@ int gap_del(GRunModeType run_mode, gint32 image_id, int nr)
, ainfo_ptr->curr_frame_nr
, TRUE);
g_free (l_title);
g_free (l_hline);
if(l_cnt >= 0)
{
l_cnt = 1 + l_cnt - ainfo_ptr->curr_frame_nr;
......@@ -1930,11 +1936,11 @@ int gap_del(GRunModeType run_mode, gint32 image_id, int nr)
int p_dup_dialog(t_anim_info *ainfo_ptr, long *range_from, long *range_to)
{
static t_arr_arg argv[3];
char l_title[50];
gchar *l_title;
sprintf(l_title, _("Duplicate Frames (%ld/%ld)")
, ainfo_ptr->curr_frame_nr
, ainfo_ptr->frame_cnt);
l_title = g_strdup_printf (_("Duplicate Frames (%ld/%ld)")
, ainfo_ptr->curr_frame_nr
, ainfo_ptr->frame_cnt);
p_init_arr_arg(&argv[0], WGT_INT_PAIR);
argv[0].label_txt = _("From :");
......@@ -1961,13 +1967,16 @@ int p_dup_dialog(t_anim_info *ainfo_ptr, long *range_from, long *range_to)
argv[2].help_txt = _("Copy selected Range n-times \n(you may type in Values > 99)");
if(TRUE == p_array_dialog(l_title, _("Duplicate Framerange"), 3, argv))
{ *range_from = (long)(argv[0].int_ret);
*range_to = (long)(argv[1].int_ret);
{
g_free (l_title);
*range_from = (long)(argv[0].int_ret);
*range_to = (long)(argv[1].int_ret);
return (int)(argv[2].int_ret);
}
else
{
return -1;
g_free (l_title);
return -1;
}
......@@ -2039,8 +2048,7 @@ int gap_exchg(GRunModeType run_mode, gint32 image_id, int nr)
long l_dest;
long l_initial;
char l_hline[50];
char l_title[50];
gchar *l_title;
rc = -1;
l_initial = 1;
......@@ -2061,16 +2069,16 @@ int gap_exchg(GRunModeType run_mode, gint32 image_id, int nr)
{
l_initial = ainfo_ptr->last_frame_nr;
}
sprintf(l_title, _("Exchange current Frame (%ld)")
, ainfo_ptr->curr_frame_nr);
sprintf(l_hline, _("With Frame (Number)"));
l_dest = p_slider_dialog(l_title, l_hline, _("Number :"), NULL