@@ -175,6 +175,7 @@ class ModulusSubstitution : public NFSubstitution {
175175 double upperBound,
176176 UBool lenientParse,
177177 uint32_t nonNumericalExecutedRuleMask,
178+ int32_t recursionCount,
178179 Formattable& result) const override ;
179180
180181 virtual double composeRuleValue (double newRuleValue, double oldRuleValue) const override {
@@ -242,6 +243,7 @@ class FractionalPartSubstitution : public NFSubstitution {
242243 double upperBound,
243244 UBool lenientParse,
244245 uint32_t nonNumericalExecutedRuleMask,
246+ int32_t recursionCount,
245247 Formattable& result) const override ;
246248
247249 virtual double composeRuleValue (double newRuleValue, double oldRuleValue) const override { return newRuleValue + oldRuleValue; }
@@ -314,6 +316,7 @@ class NumeratorSubstitution : public NFSubstitution {
314316 double upperBound,
315317 UBool /* lenientParse*/ ,
316318 uint32_t nonNumericalExecutedRuleMask,
319+ int32_t recursionCount,
317320 Formattable& result) const override ;
318321
319322 virtual double composeRuleValue (double newRuleValue, double oldRuleValue) const override { return newRuleValue / oldRuleValue; }
@@ -706,6 +709,7 @@ NFSubstitution::doParse(const UnicodeString& text,
706709 double upperBound,
707710 UBool lenientParse,
708711 uint32_t nonNumericalExecutedRuleMask,
712+ int32_t recursionCount,
709713 Formattable& result) const
710714{
711715#ifdef RBNF_DEBUG
@@ -726,7 +730,7 @@ NFSubstitution::doParse(const UnicodeString& text,
726730 // on), then also try parsing the text using a default-
727731 // constructed NumberFormat
728732 if (ruleSet != nullptr ) {
729- ruleSet->parse (text, parsePosition, upperBound, nonNumericalExecutedRuleMask, result);
733+ ruleSet->parse (text, parsePosition, upperBound, nonNumericalExecutedRuleMask, recursionCount, result);
730734 if (lenientParse && !ruleSet->isFractionRuleSet () && parsePosition.getIndex () == 0 ) {
731735 UErrorCode status = U_ZERO_ERROR;
732736 NumberFormat* fmt = NumberFormat::createInstance (status);
@@ -949,18 +953,19 @@ ModulusSubstitution::doParse(const UnicodeString& text,
949953 double upperBound,
950954 UBool lenientParse,
951955 uint32_t nonNumericalExecutedRuleMask,
956+ int32_t recursionCount,
952957 Formattable& result) const
953958{
954959 // if this isn't a >>> substitution, we can just use the
955960 // inherited parse() routine to do the parsing
956961 if (ruleToUse == nullptr ) {
957- return NFSubstitution::doParse (text, parsePosition, baseValue, upperBound, lenientParse, nonNumericalExecutedRuleMask, result);
962+ return NFSubstitution::doParse (text, parsePosition, baseValue, upperBound, lenientParse, nonNumericalExecutedRuleMask, recursionCount, result);
958963
959964 // but if it IS a >>> substitution, we have to do it here: we
960965 // use the specific rule's doParse() method, and then we have to
961966 // do some of the other work of NFRuleSet.parse()
962967 } else {
963- ruleToUse->doParse (text, parsePosition, false , upperBound, nonNumericalExecutedRuleMask, result);
968+ ruleToUse->doParse (text, parsePosition, false , upperBound, nonNumericalExecutedRuleMask, recursionCount, result);
964969
965970 if (parsePosition.getIndex () != 0 ) {
966971 UErrorCode status = U_ZERO_ERROR;
@@ -1136,12 +1141,13 @@ FractionalPartSubstitution::doParse(const UnicodeString& text,
11361141 double /* upperBound*/ ,
11371142 UBool lenientParse,
11381143 uint32_t nonNumericalExecutedRuleMask,
1144+ int32_t recursionCount,
11391145 Formattable& resVal) const
11401146{
11411147 // if we're not in byDigits mode, we can just use the inherited
11421148 // doParse()
11431149 if (!byDigits) {
1144- return NFSubstitution::doParse (text, parsePosition, baseValue, 0 , lenientParse, nonNumericalExecutedRuleMask, resVal);
1150+ return NFSubstitution::doParse (text, parsePosition, baseValue, 0 , lenientParse, nonNumericalExecutedRuleMask, recursionCount, resVal);
11451151
11461152 // if we ARE in byDigits mode, parse the text one digit at a time
11471153 // using this substitution's owning rule set (we do this by setting
@@ -1160,7 +1166,7 @@ FractionalPartSubstitution::doParse(const UnicodeString& text,
11601166 while (workText.length () > 0 && workPos.getIndex () != 0 ) {
11611167 workPos.setIndex (0 );
11621168 Formattable temp;
1163- getRuleSet ()->parse (workText, workPos, 10 , nonNumericalExecutedRuleMask, temp);
1169+ getRuleSet ()->parse (workText, workPos, 10 , nonNumericalExecutedRuleMask, recursionCount, temp);
11641170 UErrorCode status = U_ZERO_ERROR;
11651171 digit = temp.getLong (status);
11661172// digit = temp.getType() == Formattable::kLong ?
@@ -1271,6 +1277,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
12711277 double upperBound,
12721278 UBool /* lenientParse*/ ,
12731279 uint32_t nonNumericalExecutedRuleMask,
1280+ int32_t recursionCount,
12741281 Formattable& result) const
12751282{
12761283 // we don't have to do anything special to do the parsing here,
@@ -1289,7 +1296,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
12891296
12901297 while (workText.length () > 0 && workPos.getIndex () != 0 ) {
12911298 workPos.setIndex (0 );
1292- getRuleSet ()->parse (workText, workPos, 1 , nonNumericalExecutedRuleMask, temp); // parse zero or nothing at all
1299+ getRuleSet ()->parse (workText, workPos, 1 , nonNumericalExecutedRuleMask, recursionCount, temp); // parse zero or nothing at all
12931300 if (workPos.getIndex () == 0 ) {
12941301 // we failed, either there were no more zeros, or the number was formatted with digits
12951302 // either way, we're done
@@ -1311,7 +1318,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
13111318 }
13121319
13131320 // we've parsed off the zeros, now let's parse the rest from our current position
1314- NFSubstitution::doParse (workText, parsePosition, withZeros ? 1 : baseValue, upperBound, false , nonNumericalExecutedRuleMask, result);
1321+ NFSubstitution::doParse (workText, parsePosition, withZeros ? 1 : baseValue, upperBound, false , nonNumericalExecutedRuleMask, recursionCount, result);
13151322
13161323 if (withZeros) {
13171324 // any base value will do in this case. is there a way to
0 commit comments