]> granicus.if.org Git - php/commitdiff
- Fixed bug #63409 (php-dba function test fails on big-endian machine) patch by:...
authorFelipe Pena <felipensp@gmail.com>
Wed, 26 Jun 2013 16:50:37 +0000 (13:50 -0300)
committerFelipe Pena <felipensp@gmail.com>
Wed, 26 Jun 2013 16:50:37 +0000 (13:50 -0300)
ext/dba/tests/bug38698.phpt

index 56dde852688d0ef31d544fdb716093276e3deff2..1d1ed674fef141fc363a125db2adfe2304a8a87b 100644 (file)
@@ -8,10 +8,18 @@ Bug #38698 (Bug #38698 for some keys cdbmake creates corrupted db and cdb can't
 --FILE--
 <?php
 
+function isLittleEndian() {
+    return 0x00FF === current(unpack('v', pack('S',0x00FF)));
+}
+
 $db_file = dirname(__FILE__) .'/129php.cdb';
 
 if (($db_make=dba_open($db_file, "n", 'cdb_make'))!==FALSE) {
-       dba_insert(pack('i',129), "Booo!", $db_make);
+       if (isLittleEndian() === FALSE) {
+        dba_insert(pack('V',129), "Booo!", $db_make);
+       } else{
+               dba_insert(pack('i',129), "Booo!", $db_make);
+       }
        dba_close($db_make);
        // write md5 checksum of generated database file
        var_dump(md5_file($db_file));