From 593e1df6ec36d150030a48d6b8ebdeadd0e617fd Mon Sep 17 00:00:00 2001 From: Haikel Guemar Date: Thu, 4 Feb 2016 08:40:49 +0100 Subject: [PATCH 1/7] Fix RPM generation CPack generated RPM failed to install due to the RPM owning directories owned by filesystem packages. Exclude mandir directories from CPack. Resolves https://github.com/htacg/tidy-html5/issues/364 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1907fd..30e7b95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,6 +395,9 @@ set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.html-tidy.org/") #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc") set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries") +## RPM config +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/man" "/usr/share/man/man1") + set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/test/;${CMAKE_CURRENT_SOURCE_DIR}/build/;${CMAKE_CURRENT_SOURCE_DIR}/.git/") if (NOT WIN32 AND NOT APPLE) From 58229b7e2485b9d590e9289242c402f882a29b6b Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Mon, 8 Feb 2016 15:10:38 +0100 Subject: [PATCH 2/7] Issue #341 - Bump to version 5.1.37Test for this fix --- version.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.txt b/version.txt index 915d3ff..43ab206 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.1.36 -2016.02.01 +5.1.37Test +2016.02.08 From 03a643f7815af5c3fbf572acb728fd438df60e83 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Mon, 8 Feb 2016 15:12:23 +0100 Subject: [PATCH 3/7] Issue #341 - No token can be inserted if istacksize == 0! --- src/istack.c | 11 +++++++++-- src/lexer.c | 9 ++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/istack.c b/src/istack.c index afa6c73..dc708e4 100644 --- a/src/istack.c +++ b/src/istack.c @@ -10,6 +10,9 @@ #include "attrs.h" #include "streamio.h" #include "tmbstr.h" +#if !defined(NDEBUG) && defined(_MSC_VER) +#include "sprtf.h" +#endif /* duplicate attributes */ AttVal *TY_(DupAttrs)( TidyDocImpl* doc, AttVal *attrs) @@ -115,6 +118,7 @@ static void PopIStack( TidyDocImpl* doc ) TY_(FreeAttribute)( doc, av ); } TidyDocFree(doc, istack->element); + istack->element = NULL; /* remove the freed element */ } static void PopIStackUntil( TidyDocImpl* doc, TidyTagId tid ) @@ -267,9 +271,12 @@ Node *TY_(InsertedToken)( TidyDocImpl* doc ) node->end = lexer->txtend; /* was : lexer->txtstart; */ istack = lexer->insert; -#if 0 && defined(_DEBUG) +/* #if 0 && defined(_DEBUG) */ +#if !defined(NDEBUG) && defined(_MSC_VER) if ( lexer->istacksize == 0 ) - fprintf( stderr, "0-size istack!\n" ); + { + SPRTF( "WARNING: ZERO sized istack!\n" ); + } #endif node->element = TY_(tmbstrdup)(doc->allocator, istack->element); diff --git a/src/lexer.c b/src/lexer.c index c08b881..ee60158 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -101,7 +101,7 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node ) tmbstr src = lex ? "lexer" : "stream"; SPRTF("R=%d C=%d: ", line, col ); // DEBUG: Be able to set a TRAP on a SPECIFIC row,col - if ((line == 8) && (col == 36)) { + if ((line == 67) && (col == 95)) { check_me("Show_Node"); // just a debug trap } if (lexer && lexer->token && @@ -2264,8 +2264,11 @@ Node* TY_(GetToken)( TidyDocImpl* doc, GetTokenMode mode ) assert( !(lexer->pushed || lexer->itoken) ); /* at start of block elements, unclosed inline - elements are inserted into the token stream */ - if (lexer->insert || lexer->inode) { + elements are inserted into the token stream + Issue #341 - Can NOT insert a token if NO istacksize + */ + if ((lexer->insert || lexer->inode) && lexer->istacksize) + { /*\ Issue #92: could fix by the following, but instead chose not to stack these 2 * if ( !(lexer->insert && (nodeIsINS(lexer->insert) || nodeIsDEL(lexer->insert))) ) { \*/ From c66bb848f232e24e10a19851264f9e4c24d2237f Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sat, 13 Feb 2016 18:34:36 +0100 Subject: [PATCH 4/7] Improve tidySaveString API documentation. This was suggested by Kevin Locke back in SF bug 917 Nov, 2009. Has taken some time to filter through! --- include/tidy.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/tidy.h b/include/tidy.h index f20e12d..0eeabca 100755 --- a/include/tidy.h +++ b/include/tidy.h @@ -744,9 +744,13 @@ TIDY_EXPORT int TIDY_CALL tidySaveStdout( TidyDoc tdoc ); /** Save to given TidyBuffer object */ TIDY_EXPORT int TIDY_CALL tidySaveBuffer( TidyDoc tdoc, TidyBuffer* buf ); -/** Save document to application buffer. If buffer is not big enough, -** ENOMEM will be returned and the necessary buffer size will be placed -** in *buflen. +/** Save document to application buffer. If TidyShowMarkup and +** the document has no errors, or TidyForceOutput, the current +** document, per the current configuration, will be Pretty Printed +** to the application buffer. The document byte length, +** not character length, will be placed in *buflen. The document +** will not be null terminated. If the buffer is not big enough, +** ENOMEM will be returned, else the actual document status. */ TIDY_EXPORT int TIDY_CALL tidySaveString( TidyDoc tdoc, tmbstr buffer, uint* buflen ); From a4f425546f924a4801d1d389b8eed818324adac7 Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sun, 14 Feb 2016 18:11:57 +0100 Subject: [PATCH 5/7] Improve MSVC DEBUG output. Previous only output the first 8 characters, followed by an elipse if more than 8. Now return first up to 19 chars. If nore than 19, return first 8, followed by an elipse, followed by the last 8 characters. This is in the get_text_string service, which is only used if MSVC and not NDEBUG. --- src/lexer.c | 91 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/src/lexer.c b/src/lexer.c index c08b881..5d368ac 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -52,7 +52,7 @@ static void check_me(char *name); static Bool show_attrs = yes; #define MX_TXT 8 -static char buffer[MX_TXT+8]; /* NOTE extra for '...'\0 tail */ +static char buffer[(MX_TXT*4)+8]; /* NOTE extra for '...'\0 tail */ static tmbstr get_text_string(Lexer* lexer, Node *node) { uint len = node->end - node->start; @@ -61,31 +61,74 @@ static tmbstr get_text_string(Lexer* lexer, Node *node) unsigned char c; uint i = 0; Bool insp = no; - buffer[0] = (char)0; - while (cp < end ) { - c = *cp; - if (c == '\n') { - buffer[i++] = '\\'; - buffer[i++] = 'n'; - insp = yes; - } else if (c == ' ') { - if (!insp) + if (len <= ((MX_TXT * 2) + 3)) { + buffer[0] = 0; + while (cp < end) { + c = *cp; + cp++; + if (c == '\n') { + buffer[i++] = '\\'; + buffer[i++] = 'n'; + } else if ( c == ' ' ) { + if (!insp) + buffer[i++] = c; + insp = yes; + } else { buffer[i++] = c; - insp = yes; - } else { - buffer[i++] = c; - insp = no; + insp = no; + } } - cp++; - if (i >= MX_TXT) - break; - } - if (i < len) { - buffer[i++] = '.'; - if (i < len) { - buffer[i++] = '.'; - if (i < len) { - buffer[i++] = '.'; + } else { + char *end1 = cp + MX_TXT; + char *bgn = cp + (len - MX_TXT); + buffer[0] = 0; + if (bgn < end1) + bgn = end1; + while (cp < end1) { + c = *cp; + cp++; + if (c == '\n') { + buffer[i++] = '\\'; + buffer[i++] = 'n'; + } else if ( c == ' ' ) { + if (!insp) + buffer[i++] = c; + insp = yes; + } else { + buffer[i++] = c; + insp = no; + } + if (i >= MX_TXT) + break; + } + c = '.'; + if ((i < len)&&(cp < bgn)) { + buffer[i++] = c; + cp++; + if ((i < len)&&(cp < bgn)) { + buffer[i++] = c; + cp++; + if ((i < len)&&(cp < bgn)) { + buffer[i++] = c; + cp++; + } + } + } + cp = bgn; + insp = no; + while (cp < end) { + c = *cp; + cp++; + if (c == '\n') { + buffer[i++] = '\\'; + buffer[i++] = 'n'; + } else if ( c == ' ' ) { + if (!insp) + buffer[i++] = c; + insp = yes; + } else { + buffer[i++] = c; + insp = no; } } } From a95536394d930eefb5d1c45500c664b5f39e7a2f Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Tue, 16 Feb 2016 10:19:06 +0800 Subject: [PATCH 6/7] Bump to 5.1.37 --- version.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.txt b/version.txt index 43ab206..60d100f 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.1.37Test -2016.02.08 +5.1.37 +2016.02.16 From 7df66c45daade612654e38b4f6652f84872de134 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Tue, 16 Feb 2016 10:20:34 +0800 Subject: [PATCH 7/7] Update version.txt --- version.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.txt b/version.txt index eac687d..e67d80b 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.1.36_attr_phase1 -2016.02.12 +5.1.38 +2016.02.16