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

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11134
Merged at revision: 11306
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 208 lines (+61/-27)
7 files modified
src/runtime/random/random_impl.cpp (+2/-3)
src/unit_tests/test_time.cpp (+1/-1)
src/util/stl_util.h (+24/-10)
src/util/time_parse.cpp (+12/-12)
src/zorbatypes/floatimpl.h (+7/-0)
src/zorbatypes/numconversions.cpp (+6/-0)
src/zorbatypes/numconversions.h (+9/-1)
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+155038@code.launchpad.net

Commit message

* Added over-flow check for to_xs_int().
* Fixed warnings.

Description of the change

* Added over-flow check for to_xs_int().
* Fixed warnings.

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-03-22T19-26-47.183Z 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-03-22T21-57-38.259Z 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
=== modified file 'src/runtime/random/random_impl.cpp'
--- src/runtime/random/random_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/random/random_impl.cpp 2013-03-22 19:09:23 +0000
@@ -70,9 +70,8 @@
7070
71 try71 try
72 {72 {
73 int_seed = static_cast<unsigned int>(73 int_seed = static_cast<unsigned>( to_xs_int( seed->getIntegerValue() ) );
74 to_xs_int( seed->getIntegerValue() ) );74 } catch (std::range_error const&)
75 } catch (std::range_error& /*e*/)
76 {75 {
77 throw XQUERY_EXCEPTION(76 throw XQUERY_EXCEPTION(
78 zerr::ZXQD0004_INVALID_PARAMETER,77 zerr::ZXQD0004_INVALID_PARAMETER,
7978
=== modified file 'src/unit_tests/test_time.cpp'
--- src/unit_tests/test_time.cpp 2013-03-20 15:26:41 +0000
+++ src/unit_tests/test_time.cpp 2013-03-22 19:09:23 +0000
@@ -90,7 +90,7 @@
90 /* 30 */ { 3, time::jan, 2010, calendar::ISO, 53 },90 /* 30 */ { 3, time::jan, 2010, calendar::ISO, 53 },
91 /* 31 */ { 4, time::jan, 2010, calendar::ISO, 1 },91 /* 31 */ { 4, time::jan, 2010, calendar::ISO, 1 },
9292
93 { 0 },93 { 0, 0, 0, calendar::unknown, 0 }
94 };94 };
9595
96 for ( test_type const *t = test; t->mday; ++t ) {96 for ( test_type const *t = test; t->mday; ++t ) {
9797
=== modified file 'src/util/stl_util.h'
--- src/util/stl_util.h 2013-02-28 11:15:32 +0000
+++ src/util/stl_util.h 2013-03-22 19:09:23 +0000
@@ -436,22 +436,29 @@
436//436//
437437
438template<typename N1,typename N2> inline438template<typename N1,typename N2> inline
439typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value439typename std::enable_if<(ZORBA_TR1_NS::is_signed<N1>::value ||
440 && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type440 ZORBA_TR1_NS::is_floating_point<N1>::value)
441 && (ZORBA_TR1_NS::is_signed<N2>::value ||
442 ZORBA_TR1_NS::is_floating_point<N2>::value),
443 bool>::type
441ge_min( N1 n1, N2 ) {444ge_min( N1 n1, N2 ) {
442 return n1 >= std::numeric_limits<N2>::min();445 return n1 >= std::numeric_limits<N2>::min();
443}446}
444447
445template<typename N1,typename N2> inline448template<typename N1,typename N2> inline
446typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value449typename std::enable_if<(ZORBA_TR1_NS::is_signed<N1>::value ||
447 && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type450 ZORBA_TR1_NS::is_floating_point<N1>::value)
451 && !!ZORBA_TR1_NS::is_unsigned<N2>::value,
452 bool>::type
448ge_min( N1 n1, N2 ) {453ge_min( N1 n1, N2 ) {
449 return n1 >= 0;454 return n1 >= 0;
450}455}
451456
452template<typename N1,typename N2> inline457template<typename N1,typename N2> inline
453typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value458typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
454 && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type459 && (ZORBA_TR1_NS::is_signed<N2>::value ||
460 ZORBA_TR1_NS::is_floating_point<N2>::value),
461 bool>::type
455ge_min( N1, N2 ) {462ge_min( N1, N2 ) {
456 return true;463 return true;
457}464}
@@ -464,22 +471,29 @@
464}471}
465472
466template<typename N1,typename N2> inline473template<typename N1,typename N2> inline
467typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value474typename std::enable_if<(ZORBA_TR1_NS::is_signed<N1>::value ||
468 && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type475 ZORBA_TR1_NS::is_floating_point<N1>::value)
476 && (ZORBA_TR1_NS::is_signed<N2>::value ||
477 ZORBA_TR1_NS::is_floating_point<N2>::value),
478 bool>::type
469le_max( N1 n1, N2 ) {479le_max( N1 n1, N2 ) {
470 return n1 <= std::numeric_limits<N2>::max();480 return n1 <= std::numeric_limits<N2>::max();
471}481}
472482
473template<typename N1,typename N2> inline483template<typename N1,typename N2> inline
474typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value484typename std::enable_if<(ZORBA_TR1_NS::is_signed<N1>::value ||
475 && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type485 ZORBA_TR1_NS::is_floating_point<N1>::value)
486 && !!ZORBA_TR1_NS::is_unsigned<N2>::value,
487 bool>::type
476le_max( N1 n1, N2 ) {488le_max( N1 n1, N2 ) {
477 return n1 <= 0 || static_cast<N2>( n1 ) <= std::numeric_limits<N2>::max();489 return n1 <= 0 || static_cast<N2>( n1 ) <= std::numeric_limits<N2>::max();
478}490}
479491
480template<typename N1,typename N2> inline492template<typename N1,typename N2> inline
481typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value493typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
482 && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type494 && (ZORBA_TR1_NS::is_signed<N2>::value ||
495 ZORBA_TR1_NS::is_floating_point<N2>::value),
496 bool>::type
483le_max( N1 n1, N2 ) {497le_max( N1 n1, N2 ) {
484 return n1 <= static_cast<N1>( std::numeric_limits<N2>::max() );498 return n1 <= static_cast<N1>( std::numeric_limits<N2>::max() );
485}499}
486500
=== modified file 'src/util/time_parse.cpp'
--- src/util/time_parse.cpp 2013-01-10 01:53:57 +0000
+++ src/util/time_parse.cpp 2013-03-22 19:09:23 +0000
@@ -170,18 +170,18 @@
170// Time."170// Time."
171//171//
172static rfc2822_obs_zone const rfc2822_obs_zones[] = {172static rfc2822_obs_zone const rfc2822_obs_zones[] = {
173 { "GMT", 0 },173 { "GMT", 0 , false },
174 { "UTC", 0 }, // non-RFC: be liberal in what you accept....174 { "UTC", 0 , false }, // non-RFC: be liberal in what you accept....
175 { "UT" , 0 }, // must go after "UTC"175 { "UT" , 0 , false }, // must go after "UTC"
176 { "EDT", -4 * 60 * 60, true },176 { "EDT", -4 * 60 * 60, true },
177 { "EST", -5 * 60 * 60 },177 { "EST", -5 * 60 * 60, false },
178 { "CDT", -5 * 60 * 60, true },178 { "CDT", -5 * 60 * 60, true },
179 { "CST", -6 * 60 * 60 },179 { "CST", -6 * 60 * 60, false },
180 { "MDT", -6 * 60 * 60, true },180 { "MDT", -6 * 60 * 60, true },
181 { "MST", -7 * 60 * 60 },181 { "MST", -7 * 60 * 60, false },
182 { "PDT", -7 * 60 * 60, true },182 { "PDT", -7 * 60 * 60, true },
183 { "PST", -8 * 60 * 60 },183 { "PST", -8 * 60 * 60, false },
184 { 0, 0, 0 }184 { 0, 0, false }
185};185};
186186
187///////////////////////////////////////////////////////////////////////////////187///////////////////////////////////////////////////////////////////////////////
188188
=== modified file 'src/zorbatypes/floatimpl.h'
--- src/zorbatypes/floatimpl.h 2013-02-07 17:24:36 +0000
+++ src/zorbatypes/floatimpl.h 2013-03-22 19:09:23 +0000
@@ -256,6 +256,8 @@
256256
257 uint32_t hash() const;257 uint32_t hash() const;
258258
259 bool is_xs_int() const;
260
259 bool isNaN() const;261 bool isNaN() const;
260 bool isFinite() const;262 bool isFinite() const;
261 bool isPosInf() const;263 bool isPosInf() const;
@@ -935,6 +937,11 @@
935}937}
936938
937template<typename F>939template<typename F>
940inline bool FloatImpl<F>::is_xs_int() const {
941 return ZORBA_IN_RANGE( value_, xs_int );
942}
943
944template<typename F>
938inline bool FloatImpl<F>::isNeg() const {945inline bool FloatImpl<F>::isNeg() const {
939 return value_ < 0;946 return value_ < 0;
940}947}
941948
=== modified file 'src/zorbatypes/numconversions.cpp'
--- src/zorbatypes/numconversions.cpp 2013-02-07 17:24:36 +0000
+++ src/zorbatypes/numconversions.cpp 2013-03-22 19:09:23 +0000
@@ -29,8 +29,14 @@
29 std::range_error( BUILD_STRING( '"', (N), "\": number can not be represented as an " TYPE ) )29 std::range_error( BUILD_STRING( '"', (N), "\": number can not be represented as an " TYPE ) )
3030
31xs_int to_xs_int( xs_double const &d ) {31xs_int to_xs_int( xs_double const &d ) {
32#ifdef ZORBA_WITH_BIG_INTEGER
32 zstring const temp( d.toIntegerString() );33 zstring const temp( d.toIntegerString() );
33 return ztd::aton<xs_int>( temp.c_str() );34 return ztd::aton<xs_int>( temp.c_str() );
35#else
36 if ( d.is_xs_int() )
37 return static_cast<xs_int>( d.getNumber() );
38 throw RANGE_ERROR( d, "xs:int" );
39#endif /* ZORBA_WITH_BIG_INTEGER */
34}40}
3541
36xs_int to_xs_int( xs_integer const &i ) {42xs_int to_xs_int( xs_integer const &i ) {
3743
=== modified file 'src/zorbatypes/numconversions.h'
--- src/zorbatypes/numconversions.h 2013-02-07 17:24:36 +0000
+++ src/zorbatypes/numconversions.h 2013-03-22 19:09:23 +0000
@@ -29,7 +29,7 @@
29 *29 *
30 * @param d The \c xs:double value to convert.30 * @param d The \c xs:double value to convert.
31 * @return Returns said value.31 * @return Returns said value.
32 * @throws std::range_error if the \c xs:double value can not be accurately32 * @throws std::range_error if \c floor(xs:double) value can not be accurately
33 * represented as an \c xs:int.33 * represented as an \c xs:int.
34 */34 */
35xs_int to_xs_int( xs_double const &d );35xs_int to_xs_int( xs_double const &d );
@@ -65,6 +65,14 @@
65xs_long to_xs_long( xs_integer const &i );65xs_long to_xs_long( xs_integer const &i );
6666
67#ifndef ZORBA_WITH_BIG_INTEGER67#ifndef ZORBA_WITH_BIG_INTEGER
68/**
69 * Converts an \c xs:nonNegativeInteger value to an \c xs:long.
70 *
71 * @param i The \c xs:nonNegativeInteger value to convert.
72 * @return Returns said value.
73 * @throws std::range_error if the \c xs:nonNegativeInteger value can not be
74 * accurately represented as an \c xs:long.
75 */
68xs_long to_xs_long( xs_nonNegativeInteger const &i );76xs_long to_xs_long( xs_nonNegativeInteger const &i );
69#endif /* ZORBA_WITH_BIG_INTEGER */77#endif /* ZORBA_WITH_BIG_INTEGER */
7078

Subscribers

People subscribed via source and target branches