Merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba
- bug-1090089
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Paul J. Lucas |
Approved revision: | 11473 |
Merged at revision: | 11451 |
Proposed branch: | lp:~paul-lucas/zorba/bug-1090089 |
Merge into: | lp:zorba |
Diff against target: |
896 lines (+218/-189) 34 files modified
src/compiler/parser/symbol_table.cpp (+0/-2) src/diagnostics/diagnostic_en.xml (+2/-2) src/diagnostics/pregenerated/dict_en.cpp (+1/-1) src/functions/func_sequences_impl.cpp (+5/-5) src/types/casting.cpp (+54/-7) src/zorbatypes/decimal.cpp (+71/-104) src/zorbatypes/floatimpl.cpp (+34/-43) src/zorbatypes/integer.cpp (+16/-18) src/zorbatypes/integer.h (+11/-5) test/fots/CMakeLists.txt (+0/-2) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-01.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-02.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-03.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-04.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-05.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-06.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-07.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-08.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-09.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-10.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-11.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/numerics/xs_float-12.xml.res (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-01.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-02.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-03.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-04.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-05.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-06.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-07.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-08.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-09.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-10.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-11.xq (+1/-0) test/rbkt/Queries/zorba/numerics/xs_float-12.xq (+1/-0) |
To merge this branch: | bzr merge lp:~paul-lucas/zorba/bug-1090089 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+163085@code.launchpad.net |
Commit message
Rewrote decimal reduction code -- fixes rounding and FOTS distinct-values tests.
Description of the change
Rewrote decimal reduction code -- fixes rounding and FOTS distinct-values tests.
Paul J. Lucas (paul-lucas) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
28 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
14 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
5 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
3 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Paul J. Lucas (paul-lucas) wrote : | # |
Note: even though FOTS test orderBy52a now fails, I think it worked before by "accident." The code is more consistent now, so orderBy52a now fails in the same way that the other FOTS orderBy tests fail.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
5 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
4 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-1090089-2013-05-
All tests succeeded!
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.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/bug-1090089 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-1090089-2013-05-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-1090089-2013-05-
All tests succeeded!
Preview Diff
1 | === modified file 'src/compiler/parser/symbol_table.cpp' | |||
2 | --- src/compiler/parser/symbol_table.cpp 2013-05-09 18:03:47 +0000 | |||
3 | +++ src/compiler/parser/symbol_table.cpp 2013-05-14 23:54:28 +0000 | |||
4 | @@ -242,7 +242,6 @@ | |||
5 | 242 | return new xs_decimal(text); | 242 | return new xs_decimal(text); |
6 | 243 | } | 243 | } |
7 | 244 | 244 | ||
8 | 245 | // Will return NULL if std::range_error is raised | ||
9 | 246 | xs_double* symbol_table::doubleval(char const* text, size_t length) | 245 | xs_double* symbol_table::doubleval(char const* text, size_t length) |
10 | 247 | { | 246 | { |
11 | 248 | try { | 247 | try { |
12 | @@ -253,7 +252,6 @@ | |||
13 | 253 | } | 252 | } |
14 | 254 | } | 253 | } |
15 | 255 | 254 | ||
16 | 256 | // Will return NULL if std::range_error is raised | ||
17 | 257 | xs_integer* symbol_table::integerval(char const* text, size_t length) | 255 | xs_integer* symbol_table::integerval(char const* text, size_t length) |
18 | 258 | { | 256 | { |
19 | 259 | try { | 257 | try { |
20 | 260 | 258 | ||
21 | === modified file 'src/diagnostics/diagnostic_en.xml' | |||
22 | --- src/diagnostics/diagnostic_en.xml 2013-05-04 21:54:40 +0000 | |||
23 | +++ src/diagnostics/diagnostic_en.xml 2013-05-14 23:54:28 +0000 | |||
24 | @@ -1301,9 +1301,9 @@ | |||
25 | 1301 | 1301 | ||
26 | 1302 | <diagnostic code="FOCA0003"> | 1302 | <diagnostic code="FOCA0003"> |
27 | 1303 | <comment> | 1303 | <comment> |
29 | 1304 | Input value too large for integer. | 1304 | Input value too large for integer. |
30 | 1305 | </comment> | 1305 | </comment> |
32 | 1306 | <value>"$1": value too large for integer</value> | 1306 | <value>"$1": value${ of type 2} too large for $3?3:{integer}</value> |
33 | 1307 | </diagnostic> | 1307 | </diagnostic> |
34 | 1308 | 1308 | ||
35 | 1309 | <diagnostic code="FOCA0005"> | 1309 | <diagnostic code="FOCA0005"> |
36 | 1310 | 1310 | ||
37 | === modified file 'src/diagnostics/pregenerated/dict_en.cpp' | |||
38 | --- src/diagnostics/pregenerated/dict_en.cpp 2013-05-04 21:54:40 +0000 | |||
39 | +++ src/diagnostics/pregenerated/dict_en.cpp 2013-05-14 23:54:28 +0000 | |||
40 | @@ -32,7 +32,7 @@ | |||
41 | 32 | { "FOAR0002", "numeric operation overflow/underflow${: 1}" }, | 32 | { "FOAR0002", "numeric operation overflow/underflow${: 1}" }, |
42 | 33 | { "FOCA0001", "\"$1\": value too large for decimal" }, | 33 | { "FOCA0001", "\"$1\": value too large for decimal" }, |
43 | 34 | { "FOCA0002", "$1" }, | 34 | { "FOCA0002", "$1" }, |
45 | 35 | { "FOCA0003", "\"$1\": value too large for integer" }, | 35 | { "FOCA0003", "\"$1\": value${ of type 2} too large for $3?3:{integer}" }, |
46 | 36 | { "FOCA0005", "NaN supplied as float/double value" }, | 36 | { "FOCA0005", "NaN supplied as float/double value" }, |
47 | 37 | { "FOCA0006", "\"$1\": string to be cast to decimal has too many digits of precision" }, | 37 | { "FOCA0006", "\"$1\": string to be cast to decimal has too many digits of precision" }, |
48 | 38 | { "FOCH0001", "\"$1\": invalid code point" }, | 38 | { "FOCH0001", "\"$1\": invalid code point" }, |
49 | 39 | 39 | ||
50 | === modified file 'src/functions/func_sequences_impl.cpp' | |||
51 | --- src/functions/func_sequences_impl.cpp 2013-03-24 20:40:03 +0000 | |||
52 | +++ src/functions/func_sequences_impl.cpp 2013-05-14 23:54:28 +0000 | |||
53 | @@ -79,7 +79,7 @@ | |||
54 | 79 | pos = to_xs_long(ipos); | 79 | pos = to_xs_long(ipos); |
55 | 80 | } | 80 | } |
56 | 81 | } | 81 | } |
58 | 82 | catch (std::range_error&) | 82 | catch (std::exception const&) |
59 | 83 | { | 83 | { |
60 | 84 | return false; | 84 | return false; |
61 | 85 | } | 85 | } |
62 | @@ -601,7 +601,7 @@ | |||
63 | 601 | pos = to_xs_long(ipos); | 601 | pos = to_xs_long(ipos); |
64 | 602 | len = to_xs_long(ilen); | 602 | len = to_xs_long(ilen); |
65 | 603 | } | 603 | } |
67 | 604 | catch (std::range_error&) | 604 | catch (std::range_error const&) |
68 | 605 | { | 605 | { |
69 | 606 | goto done; | 606 | goto done; |
70 | 607 | } | 607 | } |
71 | @@ -791,7 +791,7 @@ | |||
72 | 791 | { | 791 | { |
73 | 792 | store::Item* posItem = static_cast<const const_expr*>(posExpr)->get_val(); | 792 | store::Item* posItem = static_cast<const const_expr*>(posExpr)->get_val(); |
74 | 793 | 793 | ||
76 | 794 | xs_integer pos = posItem->getIntegerValue();; | 794 | xs_integer pos( posItem->getIntegerValue() ); |
77 | 795 | 795 | ||
78 | 796 | if (inputExpr->get_expr_kind() == relpath_expr_kind) | 796 | if (inputExpr->get_expr_kind() == relpath_expr_kind) |
79 | 797 | { | 797 | { |
80 | @@ -799,14 +799,14 @@ | |||
81 | 799 | 799 | ||
82 | 800 | csize numSteps = pathExpr->numSteps(); | 800 | csize numSteps = pathExpr->numSteps(); |
83 | 801 | 801 | ||
85 | 802 | if (pos > Integer(0) && numSteps == 2) | 802 | if (pos.sign() > 0 && numSteps == 2) |
86 | 803 | { | 803 | { |
87 | 804 | xs_long pos2; | 804 | xs_long pos2; |
88 | 805 | try | 805 | try |
89 | 806 | { | 806 | { |
90 | 807 | pos2 = posItem->getLongValue(); | 807 | pos2 = posItem->getLongValue(); |
91 | 808 | } | 808 | } |
93 | 809 | catch (std::range_error&) | 809 | catch (std::range_error const&) |
94 | 810 | { | 810 | { |
95 | 811 | goto done; | 811 | goto done; |
96 | 812 | } | 812 | } |
97 | 813 | 813 | ||
98 | === modified file 'src/types/casting.cpp' | |||
99 | --- src/types/casting.cpp 2013-05-09 00:21:51 +0000 | |||
100 | +++ src/types/casting.cpp 2013-05-14 23:54:28 +0000 | |||
101 | @@ -148,6 +148,45 @@ | |||
102 | 148 | } | 148 | } |
103 | 149 | 149 | ||
104 | 150 | 150 | ||
105 | 151 | void throwFOCA0003Exception(const zstring& str, const ErrorInfo& info) | ||
106 | 152 | { | ||
107 | 153 | if (info.theSourceType) | ||
108 | 154 | { | ||
109 | 155 | throw XQUERY_EXCEPTION( | ||
110 | 156 | err::FOCA0003, | ||
111 | 157 | ERROR_PARAMS( | ||
112 | 158 | str, | ||
113 | 159 | info.theSourceType->toSchemaString(), | ||
114 | 160 | info.theTargetType->toSchemaString() | ||
115 | 161 | ), | ||
116 | 162 | ERROR_LOC( info.theLoc ) | ||
117 | 163 | ); | ||
118 | 164 | } | ||
119 | 165 | else | ||
120 | 166 | { | ||
121 | 167 | TypeManager& tm = GENV_TYPESYSTEM; | ||
122 | 168 | |||
123 | 169 | xqtref_t sourceType = | ||
124 | 170 | tm.create_builtin_atomic_type(info.theSourceTypeCode, | ||
125 | 171 | TypeConstants::QUANT_ONE); | ||
126 | 172 | |||
127 | 173 | xqtref_t targetType = | ||
128 | 174 | tm.create_builtin_atomic_type(info.theTargetTypeCode, | ||
129 | 175 | TypeConstants::QUANT_ONE); | ||
130 | 176 | |||
131 | 177 | throw XQUERY_EXCEPTION( | ||
132 | 178 | err::FOCA0003, | ||
133 | 179 | ERROR_PARAMS( | ||
134 | 180 | str, | ||
135 | 181 | sourceType->toSchemaString(), | ||
136 | 182 | targetType->toSchemaString() | ||
137 | 183 | ), | ||
138 | 184 | ERROR_LOC( info.theLoc ) | ||
139 | 185 | ); | ||
140 | 186 | } | ||
141 | 187 | } | ||
142 | 188 | |||
143 | 189 | |||
144 | 151 | void throwFORG0001Exception(const zstring& str, const ErrorInfo& info) | 190 | void throwFORG0001Exception(const zstring& str, const ErrorInfo& info) |
145 | 152 | { | 191 | { |
146 | 153 | if (info.theTargetType) | 192 | if (info.theTargetType) |
147 | @@ -375,14 +414,14 @@ | |||
148 | 375 | { | 414 | { |
149 | 376 | try | 415 | try |
150 | 377 | { | 416 | { |
152 | 378 | const xs_nonNegativeInteger n(strval.c_str()); | 417 | xs_nonNegativeInteger const n(strval.c_str()); |
153 | 379 | aFactory->createNonNegativeInteger(result, n); | 418 | aFactory->createNonNegativeInteger(result, n); |
154 | 380 | } | 419 | } |
156 | 381 | catch (const std::invalid_argument& ) | 420 | catch ( std::invalid_argument const& ) |
157 | 382 | { | 421 | { |
158 | 383 | throwFORG0001Exception(strval, errInfo); | 422 | throwFORG0001Exception(strval, errInfo); |
159 | 384 | } | 423 | } |
161 | 385 | catch (const std::range_error& ) | 424 | catch ( std::range_error const& ) |
162 | 386 | { | 425 | { |
163 | 387 | RAISE_ERROR(err::FOAR0002, errInfo.theLoc, ERROR_PARAMS(strval)); | 426 | RAISE_ERROR(err::FOAR0002, errInfo.theLoc, ERROR_PARAMS(strval)); |
164 | 388 | } | 427 | } |
165 | @@ -954,13 +993,17 @@ | |||
166 | 954 | 993 | ||
167 | 955 | T1_TO_T2(flt, int) | 994 | T1_TO_T2(flt, int) |
168 | 956 | { | 995 | { |
169 | 996 | xs_float const f( aItem->getFloatValue() ); | ||
170 | 997 | if ( !f.isFinite() ) | ||
171 | 998 | throwFOCA0002Exception(aItem->getStringValue(), errInfo); | ||
172 | 957 | try | 999 | try |
173 | 958 | { | 1000 | { |
175 | 959 | aFactory->createInteger(result, xs_integer(aItem->getFloatValue())); | 1001 | xs_integer const n( f ); |
176 | 1002 | aFactory->createInteger(result, n); | ||
177 | 960 | } | 1003 | } |
178 | 961 | catch (const std::exception&) | 1004 | catch (const std::exception&) |
179 | 962 | { | 1005 | { |
181 | 963 | throwFOCA0002Exception(aItem->getStringValue(), errInfo); | 1006 | throwFOCA0003Exception(aItem->getStringValue(), errInfo); |
182 | 964 | } | 1007 | } |
183 | 965 | } | 1008 | } |
184 | 966 | 1009 | ||
185 | @@ -1007,13 +1050,17 @@ | |||
186 | 1007 | 1050 | ||
187 | 1008 | T1_TO_T2(dbl, int) | 1051 | T1_TO_T2(dbl, int) |
188 | 1009 | { | 1052 | { |
189 | 1053 | xs_double const d( aItem->getDoubleValue() ); | ||
190 | 1054 | if ( !d.isFinite() ) | ||
191 | 1055 | throwFOCA0002Exception(aItem->getStringValue(), errInfo); | ||
192 | 1010 | try | 1056 | try |
193 | 1011 | { | 1057 | { |
195 | 1012 | aFactory->createInteger(result, xs_integer(aItem->getDoubleValue())); | 1058 | xs_integer const n( d ); |
196 | 1059 | aFactory->createInteger(result, n); | ||
197 | 1013 | } | 1060 | } |
198 | 1014 | catch (const std::exception& ) | 1061 | catch (const std::exception& ) |
199 | 1015 | { | 1062 | { |
201 | 1016 | throwFOCA0002Exception(aItem->getStringValue(), errInfo); | 1063 | throwFOCA0003Exception(aItem->getStringValue(), errInfo); |
202 | 1017 | } | 1064 | } |
203 | 1018 | } | 1065 | } |
204 | 1019 | 1066 | ||
205 | 1020 | 1067 | ||
206 | === modified file 'src/zorbatypes/decimal.cpp' | |||
207 | --- src/zorbatypes/decimal.cpp 2013-05-09 00:21:51 +0000 | |||
208 | +++ src/zorbatypes/decimal.cpp 2013-05-14 23:54:28 +0000 | |||
209 | @@ -27,6 +27,8 @@ | |||
210 | 27 | #include "integer.h" | 27 | #include "integer.h" |
211 | 28 | #include "numconversions.h" | 28 | #include "numconversions.h" |
212 | 29 | 29 | ||
213 | 30 | using namespace std; | ||
214 | 31 | |||
215 | 30 | namespace zorba { | 32 | namespace zorba { |
216 | 31 | 33 | ||
217 | 32 | /////////////////////////////////////////////////////////////////////////////// | 34 | /////////////////////////////////////////////////////////////////////////////// |
218 | @@ -35,7 +37,7 @@ | |||
219 | 35 | 37 | ||
220 | 36 | void Decimal::parse( char const *s, value_type *result, int parse_options ) { | 38 | void Decimal::parse( char const *s, value_type *result, int parse_options ) { |
221 | 37 | if ( !*s ) | 39 | if ( !*s ) |
223 | 38 | throw std::invalid_argument( "empty string" ); | 40 | throw invalid_argument( "empty string" ); |
224 | 39 | 41 | ||
225 | 40 | s = ascii::trim_start_space( s ); | 42 | s = ascii::trim_start_space( s ); |
226 | 41 | char const *const first_non_ws = s; | 43 | char const *const first_non_ws = s; |
227 | @@ -58,13 +60,11 @@ | |||
228 | 58 | ++s; | 60 | ++s; |
229 | 59 | } | 61 | } |
230 | 60 | if ( *s ) | 62 | if ( *s ) |
234 | 61 | throw std::invalid_argument( | 63 | throw invalid_argument( BUILD_STRING( '"', *s, "\": invalid character" ) ); |
232 | 62 | BUILD_STRING( '"', *s, "\": invalid character" ) | ||
233 | 63 | ); | ||
235 | 64 | 64 | ||
236 | 65 | if ( first_trailing_ws ) { | 65 | if ( first_trailing_ws ) { |
237 | 66 | ptrdiff_t const size = first_trailing_ws - first_non_ws; | 66 | ptrdiff_t const size = first_trailing_ws - first_non_ws; |
239 | 67 | char *const copy = std::strncpy( new char[ size + 1 ], first_non_ws, size ); | 67 | char *const copy = ::strncpy( new char[ size + 1 ], first_non_ws, size ); |
240 | 68 | copy[ size ] = '\0'; | 68 | copy[ size ] = '\0'; |
241 | 69 | *result = copy; | 69 | *result = copy; |
242 | 70 | delete[] copy; | 70 | delete[] copy; |
243 | @@ -73,98 +73,66 @@ | |||
244 | 73 | } | 73 | } |
245 | 74 | 74 | ||
246 | 75 | /** | 75 | /** |
249 | 76 | * Remove trailing .99999 or .000001. | 76 | * Rounds .xxx9999xxx or .xxx000000xxx. |
248 | 77 | * Find four or five consecutive 9 or 0 after decimal point and eliminate them. | ||
250 | 78 | */ | 77 | */ |
251 | 79 | void Decimal::reduce( char *s ) { | 78 | void Decimal::reduce( char *s ) { |
254 | 80 | char *dot = strrchr( s, '.' ); | 79 | char *const dot = ::strrchr( s, '.' ); |
255 | 81 | if ( !dot ) // not a floating point number | 80 | if ( !dot ) // not a floating-point number |
256 | 82 | return; | 81 | return; |
257 | 83 | 82 | ||
258 | 84 | bool has_e = false; | 83 | bool has_e = false; |
264 | 85 | char *e = strrchr( s, 'E' ); | 84 | char *e = ::strpbrk( s, "eE" ); |
265 | 86 | if ( !e ) | 85 | if ( !e ) |
266 | 87 | e = strrchr( s, 'e' ); | 86 | e = s + ::strlen( s ); // eliminates a special-case |
262 | 88 | if ( !e ) | ||
263 | 89 | e = s + strlen( s ); | ||
267 | 90 | else | 87 | else |
268 | 91 | has_e = true; | 88 | has_e = true; |
345 | 92 | 89 | char *digit = e - 1; | |
346 | 93 | char *digits = e - 1; | 90 | |
347 | 94 | for ( int pos = (int)(digits - dot); pos > 8; --pos, --digits ) { | 91 | if ( ::strncmp( dot + 1, "9999", 3 ) == 0 ) { |
348 | 95 | if ( *digits == '9' ) { | 92 | // The "leading nines" case, e.g., 12.9999[34][E56] |
349 | 96 | if ( digits[-1] == '9' && digits[-2] == '9' && digits[-3] == '9' ) { | 93 | if ( has_e ) { |
350 | 97 | if ( ascii::is_digit( digits[1] ) && digits[1] >= '5' ) | 94 | ::memmove( dot + 2, e, strlen( e ) + 1 ); |
351 | 98 | digits -= 4; | 95 | dot[1] = '0'; |
352 | 99 | else if ( digits[-4] == '9' ) | 96 | } else |
353 | 100 | digits -= 5; | 97 | ::memmove( dot, e, strlen( e ) + 1 ); |
354 | 101 | else | 98 | digit = dot - 1; |
355 | 102 | continue; | 99 | char const *const first = *s == '-' ? s + 1 : s; |
356 | 103 | 100 | while ( true ) { | |
357 | 104 | // now add 1 to remaining digits | 101 | if ( *digit == '9' ) { |
358 | 105 | char *last_digit = digits; | 102 | *digit = '0'; |
359 | 106 | while ( digits >= s ) { | 103 | if ( digit == first ) { |
360 | 107 | if ( digits[0] == '.' ) { | 104 | // slide to the right to insert a leading '1' |
361 | 108 | // skip | 105 | ::memmove( digit + 1, digit, strlen( digit ) + 1 ); |
362 | 109 | } else if ( digits[0] == '9' ) { | 106 | *digit = '1'; |
363 | 110 | digits[0] = '0'; | 107 | break; |
364 | 111 | if ( last_digit == digits ) | 108 | } |
365 | 112 | --last_digit; | 109 | --digit; |
366 | 113 | } else { | 110 | } else { |
367 | 114 | if ( ascii::is_digit( digits[0] ) ) | 111 | ++digit[0]; // e.g., 12 => 13 |
368 | 115 | digits[0]++; | 112 | break; |
369 | 116 | break; | 113 | } |
370 | 117 | } | 114 | } |
371 | 118 | --digits; | 115 | return; |
372 | 119 | } | 116 | } |
373 | 120 | if ( last_digit[0] != '.' ) | 117 | |
374 | 121 | ++last_digit; | 118 | if ( char *const nines = ::strstr( dot + 1, "9999" ) ) { |
375 | 122 | else if ( has_e ) { | 119 | // The "in-the-middle nines" case, e.g., 12.349999[56][E78] |
376 | 123 | last_digit[1] = '0'; | 120 | ++nines[-1]; // e.g., .xxx19 => .xxx29 |
377 | 124 | last_digit += 2; | 121 | ::memmove( nines, e, strlen( e ) + 1 ); |
378 | 125 | } | 122 | return; |
379 | 126 | if ( digits < s || !ascii::is_digit( digits[0] ) ) { | 123 | } |
380 | 127 | memmove( s + 1, s, last_digit - s ); | 124 | |
381 | 128 | ++last_digit; | 125 | if ( char *zeros = ::strstr( dot + 1, "000000" ) ) { |
382 | 129 | if ( ascii::is_digit( s[0] ) ) | 126 | // The "zeros" case, e.g., 12.0000003, 12.340000005. |
383 | 130 | s[0] = '1'; | 127 | if ( zeros == dot + 1 && has_e ) |
384 | 131 | else | 128 | ++zeros; // leave one 0 after . and before E |
385 | 132 | s[1] = '1'; | 129 | ::memmove( zeros, e, strlen( e ) + 1 ); |
386 | 133 | if ( has_e ) { // increment the exponent | 130 | if ( !has_e ) { |
387 | 134 | ++dot; | 131 | char *const last = s + ::strlen( s ) - 1; |
388 | 135 | dot[0] = dot[-1]; | 132 | if ( *last == '.' ) |
389 | 136 | dot[-1] = '.'; | 133 | *last = '\0'; |
390 | 137 | sprintf( e + 1, "%d", atoi( e + 1 ) + 1 ); | 134 | } |
391 | 138 | --last_digit; | 135 | return; |
316 | 139 | } | ||
317 | 140 | } | ||
318 | 141 | int const e_len = strlen( e ); | ||
319 | 142 | memmove( last_digit, e, e_len ); | ||
320 | 143 | last_digit[ e_len ] = 0; | ||
321 | 144 | break; | ||
322 | 145 | } | ||
323 | 146 | } else if ( *digits == '0' ) { | ||
324 | 147 | if ( digits[-1] == '0' && digits[-2] == '0' && digits[-3] == '0' ) { | ||
325 | 148 | if ( ascii::is_digit( digits[1] ) && digits[1] < '5' ) | ||
326 | 149 | digits -= 4; | ||
327 | 150 | else if ( digits[-4] == '0' ) | ||
328 | 151 | digits -= 5; | ||
329 | 152 | else | ||
330 | 153 | continue; | ||
331 | 154 | while ( *digits == '0' ) | ||
332 | 155 | --digits; | ||
333 | 156 | if ( *digits != '.' ) | ||
334 | 157 | ++digits; | ||
335 | 158 | else if ( has_e ) { | ||
336 | 159 | digits[1] = '0'; | ||
337 | 160 | digits += 2; | ||
338 | 161 | } | ||
339 | 162 | int const e_len = strlen( e ); | ||
340 | 163 | memmove( digits, e, e_len ); | ||
341 | 164 | digits[ e_len ] = '\0'; | ||
342 | 165 | break; | ||
343 | 166 | } | ||
344 | 167 | } | ||
392 | 168 | } | 136 | } |
393 | 169 | } | 137 | } |
394 | 170 | 138 | ||
395 | @@ -189,7 +157,7 @@ | |||
396 | 189 | if ( f != f || | 157 | if ( f != f || |
397 | 190 | f == std::numeric_limits<float>::infinity() || | 158 | f == std::numeric_limits<float>::infinity() || |
398 | 191 | f == -std::numeric_limits<float>::infinity() ) | 159 | f == -std::numeric_limits<float>::infinity() ) |
400 | 192 | throw std::invalid_argument( "float value = infinity" ); | 160 | throw invalid_argument( "float value = infinity" ); |
401 | 193 | value_ = f; | 161 | value_ = f; |
402 | 194 | } | 162 | } |
403 | 195 | 163 | ||
404 | @@ -197,19 +165,19 @@ | |||
405 | 197 | if ( d != d || | 165 | if ( d != d || |
406 | 198 | d == std::numeric_limits<double>::infinity() || | 166 | d == std::numeric_limits<double>::infinity() || |
407 | 199 | d == -std::numeric_limits<double>::infinity() ) | 167 | d == -std::numeric_limits<double>::infinity() ) |
409 | 200 | throw std::invalid_argument( "double value = infinity" ); | 168 | throw invalid_argument( "double value = infinity" ); |
410 | 201 | value_ = d; | 169 | value_ = d; |
411 | 202 | } | 170 | } |
412 | 203 | 171 | ||
413 | 204 | Decimal::Decimal( Double const &d ) { | 172 | Decimal::Decimal( Double const &d ) { |
414 | 205 | if ( !d.isFinite() ) | 173 | if ( !d.isFinite() ) |
416 | 206 | throw std::invalid_argument( "double value = infinity" ); | 174 | throw invalid_argument( "double value = infinity" ); |
417 | 207 | value_ = d.getNumber(); | 175 | value_ = d.getNumber(); |
418 | 208 | } | 176 | } |
419 | 209 | 177 | ||
420 | 210 | Decimal::Decimal( Float const &f ) { | 178 | Decimal::Decimal( Float const &f ) { |
421 | 211 | if ( !f.isFinite() ) | 179 | if ( !f.isFinite() ) |
423 | 212 | throw std::invalid_argument( "float value = infinity" ); | 180 | throw invalid_argument( "float value = infinity" ); |
424 | 213 | value_ = f.getNumber(); | 181 | value_ = f.getNumber(); |
425 | 214 | } | 182 | } |
426 | 215 | 183 | ||
427 | @@ -252,14 +220,14 @@ | |||
428 | 252 | 220 | ||
429 | 253 | Decimal& Decimal::operator=( Double const &d ) { | 221 | Decimal& Decimal::operator=( Double const &d ) { |
430 | 254 | if ( !d.isFinite() ) | 222 | if ( !d.isFinite() ) |
432 | 255 | throw std::invalid_argument( "not finite" ); | 223 | throw invalid_argument( "not finite" ); |
433 | 256 | value_ = d.getNumber(); | 224 | value_ = d.getNumber(); |
434 | 257 | return *this; | 225 | return *this; |
435 | 258 | } | 226 | } |
436 | 259 | 227 | ||
437 | 260 | Decimal& Decimal::operator=( Float const &f ) { | 228 | Decimal& Decimal::operator=( Float const &f ) { |
438 | 261 | if ( !f.isFinite() ) | 229 | if ( !f.isFinite() ) |
440 | 262 | throw std::invalid_argument( "not finite" ); | 230 | throw invalid_argument( "not finite" ); |
441 | 263 | value_ = f.getNumber(); | 231 | value_ = f.getNumber(); |
442 | 264 | return *this; | 232 | return *this; |
443 | 265 | } | 233 | } |
444 | @@ -389,7 +357,7 @@ | |||
445 | 389 | if ( value >= MAPM::getMinInt64() ) { | 357 | if ( value >= MAPM::getMinInt64() ) { |
446 | 390 | // hash it as int64 | 358 | // hash it as int64 |
447 | 391 | value.toIntegerString( bufp ); | 359 | value.toIntegerString( bufp ); |
449 | 392 | std::stringstream ss( bufp ); | 360 | stringstream ss( bufp ); |
450 | 393 | int64_t n; | 361 | int64_t n; |
451 | 394 | ss >> n; | 362 | ss >> n; |
452 | 395 | assert( ss.eof() ); | 363 | assert( ss.eof() ); |
453 | @@ -400,7 +368,7 @@ | |||
454 | 400 | } else if ( value <= MAPM::getMaxUInt64() ) { | 368 | } else if ( value <= MAPM::getMaxUInt64() ) { |
455 | 401 | // hash it as uint64 | 369 | // hash it as uint64 |
456 | 402 | value.toIntegerString( bufp ); | 370 | value.toIntegerString( bufp ); |
458 | 403 | std::stringstream ss( bufp ); | 371 | stringstream ss( bufp ); |
459 | 404 | uint64_t n; | 372 | uint64_t n; |
460 | 405 | ss >> n; | 373 | ss >> n; |
461 | 406 | assert( ss.eof() ); | 374 | assert( ss.eof() ); |
462 | @@ -411,7 +379,7 @@ | |||
463 | 411 | 379 | ||
464 | 412 | // In all other cases, hash it as double | 380 | // In all other cases, hash it as double |
465 | 413 | value.toFixPtString( bufp, ZORBA_FLOAT_POINT_PRECISION ); | 381 | value.toFixPtString( bufp, ZORBA_FLOAT_POINT_PRECISION ); |
467 | 414 | std::stringstream ss( bufp ); | 382 | stringstream ss( bufp ); |
468 | 415 | double n; | 383 | double n; |
469 | 416 | ss >> n; | 384 | ss >> n; |
470 | 417 | assert( ss.eof() ); | 385 | assert( ss.eof() ); |
471 | @@ -422,7 +390,7 @@ | |||
472 | 422 | 390 | ||
473 | 423 | zstring Decimal::toString( value_type const &value, bool minusZero, | 391 | zstring Decimal::toString( value_type const &value, bool minusZero, |
474 | 424 | int precision ) { | 392 | int precision ) { |
476 | 425 | char buf[ 1024 ]; | 393 | char buf[ 2048 ]; |
477 | 426 | 394 | ||
478 | 427 | if ( minusZero ) { | 395 | if ( minusZero ) { |
479 | 428 | if ( value.sign() == 0 ) | 396 | if ( value.sign() == 0 ) |
480 | @@ -440,10 +408,9 @@ | |||
481 | 440 | // | 408 | // |
482 | 441 | if ( strchr( buf, '.' ) != 0 ) { | 409 | if ( strchr( buf, '.' ) != 0 ) { |
483 | 442 | // remove trailing 0's | 410 | // remove trailing 0's |
488 | 443 | char *last = buf + strlen( buf ) - 1; | 411 | char *last = buf + strlen( buf ); |
489 | 444 | while ( *last == '0' && last > buf ) | 412 | while ( *--last == '0' ) |
490 | 445 | *last-- = '\0'; | 413 | *last = '\0'; |
487 | 446 | |||
491 | 447 | if ( *last == '.' ) // remove '.' if no digits after it | 414 | if ( *last == '.' ) // remove '.' if no digits after it |
492 | 448 | *last = '\0'; | 415 | *last = '\0'; |
493 | 449 | } | 416 | } |
494 | 450 | 417 | ||
495 | === modified file 'src/zorbatypes/floatimpl.cpp' | |||
496 | --- src/zorbatypes/floatimpl.cpp 2013-05-09 00:21:51 +0000 | |||
497 | +++ src/zorbatypes/floatimpl.cpp 2013-05-14 23:54:28 +0000 | |||
498 | @@ -130,7 +130,7 @@ | |||
499 | 130 | } else if ( strncmp( s, "NaN", 3 ) == 0 ) { | 130 | } else if ( strncmp( s, "NaN", 3 ) == 0 ) { |
500 | 131 | value_ = FloatImpl<FloatType>::nan().value_; | 131 | value_ = FloatImpl<FloatType>::nan().value_; |
501 | 132 | s += 3; | 132 | s += 3; |
503 | 133 | } else if ( strncmp( s, "+INF", 4 ) == 0 ) { | 133 | } else if ( strncmp( s, "+INF", 4 ) == 0 ) { // allowed by XSD 1.1 |
504 | 134 | value_ = FloatImpl<FloatType>::pos_inf().value_; | 134 | value_ = FloatImpl<FloatType>::pos_inf().value_; |
505 | 135 | s += 4; | 135 | s += 4; |
506 | 136 | } else | 136 | } else |
507 | @@ -351,11 +351,7 @@ | |||
508 | 351 | return "0"; | 351 | return "0"; |
509 | 352 | if ( isNegZero() ) | 352 | if ( isNegZero() ) |
510 | 353 | return "-0"; | 353 | return "-0"; |
516 | 354 | 354 | return ztd::to_string( static_cast<long long>( value_ ) ); | |
512 | 355 | // TODO: make xs_int | ||
513 | 356 | char buf[174]; | ||
514 | 357 | sprintf( buf, "%d", (int)value_ ); | ||
515 | 358 | return buf; | ||
517 | 359 | } | 355 | } |
518 | 360 | 356 | ||
519 | 361 | template<typename F> | 357 | template<typename F> |
520 | @@ -379,9 +375,9 @@ | |||
521 | 379 | #if 1 | 375 | #if 1 |
522 | 380 | // This is the "spec" implementation, i.e., it is an exact application of | 376 | // This is the "spec" implementation, i.e., it is an exact application of |
523 | 381 | // the spec in http://www.w3.org/TR/xpath-functions/#casting | 377 | // the spec in http://www.w3.org/TR/xpath-functions/#casting |
527 | 382 | MAPM decimal_mapm( value_ ); | 378 | MAPM temp( value_ ); |
528 | 383 | decimal_mapm = decimal_mapm.round( precision_ ); | 379 | temp = temp.round( precision_ ); |
529 | 384 | return Decimal::toString( decimal_mapm, isNegZero(), max_precision() ); | 380 | return Decimal::toString( temp, isNegZero(), max_precision() ); |
530 | 385 | #else | 381 | #else |
531 | 386 | std::stringstream stream; | 382 | std::stringstream stream; |
532 | 387 | stream.precision(7); | 383 | stream.precision(7); |
533 | @@ -410,42 +406,37 @@ | |||
534 | 410 | return result; | 406 | return result; |
535 | 411 | #endif | 407 | #endif |
536 | 412 | } else { | 408 | } else { |
537 | 413 | char format[15]; | ||
538 | 414 | sprintf( format, "%%#1.%dE", static_cast<int>( precision_ ) ); | ||
539 | 415 | |||
540 | 416 | char buf[174]; | 409 | char buf[174]; |
554 | 417 | sprintf( buf, format, static_cast<double>( value_ ) ); | 410 | sprintf( buf, "%#1.*E", (int)precision_, (double)value_ ); |
555 | 418 | 411 | char *e = ::strchr( buf, 'E' ); | |
556 | 419 | char *e = strchr( buf, 'E' ); | 412 | |
557 | 420 | char *zeros = e ? e - 1 : buf + strlen( buf ) - 1; | 413 | // |
558 | 421 | 414 | // Clean-up, part 1: remove trailing zeros from mantissa | |
559 | 422 | while ( *zeros == '0' ) | 415 | // e.g.: xx.xx12300Exx => xx.xx123Exx |
560 | 423 | --zeros; | 416 | // |
561 | 424 | 417 | char *zero = e - 1; | |
562 | 425 | if ( e ) { | 418 | while ( *zero == '0' && zero[-1] != '.' ) |
563 | 426 | if ( *zeros == '.' ) | 419 | --zero; |
564 | 427 | ++zeros; | 420 | if ( zero < e - 1 ) |
565 | 428 | 421 | ::memmove( zero + 1, e, strlen( e ) + 1 ); | |
566 | 429 | zeros[1] = 'E'; | 422 | |
567 | 423 | // | ||
568 | 424 | // Clean-up, part 2: remove '+' and leading '0' from exponent | ||
569 | 425 | // e.g: 1E+xx => 1Exx, 1E-0x => 1E-x | ||
570 | 426 | // | ||
571 | 427 | e = ::strchr( buf, 'E' ); | ||
572 | 428 | char *dest = ++e; | ||
573 | 429 | switch ( *e ) { | ||
574 | 430 | case '-': | ||
575 | 431 | ++dest; | ||
576 | 432 | // no break; | ||
577 | 433 | case '+': | ||
578 | 434 | ++e; | ||
579 | 435 | } | ||
580 | 436 | if ( *e == '0' ) | ||
581 | 430 | ++e; | 437 | ++e; |
600 | 431 | 438 | if ( dest < e ) | |
601 | 432 | if ( *e == '+' ) | 439 | ::memmove( dest, e, strlen( e ) + 1 ); |
584 | 433 | ++e; | ||
585 | 434 | else if ( *e == '-' ) { | ||
586 | 435 | ++zeros; | ||
587 | 436 | zeros[1] = '-'; | ||
588 | 437 | ++e; | ||
589 | 438 | } | ||
590 | 439 | |||
591 | 440 | while ( *e == '0' ) | ||
592 | 441 | ++e; | ||
593 | 442 | |||
594 | 443 | memmove( (void*)(zeros + 2), e, strlen( e ) + 1 ); | ||
595 | 444 | } else { | ||
596 | 445 | if ( *zeros == '.' ) | ||
597 | 446 | --zeros; | ||
598 | 447 | zeros[1] = '\0'; | ||
599 | 448 | } | ||
602 | 449 | 440 | ||
603 | 450 | Decimal::reduce( buf ); | 441 | Decimal::reduce( buf ); |
604 | 451 | return buf; | 442 | return buf; |
605 | 452 | 443 | ||
606 | === modified file 'src/zorbatypes/integer.cpp' | |||
607 | --- src/zorbatypes/integer.cpp 2013-05-07 00:39:46 +0000 | |||
608 | +++ src/zorbatypes/integer.cpp 2013-05-14 23:54:28 +0000 | |||
609 | @@ -19,7 +19,6 @@ | |||
610 | 19 | // standard | 19 | // standard |
611 | 20 | #include <cerrno> | 20 | #include <cerrno> |
612 | 21 | #include <cstdlib> | 21 | #include <cstdlib> |
613 | 22 | #include <sstream> | ||
614 | 23 | 22 | ||
615 | 24 | // Zorba | 23 | // Zorba |
616 | 25 | #include <zorba/internal/unique_ptr.h> | 24 | #include <zorba/internal/unique_ptr.h> |
617 | @@ -38,12 +37,6 @@ | |||
618 | 38 | 37 | ||
619 | 39 | /////////////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////////////// |
620 | 40 | 39 | ||
621 | 41 | ostream& operator<<( ostream &o, MAPM const &m ) { | ||
622 | 42 | unique_ptr<char[]> const buf( new char[ m.exponent() + 3 ] ); | ||
623 | 43 | m.toIntegerString( buf.get() ); | ||
624 | 44 | return o << buf.get(); | ||
625 | 45 | } | ||
626 | 46 | |||
627 | 47 | void integer_traits::throw_error( string const &what, bool throw_range_error ) { | 40 | void integer_traits::throw_error( string const &what, bool throw_range_error ) { |
628 | 48 | if ( throw_range_error ) | 41 | if ( throw_range_error ) |
629 | 49 | throw range_error( what ); | 42 | throw range_error( what ); |
630 | @@ -52,27 +45,32 @@ | |||
631 | 52 | 45 | ||
632 | 53 | void integer_traits::throw_error( MAPM const &n, char const *op, | 46 | void integer_traits::throw_error( MAPM const &n, char const *op, |
633 | 54 | bool throw_range_error ) { | 47 | bool throw_range_error ) { |
637 | 55 | ostringstream oss; | 48 | unique_ptr<char[]> const buf( new char[ n.exponent() + 3 ] ); |
638 | 56 | oss << n; | 49 | n.toIntegerString( buf.get() ); |
639 | 57 | string const what( BUILD_STRING( oss.str(), ": not ", op, " 0" ) ); | 50 | string const what( BUILD_STRING( buf.get(), ": not ", op, " 0" ) ); |
640 | 58 | throw_error( what, throw_range_error ); | 51 | throw_error( what, throw_range_error ); |
641 | 59 | } | 52 | } |
642 | 60 | 53 | ||
643 | 61 | /////////////////////////////////////////////////////////////////////////////// | 54 | /////////////////////////////////////////////////////////////////////////////// |
644 | 62 | 55 | ||
645 | 56 | #ifndef ZORBA_WITH_BIG_INTEGER | ||
646 | 57 | template<class T> | ||
647 | 58 | typename IntegerImpl<T>::value_type IntegerImpl<T>::ftoi( double d ) { | ||
648 | 59 | value_type const v( d >= 0 ? floor( d ) : ceil( d ) ); | ||
649 | 60 | if ( v < 0 && d > 0 ) | ||
650 | 61 | throw range_error( | ||
651 | 62 | BUILD_STRING( '"', d, "\": value too large for integer" ) | ||
652 | 63 | ); | ||
653 | 64 | return v; | ||
654 | 65 | } | ||
655 | 66 | #endif /* ZORBA_WITH_BIG_INTEGER */ | ||
656 | 67 | |||
657 | 63 | template<class T> | 68 | template<class T> |
658 | 64 | void IntegerImpl<T>::parse( char const *s, bool throw_range_error ) { | 69 | void IntegerImpl<T>::parse( char const *s, bool throw_range_error ) { |
659 | 65 | #ifdef ZORBA_WITH_BIG_INTEGER | 70 | #ifdef ZORBA_WITH_BIG_INTEGER |
660 | 66 | Decimal::parse( s, &value_, Decimal::parse_integer ); | 71 | Decimal::parse( s, &value_, Decimal::parse_integer ); |
661 | 67 | #else | 72 | #else |
670 | 68 | try { | 73 | value_ = ztd::aton<value_type>( s ); |
663 | 69 | value_ = ztd::aton<value_type>( s ); | ||
664 | 70 | } | ||
665 | 71 | catch ( std::range_error const &e ) { | ||
666 | 72 | if ( throw_range_error ) | ||
667 | 73 | throw; | ||
668 | 74 | throw invalid_argument( e.what() ); | ||
669 | 75 | } | ||
671 | 76 | #endif /* ZORBA_WITH_BIG_INTEGER */ | 74 | #endif /* ZORBA_WITH_BIG_INTEGER */ |
672 | 77 | T::check_value( value_, throw_range_error ); | 75 | T::check_value( value_, throw_range_error ); |
673 | 78 | } | 76 | } |
674 | 79 | 77 | ||
675 | === modified file 'src/zorbatypes/integer.h' | |||
676 | --- src/zorbatypes/integer.h 2013-05-07 00:39:46 +0000 | |||
677 | +++ src/zorbatypes/integer.h 2013-05-14 23:54:28 +0000 | |||
678 | @@ -50,8 +50,6 @@ | |||
679 | 50 | 50 | ||
680 | 51 | /////////////////////////////////////////////////////////////////////////////// | 51 | /////////////////////////////////////////////////////////////////////////////// |
681 | 52 | 52 | ||
682 | 53 | std::ostream& operator<<( std::ostream&, MAPM const& ); | ||
683 | 54 | |||
684 | 55 | struct integer_traits { | 53 | struct integer_traits { |
685 | 56 | static int const default_value = 0; | 54 | static int const default_value = 0; |
686 | 57 | 55 | ||
687 | @@ -138,6 +136,8 @@ | |||
688 | 138 | } | 136 | } |
689 | 139 | }; | 137 | }; |
690 | 140 | 138 | ||
691 | 139 | /////////////////////////////////////////////////////////////////////////////// | ||
692 | 140 | |||
693 | 141 | template<class TraitsType> | 141 | template<class TraitsType> |
694 | 142 | class IntegerImpl { | 142 | class IntegerImpl { |
695 | 143 | public: | 143 | public: |
696 | @@ -199,6 +199,8 @@ | |||
697 | 199 | * | 199 | * |
698 | 200 | * @tparam TraitsType2 The traits type of \a i. | 200 | * @tparam TraitsType2 The traits type of \a i. |
699 | 201 | * @param i The %IntegerImpl to copy from. | 201 | * @param i The %IntegerImpl to copy from. |
700 | 202 | * @throw std::invalid_argument if \a i contains a value that is invalid for | ||
701 | 203 | * this type of integer. | ||
702 | 202 | */ | 204 | */ |
703 | 203 | template<class TraitsType2> | 205 | template<class TraitsType2> |
704 | 204 | IntegerImpl( IntegerImpl<TraitsType2> const &i ); | 206 | IntegerImpl( IntegerImpl<TraitsType2> const &i ); |
705 | @@ -212,6 +214,8 @@ | |||
706 | 212 | * @tparam TraitsType2 The traits type of \a i. | 214 | * @tparam TraitsType2 The traits type of \a i. |
707 | 213 | * @param i The %IntegerImpl to assign from. | 215 | * @param i The %IntegerImpl to assign from. |
708 | 214 | * @return Returns \c *this. | 216 | * @return Returns \c *this. |
709 | 217 | * @throw std::invalid_argument if \a i contains a value that is invalid for | ||
710 | 218 | * this type of integer. | ||
711 | 215 | */ | 219 | */ |
712 | 216 | template<class TraitsType2> | 220 | template<class TraitsType2> |
713 | 217 | IntegerImpl& operator=( IntegerImpl<TraitsType2> const &i ); | 221 | IntegerImpl& operator=( IntegerImpl<TraitsType2> const &i ); |
714 | @@ -552,13 +556,13 @@ | |||
715 | 552 | 556 | ||
716 | 553 | value_type value_; | 557 | value_type value_; |
717 | 554 | 558 | ||
718 | 559 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
719 | 560 | IntegerImpl( value_type const &v ) : value_( v ) { } | ||
720 | 561 | |||
721 | 555 | static value_type ftoi( double d ) { | 562 | static value_type ftoi( double d ) { |
722 | 556 | return value_type( d >= 0 ? floor( d ) : ceil( d ) ); | 563 | return value_type( d >= 0 ? floor( d ) : ceil( d ) ); |
723 | 557 | } | 564 | } |
724 | 558 | 565 | ||
725 | 559 | #ifdef ZORBA_WITH_BIG_INTEGER | ||
726 | 560 | IntegerImpl( value_type const &v ) : value_( v ) { } | ||
727 | 561 | |||
728 | 562 | static value_type ftoi( MAPM const &d ) { | 566 | static value_type ftoi( MAPM const &d ) { |
729 | 563 | return d.sign() >= 0 ? d.floor() : d.ceil(); | 567 | return d.sign() >= 0 ? d.floor() : d.ceil(); |
730 | 564 | } | 568 | } |
731 | @@ -573,6 +577,8 @@ | |||
732 | 573 | } | 577 | } |
733 | 574 | #else /* ZORBA_WITH_BIG_INTEGER */ | 578 | #else /* ZORBA_WITH_BIG_INTEGER */ |
734 | 575 | 579 | ||
735 | 580 | static value_type ftoi( double d ); | ||
736 | 581 | |||
737 | 576 | static value_type ftoi( value_type v ) { | 582 | static value_type ftoi( value_type v ) { |
738 | 577 | return v; // intentional no-op | 583 | return v; // intentional no-op |
739 | 578 | } | 584 | } |
740 | 579 | 585 | ||
741 | === modified file 'test/fots/CMakeLists.txt' | |||
742 | --- test/fots/CMakeLists.txt 2013-05-08 20:14:47 +0000 | |||
743 | +++ test/fots/CMakeLists.txt 2013-05-14 23:54:28 +0000 | |||
744 | @@ -157,8 +157,6 @@ | |||
745 | 157 | EXPECTED_FOTS_FAILURE (fn-available-environment-variables fn-available-environment-variables-011 0) | 157 | EXPECTED_FOTS_FAILURE (fn-available-environment-variables fn-available-environment-variables-011 0) |
746 | 158 | EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-36 0) | 158 | EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-36 0) |
747 | 159 | EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-37 0) | 159 | EXPECTED_FOTS_FAILURE (fn-deep-equal K2-SeqDeepEqualFunc-37 0) |
748 | 160 | EXPECTED_FOTS_FAILURE (fn-distinct-values cbcl-distinct-values-002 1090089) | ||
749 | 161 | EXPECTED_FOTS_FAILURE (fn-distinct-values cbcl-distinct-values-002b 1090089) | ||
750 | 162 | EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-005 0) | 160 | EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-005 0) |
751 | 163 | EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-006 0) | 161 | EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-006 0) |
752 | 164 | EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-007 0) | 162 | EXPECTED_FOTS_FAILURE (fn-environment-variable environment-variable-007 0) |
753 | 165 | 163 | ||
754 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-01.xml.res' | |||
755 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-01.xml.res 1970-01-01 00:00:00 +0000 | |||
756 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-01.xml.res 2013-05-14 23:54:28 +0000 | |||
757 | @@ -0,0 +1,1 @@ | |||
758 | 1 | 1.899 | ||
759 | 0 | 2 | ||
760 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-02.xml.res' | |||
761 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-02.xml.res 1970-01-01 00:00:00 +0000 | |||
762 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-02.xml.res 2013-05-14 23:54:28 +0000 | |||
763 | @@ -0,0 +1,1 @@ | |||
764 | 1 | 2 | ||
765 | 0 | 2 | ||
766 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-03.xml.res' | |||
767 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-03.xml.res 1970-01-01 00:00:00 +0000 | |||
768 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-03.xml.res 2013-05-14 23:54:28 +0000 | |||
769 | @@ -0,0 +1,1 @@ | |||
770 | 1 | 1.6 | ||
771 | 0 | 2 | ||
772 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-04.xml.res' | |||
773 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-04.xml.res 1970-01-01 00:00:00 +0000 | |||
774 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-04.xml.res 2013-05-14 23:54:28 +0000 | |||
775 | @@ -0,0 +1,1 @@ | |||
776 | 1 | 10 | ||
777 | 0 | 2 | ||
778 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-05.xml.res' | |||
779 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-05.xml.res 1970-01-01 00:00:00 +0000 | |||
780 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-05.xml.res 2013-05-14 23:54:28 +0000 | |||
781 | @@ -0,0 +1,1 @@ | |||
782 | 1 | -1.9 | ||
783 | 0 | 2 | ||
784 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-06.xml.res' | |||
785 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-06.xml.res 1970-01-01 00:00:00 +0000 | |||
786 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-06.xml.res 2013-05-14 23:54:28 +0000 | |||
787 | @@ -0,0 +1,1 @@ | |||
788 | 1 | -2 | ||
789 | 0 | 2 | ||
790 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-07.xml.res' | |||
791 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-07.xml.res 1970-01-01 00:00:00 +0000 | |||
792 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-07.xml.res 2013-05-14 23:54:28 +0000 | |||
793 | @@ -0,0 +1,1 @@ | |||
794 | 1 | -1.6 | ||
795 | 0 | 2 | ||
796 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-08.xml.res' | |||
797 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-08.xml.res 1970-01-01 00:00:00 +0000 | |||
798 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-08.xml.res 2013-05-14 23:54:28 +0000 | |||
799 | @@ -0,0 +1,1 @@ | |||
800 | 1 | -10 | ||
801 | 0 | 2 | ||
802 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-09.xml.res' | |||
803 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-09.xml.res 1970-01-01 00:00:00 +0000 | |||
804 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-09.xml.res 2013-05-14 23:54:28 +0000 | |||
805 | @@ -0,0 +1,1 @@ | |||
806 | 1 | 1 | ||
807 | 0 | 2 | ||
808 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-10.xml.res' | |||
809 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-10.xml.res 1970-01-01 00:00:00 +0000 | |||
810 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-10.xml.res 2013-05-14 23:54:28 +0000 | |||
811 | @@ -0,0 +1,1 @@ | |||
812 | 1 | 1 | ||
813 | 0 | 2 | ||
814 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-11.xml.res' | |||
815 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-11.xml.res 1970-01-01 00:00:00 +0000 | |||
816 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-11.xml.res 2013-05-14 23:54:28 +0000 | |||
817 | @@ -0,0 +1,1 @@ | |||
818 | 1 | 1.234 | ||
819 | 0 | 2 | ||
820 | === added file 'test/rbkt/ExpQueryResults/zorba/numerics/xs_float-12.xml.res' | |||
821 | --- test/rbkt/ExpQueryResults/zorba/numerics/xs_float-12.xml.res 1970-01-01 00:00:00 +0000 | |||
822 | +++ test/rbkt/ExpQueryResults/zorba/numerics/xs_float-12.xml.res 2013-05-14 23:54:28 +0000 | |||
823 | @@ -0,0 +1,1 @@ | |||
824 | 1 | 1.9 | ||
825 | 0 | 2 | ||
826 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-01.xq' | |||
827 | --- test/rbkt/Queries/zorba/numerics/xs_float-01.xq 1970-01-01 00:00:00 +0000 | |||
828 | +++ test/rbkt/Queries/zorba/numerics/xs_float-01.xq 2013-05-14 23:54:28 +0000 | |||
829 | @@ -0,0 +1,1 @@ | |||
830 | 1 | xs:float(1.899) | ||
831 | 0 | 2 | ||
832 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-02.xq' | |||
833 | --- test/rbkt/Queries/zorba/numerics/xs_float-02.xq 1970-01-01 00:00:00 +0000 | |||
834 | +++ test/rbkt/Queries/zorba/numerics/xs_float-02.xq 2013-05-14 23:54:28 +0000 | |||
835 | @@ -0,0 +1,1 @@ | |||
836 | 1 | xs:float(1.999) | ||
837 | 0 | 2 | ||
838 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-03.xq' | |||
839 | --- test/rbkt/Queries/zorba/numerics/xs_float-03.xq 1970-01-01 00:00:00 +0000 | |||
840 | +++ test/rbkt/Queries/zorba/numerics/xs_float-03.xq 2013-05-14 23:54:28 +0000 | |||
841 | @@ -0,0 +1,1 @@ | |||
842 | 1 | xs:float(1.59999) | ||
843 | 0 | 2 | ||
844 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-04.xq' | |||
845 | --- test/rbkt/Queries/zorba/numerics/xs_float-04.xq 1970-01-01 00:00:00 +0000 | |||
846 | +++ test/rbkt/Queries/zorba/numerics/xs_float-04.xq 2013-05-14 23:54:28 +0000 | |||
847 | @@ -0,0 +1,1 @@ | |||
848 | 1 | xs:float(9.999) | ||
849 | 0 | 2 | ||
850 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-05.xq' | |||
851 | --- test/rbkt/Queries/zorba/numerics/xs_float-05.xq 1970-01-01 00:00:00 +0000 | |||
852 | +++ test/rbkt/Queries/zorba/numerics/xs_float-05.xq 2013-05-14 23:54:28 +0000 | |||
853 | @@ -0,0 +1,1 @@ | |||
854 | 1 | xs:float(-1.89999) | ||
855 | 0 | 2 | ||
856 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-06.xq' | |||
857 | --- test/rbkt/Queries/zorba/numerics/xs_float-06.xq 1970-01-01 00:00:00 +0000 | |||
858 | +++ test/rbkt/Queries/zorba/numerics/xs_float-06.xq 2013-05-14 23:54:28 +0000 | |||
859 | @@ -0,0 +1,1 @@ | |||
860 | 1 | xs:float(-1.999) | ||
861 | 0 | 2 | ||
862 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-07.xq' | |||
863 | --- test/rbkt/Queries/zorba/numerics/xs_float-07.xq 1970-01-01 00:00:00 +0000 | |||
864 | +++ test/rbkt/Queries/zorba/numerics/xs_float-07.xq 2013-05-14 23:54:28 +0000 | |||
865 | @@ -0,0 +1,1 @@ | |||
866 | 1 | xs:float(-1.59999) | ||
867 | 0 | 2 | ||
868 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-08.xq' | |||
869 | --- test/rbkt/Queries/zorba/numerics/xs_float-08.xq 1970-01-01 00:00:00 +0000 | |||
870 | +++ test/rbkt/Queries/zorba/numerics/xs_float-08.xq 2013-05-14 23:54:28 +0000 | |||
871 | @@ -0,0 +1,1 @@ | |||
872 | 1 | xs:float(-9.999) | ||
873 | 0 | 2 | ||
874 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-09.xq' | |||
875 | --- test/rbkt/Queries/zorba/numerics/xs_float-09.xq 1970-01-01 00:00:00 +0000 | |||
876 | +++ test/rbkt/Queries/zorba/numerics/xs_float-09.xq 2013-05-14 23:54:28 +0000 | |||
877 | @@ -0,0 +1,1 @@ | |||
878 | 1 | xs:float(1.0000001) | ||
879 | 0 | 2 | ||
880 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-10.xq' | |||
881 | --- test/rbkt/Queries/zorba/numerics/xs_float-10.xq 1970-01-01 00:00:00 +0000 | |||
882 | +++ test/rbkt/Queries/zorba/numerics/xs_float-10.xq 2013-05-14 23:54:28 +0000 | |||
883 | @@ -0,0 +1,1 @@ | |||
884 | 1 | xs:float(1.00000001) | ||
885 | 0 | 2 | ||
886 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-11.xq' | |||
887 | --- test/rbkt/Queries/zorba/numerics/xs_float-11.xq 1970-01-01 00:00:00 +0000 | |||
888 | +++ test/rbkt/Queries/zorba/numerics/xs_float-11.xq 2013-05-14 23:54:28 +0000 | |||
889 | @@ -0,0 +1,1 @@ | |||
890 | 1 | xs:float(1.234000001) | ||
891 | 0 | 2 | ||
892 | === added file 'test/rbkt/Queries/zorba/numerics/xs_float-12.xq' | |||
893 | --- test/rbkt/Queries/zorba/numerics/xs_float-12.xq 1970-01-01 00:00:00 +0000 | |||
894 | +++ test/rbkt/Queries/zorba/numerics/xs_float-12.xq 2013-05-14 23:54:28 +0000 | |||
895 | @@ -0,0 +1,1 @@ | |||
896 | 1 | xs:float(1.89999123) |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ bug-1090089- 2013-05- 09T05-23- 51.58Z/ log.html
Log at: http://