Bump to 5.1.39 for merging.

Merge branch 'master' into attrdict_phase2
This commit is contained in:
Jim Derry 2016-02-16 11:11:36 +08:00
commit 97abad0c05
5 changed files with 95 additions and 34 deletions

View file

@ -336,6 +336,9 @@ set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.html-tidy.org/")
#set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc") #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc")
set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries") 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/") 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) if (NOT WIN32 AND NOT APPLE)

View file

@ -744,9 +744,13 @@ TIDY_EXPORT int TIDY_CALL tidySaveStdout( TidyDoc tdoc );
/** Save to given TidyBuffer object */ /** Save to given TidyBuffer object */
TIDY_EXPORT int TIDY_CALL tidySaveBuffer( TidyDoc tdoc, TidyBuffer* buf ); TIDY_EXPORT int TIDY_CALL tidySaveBuffer( TidyDoc tdoc, TidyBuffer* buf );
/** Save document to application buffer. If buffer is not big enough, /** Save document to application buffer. If TidyShowMarkup and
** ENOMEM will be returned and the necessary buffer size will be placed ** the document has no errors, or TidyForceOutput, the current
** in *buflen. ** 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, TIDY_EXPORT int TIDY_CALL tidySaveString( TidyDoc tdoc,
tmbstr buffer, uint* buflen ); tmbstr buffer, uint* buflen );

View file

@ -10,6 +10,9 @@
#include "attrs.h" #include "attrs.h"
#include "streamio.h" #include "streamio.h"
#include "tmbstr.h" #include "tmbstr.h"
#if !defined(NDEBUG) && defined(_MSC_VER)
#include "sprtf.h"
#endif
/* duplicate attributes */ /* duplicate attributes */
AttVal *TY_(DupAttrs)( TidyDocImpl* doc, AttVal *attrs) AttVal *TY_(DupAttrs)( TidyDocImpl* doc, AttVal *attrs)
@ -115,6 +118,7 @@ static void PopIStack( TidyDocImpl* doc )
TY_(FreeAttribute)( doc, av ); TY_(FreeAttribute)( doc, av );
} }
TidyDocFree(doc, istack->element); TidyDocFree(doc, istack->element);
istack->element = NULL; /* remove the freed element */
} }
static void PopIStackUntil( TidyDocImpl* doc, TidyTagId tid ) static void PopIStackUntil( TidyDocImpl* doc, TidyTagId tid )
@ -267,9 +271,12 @@ Node *TY_(InsertedToken)( TidyDocImpl* doc )
node->end = lexer->txtend; /* was : lexer->txtstart; */ node->end = lexer->txtend; /* was : lexer->txtstart; */
istack = lexer->insert; istack = lexer->insert;
#if 0 && defined(_DEBUG) /* #if 0 && defined(_DEBUG) */
#if !defined(NDEBUG) && defined(_MSC_VER)
if ( lexer->istacksize == 0 ) if ( lexer->istacksize == 0 )
fprintf( stderr, "0-size istack!\n" ); {
SPRTF( "WARNING: ZERO sized istack!\n" );
}
#endif #endif
node->element = TY_(tmbstrdup)(doc->allocator, istack->element); node->element = TY_(tmbstrdup)(doc->allocator, istack->element);

View file

@ -52,7 +52,7 @@
static void check_me(char *name); static void check_me(char *name);
static Bool show_attrs = yes; static Bool show_attrs = yes;
#define MX_TXT 8 #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) static tmbstr get_text_string(Lexer* lexer, Node *node)
{ {
uint len = node->end - node->start; uint len = node->end - node->start;
@ -61,31 +61,74 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
unsigned char c; unsigned char c;
uint i = 0; uint i = 0;
Bool insp = no; Bool insp = no;
buffer[0] = (char)0; if (len <= ((MX_TXT * 2) + 3)) {
while (cp < end ) { buffer[0] = 0;
c = *cp; while (cp < end) {
if (c == '\n') { c = *cp;
buffer[i++] = '\\'; cp++;
buffer[i++] = 'n'; if (c == '\n') {
insp = yes; buffer[i++] = '\\';
} else if (c == ' ') { buffer[i++] = 'n';
if (!insp) } else if ( c == ' ' ) {
if (!insp)
buffer[i++] = c;
insp = yes;
} else {
buffer[i++] = c; buffer[i++] = c;
insp = yes; insp = no;
} else { }
buffer[i++] = c;
insp = no;
} }
cp++; } else {
if (i >= MX_TXT) char *end1 = cp + MX_TXT;
break; char *bgn = cp + (len - MX_TXT);
} buffer[0] = 0;
if (i < len) { if (bgn < end1)
buffer[i++] = '.'; bgn = end1;
if (i < len) { while (cp < end1) {
buffer[i++] = '.'; c = *cp;
if (i < len) { cp++;
buffer[i++] = '.'; 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;
} }
} }
} }
@ -101,7 +144,7 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node )
tmbstr src = lex ? "lexer" : "stream"; tmbstr src = lex ? "lexer" : "stream";
SPRTF("R=%d C=%d: ", line, col ); SPRTF("R=%d C=%d: ", line, col );
// DEBUG: Be able to set a TRAP on a SPECIFIC row,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 check_me("Show_Node"); // just a debug trap
} }
if (lexer && lexer->token && if (lexer && lexer->token &&
@ -2265,8 +2308,11 @@ Node* TY_(GetToken)( TidyDocImpl* doc, GetTokenMode mode )
assert( !(lexer->pushed || lexer->itoken) ); assert( !(lexer->pushed || lexer->itoken) );
/* at start of block elements, unclosed inline /* at start of block elements, unclosed inline
elements are inserted into the token stream */ elements are inserted into the token stream
if (lexer->insert || lexer->inode) { 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 /*\ Issue #92: could fix by the following, but instead chose not to stack these 2
* if ( !(lexer->insert && (nodeIsINS(lexer->insert) || nodeIsDEL(lexer->insert))) ) { * if ( !(lexer->insert && (nodeIsINS(lexer->insert) || nodeIsDEL(lexer->insert))) ) {
\*/ \*/

View file

@ -1,2 +1,3 @@
5.1.36_attr_phase2 5.1.39
2016.02.12 2016.02.16