*/
PHP_FUNCTION( datefmt_get_error_code )
{
- zval* object = NULL;
- IntlDateFormatter_object* dfo = NULL;
+ DATE_FORMAT_METHOD_INIT_VARS;
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
PHP_FUNCTION( datefmt_get_error_message )
{
char* message = NULL;
- zval* object = NULL;
- IntlDateFormatter_object* dfo = NULL;
+ DATE_FORMAT_METHOD_INIT_VARS;
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
dfo = (IntlDateFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
/* Return last error message. */
- message = intl_error_get_message( &dfo->datef_data.error TSRMLS_CC );
+ message = intl_error_get_message( INTL_DATA_ERROR_P(dfo) TSRMLS_CC );
RETURN_STRING( message, 0);
}
/* }}} */
nfo = (NumberFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
/* Return last error message. */
- message = intl_error_get_message( &INTL_DATA_ERROR(nfo) TSRMLS_CC );
+ message = intl_error_get_message( INTL_DATA_ERROR_P(nfo) TSRMLS_CC );
RETURN_STRING( message, 0);
}
/* }}} */
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
efree( ustring );
RETURN_NULL();
}
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
efree( ustr );
RETURN_FALSE;
}
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC );
efree( sub_str );
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC );
if ( NULL != sub_str )
efree( sub_str );
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
if ( NULL != ustr )
efree( ustr );
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
efree( uhaystack );
return -1;
}
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
efree( uhaystack );
efree( uneedle );
ubrk_close (bi);
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
efree( uhaystack );
return -1;
}
intl_error_set_code( NULL, status TSRMLS_CC );
/* Set error messages. */
- intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
efree( uhaystack );
efree( uneedle );
ubrk_close (bi);
int32_t converted_ret_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "u|l", (char **)&domain, &domain_len, &option) == FAILURE) {
- return;
+ RETURN_FALSE;
}
if (domain_len < 1) {
if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) )
return;
- if( !err->free_custom_error_message )
- return;
-
- efree( err->custom_error_message );
+ if( err->free_custom_error_message ) {
+ efree( err->custom_error_message );
+ }
err->custom_error_message = NULL;
err->free_custom_error_message = 0;
}
/* }}} */
+/* {{{ void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg )
+ * Set error code and message.
+ */
+void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC )
+{
+ intl_errors_set_code( err, code TSRMLS_CC );
+ intl_errors_set_custom_msg( err, msg, copyMsg TSRMLS_CC );
+}
+/* }}} */
+
/* {{{ void intl_errors_reset( intl_error* err )
*/
void intl_errors_reset( intl_error* err TSRMLS_DC )
void intl_errors_reset( intl_error* err TSRMLS_DC );
void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg TSRMLS_DC );
void intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC );
+void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg TSRMLS_DC );
#endif // INTL_ERROR_H
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, msg , 1 TSRMLS_CC );
efree(msg);
- RETURN_NULL();
+ RETURN_FALSE;
}
if(loc_name_len == 0) {
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
&loc_name, &loc_name_len ) == FAILURE)
{
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"locale_parse: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
+ RETURN_FALSE;
}
if(loc_name_len == 0) {
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "as|bs", &arr, &loc_range, &loc_range_len,
&boolCanonical, &fallback_loc, &fallback_loc_len) == FAILURE) {
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "locale_lookup: unable to parse input params", 0 TSRMLS_CC );
- RETURN_NULL();
+ RETURN_FALSE;
}
if(loc_range_len == 0) {
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"locale_accept_from_http: unable to parse input parameters", 0 TSRMLS_CC );
- RETURN_NULL();
+ RETURN_FALSE;
}
available = ures_openAvailableLocales(NULL, &status);
&uinput, &uinput_len, &form ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "normalizer_normalize: unable to parse input params", 1 TSRMLS_CC );
+ "normalizer_normalize: unable to parse input params", 0 TSRMLS_CC );
- RETURN_NULL();
+ RETURN_FALSE;
}
expansion_factor = 1;
break;
default:
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "normalizer_normalize: illegal normalization form", 1 TSRMLS_CC );
- RETURN_NULL();
+ "normalizer_normalize: illegal normalization form", 0 TSRMLS_CC );
+ RETURN_FALSE;
}
/*
*/
if( U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR && status != U_STRING_NOT_TERMINATED_WARNING ) {
efree( uret_buf );
- RETURN_NULL();
+ RETURN_FALSE;
}
if ( size_needed > uret_len ) {
/* Bail out if an unexpected error occured. */
if( U_FAILURE(status) ) {
/* Set error messages. */
- intl_error_set_custom_msg( NULL,"Error normalizing string", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL,"Error normalizing string", 0 TSRMLS_CC );
efree( uret_buf );
- RETURN_NULL();
+ RETURN_FALSE;
}
}
&uinput, &uinput_len, &form) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "normalizer_is_normalized: unable to parse input params", 1 TSRMLS_CC );
+ "normalizer_is_normalized: unable to parse input params", 0 TSRMLS_CC );
RETURN_FALSE;
}
break;
default:
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "normalizer_normalize: illegal normalization form", 1 TSRMLS_CC );
- RETURN_NULL();
+ "normalizer_normalize: illegal normalization form", 0 TSRMLS_CC );
+ RETURN_FALSE;
}
/* Bail out if an unexpected error occured. */
if( U_FAILURE(status) ) {
/* Set error messages. */
- intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 1 TSRMLS_CC );
+ intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 0 TSRMLS_CC );
RETURN_FALSE;
}
--- /dev/null
+--TEST--
+Check that bad argumens return the same
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+$funcs = get_extension_funcs("intl");
+function ignore_err() {}
+set_error_handler("ignore_err");
+$arg = new stdClass();
+foreach($funcs as $func) {
+ $rfunc = new ReflectionFunction($func);
+ if($rfunc->getNumberOfRequiredParameters() == 0) {
+ continue;
+ }
+ $res = $func($arg);
+ if($res != false) {
+ echo "$func: ";
+ var_dump($res);
+ }
+}
+echo "OK!\n";
+?>
+--EXPECT--
+OK!