Replace tabs with spaces in more files.

--HG--
branch : trunk
This commit is contained in:
Paradox
2009-02-09 08:16:34 -05:00
parent b0694d7e5e
commit d230302b16
602 changed files with 41367 additions and 41366 deletions

View File

@@ -64,7 +64,7 @@ namespace utf8
};
/// The library API - functions intended to be called by the users
template <typename octet_iterator, typename output_iterator>
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
{
@@ -92,7 +92,7 @@ namespace utf8
++start;
break;
}
}
}
return out;
}
@@ -106,11 +106,11 @@ namespace utf8
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (!internal::is_code_point_valid(cp))
if (!internal::is_code_point_valid(cp))
throw invalid_code_point(cp);
if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
*(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
@@ -149,7 +149,7 @@ namespace utf8
case internal::INVALID_CODE_POINT :
throw invalid_code_point(cp);
}
return cp;
return cp;
}
template <typename octet_iterator>
@@ -162,7 +162,7 @@ namespace utf8
uint32_t prior(octet_iterator& it, octet_iterator start)
{
octet_iterator end = it;
while (internal::is_trail(*(--it)))
while (internal::is_trail(*(--it)))
if (it < start)
throw invalid_utf8(*it); // error - no lead byte in the sequence
octet_iterator temp = it;
@@ -174,7 +174,7 @@ namespace utf8
uint32_t previous(octet_iterator& it, octet_iterator pass_start)
{
octet_iterator end = it;
while (internal::is_trail(*(--it)))
while (internal::is_trail(*(--it)))
if (it == pass_start)
throw invalid_utf8(*it); // error - no lead byte in the sequence
octet_iterator temp = it;
@@ -193,14 +193,14 @@ namespace utf8
distance (octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
for (dist = 0; first < last; ++dist)
next(first, last);
return dist;
}
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
{
{
while (start != end) {
uint32_t cp = internal::mask16(*start++);
// Take care of surrogate pairs first
@@ -208,17 +208,17 @@ namespace utf8
if (start != end) {
uint32_t trail_surrogate = internal::mask16(*start++);
if (trail_surrogate >= internal::TRAIL_SURROGATE_MIN && trail_surrogate <= internal::TRAIL_SURROGATE_MAX)
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
else
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
else
throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
}
else
else
throw invalid_utf16(static_cast<uint16_t>(*start));
}
result = append(cp, result);
}
return result;
return result;
}
template <typename u16bit_iterator, typename octet_iterator>
@@ -256,13 +256,13 @@ namespace utf8
// The iterator class
template <typename octet_iterator>
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
octet_iterator it;
octet_iterator range_start;
octet_iterator range_end;
public:
iterator () {};
explicit iterator (const octet_iterator& octet_it,
explicit iterator (const octet_iterator& octet_it,
const octet_iterator& range_start,
const octet_iterator& range_end) :
it(octet_it), range_start(range_start), range_end(range_end)
@@ -277,8 +277,8 @@ namespace utf8
octet_iterator temp = it;
return next(temp, range_end);
}
bool operator == (const iterator& rhs) const
{
bool operator == (const iterator& rhs) const
{
if (range_start != rhs.range_start || range_end != rhs.range_end)
throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
return (it == rhs.it);
@@ -287,7 +287,7 @@ namespace utf8
{
return !(operator == (rhs));
}
iterator& operator ++ ()
iterator& operator ++ ()
{
next(it, range_end);
return *this;
@@ -297,7 +297,7 @@ namespace utf8
iterator temp = *this;
next(it, range_end);
return temp;
}
}
iterator& operator -- ()
{
prior(it, range_start);

View File

@@ -36,7 +36,7 @@ DEALINGS IN THE SOFTWARE.
namespace utf8
{
// The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
// You may need to change them to match your system.
// You may need to change them to match your system.
// These typedefs have the same names as ones from cstdint, or boost/cstdint
/* use Trinity alternatives
@@ -50,7 +50,7 @@ namespace utf8
// Helper code - not intended to be directly called by the library users. May be changed at any time
namespace internal
{
{
// Unicode constants
// Leading (high) surrogates: 0xd800 - 0xdbff
// Trailing (low) surrogates: 0xdc00 - 0xdfff
@@ -90,14 +90,14 @@ namespace internal
inline bool is_code_point_valid(u32 cp)
{
return (cp <= CODE_POINT_MAX && !is_surrogate(cp) && cp != 0xfffe && cp != 0xffff);
}
}
template <typename octet_iterator>
inline typename std::iterator_traits<octet_iterator>::difference_type
sequence_length(octet_iterator lead_it)
{
uint8_t lead = mask8(*lead_it);
if (lead < 0x80)
if (lead < 0x80)
return 1;
else if ((lead >> 5) == 0x6)
return 2;
@@ -105,7 +105,7 @@ namespace internal
return 3;
else if ((lead >> 3) == 0x1e)
return 4;
else
else
return 0;
}
@@ -131,17 +131,17 @@ namespace internal
return NOT_ENOUGH_ROOM;
}
// Do we have enough memory?
// Do we have enough memory?
if (std::distance(it, end) < length)
return NOT_ENOUGH_ROOM;
// Check trail octets and calculate the code point
switch (length) {
case 0:
return INVALID_LEAD;
break;
case 2:
if (is_trail(*(++it))) {
if (is_trail(*(++it))) {
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
}
else {
@@ -167,11 +167,11 @@ namespace internal
break;
case 4:
if (is_trail(*(++it))) {
cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff);
cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff);
if (is_trail(*(++it))) {
cp += (mask8(*it) << 6) & 0xfff;
if (is_trail(*(++it))) {
cp += (*it) & 0x3f;
cp += (*it) & 0x3f;
}
else {
std::advance(it, -3);
@@ -191,14 +191,14 @@ namespace internal
}
// Is the code point valid?
if (!is_code_point_valid(cp)) {
for (octet_difference_type i = 0; i < length - 1; ++i)
for (octet_difference_type i = 0; i < length - 1; ++i)
--it;
return INVALID_CODE_POINT;
}
if (code_point)
*code_point = cp;
if (cp < 0x80) {
if (length != 1) {
std::advance(it, -(length-1));
@@ -217,9 +217,9 @@ namespace internal
return OVERLONG_SEQUENCE;
}
}
++it;
return OK;
return OK;
}
template <typename octet_iterator>
@@ -227,12 +227,12 @@ namespace internal
return validate_next(it, end, 0);
}
} // namespace internal
} // namespace internal
/// The library API - functions intended to be called by the users
// Byte order mark
const uint8_t bom[] = {0xef, 0xbb, 0xbf};
const uint8_t bom[] = {0xef, 0xbb, 0xbf};
template <typename octet_iterator>
octet_iterator find_invalid(octet_iterator start, octet_iterator end)

View File

@@ -32,13 +32,13 @@ DEALINGS IN THE SOFTWARE.
namespace utf8
{
namespace unchecked
namespace unchecked
{
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
*(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
@@ -70,28 +70,28 @@ namespace utf8
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break;
case 3:
++it;
++it;
cp = ((cp << 12) & 0xffff) + ((internal::mask8(*it) << 6) & 0xfff);
++it;
cp += (*it) & 0x3f;
break;
case 4:
++it;
cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff);
cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff);
++it;
cp += (internal::mask8(*it) << 6) & 0xfff;
++it;
cp += (*it) & 0x3f;
cp += (*it) & 0x3f;
break;
}
++it;
return cp;
return cp;
}
template <typename octet_iterator>
uint32_t peek_next(octet_iterator it)
{
return next(it);
return next(it);
}
template <typename octet_iterator>
@@ -121,14 +121,14 @@ namespace utf8
distance (octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
for (dist = 0; first < last; ++dist)
next(first);
return dist;
}
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
{
{
while (start != end) {
uint32_t cp = internal::mask16(*start++);
// Take care of surrogate pairs first
@@ -138,7 +138,7 @@ namespace utf8
}
result = append(cp, result);
}
return result;
return result;
}
template <typename u16bit_iterator, typename octet_iterator>
@@ -176,7 +176,7 @@ namespace utf8
// The iterator class
template <typename octet_iterator>
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
octet_iterator it;
public:
iterator () {};
@@ -188,15 +188,15 @@ namespace utf8
octet_iterator temp = it;
return next(temp);
}
bool operator == (const iterator& rhs) const
{
bool operator == (const iterator& rhs) const
{
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
{
return !(operator == (rhs));
}
iterator& operator ++ ()
iterator& operator ++ ()
{
std::advance(it, internal::sequence_length(it));
return *this;
@@ -206,7 +206,7 @@ namespace utf8
iterator temp = *this;
std::advance(it, internal::sequence_length(it));
return temp;
}
}
iterator& operator -- ()
{
prior(it);
@@ -221,7 +221,7 @@ namespace utf8
}; // class iterator
} // namespace utf8::unchecked
} // namespace utf8
} // namespace utf8
#endif // header guard