@@ -32,17 +32,16 @@ static inline RuleBasedBreakIterator *fetch_rbbi(BreakIterator_object *bio) {
32
32
return (RuleBasedBreakIterator*)bio->biter ;
33
33
}
34
34
35
- static void _php_intlrbbi_constructor_body (INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced )
35
+ U_CFUNC PHP_METHOD (IntlRuleBasedBreakIterator, __construct )
36
36
{
37
- char *rules;
38
- size_t rules_len;
39
- bool compiled = false ;
40
- UErrorCode status = U_ZERO_ERROR;
37
+ zend_string *rules;
38
+ bool compiled = false ;
39
+ UErrorCode status = U_ZERO_ERROR;
41
40
BREAKITER_METHOD_INIT_VARS;
42
41
object = ZEND_THIS;
43
42
44
43
ZEND_PARSE_PARAMETERS_START (1 , 2 )
45
- Z_PARAM_STRING (rules, rules_len )
44
+ Z_PARAM_STR (rules)
46
45
Z_PARAM_OPTIONAL
47
46
Z_PARAM_BOOL (compiled)
48
47
ZEND_PARSE_PARAMETERS_END ();
@@ -53,20 +52,14 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend_er
53
52
RETURN_THROWS ();
54
53
}
55
54
56
- zend_replace_error_handling (EH_THROW, IntlException_ce_ptr, error_handling);
57
- *error_handling_replaced = 1 ;
58
-
59
- // instantiation of ICU object
60
55
RuleBasedBreakIterator *rbbi;
61
56
62
57
if (!compiled) {
63
58
UnicodeString rulesStr;
64
59
UParseError parseError = UParseError ();
65
- if (intl_stringFromChar (rulesStr, rules, rules_len, &status)
66
- == FAILURE) {
60
+ if (intl_stringFromChar (rulesStr, ZSTR_VAL (rules), ZSTR_LEN (rules), &status) == FAILURE) {
67
61
zend_throw_exception (IntlException_ce_ptr,
68
- " IntlRuleBasedBreakIterator::__construct(): "
69
- " rules were not a valid UTF-8 string" , 0 );
62
+ " IntlRuleBasedBreakIterator::__construct(): rules were not a valid UTF-8 string" , 0 );
70
63
RETURN_THROWS ();
71
64
}
72
65
@@ -84,29 +77,16 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend_er
84
77
RETURN_THROWS ();
85
78
}
86
79
} else { // compiled
87
- rbbi = new RuleBasedBreakIterator (( uint8_t *) rules, rules_len , status);
80
+ rbbi = new RuleBasedBreakIterator (reinterpret_cast < uint8_t *>( ZSTR_VAL ( rules)), ZSTR_LEN (rules) , status);
88
81
if (U_FAILURE (status)) {
89
82
zend_throw_exception (IntlException_ce_ptr,
90
- " IntlRuleBasedBreakIterator::__construct(): "
91
- " unable to create instance from compiled rules" , 0 );
83
+ " IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules" , 0 );
92
84
delete rbbi;
93
85
RETURN_THROWS ();
94
86
}
95
87
}
96
88
97
- breakiterator_object_create (return_value, rbbi, 0 );
98
- }
99
-
100
- U_CFUNC PHP_METHOD (IntlRuleBasedBreakIterator, __construct)
101
- {
102
- zend_error_handling error_handling;
103
- bool error_handling_replaced = 0 ;
104
-
105
- return_value = ZEND_THIS;
106
- _php_intlrbbi_constructor_body (INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced);
107
- if (error_handling_replaced) {
108
- zend_restore_error_handling (&error_handling);
109
- }
89
+ breakiterator_object_create (object, rbbi, false );
110
90
}
111
91
112
92
U_CFUNC PHP_METHOD (IntlRuleBasedBreakIterator, getRules)
0 commit comments