Author: dbertoni
Date: Fri Jan 20 14:05:46 2006
New Revision: 370907
URL: http://svn.apache.org/viewcvs?rev=370907&view=rev
Log:
Fixes for Jira issue XERCESC-1548.
Modified:
xerces/c/trunk/src/xercesc/util/Base64.cpp
xerces/c/trunk/src/xercesc/util/Base64.hpp
xerces/c/trunk/src/xercesc/util/HexBin.cpp
xerces/c/trunk/src/xercesc/util/HexBin.hpp
Modified: xerces/c/trunk/src/xercesc/util/Base64.cpp
URL:
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Base64.cpp?rev=370907&r1=370906&r2=370907&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Base64.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/Base64.cpp Fri Jan 20 14:05:46 2006
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-/*
- * $Id$
- */
-
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
@@ -46,22 +42,43 @@
chLatin_K, chLatin_L, chLatin_M, chLatin_N, chLatin_O,
chLatin_P, chLatin_Q, chLatin_R, chLatin_S, chLatin_T,
chLatin_U, chLatin_V, chLatin_W, chLatin_X, chLatin_Y, chLatin_Z,
- chLatin_a, chLatin_b, chLatin_c, chLatin_d, chLatin_e,
- chLatin_f, chLatin_g, chLatin_h, chLatin_i, chLatin_j,
- chLatin_k, chLatin_l, chLatin_m, chLatin_n, chLatin_o,
- chLatin_p, chLatin_q, chLatin_r, chLatin_s, chLatin_t,
- chLatin_u, chLatin_v, chLatin_w, chLatin_x, chLatin_y, chLatin_z,
- chDigit_0, chDigit_1, chDigit_2, chDigit_3, chDigit_4,
- chDigit_5, chDigit_6, chDigit_7, chDigit_8, chDigit_9,
- chPlus, chForwardSlash, chNull
+ chLatin_a, chLatin_b, chLatin_c, chLatin_d, chLatin_e,
+ chLatin_f, chLatin_g, chLatin_h, chLatin_i, chLatin_j,
+ chLatin_k, chLatin_l, chLatin_m, chLatin_n, chLatin_o,
+ chLatin_p, chLatin_q, chLatin_r, chLatin_s, chLatin_t,
+ chLatin_u, chLatin_v, chLatin_w, chLatin_x, chLatin_y, chLatin_z,
+ chDigit_0, chDigit_1, chDigit_2, chDigit_3, chDigit_4,
+ chDigit_5, chDigit_6, chDigit_7, chDigit_8, chDigit_9,
+ chPlus, chForwardSlash, chNull
};
-XMLByte Base64::base64Inverse[BASELENGTH];
+// This is an inverse table for base64 decoding. So, if
+// base64Alphabet[17] = 'R', then base64Inverse['R'] = 17.
+//
+// For characters not in base64Alphabet then
+// base64Inverse[ch] = 0xFF.
+const XMLByte Base64::base64Inverse[BASELENGTH] =
+{
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3E,
0xFF, 0xFF, 0xFF, 0x3F,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E,
+ 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF
+};
const XMLByte Base64::base64Padding = chEqual;
-bool Base64::isInitialized = false;
-
/***
*
* Memory Management Issue:
@@ -130,9 +147,6 @@
, unsigned int* outputLength
, MemoryManager* const memMgr)
{
- if (!isInitialized)
- init();
-
if (!inputData || !outputLength)
return 0;
@@ -278,29 +292,29 @@
, MemoryManager* const memMgr
, Conformance conform )
{
- if (!inputData)
- return 0;
+ if (!inputData)
+ return 0;
/***
* Move input data to a XMLByte buffer
*/
- unsigned int srcLen = XMLString::stringLen(inputData);
+ unsigned int srcLen = XMLString::stringLen(inputData);
XMLByte *dataInByte = (XMLByte*) getExternalMemory(memMgr, (srcLen+1) *
sizeof(XMLByte));
ArrayJanitor<XMLByte> janFill(dataInByte, memMgr ? memMgr :
XMLPlatformUtils::fgMemoryManager);
for (unsigned int i = 0; i < srcLen; i++)
- dataInByte[i] = (XMLByte)inputData[i];
+ dataInByte[i] = (XMLByte)inputData[i];
- dataInByte[srcLen] = 0;
+ dataInByte[srcLen] = 0;
/***
* Forward to the actual decoding method to do the decoding
*/
- *decodedLen = 0;
- XMLByte *DecodedBuf = decode(dataInByte, decodedLen, memMgr, conform);
+ *decodedLen = 0;
+ XMLByte *DecodedBuf = decode(dataInByte, decodedLen, memMgr, conform);
- if (!DecodedBuf)
- return 0;
+ if (!DecodedBuf)
+ return 0;
/***
* Move decoded data to a XMLCh buffer to return
@@ -308,9 +322,9 @@
XMLCh *toRet = (XMLCh*) getExternalMemory(memMgr, (*decodedLen+1) *
sizeof(XMLCh));
for (unsigned int j = 0; j < *decodedLen; j++)
- toRet[j] = (XMLCh)DecodedBuf[j];
+ toRet[j] = (XMLCh)DecodedBuf[j];
- toRet[*decodedLen] = 0;
+ toRet[*decodedLen] = 0;
/***
* Release the memory allocated in the actual decoding method
@@ -325,26 +339,26 @@
, MemoryManager* const memMgr
, Conformance conform )
{
- if (!inputData || !*inputData)
- return 0;
+ if (!inputData || !*inputData)
+ return 0;
/***
* Move input data to a XMLByte buffer
*/
- unsigned int srcLen = XMLString::stringLen(inputData);
+ unsigned int srcLen = XMLString::stringLen(inputData);
XMLByte *dataInByte = (XMLByte*) getExternalMemory(memMgr, (srcLen+1) *
sizeof(XMLByte));
ArrayJanitor<XMLByte> janFill(dataInByte, memMgr ? memMgr :
XMLPlatformUtils::fgMemoryManager);
for (unsigned int i = 0; i < srcLen; i++)
- dataInByte[i] = (XMLByte)inputData[i];
+ dataInByte[i] = (XMLByte)inputData[i];
- dataInByte[srcLen] = 0;
+ dataInByte[srcLen] = 0;
/***
* Forward to the actual decoding method to do the decoding
*/
- *decodedLen = 0;
- return decode(dataInByte, decodedLen, memMgr, conform);
+ *decodedLen = 0;
+ return decode(dataInByte, decodedLen, memMgr, conform);
}
/***
@@ -361,25 +375,25 @@
, Conformance conform)
{
- if (!inputData || !*inputData)
- return 0;
+ if (!inputData || !*inputData)
+ return 0;
/***
* Move input data to a XMLByte buffer
*/
- unsigned int srcLen = XMLString::stringLen(inputData);
+ unsigned int srcLen = XMLString::stringLen(inputData);
XMLByte *dataInByte = (XMLByte*) getExternalMemory(memMgr, (srcLen+1) *
sizeof(XMLByte));
ArrayJanitor<XMLByte> janFill(dataInByte, memMgr ? memMgr :
XMLPlatformUtils::fgMemoryManager);
for (unsigned int i = 0; i < srcLen; i++)
- dataInByte[i] = (XMLByte)inputData[i];
+ dataInByte[i] = (XMLByte)inputData[i];
- dataInByte[srcLen] = 0;
+ dataInByte[srcLen] = 0;
/***
* Forward to the actual decoding method to do the decoding
*/
- unsigned int decodedLength = 0;
+ unsigned int decodedLength = 0;
XMLByte* canRepInByte = 0;
XMLByte* retStr = decode(
dataInByte
@@ -398,9 +412,9 @@
XMLCh *canRepData = (XMLCh*) getExternalMemory(memMgr, (canRepLen + 1) *
sizeof(XMLCh));
for (unsigned int j = 0; j < canRepLen; j++)
- canRepData[j] = (XMLCh)canRepInByte[j];
+ canRepData[j] = (XMLCh)canRepInByte[j];
- canRepData[canRepLen] = 0;
+ canRepData[canRepLen] = 0;
/***
* Release the memory allocated in the actual decoding method
@@ -474,9 +488,6 @@
, Conformance conform
)
{
- if (!isInitialized)
- init();
-
if ((!inputData) || (!*inputData))
return 0;
@@ -665,27 +676,6 @@
canRepData = rawInputData;
return decodedData;
-}
-
-void Base64::init()
-{
- if (isInitialized)
- return;
-
- isInitialized = true;
-
- // create inverse table for base64 decoding
- // if base64Alphabet[ 17 ] = 'R', then base64Inverse[ 'R' ] = 17
- // for characters not in base64Alphabet the base64Inverse[] = -1
-
- int i;
- // set all fields to -1
- for ( i = 0; i < BASELENGTH; i++ )
- base64Inverse[i] = (XMLByte)-1;
-
- // compute inverse table
- for ( i = 0; i < 64; i++ )
- base64Inverse[ base64Alphabet[i] ] = (XMLByte)i;
}
bool Base64::isData(const XMLByte& octet)
Modified: xerces/c/trunk/src/xercesc/util/Base64.hpp
URL:
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/Base64.hpp?rev=370907&r1=370906&r2=370907&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/Base64.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/Base64.hpp Fri Jan 20 14:05:46 2006
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-/*
- * $Id$
- */
-
#ifndef BASE64_HPP
#define BASE64_HPP
@@ -215,8 +211,6 @@
, Conformance conform = Conf_RFC2045
);
- static void init();
-
static bool isData(const XMLByte& octet);
static bool isPad(const XMLByte& octet);
@@ -259,8 +253,7 @@
static const XMLByte base64Alphabet[];
static const XMLByte base64Padding;
- static XMLByte base64Inverse[];
- static bool isInitialized;
+ static const XMLByte base64Inverse[];
static const unsigned int quadsPerLine;
};
Modified: xerces/c/trunk/src/xercesc/util/HexBin.cpp
URL:
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/HexBin.cpp?rev=370907&r1=370906&r2=370907&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/HexBin.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/HexBin.cpp Fri Jan 20 14:05:46 2006
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-/*
- * $Id$
- */
-
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
@@ -36,8 +32,26 @@
// ---------------------------------------------------------------------------
// class data member
// ---------------------------------------------------------------------------
-XMLByte HexBin::hexNumberTable[BASELENGTH];
-bool HexBin::isInitialized = false;
+const XMLByte HexBin::hexNumberTable[BASELENGTH] =
+{
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF
+};
+
int HexBin::getDataLength(const XMLCh* const hexData)
{
@@ -49,9 +63,6 @@
bool HexBin::isArrayByteHex(const XMLCh* const hexData)
{
- if ( !isInitialized )
- init();
-
if (( hexData == 0 ) || ( *hexData == 0 )) // zero length
return true;
@@ -89,9 +100,6 @@
if ( strLen%2 != 0 )
return 0;
- if ( !isInitialized )
- init();
-
//prepare the return string
int decodeLength = strLen/2;
XMLCh *retVal = (XMLCh*) manager->allocate( (decodeLength + 1) *
sizeof(XMLCh));
@@ -123,9 +131,6 @@
if ( strLen%2 != 0 )
return 0;
- if ( !isInitialized )
- init();
-
//prepare the return string
int decodeLength = strLen/2;
XMLByte *retVal = (XMLByte*) manager->allocate( (decodeLength + 1) *
sizeof(XMLByte));
@@ -158,27 +163,6 @@
return false;
return (hexNumberTable[octet] != (XMLByte) -1);
-}
-
-void HexBin::init()
-{
- if ( isInitialized )
- return;
-
- int i;
- for ( i = 0; i < BASELENGTH; i++ )
- hexNumberTable[i] = (XMLByte)-1;
-
- for ( i = chDigit_9; i >= chDigit_0; i-- )
- hexNumberTable[i] = (XMLByte) (i - chDigit_0);
-
- for ( i = chLatin_F; i >= chLatin_A; i-- )
- hexNumberTable[i] = (XMLByte) (i - chLatin_A + 10);
-
- for ( i = chLatin_f; i >= chLatin_a; i-- )
- hexNumberTable[i] = (XMLByte) (i - chLatin_a + 10);
-
- isInitialized = true;
}
XERCES_CPP_NAMESPACE_END
Modified: xerces/c/trunk/src/xercesc/util/HexBin.hpp
URL:
http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/HexBin.hpp?rev=370907&r1=370906&r2=370907&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/HexBin.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/HexBin.hpp Fri Jan 20 14:05:46 2006
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-/*
- * $Id$
- */
-
#ifndef HEXBIN_HPP
#define HEXBIN_HPP
@@ -125,8 +121,6 @@
// Helper methods
// -----------------------------------------------------------------------
- static void init();
-
static bool isHex(const XMLCh& octect);
// -----------------------------------------------------------------------
@@ -148,8 +142,7 @@
// arrany holding valid hexNumber character.
//
// -----------------------------------------------------------------------
- static bool isInitialized;
- static XMLByte hexNumberTable[];
+ static const XMLByte hexNumberTable[];
};
XERCES_CPP_NAMESPACE_END
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]