php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63409
Patch bug38698_add_endian_check.patch revision 2012-11-01 09:06 UTC by tianhonglouis at gmail dot com

Patch bug38698_add_endian_check.patch for Testing related Bug #63409

Patch version 2012-11-01 09:06 UTC

Return to Bug #63409 | Download this patch
Patch Revisions:

Developer: tianhonglouis@gmail.com

--- bug38698.phpt.orig	2012-11-01 17:00:56.590414252 +0800
+++ bug38698.phpt	2012-11-01 17:02:26.902414228 +0800
@@ -8,10 +8,19 @@
 --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));
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 12:01:23 2020 UTC