Merge lp:~nbrinza/zorba/bugs2 into lp:zorba

Proposed by Nicolae Brinza
Status: Merged
Approved by: Nicolae Brinza
Approved revision: no longer in the source branch.
Merged at revision: 10805
Proposed branch: lp:~nbrinza/zorba/bugs2
Merge into: lp:zorba
Diff against target: 220 lines (+60/-26)
4 files modified
ChangeLog (+2/-1)
src/diagnostics/diagnostic_en.xml (+26/-1)
src/diagnostics/pregenerated/dict_en.cpp (+7/-1)
src/runtime/numerics/numerics_impl.cpp (+25/-23)
To merge this branch: bzr merge lp:~nbrinza/zorba/bugs2
Reviewer Review Type Date Requested Status
Nicolae Brinza Approve
Matthias Brantner Approve
Review via email: mp+103938@code.launchpad.net

This proposal supersedes a proposal from 2012-04-24.

Commit message

Fixes for bugs #931501 and #866987 -- improved error messages for fn:format-number()

Description of the change

Fixes for bugs #931501 and #866987 -- improved error messages for fn:format-number()

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2012-04-28T07-07-01.371Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2012-04-28T12-33-01.78Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2012-04-28T13-24-54.156Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve.

Revision history for this message
Nicolae Brinza (nbrinza) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bugs2-2012-04-28T14-31-57.441Z is finished. The final status was:

All tests succeeded!

lp:~nbrinza/zorba/bugs2 updated
10805. By Nicolae Brinza

Fixes for bugs #931501 and #866987 -- improved error messages for fn:format-number() Approved: Nicolae Brinza, Matthias Brantner

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-04-25 17:16:48 +0000
3+++ ChangeLog 2012-04-27 20:11:20 +0000
4@@ -16,12 +16,13 @@
5 Optimization:
6
7 Bug Fixes/Other Changes:
8+ * 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)
9 * Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)
10 * Fixed bug 955135 (err:XQDY0044 not caught by try-catch expressions)
11 * Fixed bug #986075 (encountering flwor expr with no clauses; due to common
12 subexression being formed when inlining var in if-then-else expression)
13 * Fixed bug #967864 (var substitution did not update theFreeVars property)
14- * Fixed buf #891650 (context size var not always declared within path expr)
15+ * Fixed bug #891650 (context size var not always declared within path expr)
16 * Fixed bug #948879 (--uri-path doesn't work with fetch:content())
17 * Fixed bug in window iterator (binding the end vars in the output tuple stream)
18 * Fixed bug #866547 (protect index-join rule from general flwor)
19
20=== modified file 'src/diagnostics/diagnostic_en.xml'
21--- src/diagnostics/diagnostic_en.xml 2012-04-24 12:39:38 +0000
22+++ src/diagnostics/diagnostic_en.xml 2012-04-27 20:11:20 +0000
23@@ -983,7 +983,7 @@
24 <comment>
25 Invalid \c fn:format-number() picture string.
26 </comment>
27- <value>"$1": invalid fn:format-number() picture string</value>
28+ <value>"$1": invalid fn:format-number() picture string$2</value>
29 </diagnostic>
30
31 <diagnostic code="FODT0001">
32@@ -3643,6 +3643,31 @@
33 <entry key="ParseFragmentInvalidOptions">
34 <value>invalid options passed to the parse-xml:parse() function, the element must in the schema target namespace</value>
35 </entry>
36+
37+ <entry key="FormatNumberDuplicates">
38+ <value>: a sub-picture must not contain more than one of the "$3" sign</value>
39+ </entry>
40+
41+ <entry key="FormatNumberGroupingAdjacentToDecimal">
42+ <value>: a sub-picture must not contain a grouping-separator-sign adjacent to a decimal-separator-sign</value>
43+ </entry>
44+
45+ <entry key="FormatNumberIntegerPart">
46+ <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>
47+ </entry>
48+
49+ <entry key="FormatNumberFractionalPart">
50+ <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>
51+ </entry>
52+
53+ <entry key="FormatNumberPercentPermille">
54+ <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>
55+ </entry>
56+
57+ <entry key="FormatNumberAtLeastOneOptionalOrDecimal">
58+ <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>
59+ </entry>
60+
61
62 </subvalues>
63
64
65=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
66--- src/diagnostics/pregenerated/dict_en.cpp 2012-04-24 12:39:38 +0000
67+++ src/diagnostics/pregenerated/dict_en.cpp 2012-04-27 20:11:20 +0000
68@@ -47,7 +47,7 @@
69 { "FODC0006", "invalid content passed to $1: $2" },
70 { "FODC0007", "\"$1\": base URI passed to fn:parse() is not a valid absolute URI" },
71 { "FODF1280", "\"$1\": invalid decimal format name for fn:format-number()" },
72- { "FODF1310", "\"$1\": invalid fn:format-number() picture string" },
73+ { "FODF1310", "\"$1\": invalid fn:format-number() picture string$2" },
74 { "FODT0001", "overflow/underflow in date/time operation" },
75 { "FODT0002", "overflow/underflow in duration operation" },
76 { "FODT0003", "\"$1\": invalid timezone value" },
77@@ -514,6 +514,12 @@
78 { "~FileNotFoundOrReadable", "file not found or readable" },
79 { "~FnNilledArgNotNode", "fn:nilled() argument not a node" },
80 { "~FnOnlyInXQueryVersion_3", "function only available in XQuery $3" },
81+ { "~FormatNumberAtLeastOneOptionalOrDecimal", ": a sub-picture must contain at least one character that is an optional-digit-sign or a member of the decimal-digit-family" },
82+ { "~FormatNumberDuplicates", ": a sub-picture must not contain more than one of the \"$3\" sign" },
83+ { "~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" },
84+ { "~FormatNumberGroupingAdjacentToDecimal", ": a sub-picture must not contain a grouping-separator-sign adjacent to a decimal-separator-sign" },
85+ { "~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" },
86+ { "~FormatNumberPercentPermille", ": a sub-picture must not contain more than one percent-sign or per-mille-sign, and it must not contain one of each" },
87 { "~FullTextNotEnabled", "full-text was not enabled in this build" },
88 { "~FunctionFailedErrorCodeMessage_123", "$2 failed (error $3): $4" },
89 { "~FunctionFailed_12o", "$2 failed${: 3}" },
90
91=== modified file 'src/runtime/numerics/numerics_impl.cpp'
92--- src/runtime/numerics/numerics_impl.cpp 2012-04-24 12:39:38 +0000
93+++ src/runtime/numerics/numerics_impl.cpp 2012-04-27 20:11:20 +0000
94@@ -427,6 +427,8 @@
95 zstring infinity;
96 zstring NaN;
97 zstring minus;
98+
99+ zstring pictureString; // The original picture string, used for debugging and error reporting
100
101 class PartInfo
102 {
103@@ -500,14 +502,14 @@
104
105
106 // returns an error if there are two or more instances of the given pattern in the string
107-static void errorIfTwoOrMore(zstring const& part, const char* sep, QueryLoc& loc)
108+static void errorIfTwoOrMore(zstring const& part, const char* sep, FormatNumberInfo& info)
109 {
110 zstring::size_type const pos = part.find(sep);
111
112 if (pos != zstring::npos)
113 {
114 if (part.find(sep, strlen(sep), pos+1) != zstring::npos)
115- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(loc));
116+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberDuplicates), sep), ERROR_LOC(info.loc));
117 }
118 }
119
120@@ -521,19 +523,19 @@
121 if (str.empty())
122 return;
123
124- errorIfTwoOrMore(str, info.percent.c_str(), info.loc);
125- errorIfTwoOrMore(str, info.per_mille.c_str(), info.loc);
126+ errorIfTwoOrMore(str, info.percent.c_str(), info);
127+ errorIfTwoOrMore(str, info.per_mille.c_str(), info);
128
129 if (str.find(info.percent.c_str()) != zstring::npos &&
130 str.find(info.per_mille.c_str()) != zstring::npos)
131 {
132- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
133+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberPercentPermille)), ERROR_LOC(info.loc));
134 }
135
136 if (str.find(info.digit_sign.c_str()) == zstring::npos &&
137 str.find(info.zero_digit.c_str()) == zstring::npos)
138 {
139- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
140+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberAtLeastOneOptionalOrDecimal)), ERROR_LOC(info.loc));
141 }
142
143 // get grouping separators
144@@ -563,15 +565,16 @@
145 start += delta;
146 }
147
148- if (first_digit_sign != -1 && last_zero_sign != -1
149- &&
150- ((!fractional && first_digit_sign > last_zero_sign)
151- ||
152- (fractional && first_digit_sign < last_zero_sign)))
153- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
154+ if (first_digit_sign != -1 && last_zero_sign != -1)
155+ {
156+ if (!fractional && first_digit_sign > last_zero_sign)
157+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberIntegerPart)), ERROR_LOC(info.loc));
158+ else if (fractional && first_digit_sign < last_zero_sign)
159+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberFractionalPart)), ERROR_LOC(info.loc));
160+ }
161
162 if (part.grouping_pos.size() > 0 && part.grouping_pos[0] == 0)
163- throw XQUERY_EXCEPTION(err::XTDE1310, ERROR_LOC(info.loc));
164+ throw XQUERY_EXCEPTION(err::FODF1310, ERROR_PARAMS(info.pictureString, ZED(FormatNumberGroupingAdjacentToDecimal)), ERROR_LOC(info.loc));
165
166 if (part.grouping_pos.size() > 0)
167 {
168@@ -606,7 +609,7 @@
169 if (str.empty())
170 return;
171
172- errorIfTwoOrMore(str, info.decimal_separator.c_str(), info.loc);
173+ errorIfTwoOrMore(str, info.decimal_separator.c_str(), info);
174 zstring::size_type pos = str.find(info.decimal_separator.c_str());
175 if (pos != zstring::npos)
176 {
177@@ -648,18 +651,18 @@
178 }
179
180
181-static void parsePicture(zstring& picture, FormatNumberInfo& info)
182+static void parsePicture(FormatNumberInfo& info)
183 {
184- errorIfTwoOrMore(picture, info.pattern_separator.c_str(), info.loc);
185+ errorIfTwoOrMore(info.pictureString, info.pattern_separator.c_str(), info);
186
187- zstring::size_type pos = picture.find(info.pattern_separator.c_str());
188+ zstring::size_type pos = info.pictureString.find(info.pattern_separator.c_str());
189 if (pos != zstring::npos)
190 {
191- info.pos_subpicture.str = picture.substr(0, pos);
192- info.neg_subpicture.str = picture.substr(pos+1, picture.size() - pos);
193+ info.pos_subpicture.str = info.pictureString.substr(0, pos);
194+ info.neg_subpicture.str = info.pictureString.substr(pos+1, info.pictureString.size() - pos);
195 }
196 else
197- info.pos_subpicture.str = picture;
198+ info.pos_subpicture.str = info.pictureString;
199
200 parseSubpicture(info.pos_subpicture, info);
201 if (info.neg_subpicture.str.empty())
202@@ -862,7 +865,6 @@
203 FormatNumberIterator::nextImpl(store::Item_t& result, PlanState& planState) const
204 {
205 zstring resultString;
206- zstring pictureString;
207 store::Item_t numberItem, pictureItem, formatName;
208 FormatNumberInfo info;
209 DecimalFormat_t df_t;
210@@ -945,8 +947,8 @@
211
212 info.readFormat(df_t);
213
214- pictureString = pictureItem->getStringValue();
215- parsePicture(pictureString, info);
216+ info.pictureString = pictureItem->getStringValue();
217+ parsePicture(info);
218 formatNumber(resultString, result, info, theSctx->get_typemanager(), loc);
219
220 STACK_PUSH (GENV_ITEMFACTORY->createString(result, resultString), state);

Subscribers

People subscribed via source and target branches