[Pkg-kde-commits] rev 1740 - in branches/kde-3.4.0/packages/kdelibs/debian: . patches

Adeodato Simó adeodato at costa.debian.org
Wed Sep 7 22:14:33 UTC 2005


Author: adeodato
Date: 2005-09-07 22:14:32 +0000 (Wed, 07 Sep 2005)
New Revision: 1740

Added:
   branches/kde-3.4.0/packages/kdelibs/debian/patches/22_htmltokenizer_cpp_from_3_5.diff
Modified:
   branches/kde-3.4.0/packages/kdelibs/debian/changelog
Log:
Fix this annoying "konqueror does not show blank lines in <pre> mode"
bug. Tried patch in upstream's #105148 but was not enough, so
backported/copied the whole file.


Modified: branches/kde-3.4.0/packages/kdelibs/debian/changelog
===================================================================
--- branches/kde-3.4.0/packages/kdelibs/debian/changelog	2005-09-07 21:10:08 UTC (rev 1739)
+++ branches/kde-3.4.0/packages/kdelibs/debian/changelog	2005-09-07 22:14:32 UTC (rev 1740)
@@ -1,3 +1,14 @@
+kdelibs (4:3.4.2-4) UNRELEASED; urgency=low
+
+  +++ Changes by Adeodato Simó:
+
+  * Use khtml/html/htmltokenizer.cpp from 3.5 to fix bogus parsing of
+    whitespace around tags found inside <pre>. This was making konqueror
+    sometimes ignore blank lines in pre mode, which made this friendly
+    maintainer of yours terribly unhappy when visiting bts.turmzimmer.net.
+
+ -- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>  Date
+
 kdelibs (4:3.4.2-3) unstable; urgency=low
 
   +++ Changes by Adeodato Simó:

Added: branches/kde-3.4.0/packages/kdelibs/debian/patches/22_htmltokenizer_cpp_from_3_5.diff
===================================================================
--- branches/kde-3.4.0/packages/kdelibs/debian/patches/22_htmltokenizer_cpp_from_3_5.diff	2005-09-07 21:10:08 UTC (rev 1739)
+++ branches/kde-3.4.0/packages/kdelibs/debian/patches/22_htmltokenizer_cpp_from_3_5.diff	2005-09-07 22:14:32 UTC (rev 1740)
@@ -0,0 +1,318 @@
+--- kdelibs/khtml/html/htmltokenizer.cpp
++++ kdelibs/khtml/html/htmltokenizer.cpp
+@@ -21,8 +21,8 @@
+ 
+     You should have received a copy of the GNU Library General Public License
+     along with this library; see the file COPYING.LIB.  If not, write to
+-    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+-    Boston, MA 02111-1307, USA.
++    the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
++    Boston, MA 02110-1301, USA.
+ */
+ //----------------------------------------------------------------------------
+ //
+@@ -319,6 +319,8 @@
+         unsigned char ch = src->latin1();
+         if ( !scriptCodeResync && !brokenComments && !textarea && !xmp && !title && ch == '-' && scriptCodeSize >= 3 && !src.escaped() && QConstString( scriptCode+scriptCodeSize-3, 3 ).string() == "<!-" ) {
+             comment = true;
++            scriptCode[ scriptCodeSize++ ] = ch;
++            ++src;
+             parseComment( src );
+             continue;
+         }
+@@ -443,33 +445,62 @@
+ 
+ void HTMLTokenizer::parseComment(TokenizerString &src)
+ {
++    // SGML strict
++    bool strict = parser->doc()->inStrictMode() && parser->doc()->htmlMode() != DocumentImpl::XHtml;
++    int delimiterCount = 0;
++    bool canClose = false;
++
+     checkScriptBuffer(src.length());
+     while ( src.length() ) {
+         scriptCode[ scriptCodeSize++ ] = *src;
++
+ #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 1
+         qDebug("comment is now: *%s*",
+                QConstString((QChar*)src.current(), kMin(16U, src.length())).string().latin1());
+ #endif
+-        if (src->unicode() == '>' &&
+-            ( ( brokenComments && !( script || style ) ) ||
+-              ( scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' &&
+-                scriptCode[scriptCodeSize-2] == '-' ) ) ) {
+-            ++src;
+-            if ( !( script || xmp || textarea || style) ) {
++
++        if (strict)
++        {
++            if (src->unicode() == '-') {
++                delimiterCount++;
++                if (delimiterCount == 2) {
++                    delimiterCount = 0;
++                    canClose = !canClose;
++                }
++            }
++            else
++                delimiterCount = 0;
++        }
++
++        if ((!strict || canClose) && src->unicode() == '>')
++        {
++            bool handleBrokenComments =  brokenComments && !( script || style );
++            bool scriptEnd=false;
++            if (!strict)
++            {
++                if ( scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' &&
++                     scriptCode[scriptCodeSize-2] == '-' )
++                    scriptEnd=true;
++            }
++
++            if (canClose || handleBrokenComments || scriptEnd ){
++                ++src;
++                if ( !( script || xmp || textarea || style) ) {
+ #ifdef COMMENTS_IN_DOM
+-                checkScriptBuffer();
+-                scriptCode[ scriptCodeSize ] = 0;
+-                scriptCode[ scriptCodeSize + 1 ] = 0;
+-                currToken.tid = ID_COMMENT;
+-                processListing(DOMStringIt(scriptCode, scriptCodeSize - 2));
+-                processToken();
+-                currToken.tid = ID_COMMENT + ID_CLOSE_TAG;
+-                processToken();
++                    checkScriptBuffer();
++                    scriptCode[ scriptCodeSize ] = 0;
++                    scriptCode[ scriptCodeSize + 1 ] = 0;
++                    currToken.tid = ID_COMMENT;
++                    processListing(DOMStringIt(scriptCode, scriptCodeSize - 2));
++                    processToken();
++                    currToken.tid = ID_COMMENT + ID_CLOSE_TAG;
++                    processToken();
+ #endif
+-                scriptCodeSize = 0;
++                    scriptCodeSize = 0;
++                }
++                comment = false;
++                return; // Finished parsing comment
+             }
+-            comment = false;
+-            return; // Finished parsing comment
+         }
+         ++src;
+     }
+@@ -987,6 +1018,15 @@
+                         ++src;
+                         break;
+                     }
++                    else if (curchar == '\r') {
++                        ++src;
++                        continue;
++                    }
++                    else if (curchar == '\t' || curchar == '\n') {
++                        *dest++ = ' ';
++                        ++src;
++                        continue;
++                    }
+                 }
+                 *dest++ = *src;
+                 ++src;
+@@ -1056,8 +1096,12 @@
+ #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 0
+             kdDebug( 6036 ) << "appending Tag: " << tagID << endl;
+ #endif
+-            // If the tag requires a end tag it cannot be flat unless we are parsing XHTML delivered as HTML
+-            if (parser->doc()->htmlMode() != DocumentImpl::XHtml && tagID < ID_CLOSE_TAG && DOM::endTag[tagID] == DOM::REQUIRED)
++            // If the tag requires an end tag it cannot be flat,
++            // unless we are using the HTML parser to parse XHTML
++            // The only exception is SCRIPT and priority 0 tokens.
++            if (tagID < ID_CLOSE_TAG && tagID != ID_SCRIPT &&
++                DOM::endTag[tagID] == DOM::REQUIRED &&
++                parser->doc()->htmlMode() != DocumentImpl::XHtml)
+                 currToken.flat = false;
+ 
+             bool beginTag = !currToken.flat && (tagID < ID_CLOSE_TAG);
+@@ -1106,7 +1150,8 @@
+                         type.compare("text/jscript") != 0 &&
+                         type.compare("text/ecmascript") != 0 &&
+                         type.compare("text/livescript") != 0 &&
+-			type.compare("application/x-javascript") != 0 )
++			type.compare("application/x-javascript") != 0 &&
++			type.compare("application/ecmascript") != 0 )
+                         javascript = false;
+                 } else if( a ) {
+                     /*
+@@ -1134,13 +1179,15 @@
+ 
+             processToken();
+ 
+-            // lets see if we're still in parsing mood for spaces
+-            pre = parser->preMode();
++            if ( parser->selectMode() && beginTag)
++                discard = AllDiscard;
+ 
+             switch( tagID ) {
+             case ID_PRE:
++                pre = beginTag;
++                if (beginTag)
++                    discard = LFDiscard;
+                 prePos = 0;
+-                discard = AllDiscard;
+                 break;
+             case ID_BR:
+                 prePos = 0;
+@@ -1320,9 +1367,11 @@
+         else if ( startTag )
+         {
+             startTag = false;
++            bool endTag = false;
+ 
+             switch(cc) {
+             case '/':
++                endTag = true;
+                 break;
+             case '!':
+             {
+@@ -1369,19 +1418,19 @@
+             }
+             }; // end case
+ 
+-            if ( pending ) {
+-                // pre context always gets its spaces/linefeeds
+-                // only add in existing inline context or if
+-                // we just started one, i.e. we're about to insert real text
+-                if ( pre || script || (!parser->selectMode() &&
+-                          ( !parser->noSpaces() || dest > buffer ))) {
++            // According to SGML any LF immediately after a starttag, or
++            // immediately before an endtag should be ignored.
++            // ### Gecko and MSIE though only ignores LF immediately after
++            // starttags and only for PRE elements -- asj (28/06-2005)
++            if ( pending )
++                if (!select)
+                     addPending();
+-		    discard = AllDiscard;
+-                }
+-                // just forget it
+                 else
+                     pending = NonePending;
+-            }
++
++            // Cancel unused discards
++            discard = NoneDiscard;
++            // if (!endTag) discard = LFDiscard;
+ 
+             processToken();
+ 
+@@ -1394,42 +1443,34 @@
+             ++src;
+             if ( pending )
+                 addPending();
++            discard = NoneDiscard;
+             parseEntity(src, dest, true);
+         }
+         else if ( cc == '<' && !src.escaped())
+         {
+             tagStartLineno = lineno+src.lineCount();
+             ++src;
++            discard = NoneDiscard;
+             startTag = true;
+         }
+         else if (( cc == '\n' ) || ( cc == '\r' ))
+         {
+-            if (select && !script)
++            if (discard == SpaceDiscard)
++                discard = NoneDiscard;
++
++            if (discard == LFDiscard) {
++                // Ignore one LF
++                discard = NoneDiscard;
++            }
++            else if (discard == AllDiscard)
+             {
+-                if (discard == LFDiscard)
+-                {
+-                    // Ignore this LF
+-                    discard = NoneDiscard; // We have discarded 1 LF
+-                }
+-                else if(discard == AllDiscard)
+-                {
+-                }
+-                else
+-                {
+-                     // Process this LF
+-                    if (pending == NonePending)
+-                        pending = LFPending;
+-                }
++                // Ignore
+             }
+-            else {
+-                if (discard == LFDiscard || discard == AllDiscard)
+-                {
+-                    // Ignore this LF
+-                    discard = NoneDiscard; // We have discarded 1 LF
+-                }
+-                else
+-                {
+-                    // Process this LF
++            else
++            {
++                if (select && !script) {
++                    pending = LFPending;
++                } else {
+                     if (pending)
+                         addPending();
+                     pending = LFPending;
+@@ -1445,25 +1486,29 @@
+         }
+         else if (( cc == ' ' ) || ( cc == '\t' ))
+         {
+-            if (select && !script) {
+-                if(discard == SpaceDiscard)
+-                    discard = NoneDiscard;
+-                else if(discard == AllDiscard)
+-                { }
+-                else
+-                        pending = SpacePending;
++            if(discard == LFDiscard)
++                discard = NoneDiscard;
+ 
++            if(discard == SpaceDiscard) {
++                // Ignore one space
++                discard = NoneDiscard;
++            }
++            else if(discard == AllDiscard)
++            {
++                // Ignore
+             }
+             else {
+-                if (discard == AllDiscard)
+-                    discard = NoneDiscard;
+-
+-                if (pending)
+-                    addPending();
+-                if (cc == ' ')
+-                    pending = SpacePending;
+-                else
+-                    pending = TabPending;
++                if (select && !script) {
++                    if (!pending)
++                        pending = SpacePending;
++                } else {
++                    if (pending)
++                        addPending();
++                    if (cc == ' ')
++                        pending = SpacePending;
++                    else
++                        pending = TabPending;
++                }
+             }
+ 
+             ++src;
+@@ -1638,8 +1683,6 @@
+ 
+     if ( currToken.flat && currToken.tid != ID_TEXT && !parser->noSpaces() )
+ 	discard = NoneDiscard;
+-    else if ( parser->selectMode() )
+-        discard = AllDiscard;
+ 
+     currToken.reset();
+     if (jsProxy)




More information about the pkg-kde-commits mailing list