]> granicus.if.org Git - php/commitdiff
- increase max locale to 80
authorStanislav Malyshev <stas@php.net>
Mon, 14 Jul 2008 06:42:11 +0000 (06:42 +0000)
committerStanislav Malyshev <stas@php.net>
Mon, 14 Jul 2008 06:42:11 +0000 (06:42 +0000)
- add some macros

ext/intl/intl_data.h

index 3f5205236e03b6c9b27e2fa31a83ae51f4c784e0..ebbcb1660a7f835784966349a3bd867d1f4e0598 100755 (executable)
@@ -45,6 +45,16 @@ typedef struct _intl_data {
        obj = (oclass##_object *) zend_object_store_get_object( object TSRMLS_CC );     \
     intl_error_reset( INTL_DATA_ERROR_P(obj) TSRMLS_CC );                                              \
 
+// Check status by error code, if error - exit
+#define INTL_CHECK_STATUS(err, msg)                                                                                    \
+    intl_error_set_code( NULL, (err) TSRMLS_CC );                                                      \
+    if( U_FAILURE((err)) )                                                                                                     \
+    {                                                                                                                                          \
+        intl_errors_set_custom_msg( NULL, msg, 0 TSRMLS_CC );                          \
+        RETURN_FALSE;                                                                                                          \
+    }
+
+// Check status in object, if error - exit
 #define INTL_METHOD_CHECK_STATUS(obj, msg)                                                                                     \
     intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) TSRMLS_CC );                                \
     if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) )                                                                     \
@@ -53,6 +63,17 @@ typedef struct _intl_data {
         RETURN_FALSE;                                                                          \
     }
 
+// Check status, if error - destroy value and exit
+#define INTL_CTOR_CHECK_STATUS(obj, msg, val)                                                                          \
+    intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) TSRMLS_CC );                                \
+    if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) )                                                                     \
+    {                                                                                                                                                          \
+        intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 TSRMLS_CC );      \
+               zval_dtor((val));                                                                                                                       \
+               ZVAL_NULL((val));                                                                                                                       \
+        RETURN_NULL();                                                                                                                         \
+    }
+
 #define INTL_METHOD_RETVAL_UTF8(obj, ustring, ulen, free_it)                                                                   \
 {                                                                                                                                                                                              \
        char *u8value;                                                                                                                                                          \
@@ -65,19 +86,19 @@ typedef struct _intl_data {
        RETVAL_STRINGL(u8value, u8len, 0);                                                                                                                      \
 }
 
-#define INTL_MAX_LOCALE_LEN 64
+#define INTL_MAX_LOCALE_LEN 80
 
 #define INTL_CHECK_LOCALE_LEN(locale_len)                                                                                              \
        if((locale_len) > INTL_MAX_LOCALE_LEN) {                                                                                        \
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,                                                                 \
-       "Locale string too long, should be no longer than 64 characters", 0 TSRMLS_CC );        \
+       "Locale string too long, should be no longer than 80 characters", 0 TSRMLS_CC );        \
                RETURN_NULL();                                                                                                                                  \
        }
 
 #define INTL_CHECK_LOCALE_LEN_OBJ(locale_len, object)                                                                  \
        if((locale_len) > INTL_MAX_LOCALE_LEN) {                                                                                        \
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,                                                                 \
-       "Locale string too long, should be no longer than 64 characters", 0 TSRMLS_CC );        \
+       "Locale string too long, should be no longer than 80 characters", 0 TSRMLS_CC );        \
                zval_dtor(object);                                                                                                                              \
                ZVAL_NULL(object);                                                                                                                              \
                RETURN_NULL();                                                                                                                                  \