Hello!

On Wed, May 21, 2008 at 10:53:13AM +0200, Michael Hanke wrote:
> On Tue, May 20, 2008 at 11:12:37PM +0200, Philipp Matthias Hahn wrote:
> > Package: qlandkarte
> > Version: 0.7.2~dfsg.1-1
> > Severity: important
> > 
> > Upstream-Bug, please forward.
> > 
> > Depending on which locale is set when QLandkarte is launched, the saved
> > .gpx files contain differenr number-formats in the @lon and @lat
> > attribute of track-points. For example, Germany uses ',' whilte the USA
> > use '.' as the floatingpoint-delimiter.
> I cannot reproduce this bug, nor can upstream. I tried with your LANG
> settings and I always get '.' as the delimiter. Whatever causes this bug
> on your system seems to be within Qt. Please also see upstream's
> response:
> 
> http://sourceforge.net/mailarchive/forum.php?thread_name=20080521053226.GB3492%40localhost&forum_name=qlandkarte-users

It's not the fault of QLandkarte, but Qt4 seams to be broken to use
"printf(%g)" for the conversion of doubles to strings. Please consider
re-assigning this bug to qt4-x11. Nether the less it affects QLandkarte.

$ locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

qt4-x11-4.4.0/src/xml/dom/qdom.cpp:4823
        void QDomElement::setAttribute(const QString& name, double value)
        {
            if (!impl)
                return;
            QString x;
            char buf[256];
            int count = qsnprintf(buf, sizeof(buf), "%.16g", value);

$ gdb bin/qlandkarte
(gdb) s
QDomElement::setAttribute (this=0xbfe82550, [EMAIL PROTECTED],
    value=53.125089034438133) at dom/qdom.cpp:4825
            ^
(gdb) n
4829        int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
                                                     ^^^^^
(gdb) print buf
$14 = "53,12508903443813\000...
         ^

qt4-x11-4.4.0/src/corelib/tools/qvsnprintf.cpp:77
        int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
        {
            if (!str || !fmt)
                return -1;

            QString buf;
            buf.vsprintf(fmt, ap);

qt4-x11-4.4.0/src/corelib/tools/qstring.cpp:4542
        QString &QString::vsprintf(const char* cformat, va_list ap)
        {
...:4760
            case 'g':
...:4780
                subst = locale.d()->doubleToString(d, precision, form, width, 
flags);

qt4-x11-4.4.0/src/corelib/tools/qlocale.cpp:3601
        QString QLocalePrivate::doubleToString(double d,
                                               int precision,
                                               DoubleForm form,
                                               int width,
                                               unsigned flags) const
        {
...:3707
                    num_str = decimalForm(digits, decpt, precision, mode,
                                            always_show_decpt, flags & 
ThousandsGroup,
                                            *this);

qt4-x11-4.4.0/src/corelib/tools/qlocale.cpp:3304
        static QString &decimalForm(QString &digits, int decpt, uint precision,
                                    PrecisionMode pm,
                                    bool always_show_decpt,
                                    bool thousands_group,
                                    const QLocalePrivate &locale)
        {
...:3333
                digits.insert(decpt, locale.decimal());

I'll also attach my short test program "dom.cc" to be compiled with
        c++ -I/usr/include/qt4 -lQtXml -o dom dom.cc

#include <Qt/qdom.h>
#include <Qt/qlocale.h>
#include <iostream>
#include <locale.h>

int main(int argc, char **argv, char **env) {
        double value = 3.1415 + argc;

        setlocale(LC_ALL, "");
        QLocale::setDefault( QLocale::system() );

        QString x;
        char buf[256];
        int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
        if (count > 0) {
                x = QString::fromLatin1(buf, count);
                std::cout << qPrintable(x) << std::endl;
        }

        x.setNum(value); // Fallback
        std::cout << qPrintable(x) << std::endl;

        QDomDocument doc( "root" );
        QDomElement root = doc.createElement( "root" );
        root.setAttribute( "double", value );
        doc.appendChild( root );
        QString xml = doc.toString();
        std::cout << qPrintable(xml) << std::endl;

        return 0;
}

LANG=en_US.UTF-8 ./dom
        4.141500000000001
        4.1415
        <!DOCTYPE root>
        <root double="4.141500000000001" />

LANG=de_DE.UTF-8 ./dom
        4,141500000000001
        4.1415
        <!DOCTYPE root>
        <root double="4,141500000000001" />

> On this system I'm running qt 4.3. Could you try if the bug also
> occurs with Qt 4.3 instead of 4.4?

I currently don't have access to any machine running Qt 4.3, but if I
find one I'll send another mail with the output of my test programm.

BYtE
Philipp
-- 
Philipp Matthias Hahn <[EMAIL PROTECTED]>
 GPG/PGP: 9A540E39 @ keyrings.debian.org



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to