summaryrefslogtreecommitdiff
path: root/ext/intl/collator
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-08-11 19:48:00 +0000
committerFelipe Pena <felipe@php.net>2008-08-11 19:48:00 +0000
commiteb1837d9de56547f76459397a930f2e812547448 (patch)
tree0c8be24ca5b3bd7fd3735fc30cb6529351c2ff2b /ext/intl/collator
parent6d083e2c39aa15f9740d041ca007ae2f86d2f10f (diff)
downloadphp-git-eb1837d9de56547f76459397a930f2e812547448.tar.gz
MFH:
- Added arginfo - Fixed WS - Changed C++ comments to C comments
Diffstat (limited to 'ext/intl/collator')
-rwxr-xr-xext/intl/collator/collator.c8
-rwxr-xr-xext/intl/collator/collator_attr.c22
-rwxr-xr-xext/intl/collator/collator_class.c24
-rwxr-xr-xext/intl/collator/collator_compare.c18
-rwxr-xr-xext/intl/collator/collator_convert.c71
-rwxr-xr-xext/intl/collator/collator_create.c4
-rwxr-xr-xext/intl/collator/collator_error.c12
-rwxr-xr-xext/intl/collator/collator_locale.c8
-rwxr-xr-xext/intl/collator/collator_sort.c99
9 files changed, 135 insertions, 131 deletions
diff --git a/ext/intl/collator/collator.c b/ext/intl/collator/collator.c
index 4c1bbc7797..047a738028 100755
--- a/ext/intl/collator/collator.c
+++ b/ext/intl/collator/collator.c
@@ -42,7 +42,7 @@ void collator_register_constants( INIT_FUNC_ARGS )
#define COLLATOR_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( #x ) - 1, UCOL_##x TSRMLS_CC );
#define COLLATOR_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );
- // UColAttributeValue constants
+ /* UColAttributeValue constants */
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_VALUE", UCOL_DEFAULT );
COLLATOR_EXPOSE_CLASS_CONST( PRIMARY );
@@ -61,7 +61,7 @@ void collator_register_constants( INIT_FUNC_ARGS )
COLLATOR_EXPOSE_CLASS_CONST( LOWER_FIRST );
COLLATOR_EXPOSE_CLASS_CONST( UPPER_FIRST );
- // UColAttribute constants
+ /* UColAttribute constants */
COLLATOR_EXPOSE_CLASS_CONST( FRENCH_COLLATION );
COLLATOR_EXPOSE_CLASS_CONST( ALTERNATE_HANDLING );
COLLATOR_EXPOSE_CLASS_CONST( CASE_FIRST );
@@ -71,11 +71,11 @@ void collator_register_constants( INIT_FUNC_ARGS )
COLLATOR_EXPOSE_CLASS_CONST( HIRAGANA_QUATERNARY_MODE );
COLLATOR_EXPOSE_CLASS_CONST( NUMERIC_COLLATION );
- // ULocDataLocaleType constants
+ /* ULocDataLocaleType constants */
COLLATOR_EXPOSE_CONST( ULOC_ACTUAL_LOCALE );
COLLATOR_EXPOSE_CONST( ULOC_VALID_LOCALE );
- // sort flags
+ /* sort flags */
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_REGULAR", COLLATOR_SORT_REGULAR );
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_STRING", COLLATOR_SORT_STRING );
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_NUMERIC", COLLATOR_SORT_NUMERIC );
diff --git a/ext/intl/collator/collator_attr.c b/ext/intl/collator/collator_attr.c
index b4fe0a4e14..684e72cc58 100755
--- a/ext/intl/collator/collator_attr.c
+++ b/ext/intl/collator/collator_attr.c
@@ -37,7 +37,7 @@ PHP_FUNCTION( collator_get_attribute )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, Collator_ce_ptr, &attribute ) == FAILURE )
{
@@ -47,7 +47,7 @@ PHP_FUNCTION( collator_get_attribute )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
value = ucol_getAttribute( co->ucoll, attribute, COLLATOR_ERROR_CODE_P( co ) );
@@ -68,7 +68,7 @@ PHP_FUNCTION( collator_set_attribute )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll",
&object, Collator_ce_ptr, &attribute, &value ) == FAILURE)
{
@@ -78,10 +78,10 @@ PHP_FUNCTION( collator_set_attribute )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Set new value for the given attribute.
+ /* Set new value for the given attribute. */
ucol_setAttribute( co->ucoll, attribute, value, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_CHECK_STATUS( co, "Error setting attribute value" );
@@ -98,7 +98,7 @@ PHP_FUNCTION( collator_get_strength )
{
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, Collator_ce_ptr ) == FAILURE )
{
@@ -108,10 +108,10 @@ PHP_FUNCTION( collator_get_strength )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Get current strength and return it.
+ /* Get current strength and return it. */
RETURN_LONG( ucol_getStrength( co->ucoll ) );
}
/* }}} */
@@ -127,7 +127,7 @@ PHP_FUNCTION( collator_set_strength )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, Collator_ce_ptr, &strength ) == FAILURE )
{
@@ -137,10 +137,10 @@ PHP_FUNCTION( collator_set_strength )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Set given strength.
+ /* Set given strength. */
ucol_setStrength( co->ucoll, strength );
RETURN_TRUE;
diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c
index 1d75f71f64..df3c12cc5a 100755
--- a/ext/intl/collator/collator_class.c
+++ b/ext/intl/collator/collator_class.c
@@ -30,9 +30,9 @@
zend_class_entry *Collator_ce_ptr = NULL;
-/////////////////////////////////////////////////////////////////////////////
-// Auxiliary functions needed by objects of 'Collator' class
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Auxiliary functions needed by objects of 'Collator' class
+ */
/* {{{ Collator_objects_dtor */
static void Collator_objects_dtor(
@@ -79,15 +79,15 @@ zend_object_value Collator_object_create(
}
/* }}} */
-/////////////////////////////////////////////////////////////////////////////
-// 'Collator' class registration structures & functions
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * 'Collator' class registration structures & functions
+ */
/* {{{ Collator methods arguments info */
-// NOTE: modifying 'collator_XX_args' do not forget to
-// modify approptiate 'collator_XX_args' for
-// the procedural API.
-
+/* NOTE: modifying 'collator_XX_args' do not forget to
+ modify approptiate 'collator_XX_args' for
+ the procedural API.
+*/
static
ZEND_BEGIN_ARG_INFO_EX( collator_0_args, 0, 0, 0 )
ZEND_END_ARG_INFO()
@@ -140,12 +140,12 @@ void collator_register_Collator_class( TSRMLS_D )
{
zend_class_entry ce;
- // Create and register 'Collator' class.
+ /* Create and register 'Collator' class. */
INIT_CLASS_ENTRY( ce, "Collator", Collator_class_functions );
ce.create_object = Collator_object_create;
Collator_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
- // Declare 'Collator' class properties.
+ /* Declare 'Collator' class properties. */
if( !Collator_ce_ptr )
{
zend_error( E_ERROR,
diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.c
index e6029e7920..4e7b3a7d49 100755
--- a/ext/intl/collator/collator_compare.c
+++ b/ext/intl/collator/collator_compare.c
@@ -45,7 +45,7 @@ PHP_FUNCTION( collator_compare )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss",
&object, Collator_ce_ptr, &str1, &str1_len, &str2, &str2_len ) == FAILURE )
{
@@ -55,7 +55,7 @@ PHP_FUNCTION( collator_compare )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
@@ -63,15 +63,15 @@ PHP_FUNCTION( collator_compare )
* Compare given strings (converting them to UTF-16 first).
*/
- // First convert the strings to UTF-16.
+ /* First convert the strings to UTF-16. */
intl_convert_utf8_to_utf16(
&ustr1, &ustr1_len, str1, str1_len, COLLATOR_ERROR_CODE_P( co ) );
if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) )
{
- // Set global error code.
+ /* Set global error code. */
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
- // Set error messages.
+ /* Set error messages. */
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
"Error converting first argument to UTF-16", 0 TSRMLS_CC );
efree( ustr1 );
@@ -82,10 +82,10 @@ PHP_FUNCTION( collator_compare )
&ustr2, &ustr2_len, str2, str2_len, COLLATOR_ERROR_CODE_P( co ) );
if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) )
{
- // Set global error code.
+ /* Set global error code. */
intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) TSRMLS_CC );
- // Set error messages.
+ /* Set error messages. */
intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
"Error converting second argument to UTF-16", 0 TSRMLS_CC );
efree( ustr1 );
@@ -93,7 +93,7 @@ PHP_FUNCTION( collator_compare )
RETURN_FALSE;
}
- // Then compare them.
+ /* Then compare them. */
result = ucol_strcoll(
co->ucoll,
ustr1, ustr1_len,
@@ -104,7 +104,7 @@ PHP_FUNCTION( collator_compare )
if( ustr2 )
efree( ustr2 );
- // Return result of the comparison.
+ /* Return result of the comparison. */
RETURN_LONG( result );
}
/* }}} */
diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c
index 7bb48ebb4b..e989d4c65a 100755
--- a/ext/intl/collator/collator_convert.c
+++ b/ext/intl/collator/collator_convert.c
@@ -51,22 +51,22 @@ static void collator_convert_hash_item_from_utf8_to_utf16(
zval** hashData = NULL;
zval* znew_val = NULL;
- // Get current hash item.
+ /* Get current hash item. */
zend_hash_get_current_data( hash, (void**) &hashData );
- // Process string values only.
+ /* Process string values only. */
if( Z_TYPE_P( *hashData ) != IS_STRING )
return;
old_val = Z_STRVAL_P( *hashData );
old_val_len = Z_STRLEN_P( *hashData );
- // Convert it from UTF-8 to UTF-16LE and save the result to new_val[_len].
+ /* Convert it from UTF-8 to UTF-16LE and save the result to new_val[_len]. */
intl_convert_utf8_to_utf16( &new_val, &new_val_len, old_val, old_val_len, status );
if( U_FAILURE( *status ) )
return;
- // Update current hash item with the converted value.
+ /* Update current hash item with the converted value. */
MAKE_STD_ZVAL( znew_val );
ZVAL_STRINGL( znew_val, (char*)new_val, UBYTES(new_val_len), FALSE );
@@ -75,7 +75,7 @@ static void collator_convert_hash_item_from_utf8_to_utf16(
zend_hash_update( hash, hashKey, strlen( hashKey ) + 1,
(void*) &znew_val, sizeof(zval*), NULL );
}
- else // hashKeyType == HASH_KEY_IS_LONG
+ else /* hashKeyType == HASH_KEY_IS_LONG */
{
zend_hash_index_update( hash, hashIndex,
(void*) &znew_val, sizeof(zval*), NULL );
@@ -95,23 +95,23 @@ static void collator_convert_hash_item_from_utf16_to_utf8(
zval** hashData = NULL;
zval* znew_val = NULL;
- // Get current hash item.
+ /* Get current hash item. */
zend_hash_get_current_data( hash, (void**) &hashData );
- // Process string values only.
+ /* Process string values only. */
if( Z_TYPE_P( *hashData ) != IS_STRING )
return;
old_val = Z_STRVAL_P( *hashData );
old_val_len = Z_STRLEN_P( *hashData );
- // Convert it from UTF-16LE to UTF-8 and save the result to new_val[_len].
+ /* Convert it from UTF-16LE to UTF-8 and save the result to new_val[_len]. */
intl_convert_utf16_to_utf8( &new_val, &new_val_len,
(UChar*)old_val, UCHARS(old_val_len), status );
if( U_FAILURE( *status ) )
return;
- // Update current hash item with the converted value.
+ /* Update current hash item with the converted value. */
MAKE_STD_ZVAL( znew_val );
ZVAL_STRINGL( znew_val, (char*)new_val, new_val_len, FALSE );
@@ -120,7 +120,7 @@ static void collator_convert_hash_item_from_utf16_to_utf8(
zend_hash_update( hash, hashKey, strlen( hashKey ) + 1,
(void*) &znew_val, sizeof(zval*), NULL );
}
- else // hashKeyType == HASH_KEY_IS_LONG
+ else /* hashKeyType == HASH_KEY_IS_LONG */
{
zend_hash_index_update( hash, hashIndex,
(void*) &znew_val, sizeof(zval*), NULL );
@@ -141,13 +141,13 @@ void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* stat
while( ( hashKeyType = zend_hash_get_current_key( hash, &hashKey, &hashIndex, 0 ) )
!= HASH_KEY_NON_EXISTANT )
{
- // Convert current hash item from UTF-8 to UTF-16LE.
+ /* Convert current hash item from UTF-8 to UTF-16LE. */
collator_convert_hash_item_from_utf8_to_utf16(
hash, hashKeyType, hashKey, hashIndex, status );
if( U_FAILURE( *status ) )
return;
- // Proceed to the next item.
+ /* Proceed to the next item. */
zend_hash_move_forward( hash );
}
}
@@ -166,13 +166,14 @@ void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* stat
while( ( hashKeyType = zend_hash_get_current_key( hash, &hashKey, &hashIndex, 0 ) )
!= HASH_KEY_NON_EXISTANT )
{
- // Convert current hash item from UTF-16LE to UTF-8.
+ /* Convert current hash item from UTF-16LE to UTF-8. */
collator_convert_hash_item_from_utf16_to_utf8(
hash, hashKeyType, hashKey, hashIndex, status );
- if( U_FAILURE( *status ) )
+ if( U_FAILURE( *status ) ) {
return;
+ }
- // Proceed to the next item.
+ /* Proceed to the next item. */
zend_hash_move_forward( hash );
}
}
@@ -193,7 +194,7 @@ zval* collator_convert_zstr_utf16_to_utf8( zval* utf16_zval )
int str_len = 0;
UErrorCode status = U_ZERO_ERROR;
- // Convert to utf8 then.
+ /* Convert to utf8 then. */
intl_convert_utf16_to_utf8( &str, &str_len,
(UChar*) Z_STRVAL_P(utf16_zval), UCHARS( Z_STRLEN_P(utf16_zval) ), &status );
if( U_FAILURE( status ) )
@@ -221,7 +222,7 @@ zval* collator_convert_zstr_utf8_to_utf16( zval* utf8_zval )
int ustr_len = 0;
UErrorCode status = U_ZERO_ERROR;
- // Convert the string to UTF-16.
+ /* Convert the string to UTF-16. */
intl_convert_utf8_to_utf16(
&ustr, &ustr_len,
Z_STRVAL_P( utf8_zval ), Z_STRLEN_P( utf8_zval ),
@@ -229,7 +230,7 @@ zval* collator_convert_zstr_utf8_to_utf16( zval* utf8_zval )
if( U_FAILURE( status ) )
php_error( E_WARNING, "Error casting object to string in collator_convert_zstr_utf8_to_utf16()" );
- // Set string.
+ /* Set string. */
ALLOC_INIT_ZVAL( zstr );
ZVAL_STRINGL( zstr, (char*)ustr, UBYTES(ustr_len), FALSE );
@@ -247,13 +248,13 @@ zval* collator_convert_object_to_string( zval* obj TSRMLS_DC )
UChar* ustr = NULL;
int ustr_len = 0;
- // Bail out if it's not an object.
+ /* Bail out if it's not an object. */
if( Z_TYPE_P( obj ) != IS_OBJECT )
{
COLLATOR_CONVERT_RETURN_FAILED( obj );
}
- // Try object's handlers.
+ /* Try object's handlers. */
if( Z_OBJ_HT_P(obj)->get )
{
zstr = Z_OBJ_HT_P(obj)->get( obj TSRMLS_CC );
@@ -262,7 +263,7 @@ zval* collator_convert_object_to_string( zval* obj TSRMLS_DC )
{
case IS_OBJECT:
{
- // Bail out.
+ /* Bail out. */
zval_ptr_dtor( &zstr );
COLLATOR_CONVERT_RETURN_FAILED( obj );
} break;
@@ -282,19 +283,19 @@ zval* collator_convert_object_to_string( zval* obj TSRMLS_DC )
if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_STRING CAST_OBJECT_SHOULD_FREE TSRMLS_CC ) == FAILURE )
{
- // cast_object failed => bail out.
+ /* cast_object failed => bail out. */
zval_ptr_dtor( &zstr );
COLLATOR_CONVERT_RETURN_FAILED( obj );
}
}
- // Object wasn't successfuly converted => bail out.
+ /* Object wasn't successfuly converted => bail out. */
if( zstr == NULL )
{
COLLATOR_CONVERT_RETURN_FAILED( obj );
}
- // Convert the string to UTF-16.
+ /* Convert the string to UTF-16. */
intl_convert_utf8_to_utf16(
&ustr, &ustr_len,
Z_STRVAL_P( zstr ), Z_STRLEN_P( zstr ),
@@ -302,14 +303,15 @@ zval* collator_convert_object_to_string( zval* obj TSRMLS_DC )
if( U_FAILURE( status ) )
php_error( E_WARNING, "Error casting object to string in collator_convert_object_to_string()" );
- // Cleanup zstr to hold utf16 string.
+ /* Cleanup zstr to hold utf16 string. */
zval_dtor( zstr );
- // Set string.
+ /* Set string. */
ZVAL_STRINGL( zstr, (char*)ustr, UBYTES(ustr_len), FALSE );
- // Don't free ustr cause it's set in zstr without copy.
- // efree( ustr );
+ /* Don't free ustr cause it's set in zstr without copy.
+ * efree( ustr );
+ */
return zstr;
}
@@ -328,7 +330,7 @@ zval* collator_convert_string_to_number( zval* str )
zval* num = collator_convert_string_to_number_if_possible( str );
if( num == str )
{
- // String wasn't converted => return zero.
+ /* String wasn't converted => return zero. */
zval_ptr_dtor( &num );
ALLOC_INIT_ZVAL( num );
@@ -452,20 +454,21 @@ zval* collator_normalize_sort_argument( zval* arg )
if( Z_TYPE_P( arg ) != IS_STRING )
{
- // If its not a string then nothing to do.
- // Return original arg.
+ /* If its not a string then nothing to do.
+ * Return original arg.
+ */
COLLATOR_CONVERT_RETURN_FAILED( arg );
}
- // Try convert to number.
+ /* Try convert to number. */
n_arg = collator_convert_string_to_number_if_possible( arg );
if( n_arg == arg )
{
- // Conversion to number failed.
+ /* Conversion to number failed. */
zval_ptr_dtor( &n_arg );
- // Convert string to utf8.
+ /* Convert string to utf8. */
n_arg = collator_convert_zstr_utf16_to_utf8( arg );
}
diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.c
index d42b7bcafd..0f0cc193e4 100755
--- a/ext/intl/collator/collator_create.c
+++ b/ext/intl/collator/collator_create.c
@@ -34,7 +34,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
intl_error_reset( NULL TSRMLS_CC );
object = return_value;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
&locale, &locale_len ) == FAILURE )
{
@@ -51,7 +51,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
locale = INTL_G(default_locale);
}
- // Open ICU collator.
+ /* Open ICU collator. */
co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
}
diff --git a/ext/intl/collator/collator_error.c b/ext/intl/collator/collator_error.c
index 55e366ccba..c4e41250a2 100755
--- a/ext/intl/collator/collator_error.c
+++ b/ext/intl/collator/collator_error.c
@@ -32,7 +32,7 @@ PHP_FUNCTION( collator_get_error_code )
{
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, Collator_ce_ptr ) == FAILURE )
{
@@ -42,12 +42,12 @@ PHP_FUNCTION( collator_get_error_code )
RETURN_FALSE;
}
- // Fetch the object (without resetting its last error code).
+ /* Fetch the object (without resetting its last error code). */
co = (Collator_object *) zend_object_store_get_object(object TSRMLS_CC);
if( co == NULL )
RETURN_FALSE;
- // Return collator's last error code.
+ /* Return collator's last error code. */
RETURN_LONG( COLLATOR_ERROR_CODE( co ) );
}
/* }}} */
@@ -63,7 +63,7 @@ PHP_FUNCTION( collator_get_error_message )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, Collator_ce_ptr ) == FAILURE )
{
@@ -73,12 +73,12 @@ PHP_FUNCTION( collator_get_error_message )
RETURN_FALSE;
}
- // Fetch the object (without resetting its last error code).
+ /* Fetch the object (without resetting its last error code). */
co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC );
if( co == NULL )
RETURN_FALSE;
- // Return last error message.
+ /* Return last error message. */
message = intl_error_get_message( COLLATOR_ERROR_P( co ) TSRMLS_CC );
RETURN_STRING( (char*)message, FALSE );
}
diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.c
index 838c50be80..353eff5982 100755
--- a/ext/intl/collator/collator_locale.c
+++ b/ext/intl/collator/collator_locale.c
@@ -38,7 +38,7 @@ PHP_FUNCTION( collator_get_locale )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, Collator_ce_ptr, &type ) == FAILURE )
{
@@ -48,15 +48,15 @@ PHP_FUNCTION( collator_get_locale )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Get locale by specified type.
+ /* Get locale by specified type. */
locale_name = (char*) ucol_getLocaleByType(
co->ucoll, type, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_CHECK_STATUS( co, "Error getting locale by type" );
- // Return it.
+ /* Return it. */
RETVAL_STRINGL( locale_name, strlen(locale_name), TRUE );
}
/* }}} */
diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.c
index db014428ad..efe4ca6e19 100755
--- a/ext/intl/collator/collator_sort.c
+++ b/ext/intl/collator/collator_sort.c
@@ -35,8 +35,8 @@ typedef long ptrdiff_t;
* buffer.
*/
typedef struct _collator_sort_key_index {
- char* key; // pointer to sort key
- zval** zstr; // pointer to original string(hash-item)
+ char* key; /* pointer to sort key */
+ zval** zstr; /* pointer to original string(hash-item) */
} collator_sort_key_index_t;
ZEND_EXTERN_MODULE_GLOBALS( intl )
@@ -64,16 +64,16 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2
zval* norm1 = NULL;
zval* norm2 = NULL;
- // If both args are strings AND either of args is not numeric string
- // then use ICU-compare. Otherwise PHP-compare.
+ /* If both args are strings AND either of args is not numeric string
+ * then use ICU-compare. Otherwise PHP-compare. */
if( Z_TYPE_P(str1) == IS_STRING && Z_TYPE_P(str2) == IS_STRING &&
( str1 == ( num1 = collator_convert_string_to_number_if_possible( str1 ) ) ||
str2 == ( num2 = collator_convert_string_to_number_if_possible( str2 ) ) ) )
{
- // Fetch collator object.
+ /* Fetch collator object. */
co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );
- // Compare the strings using ICU.
+ /* Compare the strings using ICU. */
result->value.lval = ucol_strcoll(
co->ucoll,
INTL_Z_STRVAL_P(str1), INTL_Z_STRLEN_P(str1),
@@ -82,35 +82,36 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2
}
else
{
- // num1 is set if str1 and str2 are strings.
+ /* num1 is set if str1 and str2 are strings. */
if( num1 )
{
if( num1 == str1 )
{
- // str1 is string but not numeric string
- // just convert it to utf8.
+ /* str1 is string but not numeric string
+ * just convert it to utf8.
+ */
norm1 = collator_convert_zstr_utf16_to_utf8( str1 );
- // num2 is not set but str2 is string => do normalization.
+ /* num2 is not set but str2 is string => do normalization. */
norm2 = collator_normalize_sort_argument( str2 );
}
else
{
- // str1 is numeric strings => passthru to PHP-compare.
+ /* str1 is numeric strings => passthru to PHP-compare. */
zval_add_ref( &num1 );
norm1 = num1;
- // str2 is numeric strings => passthru to PHP-compare.
+ /* str2 is numeric strings => passthru to PHP-compare. */
zval_add_ref( &num2 );
norm2 = num2;
}
}
else
{
- // num1 is not set if str1 or str2 is not a string => do normalization.
+ /* num1 is not set if str1 or str2 is not a string => do normalization. */
norm1 = collator_normalize_sort_argument( str1 );
- // if num1 is not set then num2 is not set as well => do normalization.
+ /* if num1 is not set then num2 is not set as well => do normalization. */
norm2 = collator_normalize_sort_argument( str2 );
}
@@ -178,10 +179,10 @@ static int collator_icu_compare_function(zval *result, zval *op1, zval *op2 TSRM
str1 = collator_make_printable_zval( op1 );
str2 = collator_make_printable_zval( op2 );
- // Fetch collator object.
+ /* Fetch collator object. */
co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );
- // Compare the strings using ICU.
+ /* Compare the strings using ICU. */
result->value.lval = ucol_strcoll(
co->ucoll,
INTL_Z_STRVAL_P(str1), INTL_Z_STRLEN_P(str1),
@@ -287,7 +288,7 @@ static void collator_sort_internal( int renumber, INTERNAL_FUNCTION_PARAMETERS )
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa|l",
&object, Collator_ce_ptr, &array, &sort_flags ) == FAILURE )
{
@@ -297,29 +298,29 @@ static void collator_sort_internal( int renumber, INTERNAL_FUNCTION_PARAMETERS )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Set 'compare function' according to sort flags.
+ /* Set 'compare function' according to sort flags. */
INTL_G(compare_func) = collator_get_compare_function( sort_flags );
hash = HASH_OF( array );
- // Convert strings in the specified array from UTF-8 to UTF-16.
+ /* Convert strings in the specified array from UTF-8 to UTF-16. */
collator_convert_hash_from_utf8_to_utf16( hash, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_CHECK_STATUS( co, "Error converting hash from UTF-8 to UTF-16" );
- // Save specified collator in the request-global (?) variable.
+ /* Save specified collator in the request-global (?) variable. */
saved_collator = INTL_G( current_collator );
INTL_G( current_collator ) = object;
- // Sort specified array.
+ /* Sort specified array. */
zend_hash_sort( hash, zend_qsort, collator_compare_func, renumber TSRMLS_CC );
- // Restore saved collator.
+ /* Restore saved collator. */
INTL_G( current_collator ) = saved_collator;
- // Convert strings in the specified array back to UTF-8.
+ /* Convert strings in the specified array back to UTF-8. */
collator_convert_hash_from_utf16_to_utf8( hash, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_CHECK_STATUS( co, "Error converting hash from UTF-16 to UTF-8" );
@@ -349,31 +350,31 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
{
zval* array = NULL;
HashTable* hash = NULL;
- zval** hashData = NULL; // currently processed item of input hash
+ zval** hashData = NULL; /* currently processed item of input hash */
- char* sortKeyBuf = NULL; // buffer to store sort keys
- uint32_t sortKeyBufSize = DEF_SORT_KEYS_BUF_SIZE; // buffer size
- ptrdiff_t sortKeyBufOffset = 0; // pos in buffer to store sort key
- int32_t sortKeyLen = 0; // the length of currently processing key
+ char* sortKeyBuf = NULL; /* buffer to store sort keys */
+ uint32_t sortKeyBufSize = DEF_SORT_KEYS_BUF_SIZE; /* buffer size */
+ ptrdiff_t sortKeyBufOffset = 0; /* pos in buffer to store sort key */
+ int32_t sortKeyLen = 0; /* the length of currently processing key */
uint32_t bufLeft = 0;
uint32_t bufIncrement = 0;
- collator_sort_key_index_t* sortKeyIndxBuf = NULL; // buffer to store 'indexes' which will be passed to 'qsort'
+ collator_sort_key_index_t* sortKeyIndxBuf = NULL; /* buffer to store 'indexes' which will be passed to 'qsort' */
uint32_t sortKeyIndxBufSize = DEF_SORT_KEYS_INDX_BUF_SIZE;
uint32_t sortKeyIndxSize = sizeof( collator_sort_key_index_t );
uint32_t sortKeyCount = 0;
uint32_t j = 0;
- UChar* utf16_buf = NULL; // tmp buffer to hold current processing string in utf-16
- int utf16_buf_size = DEF_UTF16_BUF_SIZE; // the length of utf16_buf
- int utf16_len = 0; // length of converted string
+ UChar* utf16_buf = NULL; /* tmp buffer to hold current processing string in utf-16 */
+ int utf16_buf_size = DEF_UTF16_BUF_SIZE; /* the length of utf16_buf */
+ int utf16_len = 0; /* length of converted string */
HashTable* sortedHash = NULL;
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa",
&object, Collator_ce_ptr, &array ) == FAILURE )
{
@@ -383,7 +384,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
@@ -395,20 +396,20 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
if( !hash || zend_hash_num_elements( hash ) == 0 )
RETURN_TRUE;
- // Create bufers
+ /* Create bufers */
sortKeyBuf = ecalloc( sortKeyBufSize, sizeof( char ) );
sortKeyIndxBuf = ecalloc( sortKeyIndxBufSize, sizeof( uint8_t ) );
utf16_buf = eumalloc( utf16_buf_size );
- // Iterate through input hash and create a sort key for each value.
+ /* Iterate through input hash and create a sort key for each value. */
zend_hash_internal_pointer_reset( hash );
while( zend_hash_get_current_data( hash, (void**) &hashData ) == SUCCESS )
{
- // Convert current hash item from UTF-8 to UTF-16LE and save the result to utf16_buf.
+ /* Convert current hash item from UTF-8 to UTF-16LE and save the result to utf16_buf. */
utf16_len = utf16_buf_size;
- // Process string values only.
+ /* Process string values only. */
if( Z_TYPE_PP( hashData ) == IS_STRING )
{
intl_convert_utf8_to_utf16( &utf16_buf, &utf16_len, Z_STRVAL_PP( hashData ), Z_STRLEN_PP( hashData ), COLLATOR_ERROR_CODE_P( co ) );
@@ -429,7 +430,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
}
else
{
- // Set empty string
+ /* Set empty string */
utf16_len = 0;
utf16_buf[utf16_len] = 0;
}
@@ -437,7 +438,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
if( (utf16_len + 1) > utf16_buf_size )
utf16_buf_size = utf16_len + 1;
- // Get sort key, reallocating the buffer if needed.
+ /* Get sort key, reallocating the buffer if needed. */
bufLeft = sortKeyBufSize - sortKeyBufOffset;
sortKeyLen = ucol_getSortKey( co->ucoll,
@@ -446,7 +447,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
(uint8_t*)sortKeyBuf + sortKeyBufOffset,
bufLeft );
- // check for sortKeyBuf overflow, increasing its size of the buffer if needed
+ /* check for sortKeyBuf overflow, increasing its size of the buffer if needed */
if( sortKeyLen > bufLeft )
{
bufIncrement = ( sortKeyLen > DEF_SORT_KEYS_BUF_INCREMENT ) ? sortKeyLen : DEF_SORT_KEYS_BUF_INCREMENT;
@@ -459,7 +460,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
sortKeyLen = ucol_getSortKey( co->ucoll, utf16_buf, utf16_len, (uint8_t*)sortKeyBuf + sortKeyBufOffset, bufLeft );
}
- // check sortKeyIndxBuf overflow, increasing its size of the buffer if needed
+ /* check sortKeyIndxBuf overflow, increasing its size of the buffer if needed */
if( ( sortKeyCount + 1 ) * sortKeyIndxSize > sortKeyIndxBufSize )
{
bufIncrement = ( sortKeyIndxSize > DEF_SORT_KEYS_INDX_BUF_INCREMENT ) ? sortKeyIndxSize : DEF_SORT_KEYS_INDX_BUF_INCREMENT;
@@ -469,8 +470,8 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
sortKeyIndxBuf = erealloc( sortKeyIndxBuf, sortKeyIndxBufSize );
}
- sortKeyIndxBuf[sortKeyCount].key = (char*)sortKeyBufOffset; // remeber just offset, cause address
- // of 'sortKeyBuf' may be changed due to realloc.
+ sortKeyIndxBuf[sortKeyCount].key = (char*)sortKeyBufOffset; /* remeber just offset, cause address */
+ /* of 'sortKeyBuf' may be changed due to realloc. */
sortKeyIndxBuf[sortKeyCount].zstr = hashData;
sortKeyBufOffset += sortKeyLen;
@@ -479,14 +480,14 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
zend_hash_move_forward( hash );
}
- // update ptrs to point to valid keys.
+ /* update ptrs to point to valid keys. */
for( j = 0; j < sortKeyCount; j++ )
sortKeyIndxBuf[j].key = sortKeyBuf + (ptrdiff_t)sortKeyIndxBuf[j].key;
- // sort it
+ /* sort it */
zend_qsort( sortKeyIndxBuf, sortKeyCount, sortKeyIndxSize, collator_cmp_sort_keys TSRMLS_CC );
- // for resulting hash we'll assign new hash keys rather then reordering
+ /* for resulting hash we'll assign new hash keys rather then reordering */
ALLOC_HASHTABLE( sortedHash );
zend_hash_init( sortedHash, 0, NULL, ZVAL_PTR_DTOR, 0 );
@@ -496,7 +497,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
zend_hash_next_index_insert( sortedHash, sortKeyIndxBuf[j].zstr, sizeof(zval **), NULL );
}
- // Save sorted hash into return variable.
+ /* Save sorted hash into return variable. */
zval_dtor( array );
(array)->value.ht = sortedHash;
(array)->type = IS_ARRAY;