[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/khtml/xml
From:       Andrew Coles <andrew_coles () yahoo ! co ! uk>
Date:       2004-10-19 15:58:55
Message-ID: 20041019155855.F033716C84 () office ! kde ! org
[Download RAW message or body]

CVS commit by coles: 



OK, so now it's back to where I started: the invalid behaviour in toLengthArray
was a red herring brought about by the single % character special case in
parseLength.


  M +8 -11     dom_stringimpl.cpp   1.54


--- kdelibs/khtml/xml/dom_stringimpl.cpp  #1.53:1.54
@@ -204,5 +204,6 @@ khtml::Length* DOMStringImpl::toLengthAr
 {
     QString str(s, l);
-
+    int pos = 0;
+    int pos2;
 
     // web authors are so stupid. This is a workaround
@@ -219,16 +219,13 @@ khtml::Length* DOMStringImpl::toLengthAr
     str = str.simplifyWhiteSpace();
 
-    QStringList segments = QStringList::split(QString(" "), str);
-
-    len = segments.size();
+    len = str.contains(' ') + 1;
     khtml::Length* r = new khtml::Length[len];
-
     int i = 0;
-
-    for ( QStringList::Iterator it = segments.begin(); it != segments.end(); ++it, ++i ) {
-        const QChar* const startPtr = (*it).unicode();
-        const unsigned int l = (*it).length();
-        r[i] = parseLength(startPtr, l);
+    while((pos2 = str.find(' ', pos)) != -1)
+    {
+        r[i++] = parseLength((QChar *) str.unicode()+pos, pos2-pos);
+        pos = pos2+1;
     }
+    r[i] = parseLength((QChar *) str.unicode()+pos, str.length()-pos);
 
     return r;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic