From 445c953785608dca10d13db91a75126de873adef Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 9 Feb 2004 19:33:56 +0000 Subject: [PATCH] fix warnings unwrap some ifs --- stepmania/src/XmlFile.cpp | 360 +++++++++++++++++++------------------- 1 file changed, 182 insertions(+), 178 deletions(-) diff --git a/stepmania/src/XmlFile.cpp b/stepmania/src/XmlFile.cpp index 3ea9d2ee94..3b83cafa9b 100644 --- a/stepmania/src/XmlFile.cpp +++ b/stepmania/src/XmlFile.cpp @@ -266,73 +266,75 @@ LPTSTR _tagXMLNode::LoadAttributes( LPCTSTR pszAttrs , LPPARSEINFO pi /*= &piDef while( xml && *xml ) { - if( xml = _tcsskip( xml ) ) + xml = _tcsskip( xml ); + if( !xml ) + continue; + + // close tag + if( *xml == chXMLTagClose || *xml == chXMLTagPre ) + // wel-formed tag + return xml; + + // XML Attr Name + TCHAR* pEnd = _tcspbrk( xml, " =" ); + if( pEnd == NULL ) { - // close tag - if( *xml == chXMLTagClose || *xml == chXMLTagPre ) - // wel-formed tag - return xml; - - // XML Attr Name - TCHAR* pEnd = _tcspbrk( xml, " =" ); - if( pEnd == NULL ) + // error + if( pi->erorr_occur == false ) { - // error - if( pi->erorr_occur == false ) - { - pi->erorr_occur = true; - pi->error_pointer = xml; - pi->error_code = PIE_ATTR_NO_VALUE; - pi->error_string.Format( ("<%s> attribute has error "), name ); - } - return NULL; + pi->erorr_occur = true; + pi->error_pointer = xml; + pi->error_code = PIE_ATTR_NO_VALUE; + pi->error_string.Format( ("<%s> attribute has error "), name ); } - - LPXAttr attr = new XAttr; - attr->parent = this; + return NULL; + } + + LPXAttr attr = new XAttr; + attr->parent = this; - // XML Attr Name - _SetString( xml, pEnd, &attr->name ); - - // add new attribute - attrs.push_back( attr ); + // XML Attr Name + _SetString( xml, pEnd, &attr->name ); + + // add new attribute + attrs.push_back( attr ); + xml = pEnd; + + // XML Attr Value + xml = _tcsskip( xml ); + if( !xml ) + continue; + + //if( xml = _tcschr( xml, '=' ) ) + if( *xml == '=' ) + { + xml = _tcsskip( ++xml ); + if( !xml ) + continue; + // if " or ' + // or none quote + int quote = *xml; + if( quote == '"' || quote == '\'' ) + pEnd = _tcsechr( ++xml, quote, chXMLEscape ); + else + { + //attr= value> + // none quote mode + //pEnd = _tcsechr( xml, ' ', '\\' ); + pEnd = _tcsepbrk( xml, (" >"), chXMLEscape ); + } + + bool trim = pi->trim_value; + TCHAR escape = pi->escape_value; + //_SetString( xml, pEnd, &attr->value, trim, chXMLEscape ); + _SetString( xml, pEnd, &attr->value, trim, escape ); xml = pEnd; - - // XML Attr Value - if( xml = _tcsskip( xml ) ) - { - //if( xml = _tcschr( xml, '=' ) ) - if( *xml == '=' ) - { - if( xml = _tcsskip( ++xml ) ) - { - // if " or ' - // or none quote - int quote = *xml; - if( quote == '"' || quote == '\'' ) - pEnd = _tcsechr( ++xml, quote, chXMLEscape ); - else - { - //attr= value> - // none quote mode - //pEnd = _tcsechr( xml, ' ', '\\' ); - pEnd = _tcsepbrk( xml, (" >"), chXMLEscape ); - } + // ATTRVALUE + if( pi->entity_value && pi->entitys ) + attr->value = pi->entitys->Ref2Entity(attr->value); - bool trim = pi->trim_value; - TCHAR escape = pi->escape_value; - //_SetString( xml, pEnd, &attr->value, trim, chXMLEscape ); - _SetString( xml, pEnd, &attr->value, trim, escape ); - xml = pEnd; - // ATTRVALUE - if( pi->entity_value && pi->entitys ) - attr->value = pi->entitys->Ref2Entity(attr->value); - - if( quote == '"' || quote == '\'' ) - xml++; - } - } - } + if( quote == '"' || quote == '\'' ) + xml++; } } @@ -376,39 +378,95 @@ LPTSTR _tagXMLNode::Load( LPCTSTR pszXml, LPPARSEINFO pi /*= &piDefault*/ ) _SetString( xml, pTagEnd, &name ); xml = pTagEnd; // Generate XML Attributte List - if( xml = LoadAttributes( xml, pi ) ) + xml = LoadAttributes( xml, pi ); + if( xml == NULL ) + return NULL; + + // alone tag + if( *xml == chXMLTagPre ) { - // alone tag - if( *xml == chXMLTagPre ) + xml++; + if( *xml == chXMLTagClose ) + // wel-formed tag + return ++xml; + else { - xml++; - if( *xml == chXMLTagClose ) - // wel-formed tag - return ++xml; - else + // error: + if( pi->erorr_occur == false ) + { + pi->erorr_occur = true; + pi->error_pointer = xml; + pi->error_code = PIE_ALONE_NOT_CLOSED; + pi->error_string = ("Element must be closed."); + } + // not wel-formed tag + return NULL; + } + } + else + // open/close tag ... + // ^- current pointer + { + // text value EֵѴ. + //if( this->value.IsEmpty() || this->value == ("") ) + if( XIsEmptyString( value ) ) + { + // Text Value + TCHAR* pEnd = _tcsechr( ++xml, chXMLTagOpen, chXMLEscape ); + if( pEnd == NULL ) { - // error: if( pi->erorr_occur == false ) { pi->erorr_occur = true; pi->error_pointer = xml; - pi->error_code = PIE_ALONE_NOT_CLOSED; - pi->error_string = ("Element must be closed."); + pi->error_code = PIE_NOT_CLOSED; + pi->error_string.Format(("%s must be closed with "), name ); } - // not wel-formed tag + // error cos not exist CloseTag return NULL; } + + bool trim = pi->trim_value; + TCHAR escape = pi->escape_value; + //_SetString( xml, pEnd, &value, trim, chXMLEscape ); + _SetString( xml, pEnd, &value, trim, escape ); + + xml = pEnd; + // TEXTVALUE reference + if( pi->entity_value && pi->entitys ) + value = pi->entitys->Ref2Entity(value); } - else - // open/close tag ... - // ^- current pointer + + // generate child nodes + while( xml && *xml ) { - // text value ֵѴ. - //if( this->value.IsEmpty() || this->value == ("") ) - if( XIsEmptyString( value ) ) + LPXNode node = new XNode; + node->parent = this; + + xml = node->Load( xml,pi ); + if( node->name.IsEmpty() == FALSE ) { - // Text Value - TCHAR* pEnd = _tcsechr( ++xml, chXMLTagOpen, chXMLEscape ); + childs.push_back( node ); + } + else + { + delete node; + } + + // open/close tag ... + // ^- current pointer + // CloseTag case + if( xml && *xml && *(xml+1) && *xml == chXMLTagOpen && *(xml+1) == chXMLTagPre ) + { + // + xml+=2; // C + + xml = _tcsskip( xml ); + if( xml == NULL ) + return NULL; + + CString closename; + TCHAR* pEnd = _tcspbrk( xml, " >" ); if( pEnd == NULL ) { if( pi->erorr_occur == false ) @@ -416,119 +474,65 @@ LPTSTR _tagXMLNode::Load( LPCTSTR pszXml, LPPARSEINFO pi /*= &piDefault*/ ) pi->erorr_occur = true; pi->error_pointer = xml; pi->error_code = PIE_NOT_CLOSED; - pi->error_string.Format(("%s must be closed with "), name ); + pi->error_string.Format(("it must be closed with "), name ); } - // error cos not exist CloseTag + // error return NULL; } - - bool trim = pi->trim_value; - TCHAR escape = pi->escape_value; - //_SetString( xml, pEnd, &value, trim, chXMLEscape ); - _SetString( xml, pEnd, &value, trim, escape ); - - xml = pEnd; - // TEXTVALUE reference - if( pi->entity_value && pi->entitys ) - value = pi->entitys->Ref2Entity(value); - } - - // generate child nodes - while( xml && *xml ) - { - LPXNode node = new XNode; - node->parent = this; - - xml = node->Load( xml,pi ); - if( node->name.IsEmpty() == FALSE ) + _SetString( xml, pEnd, &closename ); + if( closename == this->name ) { - childs.push_back( node ); + // wel-formed open/close + xml = pEnd+1; + // return '>' or ' ' after pointer + return xml; } else { - delete node; - } - - // open/close tag ... - // ^- current pointer - // CloseTag case - if( xml && *xml && *(xml+1) && *xml == chXMLTagOpen && *(xml+1) == chXMLTagPre ) - { - // - xml+=2; // C - - if( xml = _tcsskip( xml ) ) + xml = pEnd+1; + // not welformed open/close + if( pi->erorr_occur == false ) { - CString closename; - TCHAR* pEnd = _tcspbrk( xml, " >" ); - if( pEnd == NULL ) - { - if( pi->erorr_occur == false ) - { - pi->erorr_occur = true; - pi->error_pointer = xml; - pi->error_code = PIE_NOT_CLOSED; - pi->error_string.Format(("it must be closed with "), name ); - } - // error - return NULL; - } - _SetString( xml, pEnd, &closename ); - if( closename == this->name ) - { - // wel-formed open/close - xml = pEnd+1; - // return '>' or ' ' after pointer - return xml; - } - else - { - xml = pEnd+1; - // not welformed open/close - if( pi->erorr_occur == false ) - { - pi->erorr_occur = true; - pi->error_pointer = xml; - pi->error_code = PIE_NOT_NESTED; - pi->error_string.Format(("'<%s> ... ' is not wel-formed."), name, closename ); + pi->erorr_occur = true; + pi->error_pointer = xml; + pi->error_code = PIE_NOT_NESTED; + pi->error_string.Format(("'<%s> ... ' is not wel-formed."), name, closename ); - } - return NULL; - } } + return NULL; } - else // Alone child Tag Loaded - // else ؾϴ ƾϴ ǽɰ. + } + else // Alone child Tag Loaded + // else ؾϴEƾϴEǽɰ. + { + + //if( xml && this->value.IsEmpty() && *xml !=chXMLTagOpen ) + if( xml && XIsEmptyString( value ) && *xml !=chXMLTagOpen ) { - - //if( xml && this->value.IsEmpty() && *xml !=chXMLTagOpen ) - if( xml && XIsEmptyString( value ) && *xml !=chXMLTagOpen ) + // Text Value + TCHAR* pEnd = _tcsechr( xml, chXMLTagOpen, chXMLEscape ); + if( pEnd == NULL ) { - // Text Value - TCHAR* pEnd = _tcsechr( xml, chXMLTagOpen, chXMLEscape ); - if( pEnd == NULL ) + // error cos not exist CloseTag + if( pi->erorr_occur == false ) { - // error cos not exist CloseTag - if( pi->erorr_occur == false ) - { - pi->erorr_occur = true; - pi->error_pointer = xml; - pi->error_code = PIE_NOT_CLOSED; - pi->error_string.Format(("it must be closed with "), name ); - } - return NULL; + pi->erorr_occur = true; + pi->error_pointer = xml; + pi->error_code = PIE_NOT_CLOSED; + pi->error_string.Format(("it must be closed with "), name ); } - - bool trim = pi->trim_value; - TCHAR escape = pi->escape_value; - //_SetString( xml, pEnd, &value, trim, chXMLEscape ); - _SetString( xml, pEnd, &value, trim, escape ); - - xml = pEnd; - //TEXTVALUE - if( pi->entity_value && pi->entitys ) - value = pi->entitys->Ref2Entity(value); + return NULL; } + + bool trim = pi->trim_value; + TCHAR escape = pi->escape_value; + //_SetString( xml, pEnd, &value, trim, chXMLEscape ); + _SetString( xml, pEnd, &value, trim, escape ); + + xml = pEnd; + //TEXTVALUE + if( pi->entity_value && pi->entitys ) + value = pi->entitys->Ref2Entity(value); } } }