Commit 090380ad authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

plug-ins/script-fu/script-fu-scripts.c plug-ins/script-fu/interp_slib.c

2002-11-08  Sven Neumann  <sven@gimp.org>

	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/interp_slib.c
	* plug-ins/script-fu/interp_sliba.c: use locale-independant
	functions to convert between strings and numbers so that Script-Fu
	doesn't get confused in locales that don't use a dot as the
	decimal point (#98014).

	* plug-ins/common/papertile.c: applied a patch from David Necas
	that makes the color button work again (#97976).
parent 31408770
2002-11-08 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/interp_slib.c
* plug-ins/script-fu/interp_sliba.c: use locale-independant
functions to convert between strings and numbers so that Script-Fu
doesn't get confused in locales that don't use a dot as the
decimal point (#98014).
* plug-ins/common/papertile.c: applied a patch from David Necas
that makes the color button work again (#97976).
2002-11-07 Dave Neary <bolsh@gimp.org>
 
* plug-ins/common/xbm.c: Applied patch from Raphael
......
......@@ -18,7 +18,7 @@
this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*============================================================================*/
*===========================================================================*/
#include "config.h"
......@@ -31,15 +31,15 @@
#include "libgimp/stdplugins-intl.h"
/*============================================================================*/
/* DEFINES */
/*============================================================================*/
/*===========================================================================*/
/* DEFINES */
/*===========================================================================*/
#define PLUGIN_PROCEDURE_NAME "plug_in_papertile"
/*============================================================================*/
/* TYPES */
/*============================================================================*/
/*===========================================================================*/
/* TYPES */
/*===========================================================================*/
typedef enum
{
......@@ -72,9 +72,9 @@ struct _PluginParams
GimpRGB background_color;
};
/*============================================================================*/
/* VARIABLES */
/*============================================================================*/
/*===========================================================================*/
/* VARIABLES */
/*===========================================================================*/
static struct
{
......@@ -120,7 +120,7 @@ static struct
FALSE /* run */
};
/*----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
params_save_to_gimp (void)
......@@ -159,9 +159,9 @@ params_load_from_gimp (void)
}
}
/*============================================================================*/
/* GUI */
/*============================================================================*/
/*===========================================================================*/
/* GUI */
/*===========================================================================*/
static struct
{
......@@ -331,7 +331,8 @@ open_dialog (void)
gtk_widget_show (sep);
button = gtk_check_button_new_with_mnemonic(_("C_entering"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), p.params.centering);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
p.params.centering);
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
gtk_widget_show (button);
......@@ -389,7 +390,7 @@ open_dialog (void)
(gpointer) BACKGROUND_TYPE_FOREGROUND, NULL,
_("Bac_kground Color"),
(gpointer) BACKGROUND_TYPE_BACKGROUND, NULL,
(gpointer) 1, /* button without label */
_("S_elect here:"),
(gpointer) BACKGROUND_TYPE_COLOR, &button,
NULL);
......@@ -401,7 +402,8 @@ open_dialog (void)
p.drawable_has_alpha ?
GIMP_COLOR_AREA_SMALL_CHECKS :
GIMP_COLOR_AREA_FLAT);
gtk_container_add (GTK_CONTAINER (button), color_button);
gtk_box_pack_start (GTK_BOX (GTK_BIN (frame)->child),
color_button, TRUE, TRUE, 0);
gtk_widget_show (color_button);
gtk_widget_set_sensitive (color_button,
......@@ -418,9 +420,9 @@ open_dialog (void)
gdk_flush ();
}
/*============================================================================*/
/* PLUGIN CORE */
/*============================================================================*/
/*===========================================================================*/
/* PLUGIN CORE */
/*===========================================================================*/
typedef struct _Tile
{
guint x;
......@@ -793,7 +795,8 @@ filter (void)
gimp_drawable_flush (p.drawable);
gimp_drawable_merge_shadow (p.drawable->drawable_id, TRUE);
gimp_drawable_update (p.drawable->drawable_id, p.selection.x0, p.selection.y0,
gimp_drawable_update (p.drawable->drawable_id,
p.selection.x0, p.selection.y0,
p.selection.width, p.selection.height);
g_free (buffer);
......
......@@ -2711,7 +2711,7 @@ lprin1g (LISP exp, struct gen_printio * f)
if (((double) n) == FLONM (exp))
sprintf (tkbuffer, "%ld", n);
else
sprintf (tkbuffer, "%g", FLONM (exp));
g_ascii_formatd (tkbuffer, sizeof(tkbuffer), "%g", FLONM (exp));
gput_st (f, tkbuffer);
break;
case tc_symbol:
......@@ -3011,7 +3011,7 @@ lreadtk (char *buffer, long j)
}
if (*p)
goto a_symbol;
return (flocons (atof (buffer)));
return (flocons (g_ascii_strtod (buffer, NULL)));
a_symbol:
return (rintern (buffer));
}
......@@ -3392,7 +3392,7 @@ parse_number (LISP x)
{
char *c;
c = get_c_string (x);
return (flocons (atof (c)));
return (flocons (g_ascii_strtod (c, NULL)));
}
void
......
......@@ -17,6 +17,8 @@
#include <ctype.h>
#include <math.h>
#include <glib.h>
#include "siod.h"
#include "siodp.h"
......@@ -166,7 +168,8 @@ array_prin1 (LISP ptr, struct gen_printio *f)
gput_st (f, "#(");
for (j = 0; j < ptr->storage_as.double_array.dim; ++j)
{
sprintf (tkbuffer, "%g", ptr->storage_as.double_array.data[j]);
g_ascii_formatd (tkbuffer, sizeof(tkbuffer), "%g",
ptr->storage_as.double_array.data[j]);
gput_st (f, tkbuffer);
if ((j + 1) < ptr->storage_as.double_array.dim)
gput_st (f, " ");
......@@ -1482,26 +1485,25 @@ number2string (LISP x, LISP b, LISP w, LISP p)
my_err ("precision too large", p);
if (NULLP (b) || EQ (sym_e, b) || EQ (sym_f, b))
{
char format[32];
if ((width >= 0) && (prec >= 0))
sprintf (buffer,
NULLP (b) ? "% *.*g" : EQ (sym_e, b) ? "% *.*e" : "% *.*f",
width,
prec,
y);
sprintf (format,
NULLP (b) ? "%%%d.%dg" :
EQ (sym_e, b) ? "%%%d.%dd" : "%%%d.%df",
width, prec);
else if (width >= 0)
sprintf (buffer,
NULLP (b) ? "% *g" : EQ (sym_e, b) ? "% *e" : "% *f",
width,
y);
sprintf (format,
NULLP (b) ? "%%%dg" : EQ (sym_e, b) ? "%%%de" : "%%%df",
width);
else if (prec >= 0)
sprintf (buffer,
NULLP (b) ? "%.*g" : EQ (sym_e, b) ? "%.*e" : "%.*f",
prec,
y);
sprintf (format,
NULLP (b) ? "%%.%dg" : EQ (sym_e, b) ? "%%.%de" : "%%.%df",
prec);
else
sprintf (buffer,
NULLP (b) ? "%g" : EQ (sym_e, b) ? "%e" : "%f",
y);
sprintf (format, NULLP (b) ? "%g" : EQ (sym_e, b) ? "%e" : "%f");
g_ascii_formatd (buffer, sizeof(buffer), format, y);
}
else if (((base = get_c_long (b)) == 10) || (base == 8) || (base == 16))
{
......@@ -1529,7 +1531,7 @@ string2number (LISP x, LISP b)
str = get_c_string (x);
if NULLP
(b)
result = atof (str);
result = g_ascii_strtod (str, NULL);
else if ((base = get_c_long (b)) == 10)
{
sscanf (str, "%ld", &value);
......
......@@ -1226,11 +1226,7 @@ script_fu_interface (SFScript *script)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
sf_interface->status = gtk_label_new (NULL);
buf = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>",
sf_interface->title);
gtk_label_set_markup (GTK_LABEL (sf_interface->status), buf);
g_free (buf);
sf_interface->status = gtk_label_new (sf_interface->title);
gtk_misc_set_alignment (GTK_MISC (sf_interface->status), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), sf_interface->status, TRUE, TRUE, 0);
gtk_widget_show (sf_interface->status);
......@@ -1782,22 +1778,21 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_ADJUSTMENT:
switch (script->arg_defaults[i].sfa_adjustment.type)
{
case SF_SLIDER:
script->arg_values[i].sfa_adjustment.value =
script->arg_values[i].sfa_adjustment.adj->value;
g_snprintf (buffer, sizeof (buffer), "%f",
script->arg_values[i].sfa_adjustment.value);
text = buffer;
switch (script->arg_defaults[i].sfa_adjustment.type)
{
case SF_SLIDER:
script->arg_values[i].sfa_adjustment.value =
script->arg_values[i].sfa_adjustment.adj->value;
text = g_ascii_dtostr (buffer, sizeof (buffer),
script->arg_values[i].sfa_adjustment.value);
break;
case SF_SPINNER:
script->arg_values[i].sfa_adjustment.value =
gtk_spin_button_get_value (GTK_SPIN_BUTTON (sf_interface->args_widgets[i]));
g_snprintf (buffer, sizeof (buffer), "%f",
script->arg_values[i].sfa_adjustment.value);
text = buffer;
text = g_ascii_dtostr (buffer, sizeof (buffer),
script->arg_values[i].sfa_adjustment.value);
break;
default:
......@@ -1833,13 +1828,20 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_BRUSH:
g_snprintf (buffer, sizeof (buffer), "'(\"%s\" %f %d %d)",
script->arg_values[i].sfa_brush.name,
script->arg_values[i].sfa_brush.opacity,
script->arg_values[i].sfa_brush.spacing,
script->arg_values[i].sfa_brush.paint_mode);
text = buffer;
break;
{
gchar opacity[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr (opacity, sizeof (opacity),
script->arg_values[i].sfa_brush.opacity);
g_snprintf (buffer, sizeof (buffer), "'(\"%s\" %s %d %d)",
script->arg_values[i].sfa_brush.name,
opacity,
script->arg_values[i].sfa_brush.spacing,
script->arg_values[i].sfa_brush.paint_mode);
text = buffer;
}
break;
case SF_OPTION:
menu_item =
......
......@@ -1226,11 +1226,7 @@ script_fu_interface (SFScript *script)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
sf_interface->status = gtk_label_new (NULL);
buf = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>",
sf_interface->title);
gtk_label_set_markup (GTK_LABEL (sf_interface->status), buf);
g_free (buf);
sf_interface->status = gtk_label_new (sf_interface->title);
gtk_misc_set_alignment (GTK_MISC (sf_interface->status), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), sf_interface->status, TRUE, TRUE, 0);
gtk_widget_show (sf_interface->status);
......@@ -1782,22 +1778,21 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_ADJUSTMENT:
switch (script->arg_defaults[i].sfa_adjustment.type)
{
case SF_SLIDER:
script->arg_values[i].sfa_adjustment.value =
script->arg_values[i].sfa_adjustment.adj->value;
g_snprintf (buffer, sizeof (buffer), "%f",
script->arg_values[i].sfa_adjustment.value);
text = buffer;
switch (script->arg_defaults[i].sfa_adjustment.type)
{
case SF_SLIDER:
script->arg_values[i].sfa_adjustment.value =
script->arg_values[i].sfa_adjustment.adj->value;
text = g_ascii_dtostr (buffer, sizeof (buffer),
script->arg_values[i].sfa_adjustment.value);
break;
case SF_SPINNER:
script->arg_values[i].sfa_adjustment.value =
gtk_spin_button_get_value (GTK_SPIN_BUTTON (sf_interface->args_widgets[i]));
g_snprintf (buffer, sizeof (buffer), "%f",
script->arg_values[i].sfa_adjustment.value);
text = buffer;
text = g_ascii_dtostr (buffer, sizeof (buffer),
script->arg_values[i].sfa_adjustment.value);
break;
default:
......@@ -1833,13 +1828,20 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_BRUSH:
g_snprintf (buffer, sizeof (buffer), "'(\"%s\" %f %d %d)",
script->arg_values[i].sfa_brush.name,
script->arg_values[i].sfa_brush.opacity,
script->arg_values[i].sfa_brush.spacing,
script->arg_values[i].sfa_brush.paint_mode);
text = buffer;
break;
{
gchar opacity[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr (opacity, sizeof (opacity),
script->arg_values[i].sfa_brush.opacity);
g_snprintf (buffer, sizeof (buffer), "'(\"%s\" %s %d %d)",
script->arg_values[i].sfa_brush.name,
opacity,
script->arg_values[i].sfa_brush.spacing,
script->arg_values[i].sfa_brush.paint_mode);
text = buffer;
}
break;
case SF_OPTION:
menu_item =
......
......@@ -2711,7 +2711,7 @@ lprin1g (LISP exp, struct gen_printio * f)
if (((double) n) == FLONM (exp))
sprintf (tkbuffer, "%ld", n);
else
sprintf (tkbuffer, "%g", FLONM (exp));
g_ascii_formatd (tkbuffer, sizeof(tkbuffer), "%g", FLONM (exp));
gput_st (f, tkbuffer);
break;
case tc_symbol:
......@@ -3011,7 +3011,7 @@ lreadtk (char *buffer, long j)
}
if (*p)
goto a_symbol;
return (flocons (atof (buffer)));
return (flocons (g_ascii_strtod (buffer, NULL)));
a_symbol:
return (rintern (buffer));
}
......@@ -3392,7 +3392,7 @@ parse_number (LISP x)
{
char *c;
c = get_c_string (x);
return (flocons (atof (c)));
return (flocons (g_ascii_strtod (c, NULL)));
}
void
......
......@@ -17,6 +17,8 @@
#include <ctype.h>
#include <math.h>
#include <glib.h>
#include "siod.h"
#include "siodp.h"
......@@ -166,7 +168,8 @@ array_prin1 (LISP ptr, struct gen_printio *f)
gput_st (f, "#(");
for (j = 0; j < ptr->storage_as.double_array.dim; ++j)
{
sprintf (tkbuffer, "%g", ptr->storage_as.double_array.data[j]);
g_ascii_formatd (tkbuffer, sizeof(tkbuffer), "%g",
ptr->storage_as.double_array.data[j]);
gput_st (f, tkbuffer);
if ((j + 1) < ptr->storage_as.double_array.dim)
gput_st (f, " ");
......@@ -1482,26 +1485,25 @@ number2string (LISP x, LISP b, LISP w, LISP p)
my_err ("precision too large", p);
if (NULLP (b) || EQ (sym_e, b) || EQ (sym_f, b))
{
char format[32];
if ((width >= 0) && (prec >= 0))
sprintf (buffer,
NULLP (b) ? "% *.*g" : EQ (sym_e, b) ? "% *.*e" : "% *.*f",
width,
prec,
y);
sprintf (format,
NULLP (b) ? "%%%d.%dg" :
EQ (sym_e, b) ? "%%%d.%dd" : "%%%d.%df",
width, prec);
else if (width >= 0)
sprintf (buffer,
NULLP (b) ? "% *g" : EQ (sym_e, b) ? "% *e" : "% *f",
width,
y);
sprintf (format,
NULLP (b) ? "%%%dg" : EQ (sym_e, b) ? "%%%de" : "%%%df",
width);
else if (prec >= 0)
sprintf (buffer,
NULLP (b) ? "%.*g" : EQ (sym_e, b) ? "%.*e" : "%.*f",
prec,
y);
sprintf (format,
NULLP (b) ? "%%.%dg" : EQ (sym_e, b) ? "%%.%de" : "%%.%df",
prec);
else
sprintf (buffer,
NULLP (b) ? "%g" : EQ (sym_e, b) ? "%e" : "%f",
y);
sprintf (format, NULLP (b) ? "%g" : EQ (sym_e, b) ? "%e" : "%f");
g_ascii_formatd (buffer, sizeof(buffer), format, y);
}
else if (((base = get_c_long (b)) == 10) || (base == 8) || (base == 16))
{
......@@ -1529,7 +1531,7 @@ string2number (LISP x, LISP b)
str = get_c_string (x);
if NULLP
(b)
result = atof (str);
result = g_ascii_strtod (str, NULL);
else if ((base = get_c_long (b)) == 10)
{
sscanf (str, "%ld", &value);
......
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