@@ -78,12 +78,13 @@ PHP_MINFO_FUNCTION(php_gettext)
78
78
/* {{{ Set the textdomain to "domain". Returns the current domain */
79
79
PHP_FUNCTION (textdomain )
80
80
{
81
- char * domain_name = NULL , * retval ;
81
+ char * retval = NULL , * domain_name = NULL ;
82
82
zend_string * domain = NULL ;
83
83
84
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "S!" , & domain ) == FAILURE ) {
85
- RETURN_THROWS ();
86
- }
84
+ ZEND_PARSE_PARAMETERS_START (0 , 1 )
85
+ Z_PARAM_OPTIONAL
86
+ Z_PARAM_STR_OR_NULL (domain )
87
+ ZEND_PARSE_PARAMETERS_END ();
87
88
88
89
if (domain != NULL && ZSTR_LEN (domain ) != 0 && !zend_string_equals_literal (domain , "0" )) {
89
90
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN (domain ))
@@ -99,7 +100,7 @@ PHP_FUNCTION(textdomain)
99
100
/* {{{ Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */
100
101
PHP_FUNCTION (gettext )
101
102
{
102
- char * msgstr ;
103
+ char * msgstr = NULL ;
103
104
zend_string * msgid ;
104
105
105
106
ZEND_PARSE_PARAMETERS_START (1 , 1 )
@@ -120,12 +121,13 @@ PHP_FUNCTION(gettext)
120
121
/* {{{ Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist */
121
122
PHP_FUNCTION (dgettext )
122
123
{
123
- char * msgstr ;
124
+ char * msgstr = NULL ;
124
125
zend_string * domain , * msgid ;
125
126
126
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "SS" , & domain , & msgid ) == FAILURE ) {
127
- RETURN_THROWS ();
128
- }
127
+ ZEND_PARSE_PARAMETERS_START (2 , 2 )
128
+ Z_PARAM_STR (domain )
129
+ Z_PARAM_STR (msgid )
130
+ ZEND_PARSE_PARAMETERS_END ();
129
131
130
132
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN (domain ))
131
133
PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN (msgid ))
@@ -143,13 +145,15 @@ PHP_FUNCTION(dgettext)
143
145
/* {{{ Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist */
144
146
PHP_FUNCTION (dcgettext )
145
147
{
146
- char * msgstr ;
148
+ char * msgstr = NULL ;
147
149
zend_string * domain , * msgid ;
148
150
zend_long category ;
149
151
150
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "SSl" , & domain , & msgid , & category ) == FAILURE ) {
151
- RETURN_THROWS ();
152
- }
152
+ ZEND_PARSE_PARAMETERS_START (3 , 3 )
153
+ Z_PARAM_STR (domain )
154
+ Z_PARAM_STR (msgid )
155
+ Z_PARAM_LONG (category )
156
+ ZEND_PARSE_PARAMETERS_END ();
153
157
154
158
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN (domain ))
155
159
PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN (msgid ))
@@ -168,24 +172,24 @@ PHP_FUNCTION(dcgettext)
168
172
/* {{{ Bind to the text domain domain_name, looking for translations in dir. Returns the current domain */
169
173
PHP_FUNCTION (bindtextdomain )
170
174
{
171
- char * domain ;
172
- size_t domain_len ;
173
- zend_string * dir = NULL ;
175
+ zend_string * domain , * dir = NULL ;
174
176
char * retval , dir_name [MAXPATHLEN ];
175
177
176
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sS!" , & domain , & domain_len , & dir ) == FAILURE ) {
177
- RETURN_THROWS ();
178
- }
178
+ ZEND_PARSE_PARAMETERS_START (1 , 2 )
179
+ Z_PARAM_STR (domain )
180
+ Z_PARAM_OPTIONAL
181
+ Z_PARAM_STR_OR_NULL (dir )
182
+ ZEND_PARSE_PARAMETERS_END ();
179
183
180
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
184
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
181
185
182
- if (!domain_len ) {
186
+ if (!ZSTR_LEN ( domain ) ) {
183
187
zend_argument_value_error (1 , "cannot be empty" );
184
188
RETURN_THROWS ();
185
189
}
186
190
187
191
if (dir == NULL ) {
188
- RETURN_STRING (bindtextdomain (domain , NULL ));
192
+ RETURN_STRING (bindtextdomain (ZSTR_VAL ( domain ) , NULL ));
189
193
}
190
194
191
195
if (ZSTR_LEN (dir ) != 0 && !zend_string_equals_literal (dir , "0" )) {
@@ -196,7 +200,7 @@ PHP_FUNCTION(bindtextdomain)
196
200
RETURN_FALSE ;
197
201
}
198
202
199
- retval = bindtextdomain (domain , dir_name );
203
+ retval = bindtextdomain (ZSTR_VAL ( domain ) , dir_name );
200
204
201
205
RETURN_STRING (retval );
202
206
}
@@ -206,18 +210,20 @@ PHP_FUNCTION(bindtextdomain)
206
210
/* {{{ Plural version of gettext() */
207
211
PHP_FUNCTION (ngettext )
208
212
{
209
- char * msgid1 , * msgid2 , * msgstr ;
210
- size_t msgid1_len , msgid2_len ;
213
+ char * msgstr = NULL ;
214
+ zend_string * msgid1 , * msgid2 ;
211
215
zend_long count ;
212
216
213
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "ssl" , & msgid1 , & msgid1_len , & msgid2 , & msgid2_len , & count ) == FAILURE ) {
214
- RETURN_THROWS ();
215
- }
217
+ ZEND_PARSE_PARAMETERS_START (3 , 3 )
218
+ Z_PARAM_STR (msgid1 )
219
+ Z_PARAM_STR (msgid2 )
220
+ Z_PARAM_LONG (count )
221
+ ZEND_PARSE_PARAMETERS_END ();
216
222
217
- PHP_GETTEXT_LENGTH_CHECK (1 , msgid1_len )
218
- PHP_GETTEXT_LENGTH_CHECK (2 , msgid2_len )
223
+ PHP_GETTEXT_LENGTH_CHECK (1 , ZSTR_LEN ( msgid1 ) )
224
+ PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN ( msgid2 ) )
219
225
220
- msgstr = ngettext (msgid1 , msgid2 , count );
226
+ msgstr = ngettext (ZSTR_VAL ( msgid1 ), ZSTR_VAL ( msgid2 ) , count );
221
227
222
228
ZEND_ASSERT (msgstr );
223
229
RETURN_STRING (msgstr );
@@ -229,20 +235,22 @@ PHP_FUNCTION(ngettext)
229
235
/* {{{ Plural version of dgettext() */
230
236
PHP_FUNCTION (dngettext )
231
237
{
232
- char * domain , * msgid1 , * msgid2 , * msgstr = NULL ;
233
- size_t domain_len , msgid1_len , msgid2_len ;
238
+ char * msgstr = NULL ;
239
+ zend_string * domain , * msgid1 , * msgid2 ;
234
240
zend_long count ;
235
241
236
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sssl" , & domain , & domain_len ,
237
- & msgid1 , & msgid1_len , & msgid2 , & msgid2_len , & count ) == FAILURE ) {
238
- RETURN_THROWS ();
239
- }
242
+ ZEND_PARSE_PARAMETERS_START (4 , 4 )
243
+ Z_PARAM_STR (domain )
244
+ Z_PARAM_STR (msgid1 )
245
+ Z_PARAM_STR (msgid2 )
246
+ Z_PARAM_LONG (count )
247
+ ZEND_PARSE_PARAMETERS_END ();
240
248
241
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
242
- PHP_GETTEXT_LENGTH_CHECK (2 , msgid1_len )
243
- PHP_GETTEXT_LENGTH_CHECK (3 , msgid2_len )
249
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
250
+ PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN ( msgid1 ) )
251
+ PHP_GETTEXT_LENGTH_CHECK (3 , ZSTR_LEN ( msgid2 ) )
244
252
245
- msgstr = dngettext (domain , msgid1 , msgid2 , count );
253
+ msgstr = dngettext (ZSTR_VAL ( domain ), ZSTR_VAL ( msgid1 ), ZSTR_VAL ( msgid2 ) , count );
246
254
247
255
ZEND_ASSERT (msgstr );
248
256
RETURN_STRING (msgstr );
@@ -254,23 +262,26 @@ PHP_FUNCTION(dngettext)
254
262
/* {{{ Plural version of dcgettext() */
255
263
PHP_FUNCTION (dcngettext )
256
264
{
257
- char * domain , * msgid1 , * msgid2 , * msgstr = NULL ;
258
- size_t domain_len , msgid1_len , msgid2_len ;
265
+ char * msgstr = NULL ;
266
+ zend_string * domain , * msgid1 , * msgid2 ;
259
267
zend_long count , category ;
260
268
261
269
RETVAL_FALSE ;
262
270
263
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sssll" , & domain , & domain_len ,
264
- & msgid1 , & msgid1_len , & msgid2 , & msgid2_len , & count , & category ) == FAILURE ) {
265
- RETURN_THROWS ();
266
- }
271
+ ZEND_PARSE_PARAMETERS_START (5 , 5 )
272
+ Z_PARAM_STR (domain )
273
+ Z_PARAM_STR (msgid1 )
274
+ Z_PARAM_STR (msgid2 )
275
+ Z_PARAM_LONG (count )
276
+ Z_PARAM_LONG (category )
277
+ ZEND_PARSE_PARAMETERS_END ();
267
278
268
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
269
- PHP_GETTEXT_LENGTH_CHECK (2 , msgid1_len )
270
- PHP_GETTEXT_LENGTH_CHECK (3 , msgid2_len )
279
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
280
+ PHP_GETTEXT_LENGTH_CHECK (2 , ZSTR_LEN ( msgid1 ) )
281
+ PHP_GETTEXT_LENGTH_CHECK (3 , ZSTR_LEN ( msgid2 ) )
271
282
PHP_DCGETTEXT_CATEGORY_CHECK (5 , category )
272
283
273
- msgstr = dcngettext (domain , msgid1 , msgid2 , count , category );
284
+ msgstr = dcngettext (ZSTR_VAL ( domain ), ZSTR_VAL ( msgid1 ), ZSTR_VAL ( msgid2 ) , count , category );
274
285
275
286
ZEND_ASSERT (msgstr );
276
287
RETURN_STRING (msgstr );
@@ -283,21 +294,23 @@ PHP_FUNCTION(dcngettext)
283
294
/* {{{ Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. */
284
295
PHP_FUNCTION (bind_textdomain_codeset )
285
296
{
286
- char * domain , * codeset = NULL , * retval = NULL ;
287
- size_t domain_len , codeset_len ;
297
+ char * retval = NULL ;
298
+ zend_string * domain , * codeset = NULL ;
288
299
289
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "ss!" , & domain , & domain_len , & codeset , & codeset_len ) == FAILURE ) {
290
- RETURN_THROWS ();
291
- }
300
+ ZEND_PARSE_PARAMETERS_START (1 , 2 )
301
+ Z_PARAM_STR (domain )
302
+ Z_PARAM_OPTIONAL
303
+ Z_PARAM_STR_OR_NULL (codeset )
304
+ ZEND_PARSE_PARAMETERS_END ();
292
305
293
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
306
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , ZSTR_LEN ( domain ) )
294
307
295
- if (!domain_len ) {
308
+ if (!ZSTR_LEN ( domain ) ) {
296
309
zend_argument_value_error (1 , "cannot be empty" );
297
310
RETURN_THROWS ();
298
311
}
299
312
300
- retval = bind_textdomain_codeset (domain , codeset );
313
+ retval = bind_textdomain_codeset (ZSTR_VAL ( domain ) , codeset ? ZSTR_VAL ( codeset ) : NULL );
301
314
302
315
if (!retval ) {
303
316
RETURN_FALSE ;
0 commit comments