|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r48719 - trunk/boost/archive/impl
From: ramey_at_[hidden]
Date: 2008-09-10 23:50:18
Author: ramey
Date: 2008-09-10 23:50:18 EDT (Wed, 10 Sep 2008)
New Revision: 48719
URL: http://svn.boost.org/trac/boost/changeset/48719
Log:
fixed base64 text padding
Text files modified:
trunk/boost/archive/impl/basic_text_iprimitive.ipp | 22 ++++++++++++++++++----
trunk/boost/archive/impl/basic_text_oprimitive.ipp | 7 ++++---
2 files changed, 22 insertions(+), 7 deletions(-)
Modified: trunk/boost/archive/impl/basic_text_iprimitive.ipp
==============================================================================
--- trunk/boost/archive/impl/basic_text_iprimitive.ipp (original)
+++ trunk/boost/archive/impl/basic_text_iprimitive.ipp 2008-09-10 23:50:18 EDT (Wed, 10 Sep 2008)
@@ -33,6 +33,23 @@
namespace boost {
namespace archive {
+namespace {
+ template<class CharType>
+ bool is_whitespace(CharType c);
+
+ template<>
+ bool is_whitespace(char t){
+ return std::isspace(t);
+ }
+
+ #ifndef BOOST_NO_CWCHAR
+ template<>
+ bool is_whitespace(wchar_t t){
+ return std::iswspace(t);
+ }
+ #endif
+}
+
// translate base64 text into binary and copy into buffer
// until buffer is full.
template<class IStream>
@@ -77,7 +94,6 @@
);
char * caddr = static_cast<char *>(address);
- std::size_t padding = 2 - count % 3;
// take care that we don't increment anymore than necessary
while(--count > 0){
@@ -86,10 +102,8 @@
}
*caddr++ = static_cast<char>(*ti_begin);
- if(padding > 1)
+ while(! is_whitespace(*ti_begin))
++ti_begin;
- if(padding > 2)
- ++ti_begin;
}
template<class IStream>
Modified: trunk/boost/archive/impl/basic_text_oprimitive.ipp
==============================================================================
--- trunk/boost/archive/impl/basic_text_oprimitive.ipp (original)
+++ trunk/boost/archive/impl/basic_text_oprimitive.ipp 2008-09-10 23:50:18 EDT (Wed, 10 Sep 2008)
@@ -64,10 +64,11 @@
),
oi
);
- std::size_t padding = 2 - count % 3;
- if(padding > 1)
+
+ std::size_t tail = count % 3;
+ if(tail > 0)
*oi = '=';
- if(padding > 2)
+ if(tail < 2)
*oi = '=';
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk