com php-src: Small cleanup in pack() implementation: ext/standard/pack.c
| From: | Nikita Popov | Date: | Wed, 09 Sep 2015 01:58:37 +0000 |
| Subject: | com php-src: Small cleanup in pack() implementation: ext/standard/pack.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88965@lists.php.net to get a copy of this message | ||
Commit: 7c8798834aefe4d4071eb66020e7dfa47111e343
Author: Nikita Popov <nikic@php.net> Wed, 9 Sep 2015 03:58:37 +0200
Parents: 6886bb688b5d3fffa6059c4d6ea4f27d4565520d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7c8798834aefe4d4071eb66020e7dfa47111e343
Log:
Small cleanup in pack() implementation
Changed paths:
M ext/standard/pack.c
Diff:
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index f46f896..8b41038 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -115,29 +115,21 @@ PHP_FUNCTION(pack)
int num_args, i;
int currentarg;
char *format;
- int formatlen;
+ size_t formatlen;
char *formatcodes;
int *formatargs;
int formatcount = 0;
int outputpos = 0, outputsize = 0;
zend_string *output;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &argv, &num_args) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s+", &format, &formatlen, &argv,
&num_args) == FAILURE) {
return;
}
- if (Z_ISREF(argv[0])) {
- SEPARATE_ZVAL(&argv[0]);
- }
- convert_to_string_ex(&argv[0]);
-
- format = Z_STRVAL(argv[0]);
- formatlen = Z_STRLEN(argv[0]);
-
/* We have a maximum of <formatlen> format codes to deal with */
formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
formatargs = safe_emalloc(formatlen, sizeof(*formatargs), 0);
- currentarg = 1;
+ currentarg = 0;
/* Preprocess format into formatcodes and formatargs */
for (i = 0; i < formatlen; formatcount++) {
@@ -187,10 +179,7 @@ PHP_FUNCTION(pack)
}
if (arg < 0) {
- if (Z_ISREF(argv[currentarg])) {
- SEPARATE_ZVAL(&argv[currentarg]);
- }
- convert_to_string_ex(&argv[currentarg]);
+ convert_to_string(&argv[currentarg]);
arg = Z_STRLEN(argv[currentarg]);
if (code == 'Z') {
/* add one because Z is always NUL-terminated:
@@ -334,7 +323,7 @@ PHP_FUNCTION(pack)
output = zend_string_alloc(outputsize, 0);
outputpos = 0;
- currentarg = 1;
+ currentarg = 0;
/* Do actual packing */
for (i = 0; i < formatcount; i++) {