From: Duncan Mac-Vicar P Date: Wed, 24 May 2006 12:58:48 +0000 (+0000) Subject: - don't parse desc and summary twice X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~746 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c82b0701a0a635bdf6566e3fa3f7ec7f9d96e88;p=platform%2Fupstream%2Flibzypp.git - don't parse desc and summary twice - fix a segfault with tranlated text --- diff --git a/zypp/parser/xmlstore/XMLLanguageParser.cc b/zypp/parser/xmlstore/XMLLanguageParser.cc index 3eba8eb..6c5b78c 100644 --- a/zypp/parser/xmlstore/XMLLanguageParser.cc +++ b/zypp/parser/xmlstore/XMLLanguageParser.cc @@ -58,21 +58,15 @@ namespace zypp { parseResObjectCommonData( dataPtr, dataNode); parseDependencies( dataPtr, dataNode); - for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next) - { - if (_helper.isElement(child)) - { - string name = _helper.name(child); - - if (name == "summary") - { - dataPtr->summary.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } - else if (name == "description") { - dataPtr->description.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } - } - } +// for (xmlNodePtr child = dataNode->children; child && child != dataNode; child = child->next) +// { +// if (_helper.isElement(child)) +// { +// string name = _helper.name(child); +// +// +// } +// } return dataPtr; } /* end process */ diff --git a/zypp/parser/xmlstore/XMLParserData.cc b/zypp/parser/xmlstore/XMLParserData.cc index f230b29..2831656 100644 --- a/zypp/parser/xmlstore/XMLParserData.cc +++ b/zypp/parser/xmlstore/XMLParserData.cc @@ -29,7 +29,7 @@ namespace zypp { XMLResObjectData::XMLResObjectData() : install_only(false) { } - XMLPatternData::XMLPatternData() + XMLPatternData::XMLPatternData() : userVisible(true) { } /* diff --git a/zypp/parser/xmlstore/XMLParserData.h b/zypp/parser/xmlstore/XMLParserData.h index 476a637..a94e469 100644 --- a/zypp/parser/xmlstore/XMLParserData.h +++ b/zypp/parser/xmlstore/XMLParserData.h @@ -93,7 +93,7 @@ namespace zypp { XMLPatternData(); std::string default_; - std::string userVisible; + bool userVisible; TranslatedText category; std::string icon; std::string script; diff --git a/zypp/parser/xmlstore/XMLPatchParser.cc b/zypp/parser/xmlstore/XMLPatchParser.cc index 273d0de..96b41b1 100644 --- a/zypp/parser/xmlstore/XMLPatchParser.cc +++ b/zypp/parser/xmlstore/XMLPatchParser.cc @@ -73,13 +73,7 @@ namespace zypp { { string name = _helper.name(child); - if (name == "summary") { - patchPtr->summary.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } - else if (name == "description") { - patchPtr->description.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } - else if (name == "id") { + if (name == "id") { patchPtr->patchId = _helper.content(child); } else if (name == "timestamp") { diff --git a/zypp/parser/xmlstore/XMLPatternParser.cc b/zypp/parser/xmlstore/XMLPatternParser.cc index 88be596..32c09b2 100644 --- a/zypp/parser/xmlstore/XMLPatternParser.cc +++ b/zypp/parser/xmlstore/XMLPatternParser.cc @@ -64,18 +64,11 @@ namespace zypp { { string name = _helper.name(child); - if (name == "summary") - { - dataPtr->summary.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } - else if (name == "default") { + if (name == "default") { dataPtr->default_ = _helper.content(child); } else if (name == "uservisible") { - dataPtr->userVisible = _helper.content(child); - } - else if (name == "description") { - dataPtr->description.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); + dataPtr->userVisible = (_helper.content(child) == "false") ? false : true; } else if (name == "category") { dataPtr->category.setText(_helper.content(child)); diff --git a/zypp/parser/xmlstore/XMLProductParser.cc b/zypp/parser/xmlstore/XMLProductParser.cc index a544d78..e972b56 100644 --- a/zypp/parser/xmlstore/XMLProductParser.cc +++ b/zypp/parser/xmlstore/XMLProductParser.cc @@ -77,12 +77,6 @@ namespace zypp { else if (name == "shortname") { productPtr->short_name.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); } - else if (name == "summary") { - productPtr->summary.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } - else if (name == "description") { - productPtr->description.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); - } else if (name == "product-flags") { parseProductFlags( productPtr, child); } diff --git a/zypp/target/store/XMLFilesBackend.cc b/zypp/target/store/XMLFilesBackend.cc index 9646021..1d83d4f 100644 --- a/zypp/target/store/XMLFilesBackend.cc +++ b/zypp/target/store/XMLFilesBackend.cc @@ -1017,7 +1017,7 @@ XMLFilesBackend::createPattern( const zypp::parser::xmlstore::XMLPatternData & p impl->_build_time = parsed.build_time; impl->_install_time = parsed.install_time; - impl->_user_visible = ((parsed.userVisible == "false" ) ? false : true ); + impl->_user_visible = parsed.userVisible; impl->_default = ((parsed.default_ == "false" ) ? false : true ); impl->_category = parsed.category; impl->_icon = parsed.icon; @@ -1059,10 +1059,10 @@ XMLFilesBackend::createSelection( const zypp::parser::xmlstore::XMLPatternData & impl->_build_time = parsed.build_time; impl->_install_time = parsed.install_time; - impl->_visible = ((parsed.userVisible == "false" ) ? false : true ); + impl->_visible = parsed.userVisible; impl->_name = parsed.name; //impl->_default = ((parsed.default_ == "false" ) ? false : true ); - impl->_category = parsed.category.text(); + impl->_category = parsed.category; Arch arch; if (!parsed.arch.empty()) diff --git a/zypp/target/store/xml/XMLSelectionImpl.cc b/zypp/target/store/xml/XMLSelectionImpl.cc index 797c269..5b9ca47 100644 --- a/zypp/target/store/xml/XMLSelectionImpl.cc +++ b/zypp/target/store/xml/XMLSelectionImpl.cc @@ -25,7 +25,7 @@ namespace zypp // METHOD NAME : XMLSelectionImpl::XMLSelectionImpl // METHOD TYPE : Ctor // - XMLSelectionImpl::XMLSelectionImpl() + XMLSelectionImpl::XMLSelectionImpl() : _visible(true) {} /////////////////////////////////////////////////////////////////// @@ -37,7 +37,7 @@ namespace zypp {} Label XMLSelectionImpl::category() const - { return _category; } + { return _category.text(); } bool XMLSelectionImpl::visible() const { return _visible; } diff --git a/zypp/target/store/xml/XMLSelectionImpl.h b/zypp/target/store/xml/XMLSelectionImpl.h index a0b0ff4..d8771a6 100644 --- a/zypp/target/store/xml/XMLSelectionImpl.h +++ b/zypp/target/store/xml/XMLSelectionImpl.h @@ -89,7 +89,7 @@ namespace zypp std::string _release; std::string _arch; std::string _order; - std::string _category; + TranslatedText _category; bool _visible; std::set _suggests;