|
|
|
@ -40,7 +40,7 @@
|
|
|
|
|
#define TOPICS_ENTRY_LEN 16
|
|
|
|
|
#define URLTBL_ENTRY_LEN 12
|
|
|
|
|
|
|
|
|
|
//#define DEBUGPARSER(A) qDebug A
|
|
|
|
|
//#define DEBUGPARSER(A) tqDebug A
|
|
|
|
|
#define DEBUGPARSER(A) ;
|
|
|
|
|
|
|
|
|
|
class KCHMShowWaitCursor
|
|
|
|
@ -310,7 +310,7 @@ TQString LCHMFileImpl::decodeEntity( const TQString & entity )
|
|
|
|
|
|
|
|
|
|
if ( !valid )
|
|
|
|
|
{
|
|
|
|
|
qWarning ( "LCHMFileImpl::decodeEntity: could not decode HTML entity '%s'", entity.ascii() );
|
|
|
|
|
tqWarning ( "LCHMFileImpl::decodeEntity: could not decode HTML entity '%s'", entity.ascii() );
|
|
|
|
|
return TQString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -322,7 +322,7 @@ TQString LCHMFileImpl::decodeEntity( const TQString & entity )
|
|
|
|
|
|
|
|
|
|
if ( it == m_entityDecodeMap.end() )
|
|
|
|
|
{
|
|
|
|
|
qWarning ("LCHMFileImpl::decodeEntity: could not decode HTML entity '%s'", entity.ascii());
|
|
|
|
|
tqWarning ("LCHMFileImpl::decodeEntity: could not decode HTML entity '%s'", entity.ascii());
|
|
|
|
|
return TQString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,12 +336,12 @@ inline int LCHMFileImpl::findStringInQuotes (const TQString& tag, int offset, TQ
|
|
|
|
|
int qbegin = tag.find ('"', offset);
|
|
|
|
|
|
|
|
|
|
if ( qbegin == -1 )
|
|
|
|
|
qFatal ("LCHMFileImpl::findStringInQuotes: cannot find first quote in <param> tag: '%s'", tag.ascii());
|
|
|
|
|
tqFatal ("LCHMFileImpl::findStringInQuotes: cannot find first quote in <param> tag: '%s'", tag.ascii());
|
|
|
|
|
|
|
|
|
|
int qend = firstquote ? tag.find ('"', qbegin + 1) : tag.findRev ('"');
|
|
|
|
|
|
|
|
|
|
if ( qend == -1 || qend <= qbegin )
|
|
|
|
|
qFatal ("LCHMFileImpl::findStringInQuotes: cannot find last quote in <param> tag: '%s'", tag.ascii());
|
|
|
|
|
tqFatal ("LCHMFileImpl::findStringInQuotes: cannot find last quote in <param> tag: '%s'", tag.ascii());
|
|
|
|
|
|
|
|
|
|
// If we do not need to decode HTML entities, just return.
|
|
|
|
|
if ( decodeentities )
|
|
|
|
@ -970,7 +970,7 @@ bool LCHMFileImpl::parseFileAndFillArray( const TQString & file, QT34VECTOR< LCH
|
|
|
|
|
int nextpos = src.find (src[i], i+1);
|
|
|
|
|
if ( nextpos == -1 && (nextpos = src.find ('>', i+1)) == -1 )
|
|
|
|
|
{
|
|
|
|
|
qWarning ("LCHMFileImpl::ParseHhcAndFillTree: corrupted TOC: %s", src.mid(i).ascii());
|
|
|
|
|
tqWarning ("LCHMFileImpl::ParseHhcAndFillTree: corrupted TOC: %s", src.mid(i).ascii());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -989,7 +989,7 @@ bool LCHMFileImpl::parseFileAndFillArray( const TQString & file, QT34VECTOR< LCH
|
|
|
|
|
else
|
|
|
|
|
tagword = tag.lower();
|
|
|
|
|
|
|
|
|
|
//qDebug ("tag: '%s', tagword: '%s'\n", tag.ascii(), tagword.ascii());
|
|
|
|
|
//tqDebug ("tag: '%s', tagword: '%s'\n", tag.ascii(), tagword.ascii());
|
|
|
|
|
|
|
|
|
|
// <OBJECT type="text/sitemap"> - a topic entry
|
|
|
|
|
if ( tagword == "object" && tag.find ("text/sitemap", 0, false) != -1 )
|
|
|
|
@ -1005,7 +1005,7 @@ bool LCHMFileImpl::parseFileAndFillArray( const TQString & file, QT34VECTOR< LCH
|
|
|
|
|
root_indent_offset = indent;
|
|
|
|
|
|
|
|
|
|
if ( root_indent_offset > 1 )
|
|
|
|
|
qWarning("CHM has improper index; root indent offset is %d", root_indent_offset);
|
|
|
|
|
tqWarning("CHM has improper index; root indent offset is %d", root_indent_offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int real_indent = indent - root_indent_offset;
|
|
|
|
@ -1016,9 +1016,9 @@ bool LCHMFileImpl::parseFileAndFillArray( const TQString & file, QT34VECTOR< LCH
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( !entry.urls.isEmpty() )
|
|
|
|
|
qDebug ("LCHMFileImpl::ParseAndFillTopicsTree: <object> tag with url \"%s\" is parsed, but name is empty.", entry.urls[0].ascii());
|
|
|
|
|
tqDebug ("LCHMFileImpl::ParseAndFillTopicsTree: <object> tag with url \"%s\" is parsed, but name is empty.", entry.urls[0].ascii());
|
|
|
|
|
else
|
|
|
|
|
qDebug ("LCHMFileImpl::ParseAndFillTopicsTree: <object> tag is parsed, but both name and url are empty.");
|
|
|
|
|
tqDebug ("LCHMFileImpl::ParseAndFillTopicsTree: <object> tag is parsed, but both name and url are empty.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entry.name = TQString();
|
|
|
|
@ -1034,19 +1034,19 @@ bool LCHMFileImpl::parseFileAndFillArray( const TQString & file, QT34VECTOR< LCH
|
|
|
|
|
TQString pname, pvalue;
|
|
|
|
|
|
|
|
|
|
if ( (offset = tag.find (name_pattern, 0, FALSE)) == -1 )
|
|
|
|
|
qFatal ("LCHMFileImpl::ParseAndFillTopicsTree: bad <param> tag '%s': no name=\n", tag.ascii());
|
|
|
|
|
tqFatal ("LCHMFileImpl::ParseAndFillTopicsTree: bad <param> tag '%s': no name=\n", tag.ascii());
|
|
|
|
|
|
|
|
|
|
// offset+5 skips 'name='
|
|
|
|
|
offset = findStringInQuotes (tag, offset + name_pattern.length(), pname, TRUE, FALSE);
|
|
|
|
|
pname = pname.lower();
|
|
|
|
|
|
|
|
|
|
if ( (offset = tag.find (value_pattern, offset, FALSE)) == -1 )
|
|
|
|
|
qFatal ("LCHMFileImpl::ParseAndFillTopicsTree: bad <param> tag '%s': no value=\n", tag.ascii());
|
|
|
|
|
tqFatal ("LCHMFileImpl::ParseAndFillTopicsTree: bad <param> tag '%s': no value=\n", tag.ascii());
|
|
|
|
|
|
|
|
|
|
// offset+6 skips 'value='
|
|
|
|
|
findStringInQuotes (tag, offset + value_pattern.length(), pvalue, FALSE, TRUE);
|
|
|
|
|
|
|
|
|
|
//qDebug ("<param>: name '%s', value '%s'", pname.ascii(), pvalue.ascii());
|
|
|
|
|
//tqDebug ("<param>: name '%s', value '%s'", pname.ascii(), pvalue.ascii());
|
|
|
|
|
|
|
|
|
|
if ( pname == "name" )
|
|
|
|
|
{
|
|
|
|
@ -1077,7 +1077,7 @@ bool LCHMFileImpl::parseFileAndFillArray( const TQString & file, QT34VECTOR< LCH
|
|
|
|
|
{
|
|
|
|
|
// Fix for buggy help files
|
|
|
|
|
if ( ++indent >= MAX_NEST_DEPTH )
|
|
|
|
|
qFatal("LCHMFileImpl::ParseAndFillTopicsTree: max nest depth (%d) is reached, error in help file", MAX_NEST_DEPTH);
|
|
|
|
|
tqFatal("LCHMFileImpl::ParseAndFillTopicsTree: max nest depth (%d) is reached, error in help file", MAX_NEST_DEPTH);
|
|
|
|
|
|
|
|
|
|
// This intended to fix <ul><ul>, which was seen in some buggy chm files,
|
|
|
|
|
// and brokes rootentry[indent-1] check
|
|
|
|
@ -1175,7 +1175,7 @@ bool LCHMFileImpl::guessTextEncoding( )
|
|
|
|
|
const LCHMTextEncoding * enc = 0;
|
|
|
|
|
|
|
|
|
|
if ( !m_detectedLCID || (enc = lookupByLCID (m_detectedLCID)) == 0 )
|
|
|
|
|
qFatal ("Could not detect text encoding by LCID");
|
|
|
|
|
tqFatal ("Could not detect text encoding by LCID");
|
|
|
|
|
|
|
|
|
|
if ( changeFileEncoding (enc->qtcodec) )
|
|
|
|
|
{
|
|
|
|
@ -1201,7 +1201,7 @@ bool LCHMFileImpl::changeFileEncoding( const char *qtencoding )
|
|
|
|
|
|
|
|
|
|
if ( !m_textCodec )
|
|
|
|
|
{
|
|
|
|
|
qWarning( "Could not set up Text Codec for encoding '%s'", buf );
|
|
|
|
|
tqWarning( "Could not set up Text Codec for encoding '%s'", buf );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1209,7 +1209,7 @@ bool LCHMFileImpl::changeFileEncoding( const char *qtencoding )
|
|
|
|
|
|
|
|
|
|
if ( !m_textCodecForSpecialFiles )
|
|
|
|
|
{
|
|
|
|
|
qWarning( "Could not set up Text Codec for encoding '%s'", p + 1 );
|
|
|
|
|
tqWarning( "Could not set up Text Codec for encoding '%s'", p + 1 );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1219,7 +1219,7 @@ bool LCHMFileImpl::changeFileEncoding( const char *qtencoding )
|
|
|
|
|
|
|
|
|
|
if ( !m_textCodec )
|
|
|
|
|
{
|
|
|
|
|
qWarning( "Could not set up Text Codec for encoding '%s'", qtencoding );
|
|
|
|
|
tqWarning( "Could not set up Text Codec for encoding '%s'", qtencoding );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|