[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Wed Apr 13 18:27:45 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv24715/java/jsword/org/crosswire/jsword/book/sword

Modified Files:
	SwordUtil.java SwordBookMetaData.java 
Log Message:
Fixed an extraneous diagnostic in GBFFilter. Cleaned up docs in it
Changed Latin1 from IS08859-1 to Windows 1252 because Sword mods use it.
Optimized converting unsigned byte to int in SwordUtil.

Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** SwordBookMetaData.java	21 Mar 2005 02:37:28 -0000	1.40
--- SwordBookMetaData.java	14 Apr 2005 01:27:43 -0000	1.41
***************
*** 250,254 ****
      static
      {
!         ENCODING_JAVA.put("Latin-1", "ISO-8859-1"); //$NON-NLS-1$ //$NON-NLS-2$
          ENCODING_JAVA.put("UTF-8", "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
      }
--- 250,256 ----
      static
      {
!         //ENCODING_JAVA.put("Latin-1", "ISO-8859-1"); //$NON-NLS-1$ //$NON-NLS-2$
!         // Sword uses MS Windows cp1252 for Latin 1 not the standard. Arrgh!
!         ENCODING_JAVA.put("Latin-1", "WINDOWS-1252"); //$NON-NLS-1$ //$NON-NLS-2$
          ENCODING_JAVA.put("UTF-8", "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
      }

Index: SwordUtil.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordUtil.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** SwordUtil.java	16 Aug 2004 22:08:42 -0000	1.16
--- SwordUtil.java	14 Apr 2005 01:27:43 -0000	1.17
***************
*** 81,88 ****
      protected static long decodeLittleEndian32(byte[] data, int offset)
      {
!         long byte1 = SwordUtil.un2complement(data[0 + offset]);
!         long byte2 = SwordUtil.un2complement(data[1 + offset]) << 8;
!         long byte3 = SwordUtil.un2complement(data[2 + offset]) << 16;
!         long byte4 = SwordUtil.un2complement(data[3 + offset]) << 24;
  
          return byte4 | byte3 | byte2 | byte1;
--- 81,94 ----
      protected static long decodeLittleEndian32(byte[] data, int offset)
      {
! //        long byte1 = SwordUtil.un2complement(data[0 + offset]);
! //        long byte2 = SwordUtil.un2complement(data[1 + offset]) << 8;
! //        long byte3 = SwordUtil.un2complement(data[2 + offset]) << 16;
! //        long byte4 = SwordUtil.un2complement(data[3 + offset]) << 24;
!         // Convert from a byte to an int, but prevent sign extension.
!         // So -16 becomes 240
!         long byte1 = data[0 + offset] & 0xFF;
!         long byte2 = (data[1 + offset] & 0xFF) << 8;
!         long byte3 = (data[2 + offset] & 0xFF) << 16;
!         long byte4 = (data[3 + offset] & 0xFF) << 24;
  
          return byte4 | byte3 | byte2 | byte1;
***************
*** 115,120 ****
      protected static int decodeLittleEndian16(byte[] data, int offset)
      {
!         int byte1 = SwordUtil.un2complement(data[0 + offset]);
!         int byte2 = SwordUtil.un2complement(data[1 + offset]) << 8;
  
          return byte2 | byte1;
--- 121,130 ----
      protected static int decodeLittleEndian16(byte[] data, int offset)
      {
! //        int byte1 = SwordUtil.un2complement(data[0 + offset]);
! //        int byte2 = SwordUtil.un2complement(data[1 + offset]) << 8;
!         // Convert from a byte to an int, but prevent sign extension.
!         // So -16 becomes 240
!         int byte1 = data[0 + offset] & 0xFF;
!         int byte2 = (data[1 + offset] & 0xFF) << 8;
  
          return byte2 | byte1;
***************
*** 126,130 ****
      protected static int un2complement(byte data)
      {
!         return data >= 0 ? data : 256 + data;
      }
  
--- 136,140 ----
      protected static int un2complement(byte data)
      {
!         return data & 0xFF; //>= 0 ? data : 256 + data;
      }
  
***************
*** 189,197 ****
          {
              // It is impossible! In case, use system default...
!             log.error("Encoding: " + charset + " not supported", ex); //$NON-NLS-1$ //$NON-NLS-2$
              txt = new String(data);
          }
  
!         return clean(key, txt);
      }
  
--- 199,207 ----
          {
              // It is impossible! In case, use system default...
!             log.error(key + ": Encoding: " + charset + " not supported", ex); //$NON-NLS-1$ //$NON-NLS-2$
              txt = new String(data);
          }
  
!         return txt;
      }
  



More information about the jsword-svn mailing list