Annotation of embedaddon/php/ext/intl/collator/collator_create.c, revision 1.1.1.2
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | PHP Version 5 |
4: +----------------------------------------------------------------------+
5: | This source file is subject to version 3.01 of the PHP license, |
6: | that is bundled with this package in the file LICENSE, and is |
7: | available through the world-wide-web at the following url: |
8: | http://www.php.net/license/3_01.txt |
9: | If you did not receive a copy of the PHP license and are unable to |
10: | obtain it through the world-wide-web, please send a note to |
11: | license@php.net so we can mail you a copy immediately. |
12: +----------------------------------------------------------------------+
13: | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
14: | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
15: +----------------------------------------------------------------------+
16: */
17:
18: #ifdef HAVE_CONFIG_H
19: #include "config.h"
20: #endif
21:
22: #include "php_intl.h"
23: #include "collator_class.h"
24: #include "collator_create.h"
25: #include "intl_data.h"
26:
27: /* {{{ */
28: static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
29: {
30: char* locale;
31: int locale_len = 0;
32: zval* object;
33: Collator_object* co;
34:
35: intl_error_reset( NULL TSRMLS_CC );
36: object = return_value;
37: /* Parse parameters. */
38: if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
39: &locale, &locale_len ) == FAILURE )
40: {
41: intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
42: "collator_create: unable to parse input params", 0 TSRMLS_CC );
43: zval_dtor(return_value);
44: RETURN_NULL();
45: }
46:
47: INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
1.1.1.2 ! misho 48: COLLATOR_METHOD_FETCH_OBJECT;
1.1 misho 49:
50: if(locale_len == 0) {
51: locale = INTL_G(default_locale);
52: }
53:
54: /* Open ICU collator. */
55: co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
56: INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
57: }
58: /* }}} */
59:
60: /* {{{ proto Collator collator_create( string $locale )
61: * Create collator.
62: */
63: PHP_FUNCTION( collator_create )
64: {
65: object_init_ex( return_value, Collator_ce_ptr );
66: collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
67: }
68: /* }}} */
69:
70: /* {{{ proto Collator Collator::__construct( string $locale )
71: * Collator object constructor.
72: */
73: PHP_METHOD( Collator, __construct )
74: {
75: return_value = getThis();
76: collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
77: }
78: /* }}} */
79:
80: /*
81: * Local variables:
82: * tab-width: 4
83: * c-basic-offset: 4
84: * End:
85: * vim600: noet sw=4 ts=4 fdm=marker
86: * vim<600: noet sw=4 ts=4
87: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>