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