identifiers shouldn't begin with _

This commit is contained in:
Glenn Maynard
2004-07-22 20:14:26 +00:00
parent 4abc886117
commit ccc1468c56
+25 -60
View File
@@ -29,23 +29,17 @@ DISP_OPT optDefault;
XENTITYS entityDefault((LPXENTITY)x_EntityTable, sizeof(x_EntityTable)/sizeof(x_EntityTable[0]) ); XENTITYS entityDefault((LPXENTITY)x_EntityTable, sizeof(x_EntityTable)/sizeof(x_EntityTable[0]) );
// skip spaces // skip spaces
char* _tcsskip( const char* psz ) char* tcsskip( const char* psz )
{ {
while( psz && *psz == ' ' ) psz++; while( psz && *psz == ' ' ) psz++;
return (char*)psz; return (char*)psz;
} }
//======================================================== // Name : tcsechr
// Name : _tcsechr
// Desc : similar with strchr with escape process // Desc : similar with strchr with escape process
// Param : escape - will be escape character // Param : escape - will be escape character
// Return : char* tcsechr( const char* psz, int ch, int escape )
//--------------------------------------------------------
// Coder Date Desc
// bro 2002-10-29
//========================================================
char* _tcsechr( const char* psz, int ch, int escape )
{ {
char* pch = (char*)psz; char* pch = (char*)psz;
char* prev_escape = NULL; char* prev_escape = NULL;
@@ -63,16 +57,9 @@ char* _tcsechr( const char* psz, int ch, int escape )
return pch; return pch;
} }
//========================================================
// Name : _tcselen
// Desc : similar with strlen with escape process // Desc : similar with strlen with escape process
// Param : escape - will be escape character // Param : escape - will be escape character
// Return : int tcselen( int escape, const char *start, const char *end )
//--------------------------------------------------------
// Coder Date Desc
// bro 2002-10-29
//========================================================
int _tcselen( int escape, const char *start, const char *end )
{ {
int len = 0; int len = 0;
if( end == NULL ) if( end == NULL )
@@ -92,15 +79,8 @@ int _tcselen( int escape, const char *start, const char *end )
return len; return len;
} }
//========================================================
// Name : strlen
// Desc : similar with _tcscpy with escape process // Desc : similar with _tcscpy with escape process
// Param : escape - will be escape character // Param : escape - will be escape character
// Return :
//--------------------------------------------------------
// Coder Date Desc
// bro 2002-10-29
//========================================================
void unescape( char *psz, int escape, char* srt, char* end = NULL ) void unescape( char *psz, int escape, char* srt, char* end = NULL )
{ {
const char* pch = srt; const char* pch = srt;
@@ -122,16 +102,9 @@ void unescape( char *psz, int escape, char* srt, char* end = NULL )
*psz = '\0'; *psz = '\0';
} }
//========================================================
// Name : _tcsepbrk
// Desc : similar with strpbrk with escape process // Desc : similar with strpbrk with escape process
// Param : escape - will be escape character // Param : escape - will be escape character
// Return : char* tcsepbrk( const char* psz, const char* chset, int escape )
//--------------------------------------------------------
// Coder Date Desc
// bro 2002-10-29
//========================================================
char* _tcsepbrk( const char* psz, const char* chset, int escape )
{ {
char* pch = (char*)psz; char* pch = (char*)psz;
char* prev_escape = NULL; char* prev_escape = NULL;
@@ -150,16 +123,8 @@ char* _tcsepbrk( const char* psz, const char* chset, int escape )
return pch; return pch;
} }
//========================================================
// Name : _SetString
// Desc : put string of (psz~end) on ps string // Desc : put string of (psz~end) on ps string
// Param : trim - will be trim? void SetString( char* psz, char* end, CString* ps, bool trim = false, int escape = 0 )
// Return :
//--------------------------------------------------------
// Coder Date Desc
// bro 2002-10-29
//========================================================
void _SetString( char* psz, char* end, CString* ps, bool trim = false, int escape = 0 )
{ {
if( trim ) if( trim )
{ {
@@ -170,7 +135,7 @@ void _SetString( char* psz, char* end, CString* ps, bool trim = false, int escap
if( len <= 0 ) return; if( len <= 0 ) return;
if( escape ) if( escape )
{ {
len = _tcselen( escape, psz, end ); len = tcselen( escape, psz, end );
char* szTemp = new char[len]; char* szTemp = new char[len];
unescape( szTemp, escape, psz, end ); unescape( szTemp, escape, psz, end );
*ps = szTemp; *ps = szTemp;
@@ -230,7 +195,7 @@ char* XNode::LoadAttributes( const char* pszAttrs , LPPARSEINFO pi /*= &piDefaul
while( xml && *xml ) while( xml && *xml )
{ {
xml = _tcsskip( xml ); xml = tcsskip( xml );
if( !xml ) if( !xml )
continue; continue;
@@ -258,40 +223,40 @@ char* XNode::LoadAttributes( const char* pszAttrs , LPPARSEINFO pi /*= &piDefaul
attr->parent = this; attr->parent = this;
// XML Attr Name // XML Attr Name
_SetString( xml, pEnd, &attr->name ); SetString( xml, pEnd, &attr->name );
// add new attribute // add new attribute
attrs.push_back( attr ); attrs.push_back( attr );
xml = pEnd; xml = pEnd;
// XML Attr Value // XML Attr Value
xml = _tcsskip( xml ); xml = tcsskip( xml );
if( !xml ) if( !xml )
continue; continue;
//if( xml = strchr( xml, '=' ) ) //if( xml = strchr( xml, '=' ) )
if( *xml == '=' ) if( *xml == '=' )
{ {
xml = _tcsskip( ++xml ); xml = tcsskip( ++xml );
if( !xml ) if( !xml )
continue; continue;
// if " or ' // if " or '
// or none quote // or none quote
int quote = *xml; int quote = *xml;
if( quote == '"' || quote == '\'' ) if( quote == '"' || quote == '\'' )
pEnd = _tcsechr( ++xml, quote, chXMLEscape ); pEnd = tcsechr( ++xml, quote, chXMLEscape );
else else
{ {
//attr= value> //attr= value>
// none quote mode // none quote mode
//pEnd = _tcsechr( xml, ' ', '\\' ); //pEnd = tcsechr( xml, ' ', '\\' );
pEnd = _tcsepbrk( xml, (" >"), chXMLEscape ); pEnd = tcsepbrk( xml, (" >"), chXMLEscape );
} }
bool trim = pi->trim_value; bool trim = pi->trim_value;
TCHAR escape = pi->escape_value; TCHAR escape = pi->escape_value;
//_SetString( xml, pEnd, &attr->value, trim, chXMLEscape ); //SetString( xml, pEnd, &attr->value, trim, chXMLEscape );
_SetString( xml, pEnd, &attr->value, trim, escape ); SetString( xml, pEnd, &attr->value, trim, escape );
xml = pEnd; xml = pEnd;
// ATTRVALUE // ATTRVALUE
if( pi->entity_value && pi->entitys ) if( pi->entity_value && pi->entitys )
@@ -339,7 +304,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
// XML Node Tag Name Open // XML Node Tag Name Open
xml++; xml++;
TCHAR* pTagEnd = strpbrk( xml, " />" ); TCHAR* pTagEnd = strpbrk( xml, " />" );
_SetString( xml, pTagEnd, &name ); SetString( xml, pTagEnd, &name );
xml = pTagEnd; xml = pTagEnd;
// Generate XML Attributte List // Generate XML Attributte List
xml = LoadAttributes( xml, pi ); xml = LoadAttributes( xml, pi );
@@ -386,7 +351,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
if( XIsEmptyString( value ) ) if( XIsEmptyString( value ) )
{ {
// Text Value // Text Value
TCHAR* pEnd = _tcsechr( ++xml, chXMLTagOpen, chXMLEscape ); TCHAR* pEnd = tcsechr( ++xml, chXMLTagOpen, chXMLEscape );
if( pEnd == NULL ) if( pEnd == NULL )
{ {
if( pi->erorr_occur == false ) if( pi->erorr_occur == false )
@@ -402,8 +367,8 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
bool trim = pi->trim_value; bool trim = pi->trim_value;
TCHAR escape = pi->escape_value; TCHAR escape = pi->escape_value;
//_SetString( xml, pEnd, &value, trim, chXMLEscape ); //SetString( xml, pEnd, &value, trim, chXMLEscape );
_SetString( xml, pEnd, &value, trim, escape ); SetString( xml, pEnd, &value, trim, escape );
xml = pEnd; xml = pEnd;
// TEXTVALUE reference // TEXTVALUE reference
@@ -435,7 +400,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
// </Close> // </Close>
xml+=2; // C xml+=2; // C
xml = _tcsskip( xml ); xml = tcsskip( xml );
if( xml == NULL ) if( xml == NULL )
return NULL; return NULL;
@@ -453,7 +418,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
// error // error
return NULL; return NULL;
} }
_SetString( xml, pEnd, &closename ); SetString( xml, pEnd, &closename );
if( closename == this->name ) if( closename == this->name )
{ {
// wel-formed open/close // wel-formed open/close
@@ -484,7 +449,7 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
if( xml && XIsEmptyString( value ) && *xml !=chXMLTagOpen ) if( xml && XIsEmptyString( value ) && *xml !=chXMLTagOpen )
{ {
// Text Value // Text Value
TCHAR* pEnd = _tcsechr( xml, chXMLTagOpen, chXMLEscape ); TCHAR* pEnd = tcsechr( xml, chXMLTagOpen, chXMLEscape );
if( pEnd == NULL ) if( pEnd == NULL )
{ {
// error cos not exist CloseTag </TAG> // error cos not exist CloseTag </TAG>
@@ -500,8 +465,8 @@ char* XNode::Load( const char* pszXml, LPPARSEINFO pi /*= &piDefault*/ )
bool trim = pi->trim_value; bool trim = pi->trim_value;
TCHAR escape = pi->escape_value; TCHAR escape = pi->escape_value;
//_SetString( xml, pEnd, &value, trim, chXMLEscape ); //SetString( xml, pEnd, &value, trim, chXMLEscape );
_SetString( xml, pEnd, &value, trim, escape ); SetString( xml, pEnd, &value, trim, escape );
xml = pEnd; xml = pEnd;
//TEXTVALUE //TEXTVALUE