Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11164
Merged at revision: 11347
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 72 lines (+22/-5)
3 files modified
src/runtime/numerics/format_integer.cpp (+20/-5)
test/rbkt/ExpQueryResults/zorba/math/format_integer/format-integer-1-10.xml.res (+1/-0)
test/rbkt/Queries/zorba/math/format_integer/format-integer-1-10.xq (+1/-0)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+157553@code.launchpad.net

Commit message

Fixed handling of what is most likely a mistake on the part of the user in a picture string, e.g., "1,000,00" where there are multiple grouping intervals, but they're not equally spaced.

Description of the change

Fixed handling of what is most likely a mistake on the part of the user in a picture string, e.g., "1,000,00" where there are multiple grouping intervals, but they're not equally spaced.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
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 pjl-misc-2013-04-07T18-05-41.007Z 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, Needs Information < 1, Resubmit < 1. Got: 1 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 pjl-misc-2013-04-07T19-16-41.14Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/runtime/numerics/format_integer.cpp'
2--- src/runtime/numerics/format_integer.cpp 2013-04-04 16:15:30 +0000
3+++ src/runtime/numerics/format_integer.cpp 2013-04-07 18:00:32 +0000
4@@ -468,11 +468,11 @@
5 bool grouping_interval_possible = true;
6 unicode::code_point grouping_separator_cp = 0;
7 int grouping_separators = 0;
8- zstring::size_type pos = 0, prev_grouping_pos = zstring::npos;
9+ utf8::size_type pos = 1, prev_grouping_pos = utf8::npos;
10
11 semicolon_counter = semicolons;
12 while ( ++u != u_picture_str.end() ) {
13- cp = *u, ++pos;
14+ cp = *u;
15 if ( cp == '#' ) {
16 if ( got_mandatory_digit ) {
17 //
18@@ -540,7 +540,7 @@
19 grouping_interval = pos - prev_grouping_pos;
20 else if ( pos - prev_grouping_pos != grouping_interval )
21 grouping_interval_possible = false;
22- prev_grouping_pos = pos;
23+ prev_grouping_pos = pos + 1;
24 }
25 } else {
26 throw XQUERY_EXCEPTION(
27@@ -554,6 +554,7 @@
28 );
29 }
30 u_pic_format += cp;
31+ ++pos;
32 } // while
33
34 if ( got_grouping_separator ) {
35@@ -571,9 +572,23 @@
36 ERROR_LOC( loc )
37 );
38 }
39+
40 if ( grouping_interval_possible ) {
41- if ( !grouping_interval && grouping_separator_cp )
42- grouping_interval = pos - prev_grouping_pos;
43+ if ( !grouping_interval ) {
44+ if ( grouping_separator_cp ) {
45+ //
46+ // There's only a single grouping separator, e.g., "1,000".
47+ //
48+ grouping_interval = pos - prev_grouping_pos;
49+ }
50+ } else if ( pos - prev_grouping_pos != grouping_interval ) {
51+ //
52+ // There are multiple grouping separators, but they're not equally
53+ // spaced from the last digit, e.g., "1,000,00". (This is most likely
54+ // a mistake on the part of the user.)
55+ //
56+ grouping_interval = 0;
57+ }
58 pic->primary.grouping_interval = grouping_interval;
59 } else
60 pic->primary.mandatory_grouping_seps = grouping_separators;
61
62=== added file 'test/rbkt/ExpQueryResults/zorba/math/format_integer/format-integer-1-10.xml.res'
63--- test/rbkt/ExpQueryResults/zorba/math/format_integer/format-integer-1-10.xml.res 1970-01-01 00:00:00 +0000
64+++ test/rbkt/ExpQueryResults/zorba/math/format_integer/format-integer-1-10.xml.res 2013-04-07 18:00:32 +0000
65@@ -0,0 +1,1 @@
66+true
67
68=== added file 'test/rbkt/Queries/zorba/math/format_integer/format-integer-1-10.xq'
69--- test/rbkt/Queries/zorba/math/format_integer/format-integer-1-10.xq 1970-01-01 00:00:00 +0000
70+++ test/rbkt/Queries/zorba/math/format_integer/format-integer-1-10.xq 2013-04-07 18:00:32 +0000
71@@ -0,0 +1,1 @@
72+fn:format-integer( 123456789, "0,000,00" ) eq "1234,567,89"

Subscribers

People subscribed via source and target branches