win32 locale bugs patches that work

Hello,
I have some patches for the win32 locale bugs (floating point output with komma instead point)
I made the diffs diff -u4 oldfile nexfile > difffile I am using a german winXP.
splivarot addresses simplify path repr-util addresses rect, circle output x and y etc. coordinates with komma instead point style addresses rect, cirlce output opacity etc. with komma instead point
I don't have access to the bugs page, so I don't know the numbers yet.
HTH,
Adib.
--- style.cpp 2004-03-26 16:16:46.000000000 +0100 +++ style.adib.cpp 2004-03-26 16:10:56.000000000 +0100 @@ -36,8 +36,9 @@ #include "marker-status.h" #include "uri-references.h" #include "sp-paint-server.h" #include "style.h" +#include "stringstream.h"
namespace Inkscape {
@@ -2044,14 +2045,17 @@ */ static gint sp_style_write_ifloat (gchar *p, gint len, const gchar *key, SPIFloat *val, SPIFloat *base, guint flags) { + Inkscape::SVGOStringStream os; + if (((flags & SP_STYLE_FLAG_IFSET) && val->set) || ((flags & SP_STYLE_FLAG_IFDIFF) && val->set && (val->value != base->value))) { if (val->inherit) { return g_snprintf (p, len, "%s:inherit;", key); } else { - return g_snprintf (p, len, "%s:%g;", key, val->value); + os << key << ":" << val->value << ";"; + return g_strlcpy (p, os.str().c_str(), len); } } return 0; } @@ -2062,15 +2066,17 @@ */ static gint sp_style_write_iscale24 (gchar *p, gint len, const gchar *key, SPIScale24 *val, SPIScale24 *base, guint flags) { + Inkscape::SVGOStringStream os;
if (((flags & SP_STYLE_FLAG_IFSET) && val->set) || ((flags & SP_STYLE_FLAG_IFDIFF) && val->set && (val->value != base->value))) { if (val->inherit) { return g_snprintf (p, len, "%s:inherit;", key); } else { - return g_snprintf (p, len, "%s:%g;", key, SP_SCALE24_TO_FLOAT (val->value)); + os << key << ":" << SP_SCALE24_TO_FLOAT(val->value) << ";"; + return g_strlcpy (p, os.str().c_str(), len); } } return 0; }
--- splivarot.cpp 2004-03-26 16:16:04.000000000 +0100 +++ splivarot.adib.cpp 2004-03-26 14:58:33.000000000 +0100 @@ -17,8 +17,9 @@
#include <libart_lgpl/art_misc.h> #include "xml/repr.h" #include "svg/svg.h" +#include "stringstream.h" #include "sp-path.h" #include "sp-text.h" #include "style.h" #include "inkscape.h" @@ -1544,24 +1545,23 @@
gchar * liv_svg_dump_path (Path * path) { - GString *result; - result = g_string_sized_new (40); + Inkscape::SVGOStringStream os;
for (int i = 0; i < path->descr_nb; i++) { Path::path_descr theD = path->descr_cmd[i]; int typ = theD.flags & descr_type_mask; if (typ == descr_moveto) { Path::path_descr_moveto* nData=(Path::path_descr_moveto*)(path->descr_data+theD.dStart); - g_string_sprintfa (result, "M %lf %lf ", nData->p[0], nData->p[1]); + os << "M " << nData->p[0] << " " << nData->p[1] << " "; } else if (typ == descr_lineto) { Path::path_descr_lineto* nData=(Path::path_descr_lineto*)(path->descr_data+theD.dStart); - g_string_sprintfa (result, "L %lf %lf ", nData->p[0], nData->p[1]); + os << "L " << nData->p[0] << " " << nData->p[1] << " "; } else if (typ == descr_cubicto) { Path::path_descr_cubicto* nData=(Path::path_descr_cubicto*)(path->descr_data+theD.dStart); @@ -1570,32 +1570,34 @@ NR::Point tmp = path->PrevPoint (i - 1); lastX=tmp[0]; lastY=tmp[1]; } - g_string_sprintfa (result, "C %lf %lf %lf %lf %lf %lf ", - lastX + nData->stD[0] / 3, - lastY + nData->stD[1] / 3, - nData->p[0] - nData->enD[0] / 3, - nData->p[1] - nData->enD[1] / 3, nData->p[0],nData->p[1]); - } + os << "C " << lastX + nData->stD[0] / 3 << " " + << lastY + nData->stD[1] / 3 << " " + << nData->p[0] - nData->enD[0] / 3 << " " + << nData->p[1] - nData->enD[1] / 3 << " " + << nData->p[0] << " " + << nData->p[1] << " "; + } else if (typ == descr_arcto) { Path::path_descr_arcto* nData=(Path::path_descr_arcto*)(path->descr_data+theD.dStart); - // g_string_sprintfa (result, "L %lf %lf ",theD.d.a.x,theD.d.a.y); - g_string_sprintfa (result, "A %g %g %g %i %i %g %g ", nData->rx,nData->ry, nData->angle, - (nData->large) ? 1 : 0,(nData->clockwise) ? 0 : 1, nData->p[NR::X],nData->p[NR::Y]); + os << "A " << nData->rx << " " + << nData->ry << " " + << nData->angle << " " + << ((nData->large) ? "1" : "0") << " " + << ((nData->clockwise) ? "0" : "1") << " " + << nData->p[NR::X] << " " + << nData->p[NR::Y] << " "; } else if (typ == descr_close) { - g_string_sprintfa (result, "z "); + os << "z "; } else { } }
- char *res; - res = result->str; - g_string_free (result, FALSE); - - return res; + return g_strdup (os.str().c_str()); + }
--- repr-util.cpp 2004-03-26 16:24:02.000000000 +0100 +++ repr-util.adib.cpp 2004-03-26 15:35:13.000000000 +0100 @@ -29,8 +29,9 @@
#include <glib.h>
#include "repr-private.h" +#include "stringstream.h"
/*##################### # DEFINITIONS #####################*/ @@ -630,21 +631,16 @@
unsigned int sp_repr_set_double (SPRepr *repr, const gchar *key, double val) { - gchar c[32]; - + Inkscape::SVGOStringStream os; + g_return_val_if_fail (repr != NULL, FALSE); g_return_val_if_fail (key != NULL, FALSE);
- //## This can be done in several ways. g_ascii_formatd() - //## might be the best for now. g_snprintf() can be - //## affected by LOCALE. g_ascii_formatd() is always "C" locale. - //g_snprintf (c, 32, "%.8f", val); - //sp_xml_dtoa (c, val, 8, 0, FALSE); - g_ascii_formatd (c, sizeof (c), "%.8f", val); - - return sp_repr_set_attr (repr, key, c); + os << val; + + return sp_repr_set_attr (repr, key, os.str().c_str()); }
unsigned int sp_repr_set_double_default (SPRepr *repr, const gchar *key, double val, double def, double e)
participants (1)
-
Adib Taraben