my win32 patch does not work, why (splivarot.cpp)
Hello, I tried to start to fix those (win32) locale problems with the float numbers.
In the file splivarot.cpp which is the "simplify path" command I replaced the printf's with g_ascii_formatd. This function is locale independent. Unfortunately it does not solve the problem.
Anyhow what is the desired method generating locale undependent number output? Am I on the right way?
Thanks,
Adib.
--- splivarot_org.cpp 2004-03-14 17:09:02.000000000 +0100 +++ splivarot.cpp 2004-03-16 14:57:26.000000000 +0100 @@ -1542,34 +1542,45 @@ 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]); + gchar cX[33], cY[33]; + g_string_sprintfa (result, "M %s %s ", g_ascii_formatd(cX, 32, "%f", nData->p[0]), g_ascii_formatd(cY, 32, "%f", 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]); + gchar cX[33], cY[33]; + g_string_sprintfa (result, "L %s %s ", g_ascii_formatd(cX, 32, "%f", nData->p[0]), g_ascii_formatd(cY, 32, "%f", nData->p[1])); } else if (typ == descr_cubicto) { Path::path_descr_cubicto* nData=(Path::path_descr_cubicto*)(path->descr_data+theD.dStart); float lastX, lastY; + gchar cX1[33], cY1[33], cX2[33], cY2[33], cX[33], cY[33]; { 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]); + g_string_sprintfa (result, "C %s %s %s %s %s %s ", + g_ascii_formatd(cX1, 32, "%f", lastX + nData->stD[0] / 3), + g_ascii_formatd(cY1, 32, "%f", lastY + nData->stD[1] / 3), + g_ascii_formatd(cX2, 32, "%f", nData->p[0] - nData->enD[0] / 3), + g_ascii_formatd(cY2, 32, "%f", nData->p[1] - nData->enD[1] / 3), + g_ascii_formatd(cX, 32, "%f", nData->p[0]), + g_ascii_formatd(cY, 32, "%f", nData->p[1])); } else if (typ == descr_arcto) { Path::path_descr_arcto* nData=(Path::path_descr_arcto*)(path->descr_data+theD.dStart); + gchar cRX[33], cRY[33], cA[33], cSX[33], cSY[33]; // 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]); + g_string_sprintfa (result, "A %s %s %s %i %i %s %s ", + g_ascii_formatd(cRX, 32, "%f", nData->rx), + g_ascii_formatd(cRY, 32, "%f", nData->ry), + g_ascii_formatd(cA, 32, "%f", nData->angle), + (nData->large) ? 1 : 0, (nData->clockwise) ? 0 : 1, + g_ascii_formatd(cSX, 32, "%f", nData->p[NR::X]), + g_ascii_formatd(cSY, 32, "%f", nData->p[NR::Y])); } else if (typ == descr_close) {
On Tue, 2004-03-16 at 09:07, Adib Taraben wrote:
Anyhow what is the desired method generating locale undependent number output?
The preferred method at this point is std::ostreams (typically ostringstreams, currently) imbued with the default C locale.
I believe bulia has introduced a stringstream subclass that takes care of the locale/formatting setup; ask him for details. I believe bulia is be working the locale/numeric things himself actually.
-mental
participants (2)
-
Adib Taraben
-
MenTaLguY