version 1.1.1.2, 2012/05/29 12:34:43
|
version 1.1.1.4, 2013/10/14 08:02:34
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2013 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 69 char machine_little_endian;
|
Line 69 char machine_little_endian;
|
/* Mapping of byte from char (8bit) to long for machine endian */ |
/* Mapping of byte from char (8bit) to long for machine endian */ |
static int byte_map[1]; |
static int byte_map[1]; |
|
|
/* Mappings of bytes from int (machine dependant) to int for machine endian */ | /* Mappings of bytes from int (machine dependent) to int for machine endian */ |
static int int_map[sizeof(int)]; |
static int int_map[sizeof(int)]; |
|
|
/* Mappings of bytes from shorts (16bit) for all endian environments */ |
/* Mappings of bytes from shorts (16bit) for all endian environments */ |
Line 503 static long php_unpack(char *data, int size, int issig
|
Line 503 static long php_unpack(char *data, int size, int issig
|
|
|
/* unpack() is based on Perl's unpack(), but is modified a bit from there. |
/* unpack() is based on Perl's unpack(), but is modified a bit from there. |
* Rather than depending on error-prone ordered lists or syntactically |
* Rather than depending on error-prone ordered lists or syntactically |
* unpleasant pass-by-reference, we return an object with named paramters | * unpleasant pass-by-reference, we return an object with named parameters |
* (like *_fetch_object()). Syntax is "f[repeat]name/...", where "f" is the |
* (like *_fetch_object()). Syntax is "f[repeat]name/...", where "f" is the |
* formatter char (like pack()), "[repeat]" is the optional repeater argument, |
* formatter char (like pack()), "[repeat]" is the optional repeater argument, |
* and "name" is the name of the variable to use. |
* and "name" is the name of the variable to use. |
Line 758 PHP_FUNCTION(unpack)
|
Line 758 PHP_FUNCTION(unpack)
|
|
|
case 'i': |
case 'i': |
case 'I': { |
case 'I': { |
long v = 0; | long v; |
int issigned = 0; |
int issigned = 0; |
|
|
if (type == 'i') { |
if (type == 'i') { |
issigned = input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)] & 0x80; |
issigned = input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)] & 0x80; |
} else if (sizeof(long) > 4 && (input[inputpos + machine_endian_long_map[3]] & 0x80) == 0x80) { |
|
v = ~INT_MAX; |
|
} |
} |
|
|
v |= php_unpack(&input[inputpos], sizeof(int), issigned, int_map); | v = php_unpack(&input[inputpos], sizeof(int), issigned, int_map); |
add_assoc_long(return_value, n, v); |
add_assoc_long(return_value, n, v); |
break; |
break; |
} |
} |