Skip to content

Commit a23f08a

Browse files
committed
Use new param API in standard
1 parent 331dcf0 commit a23f08a

File tree

9 files changed

+99
-68
lines changed

9 files changed

+99
-68
lines changed

ext/standard/info.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,9 +1267,10 @@ PHP_FUNCTION(phpinfo)
12671267
{
12681268
zend_long flag = PHP_INFO_ALL;
12691269

1270-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
1271-
return;
1272-
}
1270+
ZEND_PARSE_PARAMETERS_START(0, 1)
1271+
Z_PARAM_OPTIONAL
1272+
Z_PARAM_LONG(flag)
1273+
ZEND_PARSE_PARAMETERS_END();
12731274

12741275
/* Andale! Andale! Yee-Hah! */
12751276
php_output_start_default();
@@ -1288,9 +1289,10 @@ PHP_FUNCTION(phpversion)
12881289
char *ext_name = NULL;
12891290
size_t ext_name_len = 0;
12901291

1291-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ext_name, &ext_name_len) == FAILURE) {
1292-
return;
1293-
}
1292+
ZEND_PARSE_PARAMETERS_START(0, 1)
1293+
Z_PARAM_OPTIONAL
1294+
Z_PARAM_STRING(ext_name, ext_name_len)
1295+
ZEND_PARSE_PARAMETERS_END();
12941296

12951297
if (!ext_name) {
12961298
RETURN_STRING(PHP_VERSION);
@@ -1311,9 +1313,10 @@ PHP_FUNCTION(phpcredits)
13111313
{
13121314
zend_long flag = PHP_CREDITS_ALL;
13131315

1314-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
1315-
return;
1316-
}
1316+
ZEND_PARSE_PARAMETERS_START(0, 1)
1317+
Z_PARAM_OPTIONAL
1318+
Z_PARAM_LONG(flag)
1319+
ZEND_PARSE_PARAMETERS_END();
13171320

13181321
php_print_credits((int)flag);
13191322
RETURN_TRUE;
@@ -1344,9 +1347,11 @@ PHP_FUNCTION(php_uname)
13441347
char *mode = "a";
13451348
size_t modelen = sizeof("a")-1;
13461349

1347-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &mode, &modelen) == FAILURE) {
1348-
return;
1349-
}
1350+
ZEND_PARSE_PARAMETERS_START(0, 1)
1351+
Z_PARAM_OPTIONAL
1352+
Z_PARAM_STRING(mode, modelen)
1353+
ZEND_PARSE_PARAMETERS_END();
1354+
13501355
RETURN_STR(php_get_uname(*mode));
13511356
}
13521357

ext/standard/iptc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,12 @@ PHP_FUNCTION(iptcembed)
197197
zend_stat_t sb;
198198
zend_bool written = 0;
199199

200-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sp|l", &iptcdata, &iptcdata_len, &jpeg_file, &jpeg_file_len, &spool) != SUCCESS) {
201-
return;
202-
}
200+
ZEND_PARSE_PARAMETERS_START(2, 3)
201+
Z_PARAM_STRING(iptcdata, iptcdata_len)
202+
Z_PARAM_PATH(jpeg_file, jpeg_file_len)
203+
Z_PARAM_OPTIONAL
204+
Z_PARAM_LONG(spool)
205+
ZEND_PARSE_PARAMETERS_END();
203206

204207
if (php_check_open_basedir(jpeg_file)) {
205208
RETURN_FALSE;
@@ -321,9 +324,9 @@ PHP_FUNCTION(iptcparse)
321324
size_t str_len;
322325
zval values, *element;
323326

324-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) != SUCCESS) {
325-
return;
326-
}
327+
ZEND_PARSE_PARAMETERS_START(1, 1)
328+
Z_PARAM_STRING(str, str_len)
329+
ZEND_PARSE_PARAMETERS_END();
327330

328331
buffer = (unsigned char *)str;
329332

ext/standard/link.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ PHP_FUNCTION(readlink)
5959
char buff[MAXPATHLEN];
6060
int ret;
6161

62-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) {
63-
return;
64-
}
62+
ZEND_PARSE_PARAMETERS_START(1, 1)
63+
Z_PARAM_PATH(link, link_len)
64+
ZEND_PARSE_PARAMETERS_END();
6565

6666
if (php_check_open_basedir(link)) {
6767
RETURN_FALSE;
@@ -90,9 +90,9 @@ PHP_FUNCTION(linkinfo)
9090
zend_stat_t sb;
9191
int ret;
9292

93-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) {
94-
return;
95-
}
93+
ZEND_PARSE_PARAMETERS_START(1, 1)
94+
Z_PARAM_PATH(link, link_len)
95+
ZEND_PARSE_PARAMETERS_END();
9696

9797
dirname = estrndup(link, link_len);
9898
php_dirname(dirname, link_len);
@@ -126,9 +126,10 @@ PHP_FUNCTION(symlink)
126126
char dirname[MAXPATHLEN];
127127
size_t len;
128128

129-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
130-
return;
131-
}
129+
ZEND_PARSE_PARAMETERS_START(2, 2)
130+
Z_PARAM_PATH(topath, topath_len)
131+
Z_PARAM_PATH(frompath, frompath_len)
132+
ZEND_PARSE_PARAMETERS_END();
132133

133134
if (!expand_filepath(frompath, source_p)) {
134135
php_error_docref(NULL, E_WARNING, "No such file or directory");
@@ -182,9 +183,10 @@ PHP_FUNCTION(link)
182183
char source_p[MAXPATHLEN];
183184
char dest_p[MAXPATHLEN];
184185

185-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &topath, &topath_len, &frompath, &frompath_len) == FAILURE) {
186-
return;
187-
}
186+
ZEND_PARSE_PARAMETERS_START(2, 2)
187+
Z_PARAM_PATH(topath, topath_len)
188+
Z_PARAM_PATH(frompath, frompath_len)
189+
ZEND_PARSE_PARAMETERS_END();
188190

189191
if (!expand_filepath(frompath, source_p) || !expand_filepath(topath, dest_p)) {
190192
php_error_docref(NULL, E_WARNING, "No such file or directory");

ext/standard/mail.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ PHP_FUNCTION(ezmlm_hash)
7878
unsigned int h = 5381;
7979
size_t j, str_len;
8080

81-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) == FAILURE) {
82-
return;
83-
}
81+
ZEND_PARSE_PARAMETERS_START(1, 1)
82+
Z_PARAM_STRING(str, str_len)
83+
ZEND_PARSE_PARAMETERS_END();
8484

8585
for (j = 0; j < str_len; j++) {
8686
h = (h + (h << 5)) ^ (zend_ulong) (unsigned char) tolower(str[j]);
@@ -295,9 +295,14 @@ PHP_FUNCTION(mail)
295295
char *to_r, *subject_r;
296296
char *p, *e;
297297

298-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|zS", &to, &to_len, &subject, &subject_len, &message, &message_len, &headers, &extra_cmd) == FAILURE) {
299-
return;
300-
}
298+
ZEND_PARSE_PARAMETERS_START(3, 5)
299+
Z_PARAM_STRING(to, to_len)
300+
Z_PARAM_STRING(subject, subject_len)
301+
Z_PARAM_STRING(message, message_len)
302+
Z_PARAM_OPTIONAL
303+
Z_PARAM_ZVAL_DEREF(headers)
304+
Z_PARAM_STR(extra_cmd)
305+
ZEND_PARSE_PARAMETERS_END();
301306

302307
/* ASCIIZ check */
303308
MAIL_ASCIIZ_CHECK(to, to_len);

ext/standard/mt_rand.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ PHP_FUNCTION(mt_srand)
191191
zend_long seed = 0;
192192
zend_long mode = MT_RAND_MT19937;
193193

194-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &seed, &mode) == FAILURE)
195-
return;
194+
ZEND_PARSE_PARAMETERS_START(0, 2)
195+
Z_PARAM_OPTIONAL
196+
Z_PARAM_LONG(seed)
197+
Z_PARAM_LONG(mode)
198+
ZEND_PARSE_PARAMETERS_END();
196199

197200
if (ZEND_NUM_ARGS() == 0)
198201
seed = GENERATE_SEED();
@@ -288,9 +291,10 @@ PHP_FUNCTION(mt_rand)
288291
RETURN_LONG(php_mt_rand() >> 1);
289292
}
290293

291-
if (zend_parse_parameters(argc, "ll", &min, &max) == FAILURE) {
292-
return;
293-
}
294+
ZEND_PARSE_PARAMETERS_START(2, 2)
295+
Z_PARAM_LONG(min)
296+
Z_PARAM_LONG(max)
297+
ZEND_PARSE_PARAMETERS_END();
294298

295299
if (UNEXPECTED(max < min)) {
296300
php_error_docref(NULL, E_WARNING, "max(" ZEND_LONG_FMT ") is smaller than min(" ZEND_LONG_FMT ")", max, min);

ext/standard/pack.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ PHP_FUNCTION(pack)
116116
int outputpos = 0, outputsize = 0;
117117
zend_string *output;
118118

119-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s*", &format, &formatlen, &argv, &num_args) == FAILURE) {
120-
return;
121-
}
119+
ZEND_PARSE_PARAMETERS_START(1, -1)
120+
Z_PARAM_STRING(format, formatlen)
121+
Z_PARAM_VARIADIC('*', argv, num_args)
122+
ZEND_PARSE_PARAMETERS_END();
122123

123124
/* We have a maximum of <formatlen> format codes to deal with */
124125
formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
@@ -547,10 +548,12 @@ PHP_FUNCTION(unpack)
547548
int i;
548549
zend_long offset = 0;
549550

550-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &formatarg,
551-
&inputarg, &offset) == FAILURE) {
552-
return;
553-
}
551+
ZEND_PARSE_PARAMETERS_START(2, 3)
552+
Z_PARAM_STR(formatarg)
553+
Z_PARAM_STR(inputarg)
554+
Z_PARAM_OPTIONAL
555+
Z_PARAM_LONG(offset)
556+
ZEND_PARSE_PARAMETERS_END();
554557

555558
format = ZSTR_VAL(formatarg);
556559
formatlen = ZSTR_LEN(formatarg);

ext/standard/password.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ PHP_FUNCTION(password_get_info)
173173
char *hash, *algo_name;
174174
zval options;
175175

176-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hash, &hash_len) == FAILURE) {
177-
return;
178-
}
176+
ZEND_PARSE_PARAMETERS_START(1, 1)
177+
Z_PARAM_STRING(hash, hash_len)
178+
ZEND_PARSE_PARAMETERS_END();
179179

180180
array_init(&options);
181181

@@ -229,9 +229,12 @@ PHP_FUNCTION(password_needs_rehash)
229229
HashTable *options = 0;
230230
zval *option_buffer;
231231

232-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|H", &hash, &hash_len, &new_algo, &options) == FAILURE) {
233-
return;
234-
}
232+
ZEND_PARSE_PARAMETERS_START(2, 3)
233+
Z_PARAM_STRING(hash, hash_len)
234+
Z_PARAM_LONG(new_algo)
235+
Z_PARAM_OPTIONAL
236+
Z_PARAM_ARRAY_OR_OBJECT_HT(options)
237+
ZEND_PARSE_PARAMETERS_END();
235238

236239
algo = php_password_determine_algo(hash, (size_t) hash_len);
237240

@@ -300,9 +303,10 @@ PHP_FUNCTION(password_verify)
300303
zend_string *ret;
301304
php_password_algo algo;
302305

303-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &password, &password_len, &hash, &hash_len) == FAILURE) {
304-
RETURN_FALSE;
305-
}
306+
ZEND_PARSE_PARAMETERS_START(2, 2)
307+
Z_PARAM_STRING(password, password_len)
308+
Z_PARAM_STRING(hash, hash_len)
309+
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
306310

307311
algo = php_password_determine_algo(hash, (size_t) hash_len);
308312

@@ -372,9 +376,12 @@ PHP_FUNCTION(password_hash)
372376
argon2_type type = Argon2_i;
373377
#endif
374378

375-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sl|H", &password, &password_len, &algo, &options) == FAILURE) {
376-
return;
377-
}
379+
ZEND_PARSE_PARAMETERS_START(2, 3)
380+
Z_PARAM_STRING(password, password_len)
381+
Z_PARAM_LONG(algo)
382+
Z_PARAM_OPTIONAL
383+
Z_PARAM_ARRAY_OR_OBJECT_HT(options)
384+
ZEND_PARSE_PARAMETERS_END();
378385

379386
switch (algo) {
380387
case PHP_PASSWORD_BCRYPT:

ext/standard/string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4981,7 +4981,7 @@ PHP_FUNCTION(str_repeat)
49814981

49824982
ZEND_PARSE_PARAMETERS_START(2, 2)
49834983
Z_PARAM_STR(input_str)
4984-
Z_PARMA_LONG(mult)
4984+
Z_PARAM_LONG(mult)
49854985
ZEND_PARSE_PARAMETERS_END();
49864986

49874987
if (mult < 0) {
@@ -5038,7 +5038,7 @@ PHP_FUNCTION(count_chars)
50385038
ZEND_PARSE_PARAMETERS_START(1, 2)
50395039
Z_PARAM_STR(input)
50405040
Z_PARAM_OPTIONAL
5041-
Z_PARMA_LONG(mymode)
5041+
Z_PARAM_LONG(mymode)
50425042
ZEND_PARSE_PARAMETERS_END();
50435043

50445044
if (mymode < 0 || mymode > 4) {

ext/standard/uuencode.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ PHP_FUNCTION(convert_uuencode)
204204
{
205205
zend_string *src;
206206

207-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) {
208-
RETURN_FALSE;
209-
}
207+
ZEND_PARSE_PARAMETERS_START(1, 1)
208+
Z_PARAM_STR(src)
209+
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
210+
if (ZSTR_LEN(src) < 1) { RETURN_FALSE; }
210211

211212
RETURN_STR(php_uuencode(ZSTR_VAL(src), ZSTR_LEN(src)));
212213
}
@@ -219,9 +220,10 @@ PHP_FUNCTION(convert_uudecode)
219220
zend_string *src;
220221
zend_string *dest;
221222

222-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) {
223-
RETURN_FALSE;
224-
}
223+
ZEND_PARSE_PARAMETERS_START(1, 1)
224+
Z_PARAM_STR(src)
225+
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
226+
if (ZSTR_LEN(src) < 1) { RETURN_FALSE; }
225227

226228
if ((dest = php_uudecode(ZSTR_VAL(src), ZSTR_LEN(src))) == NULL) {
227229
php_error_docref(NULL, E_WARNING, "The given parameter is not a valid uuencoded string");

0 commit comments

Comments
 (0)