Skip to content

Commit 2a77e28

Browse files
committed
ext/standard/pack: Inline constant single use variables
They serve no purpose and are just confusing
1 parent dbabbe1 commit 2a77e28

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/standard/pack.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,6 @@ PHP_FUNCTION(unpack)
919919
}
920920
case 'A': {
921921
/* A will strip any trailing whitespace */
922-
char padn = '\0'; char pads = ' '; char padt = '\t'; char padc = '\r'; char padl = '\n';
923922
zend_long len = inputlen - inputpos; /* Remaining string */
924923

925924
/* If size was given take minimum of len and size */
@@ -931,11 +930,11 @@ PHP_FUNCTION(unpack)
931930

932931
/* Remove trailing white space and nulls chars from unpacked data */
933932
while (--len >= 0) {
934-
if (input[inputpos + len] != padn
935-
&& input[inputpos + len] != pads
936-
&& input[inputpos + len] != padt
937-
&& input[inputpos + len] != padc
938-
&& input[inputpos + len] != padl
933+
if (input[inputpos + len] != '\0'
934+
&& input[inputpos + len] != ' '
935+
&& input[inputpos + len] != '\t'
936+
&& input[inputpos + len] != '\r'
937+
&& input[inputpos + len] != '\n'
939938
)
940939
break;
941940
}
@@ -946,7 +945,6 @@ PHP_FUNCTION(unpack)
946945
/* New option added for Z to remain in-line with the Perl implementation */
947946
case 'Z': {
948947
/* Z will strip everything after the first null character */
949-
char pad = '\0';
950948
zend_long s,
951949
len = inputlen - inputpos; /* Remaining string */
952950

@@ -959,7 +957,7 @@ PHP_FUNCTION(unpack)
959957

960958
/* Remove everything after the first null */
961959
for (s=0 ; s < len ; s++) {
962-
if (input[inputpos + s] == pad)
960+
if (input[inputpos + s] == '\0')
963961
break;
964962
}
965963
len = s;

0 commit comments

Comments
 (0)