Added workarounds for all instances of DMC overfetch bug

git-svn-id: http://pugixml.googlecode.com/svn/trunk@640 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2010-08-29 15:09:34 +00:00
parent 608d5bbd79
commit 9b6dc1a585
2 changed files with 19 additions and 3 deletions

View File

@ -1077,7 +1077,12 @@ namespace
// try to guess encoding (based on XML specification, Appendix F.1) // try to guess encoding (based on XML specification, Appendix F.1)
const uint8_t* data = static_cast<const uint8_t*>(contents); const uint8_t* data = static_cast<const uint8_t*>(contents);
return guess_buffer_encoding(data[0], data[1], data[2], data[3]); #ifdef __DMC__
volatile // explicitly store to local to work around DMC bug (it loads 4 bytes from data[3] otherwise)
#endif
uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3];
return guess_buffer_encoding(d0, d1, d2, d3);
} }
bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable)

View File

@ -2357,7 +2357,15 @@ namespace pugi
if (!r.empty() && r[r.size() - 1] != ' ') if (!r.empty() && r[r.size() - 1] != ' ')
r += ' '; r += ' ';
} }
else r += *it; else
{
#ifdef __DMC__
volatile // explicitly store to local to work around DMC bug (it loads 4 bytes from &*it otherwise)
#endif
char_t ch = *it;
r += ch;
}
} }
string_t::size_type pos = r.find_last_not_of(' '); string_t::size_type pos = r.find_last_not_of(' ');
@ -2375,7 +2383,10 @@ namespace pugi
for (string_t::iterator it = s.begin(); it != s.end(); ) for (string_t::iterator it = s.begin(); it != s.end(); )
{ {
char_t ch = *it; // explicitly store to local to work around DMC bug (it loads 4 bytes from &*it otherwise) #ifdef __DMC__
volatile // explicitly store to local to work around DMC bug (it loads 4 bytes from &*it otherwise)
#endif
char_t ch = *it;
string_t::size_type pos = from.find(ch); string_t::size_type pos = from.find(ch);