You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/04/18 06:50:50 UTC

cvs commit: xml-xalan/c/src/PlatformSupport XalanTranscodingServices.cpp XalanTranscodingServices.hpp XalanUTF16Transcoder.cpp

dbertoni    02/04/17 21:50:50

  Modified:    c/src/PlatformSupport XalanTranscodingServices.cpp
                        XalanTranscodingServices.hpp
                        XalanUTF16Transcoder.cpp
  Log:
  Re-wrote code so there is no need to be aware of the endianness of the platform.
  
  Revision  Changes    Path
  1.14      +8 -12     xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.cpp
  
  Index: XalanTranscodingServices.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XalanTranscodingServices.cpp	23 Feb 2002 04:17:46 -0000	1.13
  +++ XalanTranscodingServices.cpp	18 Apr 2002 04:50:50 -0000	1.14
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -161,17 +161,9 @@
   
   
   
  -const XalanTranscodingServices::XalanXMLByte	XalanTranscodingServices::s_UTF16ByteOrderMark[] =
  +const XalanDOMChar	XalanTranscodingServices::s_UTF16ByteOrderMark[] =
   {
  -#if defined(XALAN_LITTLE_ENDIAN)
  -	XalanTranscodingServices::XalanXMLByte(0xFF),
  -	XalanTranscodingServices::XalanXMLByte(0xFE),
  -#elif defined(XALAN_BIG_ENDIAN)
  -	XalanTranscodingServices::XalanXMLByte(0xFE),
  -	XalanTranscodingServices::XalanXMLByte(0xFF),
  -#else
  -#error The platform must define the byte order!
  -#endif
  +	XalanDOMChar(0xFEFF),
   	XalanTranscodingServices::XalanXMLByte(0)
   };
   
  @@ -286,7 +278,11 @@
   {
   	if (compareIgnoreCaseASCII(c_wstr(theEncodingName), s_utf16String) == 0)
   	{
  -		return s_UTF16ByteOrderMark;
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +		return (const XalanXMLByte*)s_UTF16ByteOrderMark;
  +#else
  +		return reinterpret_cast<const XalanXMLByte*>(s_UTF16ByteOrderMark);
  +#endif
   	}
   #if 0
   	// We won't do this for now...
  
  
  
  1.9       +1 -1      xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp
  
  Index: XalanTranscodingServices.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanTranscodingServices.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XalanTranscodingServices.hpp	23 Feb 2002 04:17:46 -0000	1.8
  +++ XalanTranscodingServices.hpp	18 Apr 2002 04:50:50 -0000	1.9
  @@ -287,7 +287,7 @@
   
   	static const XalanXMLByte	s_dummyByteOrderMark[];
   	static const XalanXMLByte	s_UTF8ByteOrderMark[];
  -	static const XalanXMLByte	s_UTF16ByteOrderMark[];
  +	static const XalanDOMChar	s_UTF16ByteOrderMark[];
   
   	static const MaximumCharacterValueMapType&	s_maximumCharacterValues;
   };
  
  
  
  1.7       +9 -22     xml-xalan/c/src/PlatformSupport/XalanUTF16Transcoder.cpp
  
  Index: XalanUTF16Transcoder.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/XalanUTF16Transcoder.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XalanUTF16Transcoder.cpp	7 Feb 2002 01:39:58 -0000	1.6
  +++ XalanUTF16Transcoder.cpp	18 Apr 2002 04:50:50 -0000	1.7
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -96,20 +96,13 @@
   		}
   		else
   		{
  -			const XalanXMLByte	theHighByte = XalanXMLByte((theSourceData[theSourceEaten] & 0xFF00) >> 8);
  -			const XalanXMLByte	theLowByte = XalanXMLByte(theSourceData[theSourceEaten] & 0x00FF);
  -
  -#if defined(XALAN_LITTLE_ENDIAN)
  -			theTarget[theTargetPosition++] = theLowByte;
  -			theTarget[theTargetPosition++] = theHighByte;
  -#elif defined(XALAN_BIG_ENDIAN)
  -			theTarget[theTargetPosition++] = theHighByte;
  -			theTarget[theTargetPosition++] = theLowByte;
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +			*(XalanDOMChar*)(theTarget + theTargetPosition) = theSourceData[theSourceEaten++];
   #else
  -#error The platform must define the byte order!
  +			*reinterpret_cast<XalanDOMChar*>(theTarget + theTargetPosition) = theSourceData[theSourceEaten++];
   #endif
   
  -			++theSourceEaten;
  +			theTargetPosition += 2;
   		}
   	}
   
  @@ -135,7 +128,7 @@
   	unsigned int	theSourceEaten = 0;
   	unsigned int	theTargetPosition = 0;
   
  -	while(theSourceEaten < theSourceCount)
  +	while(theSourceEaten + 1 < theSourceCount)
   	{
   		// Swap bytes to big endian...
   		if (theTargetPosition + 1 >= theTargetSize)
  @@ -144,17 +137,11 @@
   		}
   		else
   		{
  -#if defined(XALAN_LITTLE_ENDIAN)
  -			const XalanXMLByte	theLowByte = theSourceData[theSourceCount++];
  -			const XalanXMLByte	theHighByte = theSourceData[theSourceCount++];
  -#elif defined(XALAN_BIG_ENDIAN)
  -			const XalanXMLByte	theHighByte = theSourceData[theSourceCount++];
  -			const XalanXMLByte	theLowByte = theSourceData[theSourceCount++];
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +			theTarget[theTargetPosition++] = *(const XalanDOMChar*)(theSourceData + theSourceCount++);
   #else
  -#error The platform must define the byte order!
  +			theTarget[theTargetPosition++] = *reinterpret_cast<const XalanDOMChar*>(theSourceData + theSourceCount++);
   #endif
  -
  -			theTarget[theTargetPosition++] = XalanDOMChar((theHighByte << 8) | theLowByte);
   
   			*theCharSizes++ = 2;
   		}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org