@@ -71,12 +71,13 @@ PHP_MINFO_FUNCTION(php_gettext)
71
71
/* {{{ Set the textdomain to "domain". Returns the current domain */
72
72
PHP_FUNCTION (textdomain )
73
73
{
74
- char * domain_name = NULL , * retval ;
74
+ char * retval = NULL , * domain_name = NULL ;
75
75
zend_string * domain = NULL ;
76
76
77
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "S!" , & domain ) == FAILURE ) {
78
- RETURN_THROWS ();
79
- }
77
+ ZEND_PARSE_PARAMETERS_START (0 , 1 )
78
+ Z_PARAM_OPTIONAL
79
+ Z_PARAM_STR_OR_NULL (domain )
80
+ ZEND_PARSE_PARAMETERS_END ();
80
81
81
82
if (domain != NULL && ZSTR_LEN (domain ) != 0 && !zend_string_equals_literal (domain , "0" )) {
82
83
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN (domain ))
@@ -92,7 +93,7 @@ PHP_FUNCTION(textdomain)
92
93
/* {{{ Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */
93
94
PHP_FUNCTION (gettext )
94
95
{
95
- char * msgstr ;
96
+ char * msgstr = NULL ;
96
97
zend_string * msgid ;
97
98
98
99
ZEND_PARSE_PARAMETERS_START (1 , 1 )
@@ -113,12 +114,13 @@ PHP_FUNCTION(gettext)
113
114
/* {{{ Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist */
114
115
PHP_FUNCTION (dgettext )
115
116
{
116
- char * msgstr ;
117
+ char * msgstr = NULL ;
117
118
zend_string * domain , * msgid ;
118
119
119
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "SS" , & domain , & msgid ) == FAILURE ) {
120
- RETURN_THROWS ();
121
- }
120
+ ZEND_PARSE_PARAMETERS_START (2 , 2 )
121
+ Z_PARAM_STR (domain )
122
+ Z_PARAM_STR (msgid )
123
+ ZEND_PARSE_PARAMETERS_END ();
122
124
123
125
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN (domain ))
124
126
PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN (msgid ))
@@ -136,13 +138,15 @@ PHP_FUNCTION(dgettext)
136
138
/* {{{ Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist */
137
139
PHP_FUNCTION (dcgettext )
138
140
{
139
- char * msgstr ;
141
+ char * msgstr = NULL ;
140
142
zend_string * domain , * msgid ;
141
143
zend_long category ;
142
144
143
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "SSl" , & domain , & msgid , & category ) == FAILURE ) {
144
- RETURN_THROWS ();
145
- }
145
+ ZEND_PARSE_PARAMETERS_START (3 , 3 )
146
+ Z_PARAM_STR (domain )
147
+ Z_PARAM_STR (msgid )
148
+ Z_PARAM_LONG (category )
149
+ ZEND_PARSE_PARAMETERS_END ();
146
150
147
151
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN (domain ))
148
152
PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN (msgid ))
@@ -160,24 +164,24 @@ PHP_FUNCTION(dcgettext)
160
164
/* {{{ Bind to the text domain domain_name, looking for translations in dir. Returns the current domain */
161
165
PHP_FUNCTION (bindtextdomain )
162
166
{
163
- char * domain ;
164
- size_t domain_len ;
165
- zend_string * dir = NULL ;
167
+ zend_string * domain , * dir = NULL ;
166
168
char * retval , dir_name [MAXPATHLEN ];
167
169
168
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sS!" , & domain , & domain_len , & dir ) == FAILURE ) {
169
- RETURN_THROWS ();
170
- }
170
+ ZEND_PARSE_PARAMETERS_START (1 , 2 )
171
+ Z_PARAM_STR (domain )
172
+ Z_PARAM_OPTIONAL
173
+ Z_PARAM_STR_OR_NULL (dir )
174
+ ZEND_PARSE_PARAMETERS_END ();
171
175
172
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
176
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
173
177
174
- if (!domain_len ) {
178
+ if (!ZSTR_LEN ( domain ) ) {
175
179
zend_argument_value_error (1 , "cannot be empty" );
176
180
RETURN_THROWS ();
177
181
}
178
182
179
183
if (dir == NULL ) {
180
- RETURN_STRING (bindtextdomain (domain , NULL ));
184
+ RETURN_STRING (bindtextdomain (ZSTR_VAL ( domain ) , NULL ));
181
185
}
182
186
183
187
if (ZSTR_LEN (dir ) != 0 && !zend_string_equals_literal (dir , "0" )) {
@@ -188,7 +192,7 @@ PHP_FUNCTION(bindtextdomain)
188
192
RETURN_FALSE ;
189
193
}
190
194
191
- retval = bindtextdomain (domain , dir_name );
195
+ retval = bindtextdomain (ZSTR_VAL ( domain ) , dir_name );
192
196
193
197
RETURN_STRING (retval );
194
198
}
@@ -198,18 +202,20 @@ PHP_FUNCTION(bindtextdomain)
198
202
/* {{{ Plural version of gettext() */
199
203
PHP_FUNCTION (ngettext )
200
204
{
201
- char * msgid1 , * msgid2 , * msgstr ;
202
- size_t msgid1_len , msgid2_len ;
205
+ char * msgstr = NULL ;
206
+ zend_string * msgid1 , * msgid2 ;
203
207
zend_long count ;
204
208
205
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "ssl" , & msgid1 , & msgid1_len , & msgid2 , & msgid2_len , & count ) == FAILURE ) {
206
- RETURN_THROWS ();
207
- }
209
+ ZEND_PARSE_PARAMETERS_START (3 , 3 )
210
+ Z_PARAM_STR (msgid1 )
211
+ Z_PARAM_STR (msgid2 )
212
+ Z_PARAM_LONG (count )
213
+ ZEND_PARSE_PARAMETERS_END ();
208
214
209
- PHP_GETTEXT_LENGTH_CHECK (1 , msgid1_len )
210
- PHP_GETTEXT_LENGTH_CHECK (2 , msgid2_len )
215
+ PHP_GETTEXT_LENGTH_CHECK (1 , ZSTR_LEN ( msgid1 ) )
216
+ PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN ( msgid2 ) )
211
217
212
- msgstr = ngettext (msgid1 , msgid2 , count );
218
+ msgstr = ngettext (ZSTR_VAL ( msgid1 ), ZSTR_VAL ( msgid2 ) , count );
213
219
214
220
ZEND_ASSERT (msgstr );
215
221
RETURN_STRING (msgstr );
@@ -221,20 +227,22 @@ PHP_FUNCTION(ngettext)
221
227
/* {{{ Plural version of dgettext() */
222
228
PHP_FUNCTION (dngettext )
223
229
{
224
- char * domain , * msgid1 , * msgid2 , * msgstr = NULL ;
225
- size_t domain_len , msgid1_len , msgid2_len ;
230
+ char * msgstr = NULL ;
231
+ zend_string * domain , * msgid1 , * msgid2 ;
226
232
zend_long count ;
227
233
228
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sssl" , & domain , & domain_len ,
229
- & msgid1 , & msgid1_len , & msgid2 , & msgid2_len , & count ) == FAILURE ) {
230
- RETURN_THROWS ();
231
- }
234
+ ZEND_PARSE_PARAMETERS_START (4 , 4 )
235
+ Z_PARAM_STR (domain )
236
+ Z_PARAM_STR (msgid1 )
237
+ Z_PARAM_STR (msgid2 )
238
+ Z_PARAM_LONG (count )
239
+ ZEND_PARSE_PARAMETERS_END ();
232
240
233
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
234
- PHP_GETTEXT_LENGTH_CHECK (2 , msgid1_len )
235
- PHP_GETTEXT_LENGTH_CHECK (3 , msgid2_len )
241
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
242
+ PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN ( msgid1 ) )
243
+ PHP_GETTEXT_LENGTH_CHECK (3 , ZSTR_LEN ( msgid2 ) )
236
244
237
- msgstr = dngettext (domain , msgid1 , msgid2 , count );
245
+ msgstr = dngettext (ZSTR_VAL ( domain ), ZSTR_VAL ( msgid1 ), ZSTR_VAL ( msgid2 ) , count );
238
246
239
247
ZEND_ASSERT (msgstr );
240
248
RETURN_STRING (msgstr );
@@ -246,22 +254,25 @@ PHP_FUNCTION(dngettext)
246
254
/* {{{ Plural version of dcgettext() */
247
255
PHP_FUNCTION (dcngettext )
248
256
{
249
- char * domain , * msgid1 , * msgid2 , * msgstr = NULL ;
250
- size_t domain_len , msgid1_len , msgid2_len ;
257
+ char * msgstr = NULL ;
258
+ zend_string * domain , * msgid1 , * msgid2 ;
251
259
zend_long count , category ;
252
260
253
261
RETVAL_FALSE ;
254
262
255
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sssll" , & domain , & domain_len ,
256
- & msgid1 , & msgid1_len , & msgid2 , & msgid2_len , & count , & category ) == FAILURE ) {
257
- RETURN_THROWS ();
258
- }
263
+ ZEND_PARSE_PARAMETERS_START (5 , 5 )
264
+ Z_PARAM_STR (domain )
265
+ Z_PARAM_STR (msgid1 )
266
+ Z_PARAM_STR (msgid2 )
267
+ Z_PARAM_LONG (count )
268
+ Z_PARAM_LONG (category )
269
+ ZEND_PARSE_PARAMETERS_END ();
259
270
260
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
261
- PHP_GETTEXT_LENGTH_CHECK (2 , msgid1_len )
262
- PHP_GETTEXT_LENGTH_CHECK (3 , msgid2_len )
271
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
272
+ PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN ( msgid1 ) )
273
+ PHP_GETTEXT_LENGTH_CHECK (3 , ZSTR_LEN ( msgid2 ) )
263
274
264
- msgstr = dcngettext (domain , msgid1 , msgid2 , count , category );
275
+ msgstr = dcngettext (ZSTR_VAL ( domain ), ZSTR_VAL ( msgid1 ), ZSTR_VAL ( msgid2 ) , count , category );
265
276
266
277
ZEND_ASSERT (msgstr );
267
278
RETURN_STRING (msgstr );
@@ -274,21 +285,23 @@ PHP_FUNCTION(dcngettext)
274
285
/* {{{ Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. */
275
286
PHP_FUNCTION (bind_textdomain_codeset )
276
287
{
277
- char * domain , * codeset = NULL , * retval = NULL ;
278
- size_t domain_len , codeset_len ;
288
+ char * retval = NULL ;
289
+ zend_string * domain , * codeset = NULL ;
279
290
280
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "ss!" , & domain , & domain_len , & codeset , & codeset_len ) == FAILURE ) {
281
- RETURN_THROWS ();
282
- }
291
+ ZEND_PARSE_PARAMETERS_START (1 , 2 )
292
+ Z_PARAM_STR (domain )
293
+ Z_PARAM_OPTIONAL
294
+ Z_PARAM_STR_OR_NULL (codeset )
295
+ ZEND_PARSE_PARAMETERS_END ();
283
296
284
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
297
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
285
298
286
- if (!domain_len ) {
299
+ if (!ZSTR_LEN ( domain ) ) {
287
300
zend_argument_value_error (1 , "cannot be empty" );
288
301
RETURN_THROWS ();
289
302
}
290
303
291
- retval = bind_textdomain_codeset (domain , codeset );
304
+ retval = bind_textdomain_codeset (ZSTR_VAL ( domain ) , codeset ? ZSTR_VAL ( codeset ) : NULL );
292
305
293
306
if (!retval ) {
294
307
RETURN_FALSE ;
0 commit comments