zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #08796
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
Nicolae Brinza has proposed merging lp:~nbrinza/zorba/bugs2 into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Related bugs:
Bug #931501 in Zorba: "improve error message for fn:format-number"
https://bugs.launchpad.net/zorba/+bug/931501
For more details, see:
https://code.launchpad.net/~nbrinza/zorba/bugs2/+merge/103938
Fixes for bugs #931501 and #866987 -- improved error messages for fn:format-number()
--
https://code.launchpad.net/~nbrinza/zorba/bugs2/+merge/103938
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-04-25 17:16:48 +0000
+++ ChangeLog 2012-04-27 20:11:20 +0000
@@ -16,12 +16,13 @@
Optimization:
Bug Fixes/Other Changes:
+ * Fixed bugs #931501 and #866987 (improved error messages for fn:format-number(). Additionally, the function now throws the FODF1310 error instead of XTDE1310, as the 3.0 spec requires)
* Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)
* Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)
* Fixed bug #986075 (encountering flwor expr with no clauses; due to common
subexression being formed when inlining var in if-then-else expression)
* Fixed bug #967864 (var substitution did not update theFreeVars property)
- * Fixed buf #891650 (context size var not always declared within path expr)
+ * Fixed bug #891650 (context size var not always declared within path expr)
* Fixed bug #948879 (--uri-path doesn't work with fetch:content())
* Fixed bug in window iterator (binding the end vars in the output tuple stream)
* Fixed bug #866547 (protect index-join rule from general flwor)
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2012-04-24 12:39:38 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-04-27 20:11:20 +0000
@@ -983,7 +983,7 @@
<comment>
Invalid \c fn:format-number() picture string.
</comment>
- <value>"$1": invalid fn:format-number() picture string</value>
+ <value>"$1": invalid fn:format-number() picture string$2</value>
</diagnostic>
<diagnostic code="FODT0001">
@@ -3643,6 +3643,31 @@
<entry key="ParseFragmentInvalidOptions">
<value>invalid options passed to the parse-xml:parse() function, the element must in the schema target namespace</value>
</entry>
+
+ <entry key="FormatNumberDuplicates">
+ <value>: a sub-picture must not contain more than one of the "$3" sign</value>
+ </entry>
+
+ <entry key="FormatNumberGroupingAdjacentToDecimal">
+ <value>: a sub-picture must not contain a grouping-separator-sign adjacent to a decimal-separator-sign</value>
+ </entry>
+
+ <entry key="FormatNumberIntegerPart">
+ <value>: the integer part of a sub-picture must not contain a member of the decimal-digit-family that is followed by an optional-digit-sign</value>
+ </entry>
+
+ <entry key="FormatNumberFractionalPart">
+ <value>: the fractional part of a sub-picture must not contain an optional-digit-sign that is followed by a member of the decimal-digit-family</value>
+ </entry>
+
+ <entry key="FormatNumberPercentPermille">
+ <value>: a sub-picture must not contain more than one percent-sign or per-mille-sign, and it must not contain one of each</value>
+ </entry>
+
+ <entry key="FormatNumberAtLeastOneOptionalOrDecimal">
+ <value>: a sub-picture must contain at least one character that is an optional-digit-sign or a member of the decimal-digit-family</value>
+ </entry>
+
</subvalues>
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2012-04-24 12:39:38 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-04-27 20:11:20 +0000
@@ -47,7 +47,7 @@
{ "FODC0006", "invalid content passed to $1: $2" },
{ "FODC0007", "\"$1\": base URI passed to fn:parse() is not a valid absolute URI" },
{ "FODF1280", "\"$1\": invalid decimal format name for fn:format-number()" },
- { "FODF1310", "\"$1\": invalid fn:format-number() picture string" },
+ { "FODF1310", "\"$1\": invalid fn:format-number() picture string$2" },
{ "FODT0001", "overflow/underflow in date/time operation" },
{ "FODT0002", "overflow/underflow in duration operation" },
{ "FODT0003", "\"$1\": invalid timezone value" },
@@ -514,6 +514,12 @@
{ "~FileNotFoundOrReadable", "file not found or readable" },
{ "~FnNilledArgNotNode", "fn:nilled() argument not a node" },
{ "~FnOnlyInXQueryVersion_3", "function only available in XQuery $3" },
+ { "~FormatNumberAtLeastOneOptionalOrDecimal", ": a sub-picture must contain at least one character that is an optional-digit-sign or a member of the decimal-digit-family" },
+ { "~FormatNumberDuplicates", ": a sub-picture must not contain more than one of the \"$3\" sign" },
+ { "~FormatNumberFractionalPart", ": the fractional part of a sub-picture must not contain an optional-digit-sign that is followed by a member of the decimal-digit-family" },
+ { "~FormatNumberGroupingAdjacentToDecimal", ": a sub-picture must not contain a grouping-separator-sign adjacent to a decimal-separator-sign" },
+ { "~FormatNumberIntegerPart", ": the integer part of a sub-picture must not contain a member of the decimal-digit-family that is followed by an optional-digit-sign" },
+ { "~FormatNumberPercentPermille", ": a sub-picture must not contain more than one percent-sign or per-mille-sign, and it must not contain one of each" },
{ "~FullTextNotEnabled", "full-text was not enabled in this build" },
{ "~FunctionFailedErrorCodeMessage_123", "$2 failed (error $3): $4" },
{ "~FunctionFailed_12o", "$2 failed${: 3}" },
=== modified file 'src/runtime/numerics/numerics_impl.cpp'
--- src/runtime/numerics/numerics_impl.cpp 2012-04-24 12:39:38 +0000
+++ src/runtime/numerics/numerics_impl.cpp 2012-04-27 20:11:20 +0000
@@ -427,6 +427,8 @@
zstring infinity;
zstring NaN;
zstring minus;
+
+ zstring pictureString; // The original picture string, used for debugging and error reporting
class PartInfo
{
@@ -500,14 +502,14 @@
// returns an error if there are two or more instances of the given pattern in the string
-static void errorIfTwoOrMore(zstring const& part, const char* sep, QueryLoc& loc)
+static void errorIfTwoOrMore(zstring const& part, const char* sep, FormatNumberInfo& info)
{
zstring::size_type const pos = part.find(sep);
if (pos != zstring::npos)
{
if (part.find(sep, strlen(sep), pos+1) != zstring::npos)
- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(loc));
+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberDuplicates), sep), ERROR_LOC(info.loc));
}
}
@@ -521,19 +523,19 @@
if (str.empty())
return;
- errorIfTwoOrMore(str, info.percent.c_str(), info.loc);
- errorIfTwoOrMore(str, info.per_mille.c_str(), info.loc);
+ errorIfTwoOrMore(str, info.percent.c_str(), info);
+ errorIfTwoOrMore(str, info.per_mille.c_str(), info);
if (str.find(info.percent.c_str()) != zstring::npos &&
str.find(info.per_mille.c_str()) != zstring::npos)
{
- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberPercentPermille)), ERROR_LOC(info.loc));
}
if (str.find(info.digit_sign.c_str()) == zstring::npos &&
str.find(info.zero_digit.c_str()) == zstring::npos)
{
- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberAtLeastOneOptionalOrDecimal)), ERROR_LOC(info.loc));
}
// get grouping separators
@@ -563,15 +565,16 @@
start += delta;
}
- if (first_digit_sign != -1 && last_zero_sign != -1
- &&
- ((!fractional && first_digit_sign > last_zero_sign)
- ||
- (fractional && first_digit_sign < last_zero_sign)))
- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
+ if (first_digit_sign != -1 && last_zero_sign != -1)
+ {
+ if (!fractional && first_digit_sign > last_zero_sign)
+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberIntegerPart)), ERROR_LOC(info.loc));
+ else if (fractional && first_digit_sign < last_zero_sign)
+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberFractionalPart)), ERROR_LOC(info.loc));
+ }
if (part.grouping_pos.size() > 0 && part.grouping_pos[0] == 0)
- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberGroupingAdjacentToDecimal)), ERROR_LOC(info.loc));
if (part.grouping_pos.size() > 0)
{
@@ -606,7 +609,7 @@
if (str.empty())
return;
- errorIfTwoOrMore(str, info.decimal_separator.c_str(), info.loc);
+ errorIfTwoOrMore(str, info.decimal_separator.c_str(), info);
zstring::size_type pos = str.find(info.decimal_separator.c_str());
if (pos != zstring::npos)
{
@@ -648,18 +651,18 @@
}
-static void parsePicture(zstring& picture, FormatNumberInfo& info)
+static void parsePicture(FormatNumberInfo& info)
{
- errorIfTwoOrMore(picture, info.pattern_separator.c_str(), info.loc);
+ errorIfTwoOrMore(info.pictureString, info.pattern_separator.c_str(), info);
- zstring::size_type pos = picture.find(info.pattern_separator.c_str());
+ zstring::size_type pos = info.pictureString.find(info.pattern_separator.c_str());
if (pos != zstring::npos)
{
- info.pos_subpicture.str = picture.substr(0, pos);
- info.neg_subpicture.str = picture.substr(pos+1, picture.size() - pos);
+ info.pos_subpicture.str = info.pictureString.substr(0, pos);
+ info.neg_subpicture.str = info.pictureString.substr(pos+1, info.pictureString.size() - pos);
}
else
- info.pos_subpicture.str = picture;
+ info.pos_subpicture.str = info.pictureString;
parseSubpicture(info.pos_subpicture, info);
if (info.neg_subpicture.str.empty())
@@ -862,7 +865,6 @@
FormatNumberIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
zstring resultString;
- zstring pictureString;
store::Item_t numberItem, pictureItem, formatName;
FormatNumberInfo info;
DecimalFormat_t df_t;
@@ -945,8 +947,8 @@
info.readFormat(df_t);
- pictureString = pictureItem->getStringValue();
- parsePicture(pictureString, info);
+ info.pictureString = pictureItem->getStringValue();
+ parsePicture(info);
formatNumber(resultString, result, info, theSctx->get_typemanager(), loc);
STACK_PUSH (GENV_ITEMFACTORY->createString(result, resultString), state);
Follow ups
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: noreply, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2012-04-28
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Nicolae Brinza, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Zorba Build Bot, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Matthias Brantner, 2012-04-28
-
[Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Matthias Brantner, 2012-04-28
-
Re: [Merge] lp:~nbrinza/zorba/bugs2 into lp:zorba
From: Matthias Brantner, 2012-04-28