Merge branch 'master' into attrdict_phase1

Bump version to 5.1.38
This commit is contained in:
Jim Derry 2016-02-16 11:07:32 +08:00
commit 3431dd05a4
4 changed files with 92 additions and 32 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_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)

View file

@ -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 );

View file

@ -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);

View file

@ -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,13 +61,14 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
unsigned char c;
uint i = 0;
Bool insp = no;
buffer[0] = (char)0;
if (len <= ((MX_TXT * 2) + 3)) {
buffer[0] = 0;
while (cp < end) {
c = *cp;
cp++;
if (c == '\n') {
buffer[i++] = '\\';
buffer[i++] = 'n';
insp = yes;
} else if ( c == ' ' ) {
if (!insp)
buffer[i++] = c;
@ -76,16 +77,58 @@ static tmbstr get_text_string(Lexer* lexer, Node *node)
buffer[i++] = c;
insp = no;
}
}
} 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;
}
if (i < len) {
buffer[i++] = '.';
if (i < len) {
buffer[i++] = '.';
if (i < len) {
buffer[i++] = '.';
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";
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 &&
@ -2265,8 +2308,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))) ) {
\*/