summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-06-06 09:36:00 (GMT)
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-06-06 09:36:00 (GMT)
commit52d541a3149d4a21e9f45fa80b26c338636f92c4 (patch)
treef20229e3df4029130e5f497b204952b344696c82 /ext
parent45b3fa4deea739c8a3bf8778efac2f748a2685bc (diff)
downloadphp-52d541a3149d4a21e9f45fa80b26c338636f92c4.tar.gz
Optimization in ext/intl/msgformat
Don't transform the string to make it apostrophe friendly in ICU 4.8+ as that it is now the default.
Diffstat (limited to 'ext')
-rwxr-xr-xext/intl/msgformat/msgformat.c2
-rwxr-xr-xext/intl/msgformat/msgformat_attr.c2
-rwxr-xr-xext/intl/msgformat/msgformat_class.h12
-rwxr-xr-xext/intl/msgformat/msgformat_data.c2
-rwxr-xr-xext/intl/msgformat/msgformat_data.h7
-rwxr-xr-xext/intl/msgformat/msgformat_format.c2
-rwxr-xr-xext/intl/msgformat/msgformat_parse.c2
7 files changed, 24 insertions, 5 deletions
diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c
index 84f14de..0a01204 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 cf34665..ed2dae2 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 0afa792..b6b8e33 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 95e81d3..4f93d6d 100755
--- a/ext/intl/msgformat/msgformat_data.c
+++ b/ext/intl/msgformat/msgformat_data.c
@@ -69,6 +69,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 +87,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 4400175..6479888 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 b664c83..9a18ac0 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 8393d4c..f540b1d 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));