diff options
author | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
commit | 26b5e033ffde3d161382fc9addbfa99738379641 (patch) | |
tree | a344f369ca32945f787a02dee35c3dbe342bed7e /dep/ACE_wrappers/ace/Codecs.cpp | |
parent | f21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff) |
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget
--HG--
branch : trunk
Diffstat (limited to 'dep/ACE_wrappers/ace/Codecs.cpp')
-rw-r--r-- | dep/ACE_wrappers/ace/Codecs.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/dep/ACE_wrappers/ace/Codecs.cpp b/dep/ACE_wrappers/ace/Codecs.cpp index d0bb0778304..7556b76088c 100644 --- a/dep/ACE_wrappers/ace/Codecs.cpp +++ b/dep/ACE_wrappers/ace/Codecs.cpp @@ -2,38 +2,28 @@ #include "ace/Log_Msg.h" #include "ace/OS_Memory.h" #include "ace/OS_NS_ctype.h" - ACE_RCSID (ace, Codecs, "$Id: Codecs.cpp 80826 2008-03-04 14:51:23Z wotte $") - namespace { // Just in case ... #undef alphabet #undef pad #undef max_columns - // Symbols which form the Base64 alphabet (Defined as per RFC 2045) ACE_Byte const alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - // The padding character used in the encoding ACE_Byte const pad = '='; - // Number of columns per line of encoded output (Can have a maximum // value of 76). int const max_columns = 72; } - ACE_BEGIN_VERSIONED_NAMESPACE_DECL - bool ACE_Base64::init_ = false; - ACE_Byte ACE_Base64::decoder_[256]; - ACE_Byte ACE_Base64::member_[256]; - ACE_Byte* ACE_Base64::encode (const ACE_Byte* input, const size_t input_len, @@ -42,27 +32,21 @@ ACE_Base64::encode (const ACE_Byte* input, { if (!ACE_Base64::init_) ACE_Base64::init(); - if (!input) return 0; - ACE_Byte* result = 0; - size_t length = ((input_len + 2) / 3) * 4; size_t num_lines = length / max_columns + 1; length += num_lines + 1; ACE_NEW_RETURN (result, ACE_Byte[length], 0); - int char_count = 0; int bits = 0; size_t pos = 0; int cols = 0; - for (size_t i = 0; i < input_len; ++i) { bits += input[i]; ++char_count; - if (char_count == 3) { result[pos++] = alphabet[bits >> 18]; @@ -83,7 +67,6 @@ ACE_Base64::encode (const ACE_Byte* input, bits <<= 8; } } - if (char_count != 0) { bits <<= (16 - (8 * char_count)); @@ -103,21 +86,17 @@ ACE_Base64::encode (const ACE_Byte* input, cols += 2; } } - if (cols > 0 && is_chunked) result[pos++] = '\n'; - result[pos] = 0; *output_len = pos; return result; } - size_t ACE_Base64::length (const ACE_Byte* input) { if (!ACE_Base64::init_) ACE_Base64::init(); - ACE_Byte* ptr = const_cast<ACE_Byte*> (input); while (*ptr != 0 && (member_[*(ptr)] == 1 || *ptr == pad @@ -127,31 +106,25 @@ ACE_Base64::length (const ACE_Byte* input) len = ((len + 3) / 4) * 3 + 1 ; return len; } - ACE_Byte* ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) { if (!ACE_Base64::init_) ACE_Base64::init(); - if (!input) return 0; - size_t result_len = ACE_Base64::length (input); ACE_Byte* result = 0; ACE_NEW_RETURN (result, ACE_Byte[result_len], 0); - ACE_Byte* ptr = const_cast<ACE_Byte*> (input); while (*ptr != 0 && (member_[*(ptr)] == 1 || *ptr == pad || ACE_OS::ace_isspace (*ptr))) ++ptr; size_t input_len = ptr - input; - int char_count = 0; int bits = 0; size_t pos = 0; - size_t i = 0; for (; i < input_len; ++i) { @@ -161,7 +134,6 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) continue; bits += decoder_[input[i]]; ++char_count; - if (char_count == 4) { result[pos++] = static_cast<ACE_Byte> (bits >> 16); @@ -175,7 +147,6 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) bits <<= 6; } } - int errors = 0; if ( i == input_len) { @@ -205,7 +176,6 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) break; } } - if (errors) { delete[] result; @@ -215,7 +185,6 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len) *output_len = pos; return result; } - void ACE_Base64::init () { @@ -230,6 +199,5 @@ ACE_Base64::init () } return; } - ACE_END_VERSIONED_NAMESPACE_DECL |