i18npool/source/localedata/LocaleNode.cxx | 43 +++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-)
New commits: commit 39e5c230e5d92b4a9dde7f516b25282f3b2eb5a3 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Mar 12 14:55:02 2020 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Thu Mar 12 15:49:47 2020 +0100 Survive missing <Eras> element Change-Id: Ic7e609ebac10921b4891877802892fe2cde9ecbe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90406 Tested-by: Jenkins Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index f056eefd9252..558967cbc978 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -1717,21 +1717,34 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const } else { if (erasNode == nullptr) erasNode = calNode -> getChildAt(nChild); - nbOfEras[i] = sal::static_int_cast<sal_Int16>( erasNode->getNumberOfChildren() ); - if (bGregorian && nbOfEras[i] != 2) - incErrorInt( "Error: A Gregorian calendar must have 2 eras, this one has %d\n", nbOfEras[i]); - elementTag = "era"; - for (j = 0; j < nbOfEras[i]; j++) { - LocaleNode *currNode = erasNode -> getChildAt(j); - OUString eraID( currNode->getChildAt(0)->getValue()); - of.writeParameter("eraID", eraID, i, j); - if ( j == 0 && bGregorian && eraID != "bc" ) - incError( "First era of a Gregorian calendar must be <EraID>bc</EraID>"); - if ( j == 1 && bGregorian && eraID != "ad" ) - incError( "Second era of a Gregorian calendar must be <EraID>ad</EraID>"); - of.writeAsciiString("\n"); - of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j); - of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j); + if (!erasNode || erasNode->getName() != "Eras") + { + incErrorStr( "Error: <Eras> element expected in calendar '%s'\n", calendarID); + --nChild; + } + else + { + nbOfEras[i] = sal::static_int_cast<sal_Int16>( erasNode->getNumberOfChildren() ); + if (bGregorian && nbOfEras[i] != 2) + incErrorInt( "Error: A Gregorian calendar must have 2 eras, this one has %d\n", nbOfEras[i]); + elementTag = "era"; + for (j = 0; j < nbOfEras[i]; j++) { + LocaleNode *currNode = erasNode -> getChildAt(j); + if (!currNode || currNode->getName() != "Era") + { + incError("<Era> element expected"); + continue; // for + } + OUString eraID( currNode->getChildAt(0)->getValue()); + of.writeParameter("eraID", eraID, i, j); + if ( j == 0 && bGregorian && eraID != "bc" ) + incError( "First era of a Gregorian calendar must be <EraID>bc</EraID>"); + if ( j == 1 && bGregorian && eraID != "ad" ) + incError( "Second era of a Gregorian calendar must be <EraID>ad</EraID>"); + of.writeAsciiString("\n"); + of.writeParameter(elementTag, "DefaultAbbrvName",currNode->getChildAt(1)->getValue() ,i, j); + of.writeParameter(elementTag, "DefaultFullName",currNode->getChildAt(2)->getValue() , i, j); + } } } ++nChild; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits