[wp-trac] [WordPress Trac] #5872: gettext fails to determine big-endian byteorder on 64bit systems

WordPress Trac wp-trac at lists.automattic.com
Sat Feb 16 03:17:17 GMT 2008


#5872: gettext fails to determine big-endian byteorder on 64bit systems
---------------------+------------------------------------------------------
 Reporter:  tkoenig  |       Owner:  anonymous                        
     Type:  defect   |      Status:  new                              
 Priority:  normal   |   Milestone:  2.3.4                            
Component:  i18n     |     Version:  2.3.3                            
 Severity:  normal   |    Keywords:  gettext byteorder 64bit bigendian
---------------------+------------------------------------------------------
 Replying to comment by nyuwec for #3780
 > So this code in the gettext.php (starting at line 105) works for me on
 both 32 and 64 bit systems:
 for I am generating the .mo-files on my PPC iBook, I end up with big-
 endian .mo-files. They are still not recognized correctly on my 64bit
 hosting platform. Thererfore the provided sourcecode is only half way
 there.

 I suggest adding another 64bit magic number. The following code should
 behave exactly as before except additionally working for big-endian .mo-
 files on 64bit architectures. I tested it and it worked well.

 {{{
                 // Caching can be turned off
                 $this->enable_cache = $enable_cache;

                 // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see
 https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
                 $MAGIC1 = (int) - 1794895138; // which is 0x959412de as
 s_int32 value
                 // $MAGIC2 = (int)0xde120495; //bug
                 $MAGIC2 = (int) - 569244523;  // which is 0xde120495 as
 s_int32 value
                 // 64-bit fix
                 $MAGIC3 = (int) 2500072158; // which is 0x959412de as
 u_int32 value
                 // 64-bit fix
                 $MAGIC4 = (int) 3725722773; // which is 0xde120495 as
 u_int32 value

                 $this->STREAM = $Reader;
                 $magic = $this->readint();
                 if ($magic == $MAGIC1 || $magic == $MAGIC3) { // to make
 sure it works for 64-bit platforms
                         $this->BYTEORDER = 0;
                 } elseif ($magic == $MAGIC2 || $magic == $MAGIC4) {
                         $this->BYTEORDER = 1;
                 } else {
                         $this->error = 1; // not MO file
                         return false;
                 }

 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5872>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list