zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #23441
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.
Commit message:
Fixed bug #1190710 (fn-format-date failures).
Requested reviews:
Paul J. Lucas (paul-lucas)
For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/169974
Fixed bug #1190710 (fn-format-date failures).
--
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/169974
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2013-06-17 23:12:02 +0000
+++ ChangeLog 2013-06-18 02:30:40 +0000
@@ -35,6 +35,7 @@
* Fixed bug #1188100 (regex issues with 'q' flag in fn:tokenize)
* Fixed invalid memory access error occuring during sequence type matching
for user-defined types.
+ * Fixed bug #1190710 (fn-format-date failures)
* Fixed bug #1190407 (wrong rewrite of if-then-else return clause in case
of general flwor)
* jn:members function takes item()* as aparameter (instead of item())
=== added file 'include/zorba/internal/README.txt'
--- include/zorba/internal/README.txt 1970-01-01 00:00:00 +0000
+++ include/zorba/internal/README.txt 2013-06-18 02:30:40 +0000
@@ -0,0 +1,6 @@
+All the files in this directory are for Zorba internal use only in order to
+implement parts the public API. You should NOT directly either #include any of
+these files or use any of the classes, constants, macros, or types defined
+herein in your own C++ code. These files are subject either to change or
+removal at any time without notice and backwards compatibility is NOT
+guaranteed.
=== modified file 'include/zorba/internal/cxx_util.h'
--- include/zorba/internal/cxx_util.h 2013-06-01 00:30:39 +0000
+++ include/zorba/internal/cxx_util.h 2013-06-18 02:30:40 +0000
@@ -27,7 +27,9 @@
namespace internal {
/**
- * A \c nullptr type.
+ * \internal
+ * A \c nullptr type for C++ compilers that don't yet implement C++11's
+ * \c nullptr keyword.
*
* See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
* section 1.1: "Alternative #1: A Library Implementation of nullptr," p. 3.
@@ -50,11 +52,12 @@
} // namespace zorba
/**
+ * \internal
* We use "zorba_nullptr" in combination with a macro to elimimate an
* "identifier 'nullptr' will become a keyword in C++0x" warning.
*
* We also use a singleton object since using multiple instances as shown in
- * Bjarne's paper has a slight performance penalty.
+ * Bjarne's paper has a slight performance penalty (surprisingly).
*/
ZORBA_DLL_PUBLIC
extern zorba::internal::nullptr_type const zorba_nullptr;
@@ -71,6 +74,12 @@
template<> struct zorba_static_assert<true> { };
template<int> struct zorba_static_assert_type { };
+/**
+ * \internal
+ * A \c static_assert macro for C++ compilers that don't yet implement C++11's
+ * \c static_assert keyword.
+ * \hideinitializer
+ */
#define static_assert(expr,msg) \
typedef ::zorba_static_assert_type< \
sizeof( ::zorba_static_assert<(expr) != 0> ) \
=== modified file 'include/zorba/internal/diagnostic.h'
--- include/zorba/internal/diagnostic.h 2013-03-22 23:40:03 +0000
+++ include/zorba/internal/diagnostic.h 2013-06-18 02:30:40 +0000
@@ -42,6 +42,7 @@
///////////////////////////////////////////////////////////////////////////////
/**
+ * \internal
* A %location holds the file location of an error.
*/
class ZORBA_DLL_PUBLIC location {
=== modified file 'include/zorba/internal/proxy.h'
--- include/zorba/internal/proxy.h 2012-01-18 05:43:09 +0000
+++ include/zorba/internal/proxy.h 2013-06-18 02:30:40 +0000
@@ -26,6 +26,8 @@
/**
* \internal
* A %proxy<T> is-a \c T that also contains a T* -- a pointer to the original.
+ *
+ * @tparam OriginalType The original type to which this %proxy refers.
*/
template<class OriginalType>
class proxy : public OriginalType {
=== modified file 'include/zorba/internal/system_diagnostic.h'
--- include/zorba/internal/system_diagnostic.h 2013-06-04 00:34:52 +0000
+++ include/zorba/internal/system_diagnostic.h 2013-06-18 02:30:40 +0000
@@ -28,6 +28,10 @@
///////////////////////////////////////////////////////////////////////////////
+/**
+ * \internal
+ * The type-independent, factored-out-code base class for SystemDiagnostic.
+ */
class ZORBA_DLL_PUBLIC SystemDiagnosticBase : public Diagnostic {
public:
/**
=== modified file 'include/zorba/internal/type_traits.h'
--- include/zorba/internal/type_traits.h 2013-02-07 17:24:36 +0000
+++ include/zorba/internal/type_traits.h 2013-06-18 02:30:40 +0000
@@ -23,7 +23,7 @@
# include <tr1/type_traits>
#else
# include <type_traits>
-#endif
+#endif /* ZORBA_TR1_IN_TR1_SUBDIRECTORY */
///////////////////////////////////////////////////////////////////////////////
=== modified file 'include/zorba/internal/unique_ptr.h'
--- include/zorba/internal/unique_ptr.h 2013-06-01 00:30:39 +0000
+++ include/zorba/internal/unique_ptr.h 2013-06-18 02:30:40 +0000
@@ -36,14 +36,14 @@
template<typename T> inline
typename enable_if<!zorba::internal::is_movable<T>::value,T&>::type
move( T &t ) {
- return t;
+ return t;
}
template<typename T> inline
typename enable_if<zorba::internal::is_movable<T>::value,
zorba::internal::rv<T>&>::type
move( T const &t ) {
- return *static_cast<zorba::internal::rv<T>*>( const_cast<T*>( &t ) );
+ return *static_cast<zorba::internal::rv<T>*>( const_cast<T*>( &t ) );
}
template<typename T> inline
@@ -131,6 +131,8 @@
* \internal
* Swaps two unique_ptr objects.
*
+ * @tparam T The pointed-to type.
+ * @tparam D The deleter type.
* @param a The first object to swap.
* @param b The second object to swap.
*/
@@ -147,6 +149,8 @@
* \internal
* The default deleter class used by unique_ptr. It simply calls \c delete on
* the pointed-to object.
+ *
+ * @tparam T The pointed-to type.
*/
template<typename T>
struct default_delete {
@@ -179,6 +183,8 @@
* \internal
* Specialization of default_delete for arrays. It simply calls \c delete[] on
* the pointed-to array.
+ *
+ * @tparam T The pointed-to type.
*/
template<typename T>
struct default_delete<T[]> {
=== modified file 'include/zorba/internal/ztd.h'
--- include/zorba/internal/ztd.h 2013-06-01 00:30:39 +0000
+++ include/zorba/internal/ztd.h 2013-06-18 02:30:40 +0000
@@ -260,9 +260,22 @@
ZORBA_DECL_HAS_MEM_FN( str );
ZORBA_DECL_HAS_MEM_FN( toString );
+/**
+ * \internal
+ * Short-hand macro for use with enable_if to determine whether the given type
+ * has a member function with the signature
+ * <code>char const* (T::*)() const</code>.
+ * \hideinitializer
+ */
#define ZORBA_HAS_C_STR(T) \
::zorba::internal::ztd::has_c_str<T,char const* (T::*)() const>::value
+/**
+ * \internal
+ * Short-hand macro for use with enable_if to determine whether the given type
+ * is a class having an API matching std::string.
+ * \hideinitializer
+ */
#define ZORBA_IS_STRING(T) ZORBA_HAS_C_STR(T)
/**
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-06-15 02:57:08 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-06-18 02:30:40 +0000
@@ -1134,6 +1134,9 @@
incorrect.
</comment>
<value>"$1": invalid picture string for date/time${: 2}</value>
+ <entry key="BadCalendar">
+ <value>invalid calendar designator</value>
+ </entry>
<entry key="BadComponent_3">
<value>'$3': invalid component specifier</value>
</entry>
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-06-15 02:57:08 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-06-18 02:30:40 +0000
@@ -604,6 +604,7 @@
{ "~FODF1310_NoPercentPermille", "sub-picture must not contain more than one percent-sign or per-mille-sign or one of each" },
{ "~FOFD1340_Bad2ndModifierHere_3", "'$3': valid second presentation modifier invalid here" },
{ "~FOFD1340_Bad2ndModifier_3", "'$3': invalid second presentation modifier" },
+ { "~FOFD1340_BadCalendar", "invalid calendar designator" },
{ "~FOFD1340_BadComponent_3", "'$3': invalid component specifier" },
{ "~FOFD1340_BadWidthModifier", "invalid width modifier" },
{ "~FOFD1340_DigitNotSameFamily_34", "\"$3\": digit not from same digit family as $4" },
=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-13 18:18:55 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-18 02:30:40 +0000
@@ -70,6 +70,7 @@
#define ZED_XQDY0074_NotCastToQName "~XQDY0074_NotCastToQName"
#define ZED_XQDY0074_NoEmptyLocalname "~XQDY0074_NoEmptyLocalname"
#define ZED_XQDY0074_NameSapceConstructor "~XQDY0074_NameSapceConstructor"
+#define ZED_FOFD1340_BadCalendar "~FOFD1340_BadCalendar"
#define ZED_FOFD1340_BadComponent_3 "~FOFD1340_BadComponent_3"
#define ZED_FOFD1340_Bad2ndModifier_3 "~FOFD1340_Bad2ndModifier_3"
#define ZED_FOFD1340_Bad2ndModifierHere_3 "~FOFD1340_Bad2ndModifierHere_3"
=== modified file 'src/runtime/durations_dates_times/format_dateTime.cpp'
--- src/runtime/durations_dates_times/format_dateTime.cpp 2013-06-11 23:38:49 +0000
+++ src/runtime/durations_dates_times/format_dateTime.cpp 2013-06-18 02:30:40 +0000
@@ -37,6 +37,7 @@
#include "util/string_util.h"
#include "util/time_util.h"
#include "util/utf8_util.h"
+#include "util/xml_util.h"
#include "zorbatypes/datetime.h"
#include "zorbatypes/zstring.h"
@@ -106,7 +107,7 @@
//
// This stuff isn't part of the "presentation modifier" as discussed in the
- // XQuery 3.0 F&O spec, but this is a convenient place to put it nonetheless.
+ // XQuery F&O 3.0 spec, but this is a convenient place to put it nonetheless.
//
iso639_1::type lang;
bool lang_is_fallback;
@@ -117,7 +118,7 @@
void append_if_fallback_lang( zstring *s ) const {
if ( lang_is_fallback ) {
//
- // XQuery 3.0 F&O: 9.8.4.3: If the fallback representation uses a
+ // XQuery F&O 3.0: 9.8.4.3: If the fallback representation uses a
// different language from that requested, the output string must
// identify the language actually used, for example by prefixing the
// string with [Language: Y] (where Y is the language actually used)
@@ -287,7 +288,7 @@
utf8_string<zstring> u_name( name );
if ( mod.gt_max_width( u_name.size() ) ) {
//
- // XQuery 3.0 F&O: 9.8.4.1: If the full representation of the value
+ // XQuery F&O 3.0: 9.8.4.1: If the full representation of the value
// exceeds the specified maximum width, then the processor should
// attempt to use an alternative shorter representation that fits
// within the maximum width. Where the presentation modifier is N,
@@ -353,7 +354,7 @@
switch ( mod.first.type ) {
case modifier::NAME:
//
- // XQuery 3.0 F&O: 9.8.4.2: If the first presentation modifier is N, then
+ // XQuery F&O 3.0: 9.8.4.2: If the first presentation modifier is N, then
// the timezone is output (where possible) as a timezone name, for
// example EST or CET. The same timezone offset has different names in
// different places; it is therefore recommended that this option should
@@ -528,7 +529,7 @@
utf8_string<zstring> u_name( name );
if ( mod.gt_max_width( u_name.size() ) ) {
//
- // XQuery 3.0 F&O: 9.8.4.1: If the full representation of the value
+ // XQuery F&O 3.0: 9.8.4.1: If the full representation of the value
// exceeds the specified maximum width, then the processor should
// attempt to use an alternative shorter representation that fits
// within the maximum width. Where the presentation modifier is N,
@@ -612,7 +613,7 @@
utf8_string<zstring>::size_type const u_size = u_tmp.size();
if ( mod.gt_max_width( u_size ) ) {
//
- // XQuery 3.0 F&O: 9.8.4.1: If the full representation of the value
+ // XQuery F&O 3.0: 9.8.4.1: If the full representation of the value
// exceeds the specified maximum width, then the processor should attempt
// to use an alternative shorter representation that fits within the
// maximum width. ... In the case of the year component, setting
@@ -646,7 +647,7 @@
if ( cp != '#' && unicode::is_grouping_separator( cp ) ) {
//
- // XQuery 3.0 F&O: 4.6.1: A grouping-separator-sign must not appear
+ // XQuery F&O 3.0: 4.6.1: A grouping-separator-sign must not appear
// at the start ... of the decimal-digit-pattern ....
//
throw XQUERY_EXCEPTION(
@@ -1067,10 +1068,32 @@
}
if ( consumeNext( item, theChildren[3].getp(), planState ) ) {
- // TODO: handle calendar being a QName.
- cal = calendar::find( item->getStringValue() );
- if ( !cal )
+ zstring const cal_str( item->getStringValue() );
+ zstring prefix_or_uri, local;
+
+ xml::split_uri_name( cal_str, &prefix_or_uri, &local )
+ || xml::split_qname( cal_str, &prefix_or_uri, &local );
+
+ if ( !prefix_or_uri.empty() ) {
+ //
+ // We don't know what to do with calendar designators in a namespace.
+ //
cal_is_fallback = true;
+ } else {
+ cal = calendar::find( local );
+ if ( !cal ) {
+ //
+ // XQuery F&O 3.0: 9.4.8.3: If the expanded QName is in no
+ // namespace, then it must identify a calendar with a designator
+ // specified [in the table given in the section].
+ //
+ throw XQUERY_EXCEPTION(
+ err::FOFD1340,
+ ERROR_PARAMS( cal_str, ZED( FOFD1340_BadCalendar ) ),
+ ERROR_LOC( loc )
+ );
+ }
+ }
}
if ( consumeNext( item, theChildren[4].getp(), planState ) ) {
@@ -1080,9 +1103,9 @@
if ( !cal ) {
//
- // XQuery 3.0 F&O: 9.8.4.3: If the $calendar argument is omitted or is
- // set to an empty sequence then the default calendar defined in the
- // dynamic context is used.
+ // Ibid: If the $calendar argument is omitted or is set to an empty
+ // sequence then the default calendar defined in the dynamic context is
+ // used.
//
cal = planState.theLocalDynCtx->get_calendar();
}
=== modified file 'src/runtime/json/jsonml_array.cpp'
--- src/runtime/json/jsonml_array.cpp 2013-06-01 00:30:39 +0000
+++ src/runtime/json/jsonml_array.cpp 2013-06-18 02:30:40 +0000
@@ -42,7 +42,7 @@
///////////////////////////////////////////////////////////////////////////////
inline void split_name( zstring const &name, zstring *prefix, zstring *local ) {
- if ( !xml::split_name( name, prefix, local ) )
+ if ( !xml::split_qname( name, prefix, local ) )
throw XQUERY_EXCEPTION(
zerr::ZJPE0008_ILLEGAL_QNAME,
ERROR_PARAMS( name )
=== modified file 'src/runtime/numerics/format_number.cpp'
--- src/runtime/numerics/format_number.cpp 2013-05-15 23:22:01 +0000
+++ src/runtime/numerics/format_number.cpp 2013-06-18 02:30:40 +0000
@@ -788,7 +788,7 @@
zstring format_name( format_name_item->getStringValue() );
ascii::trim_space( format_name );
zstring prefix, local;
- if ( !xml::split_name( format_name, &prefix, &local ) ||
+ if ( !xml::split_qname( format_name, &prefix, &local ) ||
prefix.empty() ) {
GENV_ITEMFACTORY->createQName( format_name_item, "", "", format_name );
} else {
=== modified file 'src/util/xml_util.h'
--- src/util/xml_util.h 2013-05-09 00:48:27 +0000
+++ src/util/xml_util.h 2013-06-18 02:30:40 +0000
@@ -93,15 +93,15 @@
}
/**
- * Splits an XML name at a \c : if present.
+ * Splits a QName at a \c : if present.
*
* @tparam InputStringType The input string type.
* @tparam PrefixStringType The output prefix string type.
* @tparam LocalStringType The output local string type.
- * @param name The XML name to be split.
+ * @param qname The QName to be split.
* @param prefix The prefix is put here, if any.
* @param local The local name is put here.
- * @return If \a name contains a \c : and either \a prefix or \a local strings
+ * @return If \a qname contains a \c : and either \a prefix or \a local strings
* become empty, returns \c false; otherwise returns \a true.
*/
template<class InputStringType,class PrefixStringType,class LocalStringType>
@@ -110,20 +110,50 @@
&& ZORBA_IS_STRING(PrefixStringType)
&& ZORBA_IS_STRING(LocalStringType),
bool>::type
-split_name( InputStringType const &name, PrefixStringType *prefix,
- LocalStringType *local ) {
- typename InputStringType::size_type const colon = name.find( ':' );
+split_qname( InputStringType const &qname, PrefixStringType *prefix,
+ LocalStringType *local ) {
+ typename InputStringType::size_type const colon = qname.find( ':' );
if ( colon != InputStringType::npos ) {
- prefix->assign( name, 0, colon );
- local->assign( name, colon + 1, LocalStringType::npos );
+ prefix->assign( qname, 0, colon );
+ local->assign( qname, colon + 1, LocalStringType::npos );
return !( prefix->empty() || local->empty() );
} else {
prefix->clear();
- *local = name;
+ *local = qname;
return true;
}
}
+/**
+ * Splits a URIQualifiedName.
+ *
+ * @tparam InputStringType The input string type.
+ * @tparam URIStringType The output URI string type.
+ * @tparam LocalStringType The output local string type.
+ * @param uname The URIQualifiedName to be split.
+ * @param uri The URI is put here, if any.
+ * @param local The local name is put here.
+ * @return Returns \a true only if \a uname is a URIQualifiedName and \a local
+ * is not empty.
+ */
+template<class InputStringType,class URIStringType,class LocalStringType> inline
+typename std::enable_if<ZORBA_IS_STRING(InputStringType)
+ && ZORBA_IS_STRING(URIStringType)
+ && ZORBA_IS_STRING(LocalStringType),
+ bool>::type
+split_uri_name( InputStringType const &uname, URIStringType *uri,
+ LocalStringType *local ) {
+ if ( uname.compare( 0, 2, "Q{" ) == 0 ) {
+ typename InputStringType::size_type const rbrace = uname.find( '}' );
+ if ( rbrace != InputStringType::npos ) {
+ uri->assign( uname, 2, rbrace - 2 );
+ local->assign( uname, rbrace + 1, LocalStringType::npos );
+ return !local->empty();
+ }
+ }
+ return false;
+}
+
////////// Character validity /////////////////////////////////////////////////
/**
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt 2013-06-13 23:04:41 +0000
+++ test/fots/CMakeLists.txt 2013-06-18 02:30:40 +0000
@@ -139,11 +139,6 @@
EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-009 1187685)
EXPECTED_FOTS_FAILURE (fn-for-each-pair fn-for-each-pair-026 1187685)
-EXPECTED_FOTS_FAILURE (fn-format-date format-date-010 1190710)
-EXPECTED_FOTS_FAILURE (fn-format-date format-date-en155 1190710)
-EXPECTED_FOTS_FAILURE (fn-format-date format-date-en156 1190710)
-EXPECTED_FOTS_FAILURE (fn-format-date format-date-en157 1190710)
-EXPECTED_FOTS_FAILURE (fn-format-date format-date-en158 1190710)
EXPECTED_FOTS_FAILURE (fn-format-number numberformat60a 1167609)
EXPECTED_FOTS_FAILURE (fn-format-number numberformat60m 1167609)
EXPECTED_FOTS_FAILURE (fn-format-number numberformat60o 1167609)
Follow ups
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: noreply, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Matthias Brantner, 2013-06-18
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Matthias Brantner, 2013-06-18
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Zorba Build Bot, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-06-18
-
Re: [Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-06-18
-
[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba
From: Paul J. Lucas, 2013-06-18