diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-07-23 10:51:19 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-07-23 10:51:19 +0200 |
commit | 3365f28adf90110ca7475df889720fc244820f4b (patch) | |
tree | 5415edde3e396a93f05f887d9f07071871467bdf /ext/intl/msgformat | |
parent | f0f8d7084aec4be5c07f02f2e29c2820f85c8315 (diff) | |
download | php-3365f28adf90110ca7475df889720fc244820f4b.tar.gz |
Imported Upstream version 5.4.5upstream/5.4.5
Diffstat (limited to 'ext/intl/msgformat')
-rwxr-xr-x | ext/intl/msgformat/msgformat.c | 2 | ||||
-rwxr-xr-x | ext/intl/msgformat/msgformat_attr.c | 2 | ||||
-rwxr-xr-x | ext/intl/msgformat/msgformat_class.h | 12 | ||||
-rwxr-xr-x | ext/intl/msgformat/msgformat_data.c | 4 | ||||
-rwxr-xr-x | ext/intl/msgformat/msgformat_data.h | 7 | ||||
-rwxr-xr-x | ext/intl/msgformat/msgformat_format.c | 2 | ||||
-rwxr-xr-x | ext/intl/msgformat/msgformat_parse.c | 2 |
7 files changed, 26 insertions, 5 deletions
diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index 84f14de1b..0a01204fa 100755 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@ -64,9 +64,11 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) locale = INTL_G(default_locale); } +#ifdef MSG_FORMAT_QUOTE_APOS if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) { INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format"); } +#endif if ((mfo)->mf_data.orig_format) { msgformat_data_free(&mfo->mf_data TSRMLS_CC); diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c index cf3466514..ed2dae27d 100755 --- a/ext/intl/msgformat/msgformat_attr.c +++ b/ext/intl/msgformat/msgformat_attr.c @@ -82,11 +82,13 @@ PHP_FUNCTION( msgfmt_set_pattern ) intl_convert_utf8_to_utf16(&spattern, &spattern_len, value, value_len, &INTL_DATA_ERROR_CODE(mfo)); INTL_METHOD_CHECK_STATUS(mfo, "Error converting pattern to UTF-16" ); +#ifdef MSG_FORMAT_QUOTE_APOS if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) { intl_error_set( NULL, U_INVALID_FORMAT_ERROR, "msgfmt_set_pattern: error converting pattern to quote-friendly format", 0 TSRMLS_CC ); RETURN_FALSE; } +#endif /* TODO: add parse error information */ umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), spattern, spattern_len, NULL, &INTL_DATA_ERROR_CODE(mfo)); diff --git a/ext/intl/msgformat/msgformat_class.h b/ext/intl/msgformat/msgformat_class.h index 0afa792ae..b6b8e3322 100755 --- a/ext/intl/msgformat/msgformat_class.h +++ b/ext/intl/msgformat/msgformat_class.h @@ -19,9 +19,11 @@ #include <php.h> -#include "intl_common.h" -#include "intl_error.h" -#include "intl_data.h" +#include <unicode/uconfig.h> + +#include "../intl_common.h" +#include "../intl_error.h" +#include "../intl_data.h" #include "msgformat_data.h" typedef struct { @@ -38,4 +40,8 @@ extern zend_class_entry *MessageFormatter_ce_ptr; #define MSG_FORMAT_METHOD_FETCH_OBJECT INTL_METHOD_FETCH_OBJECT(MessageFormatter, mfo) #define MSG_FORMAT_OBJECT(mfo) (mfo)->mf_data.umsgf +#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM < 48 +# define MSG_FORMAT_QUOTE_APOS 1 +#endif + #endif // #ifndef MSG_FORMAT_CLASS_H diff --git a/ext/intl/msgformat/msgformat_data.c b/ext/intl/msgformat/msgformat_data.c index 95e81d3ea..527c1d4d1 100755 --- a/ext/intl/msgformat/msgformat_data.c +++ b/ext/intl/msgformat/msgformat_data.c @@ -21,6 +21,8 @@ #include <unicode/ustring.h> #include "msgformat_data.h" +#include "msgformat_class.h" + /* {{{ void msgformat_data_init( msgformat_data* mf_data ) * Initialize internals of msgformat_data. */ @@ -69,6 +71,7 @@ msgformat_data* msgformat_data_create( TSRMLS_D ) } /* }}} */ +#ifdef MSG_FORMAT_QUOTE_APOS int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec) { if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) { @@ -86,6 +89,7 @@ int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *e } return SUCCESS; } +#endif /* diff --git a/ext/intl/msgformat/msgformat_data.h b/ext/intl/msgformat/msgformat_data.h index 44001753b..6479888f8 100755 --- a/ext/intl/msgformat/msgformat_data.h +++ b/ext/intl/msgformat/msgformat_data.h @@ -19,9 +19,9 @@ #include <php.h> -#include <unicode/umsg.h> +#include "../intl_error.h" -#include "intl_error.h" +#include <unicode/umsg.h> typedef struct { // error hangling @@ -36,6 +36,9 @@ typedef struct { msgformat_data* msgformat_data_create( TSRMLS_D ); void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC ); void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC ); + +#ifdef MSG_FORMAT_QUOTE_APOS int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec); +#endif #endif // MSG_FORMAT_DATA_H diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index b664c83ec..9a18ac0a7 100755 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c @@ -154,11 +154,13 @@ PHP_FUNCTION( msgfmt_format_message ) slocale = INTL_G(default_locale); } +#ifdef MSG_FORMAT_QUOTE_APOS if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) { intl_error_set( NULL, U_INVALID_FORMAT_ERROR, "msgfmt_format_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC ); RETURN_FALSE; } +#endif /* Create an ICU message formatter. */ MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo)); diff --git a/ext/intl/msgformat/msgformat_parse.c b/ext/intl/msgformat/msgformat_parse.c index 8393d4c6e..f540b1d0c 100755 --- a/ext/intl/msgformat/msgformat_parse.c +++ b/ext/intl/msgformat/msgformat_parse.c @@ -129,11 +129,13 @@ PHP_FUNCTION( msgfmt_parse_message ) slocale = INTL_G(default_locale); } +#ifdef MSG_FORMAT_QUOTE_APOS if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) { intl_error_set( NULL, U_INVALID_FORMAT_ERROR, "msgfmt_parse_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC ); RETURN_FALSE; } +#endif /* Create an ICU message formatter. */ MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo)); |