summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r--plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp855
-rw-r--r--plugins/UserInfoEx/src/mir_db.cpp55
-rw-r--r--plugins/UserInfoEx/src/psp_anniversary.cpp1
3 files changed, 385 insertions, 526 deletions
diff --git a/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp b/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp
index 8f38ee8ce7..3f4bc639e9 100644
--- a/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp
+++ b/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp
@@ -86,7 +86,7 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt
const unsigned long BYTE_MARK = 0x80;
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
- if (input < 0x80)
+ if (input < 0x80)
*length = 1;
else if (input < 0x800)
*length = 2;
@@ -94,29 +94,29 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt
*length = 3;
else if (input < 0x200000)
*length = 4;
- else
- { *length = 0; return; } // This code won't covert this correctly anyway.
+ else {
+ *length = 0; return;
+ } // This code won't covert this correctly anyway.
output += *length;
// Scary scary fall throughs.
- switch (*length)
- {
- case 4:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 3:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 2:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 1:
- --output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
+ switch (*length) {
+ case 4:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 3:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 2:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 1:
+ --output;
+ *output = (char)(input | FIRST_BYTE_MARK[*length]);
}
}
@@ -130,10 +130,10 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt
// if (encoding == TIXML_ENCODING_UTF8)
// {
- if (anyByte < 127)
- return isalpha(anyByte);
- else
- return 1; // What else to do? The unicode set is huge...get the english ones right.
+ if (anyByte < 127)
+ return isalpha(anyByte);
+ else
+ return 1; // What else to do? The unicode set is huge...get the english ones right.
// }
// else
// {
@@ -151,10 +151,10 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt
// if (encoding == TIXML_ENCODING_UTF8)
// {
- if (anyByte < 127)
- return isalnum(anyByte);
- else
- return 1; // What else to do? The unicode set is huge...get the english ones right.
+ if (anyByte < 127)
+ return isalnum(anyByte);
+ else
+ return 1; // What else to do? The unicode set is huge...get the english ones right.
// }
// else
// {
@@ -166,12 +166,12 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt
class TiXmlParsingData
{
friend class TiXmlDocument;
- public:
+public:
void Stamp(const char* now, TiXmlEncoding encoding);
- const TiXmlCursor& Cursor() { return cursor; }
+ const TiXmlCursor& Cursor() { return cursor; }
- private:
+private:
// Only used by the document!
TiXmlParsingData(const char* start, int _tabsize, int row, int col)
{
@@ -193,8 +193,7 @@ void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding)
assert(now);
// Do nothing if the tabsize is 0.
- if (tabsize < 1)
- {
+ if (tabsize < 1) {
return;
}
@@ -204,97 +203,92 @@ void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding)
const char* p = stamp;
assert(p);
- while (p < now)
- {
+ while (p < now) {
// Treat p as unsigned, so we have a happy compiler.
const unsigned char* pU = (const unsigned char*)p;
// Code contributed by Fletcher Dunn: (modified by lee)
switch (*pU) {
- case 0:
- // We *should* never get here, but in case we do, don't
- // advance past the terminating null character, ever
- return;
+ case 0:
+ // We *should* never get here, but in case we do, don't
+ // advance past the terminating null character, ever
+ return;
+
+ case '\r':
+ // bump down to the next line
+ ++row;
+ col = 0;
+ // Eat the character
+ ++p;
- case '\r':
- // bump down to the next line
- ++row;
- col = 0;
- // Eat the character
+ // Check for \r\n sequence, and treat this as a single character
+ if (*p == '\n') {
++p;
+ }
+ break;
- // Check for \r\n sequence, and treat this as a single character
- if (*p == '\n') {
- ++p;
- }
- break;
+ case '\n':
+ // bump down to the next line
+ ++row;
+ col = 0;
- case '\n':
- // bump down to the next line
- ++row;
- col = 0;
+ // Eat the character
+ ++p;
- // Eat the character
+ // Check for \n\r sequence, and treat this as a single
+ // character. (Yes, this bizarre thing does occur still
+ // on some arcane platforms...)
+ if (*p == '\r') {
++p;
+ }
+ break;
- // Check for \n\r sequence, and treat this as a single
- // character. (Yes, this bizarre thing does occur still
- // on some arcane platforms...)
- if (*p == '\r') {
- ++p;
- }
- break;
-
- case '\t':
- // Eat the character
- ++p;
+ case '\t':
+ // Eat the character
+ ++p;
- // Skip to next tab stop
- col = (col / tabsize + 1) * tabsize;
- break;
+ // Skip to next tab stop
+ col = (col / tabsize + 1) * tabsize;
+ break;
- case TIXML_UTF_LEAD_0:
- if (encoding == TIXML_ENCODING_UTF8)
- {
- if (*(p+1) && *(p+2))
- {
- // In these cases, don't advance the column. These are
- // 0-width spaces.
- if (*(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2)
- p += 3;
- else if (*(pU+1)==0xbfU && *(pU+2)==0xbeU)
- p += 3;
- else if (*(pU+1)==0xbfU && *(pU+2)==0xbfU)
- p += 3;
- else
- { p +=3; ++col; } // A normal character.
- }
+ case TIXML_UTF_LEAD_0:
+ if (encoding == TIXML_ENCODING_UTF8) {
+ if (*(p + 1) && *(p + 2)) {
+ // In these cases, don't advance the column. These are
+ // 0-width spaces.
+ if (*(pU + 1) == TIXML_UTF_LEAD_1 && *(pU + 2) == TIXML_UTF_LEAD_2)
+ p += 3;
+ else if (*(pU + 1) == 0xbfU && *(pU + 2) == 0xbeU)
+ p += 3;
+ else if (*(pU + 1) == 0xbfU && *(pU + 2) == 0xbfU)
+ p += 3;
+ else {
+ p += 3; ++col;
+ } // A normal character.
}
- else
- {
- ++p;
- ++col;
- }
- break;
+ }
+ else {
+ ++p;
+ ++col;
+ }
+ break;
- default:
- if (encoding == TIXML_ENCODING_UTF8)
- {
- // Eat the 1 to 4 byte utf8 character.
- int step = TiXmlBase::utf8ByteTable[*((unsigned char*)p)];
- if (step == 0)
- step = 1; // Error case from bad encoding, but handle gracefully.
- p += step;
-
- // Just advance one column, of course.
- ++col;
- }
- else
- {
- ++p;
- ++col;
- }
- break;
+ default:
+ if (encoding == TIXML_ENCODING_UTF8) {
+ // Eat the 1 to 4 byte utf8 character.
+ int step = TiXmlBase::utf8ByteTable[*((unsigned char*)p)];
+ if (step == 0)
+ step = 1; // Error case from bad encoding, but handle gracefully.
+ p += step;
+
+ // Just advance one column, of course.
+ ++col;
+ }
+ else {
+ ++p;
+ ++col;
+ }
+ break;
}
}
cursor.row = row;
@@ -308,48 +302,41 @@ void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding)
const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding)
{
- if (!p || !*p)
- {
+ if (!p || !*p) {
return 0;
}
- if (encoding == TIXML_ENCODING_UTF8)
- {
- while (*p)
- {
+ if (encoding == TIXML_ENCODING_UTF8) {
+ while (*p) {
const unsigned char* pU = (const unsigned char*)p;
-
+
// Skip the stupid Microsoft UTF-8 Byte order marks
- if ( *(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==TIXML_UTF_LEAD_1
- && *(pU+2)==TIXML_UTF_LEAD_2)
- {
+ if (*(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) == TIXML_UTF_LEAD_1
+ && *(pU + 2) == TIXML_UTF_LEAD_2) {
p += 3;
continue;
}
- else if (*(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==0xbfU
- && *(pU+2)==0xbeU)
- {
+ else if (*(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) == 0xbfU
+ && *(pU + 2) == 0xbeU) {
p += 3;
continue;
}
- else if (*(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==0xbfU
- && *(pU+2)==0xbfU)
- {
+ else if (*(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) == 0xbfU
+ && *(pU + 2) == 0xbfU) {
p += 3;
continue;
}
- if (IsWhiteSpace(*p) || *p == '\n' || *p =='\r') // Still using old rules for white space.
+ if (IsWhiteSpace(*p) || *p == '\n' || *p == '\r') // Still using old rules for white space.
++p;
else
break;
}
}
- else
- {
- while (*p && IsWhiteSpace(*p) || *p == '\n' || *p =='\r')
+ else {
+ while (*p && IsWhiteSpace(*p) || *p == '\n' || *p == '\r')
++p;
}
@@ -359,8 +346,7 @@ const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding)
#ifdef TIXML_USE_STL
/*static*/ bool TiXmlBase::StreamWhiteSpace(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- for (;;)
- {
+ for (;;) {
if (!in->good()) return false;
int c = in->peek();
@@ -368,15 +354,14 @@ const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding)
if (!IsWhiteSpace(c) || c <= 0)
return true;
- *tag += (char) in->get();
+ *tag += (char)in->get();
}
}
/*static*/ bool TiXmlBase::StreamTo(TIXML_ISTREAM * in, int character, TIXML_STRING * tag)
{
//assert(character > 0 && character < 128); // else it won't work in utf-8
- while (in->good())
- {
+ while (in->good()) {
int c = in->peek();
if (c == character)
return true;
@@ -384,7 +369,7 @@ const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding)
return false;
in->get();
- *tag += (char) c;
+ *tag += (char)c;
}
return false;
}
@@ -402,16 +387,14 @@ const char* TiXmlBase::ReadName(const char* p, TIXML_STRING * name, TiXmlEncodin
// After that, they can be letters, underscores, numbers,
// hyphens, or colons. (Colons are valid ony for namespaces,
// but tinyxml can't tell namespaces from names.)
- if ( p && *p
- && (IsAlpha((unsigned char) *p, encoding) || *p == '_'))
- {
- while ( p && *p
- && ( IsAlphaNum((unsigned char) *p, encoding)
- || *p == '_'
- || *p == '-'
- || *p == '.'
- || *p == ':'))
- {
+ if (p && *p
+ && (IsAlpha((unsigned char)*p, encoding) || *p == '_')) {
+ while (p && *p
+ && (IsAlphaNum((unsigned char)*p, encoding)
+ || *p == '_'
+ || *p == '-'
+ || *p == '.'
+ || *p == ':')) {
(*name) += *p;
++p;
}
@@ -423,73 +406,66 @@ const char* TiXmlBase::ReadName(const char* p, TIXML_STRING * name, TiXmlEncodin
const char* TiXmlBase::GetEntity(const char* p, char* value, int* length, TiXmlEncoding encoding)
{
// Presume an entity, and pull it out.
- TIXML_STRING ent;
+ TIXML_STRING ent;
int i;
*length = 0;
- if (*(p+1) && *(p+1) == '#' && *(p+2))
- {
+ if (*(p + 1) && *(p + 1) == '#' && *(p + 2)) {
unsigned long ucs = 0;
ptrdiff_t delta = 0;
unsigned mult = 1;
- if (*(p+2) == 'x')
- {
+ if (*(p + 2) == 'x') {
// Hexadecimal.
- if (!*(p+3)) return 0;
+ if (!*(p + 3)) return 0;
- const char* q = p+3;
+ const char* q = p + 3;
q = strchr(q, ';');
if (!q || !*q) return 0;
- delta = q-p;
+ delta = q - p;
--q;
- while (*q != 'x')
- {
+ while (*q != 'x') {
if (*q >= '0' && *q <= '9')
ucs += mult * (*q - '0');
else if (*q >= 'a' && *q <= 'f')
ucs += mult * (*q - 'a' + 10);
else if (*q >= 'A' && *q <= 'F')
ucs += mult * (*q - 'A' + 10);
- else
+ else
return 0;
mult *= 16;
--q;
}
}
- else
- {
+ else {
// Decimal.
- if (!*(p+2)) return 0;
+ if (!*(p + 2)) return 0;
- const char* q = p+2;
+ const char* q = p + 2;
q = strchr(q, ';');
if (!q || !*q) return 0;
- delta = q-p;
+ delta = q - p;
--q;
- while (*q != '#')
- {
+ while (*q != '#') {
if (*q >= '0' && *q <= '9')
ucs += mult * (*q - '0');
- else
+ else
return 0;
mult *= 10;
--q;
}
}
- if (encoding == TIXML_ENCODING_UTF8)
- {
+ if (encoding == TIXML_ENCODING_UTF8) {
// convert the UCS to UTF-8
ConvertUTF32ToUTF8(ucs, value, length);
}
- else
- {
+ else {
*value = (char)ucs;
*length = 1;
}
@@ -497,10 +473,8 @@ const char* TiXmlBase::GetEntity(const char* p, char* value, int* length, TiXmlE
}
// Now try to match it.
- for (i=0; i<NUM_ENTITY; ++i)
- {
- if (strncmp(entity[i].str, p, entity[i].strLength) == 0)
- {
+ for (i = 0; i < NUM_ENTITY; ++i) {
+ if (strncmp(entity[i].str, p, entity[i].strLength) == 0) {
assert(mir_strlen(entity[i].str) == entity[i].strLength);
*value = entity[i].chr;
*length = 1;
@@ -512,29 +486,26 @@ const char* TiXmlBase::GetEntity(const char* p, char* value, int* length, TiXmlE
*value = *p; // Don't put back the last one, since we return it!
//*length = 1; // Leave unrecognized entities - this doesn't really work.
// Just writes strange XML.
- return p+1;
+ return p + 1;
}
bool TiXmlBase::StringEqual(const char* p,
- const char* tag,
- bool ignoreCase,
- TiXmlEncoding encoding)
+ const char* tag,
+ bool ignoreCase,
+ TiXmlEncoding encoding)
{
assert(p);
assert(tag);
- if (!p || !*p)
- {
+ if (!p || !*p) {
assert(0);
return false;
}
const char* q = p;
- if (ignoreCase)
- {
- while (*q && *tag && ToLower(*q, encoding) == ToLower(*tag, encoding))
- {
+ if (ignoreCase) {
+ while (*q && *tag && ToLower(*q, encoding) == ToLower(*tag, encoding)) {
++q;
++tag;
}
@@ -542,10 +513,8 @@ bool TiXmlBase::StringEqual(const char* p,
if (*tag == 0)
return true;
}
- else
- {
- while (*q && *tag && *q == *tag)
- {
+ else {
+ while (*q && *tag && *q == *tag) {
++q;
++tag;
}
@@ -556,53 +525,46 @@ bool TiXmlBase::StringEqual(const char* p,
return false;
}
-const char* TiXmlBase::ReadText( const char* p,
- TIXML_STRING * text,
- bool trimWhiteSpace,
- const char* endTag,
- bool caseInsensitive,
- TiXmlEncoding encoding)
+const char* TiXmlBase::ReadText(const char* p,
+ TIXML_STRING * text,
+ bool trimWhiteSpace,
+ const char* endTag,
+ bool caseInsensitive,
+ TiXmlEncoding encoding)
{
- *text = "";
- if ( !trimWhiteSpace // certain tags always keep whitespace
- || !condenseWhiteSpace) // if true, whitespace is always kept
+ *text = "";
+ if (!trimWhiteSpace // certain tags always keep whitespace
+ || !condenseWhiteSpace) // if true, whitespace is always kept
{
// Keep all the white space.
- while ( p && *p
- && !StringEqual(p, endTag, caseInsensitive, encoding)
- )
- {
+ while (p && *p
+ && !StringEqual(p, endTag, caseInsensitive, encoding)
+ ) {
int len;
char cArr[4] = { 0, 0, 0, 0 };
p = GetChar(p, cArr, &len, encoding);
text->append(cArr, len);
}
}
- else
- {
+ else {
bool whitespace = false;
// Remove leading white space:
p = SkipWhiteSpace(p, encoding);
- while ( p && *p
- && !StringEqual(p, endTag, caseInsensitive, encoding))
- {
- if (*p == '\r' || *p == '\n')
- {
+ while (p && *p
+ && !StringEqual(p, endTag, caseInsensitive, encoding)) {
+ if (*p == '\r' || *p == '\n') {
whitespace = true;
++p;
}
- else if (IsWhiteSpace(*p))
- {
+ else if (IsWhiteSpace(*p)) {
whitespace = true;
++p;
}
- else
- {
+ else {
// If we've found whitespace, add it before the
// new character. Any whitespace just becomes a space.
- if (whitespace)
- {
+ if (whitespace) {
(*text) += ' ';
whitespace = false;
}
@@ -630,35 +592,29 @@ void TiXmlDocument::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
// This "pre-streaming" will never read the closing ">" so the
// sub-tag can orient itself.
- if (!StreamTo(in, '<', tag))
- {
+ if (!StreamTo(in, '<', tag)) {
SetError(TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- while (in->good())
- {
- int tagIndex = (int) tag->length();
- while (in->good() && in->peek() != '>')
- {
+ while (in->good()) {
+ int tagIndex = (int)tag->length();
+ while (in->good() && in->peek() != '>') {
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
break;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
}
- if (in->good())
- {
+ if (in->good()) {
// We now have something we presume to be a node of
// some sort. Identify it, and call the node to
// continue streaming.
TiXmlNode* node = Identify(tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING);
- if (node)
- {
+ if (node) {
node->StreamIn(in, tag);
bool isElement = node->ToElement() != 0;
delete node;
@@ -666,13 +622,11 @@ void TiXmlDocument::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
// If this is the root element, we're done. Parsing will be
// done by the >> operator.
- if (isElement)
- {
+ if (isElement) {
return;
}
}
- else
- {
+ else {
SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
@@ -691,8 +645,7 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm
// Parse away, at the document level. Since a document
// contains nothing but other tags, most of what happens
// here is skipping white space.
- if (!p || !*p)
- {
+ if (!p || !*p) {
SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return 0;
}
@@ -701,56 +654,47 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm
// before the while space skip, so that parsing
// starts from the pointer we are given.
location.Clear();
- if (prevData)
- {
+ if (prevData) {
location.row = prevData->cursor.row;
location.col = prevData->cursor.col;
}
- else
- {
+ else {
location.row = 0;
location.col = 0;
}
TiXmlParsingData data(p, TabSize(), location.row, location.col);
location = data.Cursor();
- if (encoding == TIXML_ENCODING_UNKNOWN)
- {
+ if (encoding == TIXML_ENCODING_UNKNOWN) {
// Check for the Microsoft UTF-8 lead bytes.
const unsigned char* pU = (const unsigned char*)p;
- if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
- && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
- && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2)
- {
+ if (*(pU + 0) && *(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) && *(pU + 1) == TIXML_UTF_LEAD_1
+ && *(pU + 2) && *(pU + 2) == TIXML_UTF_LEAD_2) {
encoding = TIXML_ENCODING_UTF8;
useMicrosoftBOM = true;
}
}
- p = SkipWhiteSpace(p, encoding);
- if (!p)
- {
+ p = SkipWhiteSpace(p, encoding);
+ if (!p) {
SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return 0;
}
- while (p && *p)
- {
+ while (p && *p) {
TiXmlNode* node = Identify(p, encoding);
- if (node)
- {
+ if (node) {
p = node->Parse(p, &data, encoding);
LinkEndChild(node);
}
- else
- {
+ else {
break;
}
// Did we get encoding info?
- if ( encoding == TIXML_ENCODING_UNKNOWN
- && node->ToDeclaration())
- {
+ if (encoding == TIXML_ENCODING_UNKNOWN
+ && node->ToDeclaration()) {
TiXmlDeclaration* dec = node->ToDeclaration();
const char* enc = dec->Encoding();
assert(enc);
@@ -761,7 +705,7 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm
encoding = TIXML_ENCODING_UTF8;
else if (StringEqual(enc, "UTF8", true, TIXML_ENCODING_UNKNOWN))
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
- else
+ else
encoding = TIXML_ENCODING_LEGACY;
}
@@ -779,19 +723,18 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm
}
void TiXmlDocument::SetError(int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding)
-{
+{
// The first error in a chain is more accurate - don't set again!
if (error)
return;
assert(err > 0 && err < TIXML_ERROR_STRING_COUNT);
- error = true;
+ error = true;
errorId = err;
- errorDesc = errorString[ errorId ];
+ errorDesc = errorString[errorId];
errorLocation.Clear();
- if (pError && data)
- {
+ if (pError && data) {
data->Stamp(pError, encoding);
errorLocation = data->Cursor();
}
@@ -803,16 +746,14 @@ TiXmlNode* TiXmlNode::Identify(const char* p, TiXmlEncoding encoding)
TiXmlNode* returnNode = 0;
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p || *p != '<')
- {
+ if (!p || !*p || *p != '<') {
return 0;
}
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
return 0;
}
@@ -828,59 +769,51 @@ TiXmlNode* TiXmlNode::Identify(const char* p, TiXmlEncoding encoding)
const char* dtdHeader = { "<!" };
const char* cdataHeader = { "<![CDATA[" };
- if (StringEqual(p, xmlHeader, true, encoding))
- {
+ if (StringEqual(p, xmlHeader, true, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Declaration\n");
+ TIXML_LOG("XML parsing Declaration\n");
#endif
returnNode = new TiXmlDeclaration();
}
- else if (StringEqual(p, commentHeader, false, encoding))
- {
+ else if (StringEqual(p, commentHeader, false, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Comment\n");
+ TIXML_LOG("XML parsing Comment\n");
#endif
returnNode = new TiXmlComment();
}
- else if (StringEqual(p, cdataHeader, false, encoding))
- {
+ else if (StringEqual(p, cdataHeader, false, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing CDATA\n");
+ TIXML_LOG("XML parsing CDATA\n");
#endif
TiXmlText* text = new TiXmlText("");
text->SetCDATA(true);
returnNode = text;
}
- else if (StringEqual(p, dtdHeader, false, encoding))
- {
+ else if (StringEqual(p, dtdHeader, false, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Unknown(1)\n");
+ TIXML_LOG("XML parsing Unknown(1)\n");
#endif
returnNode = new TiXmlUnknown();
}
- else if ( IsAlpha(*(p+1), encoding)
- || *(p+1) == '_')
- {
+ else if (IsAlpha(*(p + 1), encoding)
+ || *(p + 1) == '_') {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Element\n");
+ TIXML_LOG("XML parsing Element\n");
#endif
returnNode = new TiXmlElement("");
}
- else
- {
+ else {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Unknown(2)\n");
+ TIXML_LOG("XML parsing Unknown(2)\n");
#endif
returnNode = new TiXmlUnknown();
}
- if (returnNode)
- {
+ if (returnNode) {
// Set the parent, so it can report errors
returnNode->parent = this;
}
- else
- {
+ else {
if (doc)
doc->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN);
}
@@ -889,22 +822,20 @@ TiXmlNode* TiXmlNode::Identify(const char* p, TiXmlEncoding encoding)
#ifdef TIXML_USE_STL
-void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
+void TiXmlElement::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
// We're called with some amount of pre-parsing. That is, some of "this"
// element is in "tag". Go ahead and stream to the closing ">"
- while (in->good())
- {
+ while (in->good()) {
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c ;
-
+ (*tag) += (char)c;
+
if (c == '>')
break;
}
@@ -914,25 +845,21 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
// If not, identify and stream.
- if ( tag->at(tag->length() - 1) == '>'
- && tag->at(tag->length() - 2) == '/')
- {
+ if (tag->at(tag->length() - 1) == '>'
+ && tag->at(tag->length() - 2) == '/') {
// All good!
return;
}
- else if (tag->at(tag->length() - 1) == '>')
- {
+ else if (tag->at(tag->length() - 1) == '>') {
// There is more. Could be:
// text
// closing tag
// another node.
- for (;;)
- {
+ for (;;) {
StreamWhiteSpace(in, tag);
// Do we have text?
- if (in->good() && in->peek() != '<')
- {
+ if (in->good() && in->peek() != '<') {
// Yep, text.
TiXmlText text("");
text.StreamIn(in, tag);
@@ -946,33 +873,30 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
// We should be at a "<", regardless.
if (!in->good()) return;
assert(in->peek() == '<');
- int tagIndex = (int) tag->length();
+ int tagIndex = (int)tag->length();
bool closingTag = false;
bool firstCharFound = false;
- for (;;)
- {
+ for (;;) {
if (!in->good())
return;
int c = in->peek();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
-
+
if (c == '>')
break;
- *tag += (char) c;
+ *tag += (char)c;
in->get();
- if (!firstCharFound && c != '<' && !IsWhiteSpace(c))
- {
+ if (!firstCharFound && c != '<' && !IsWhiteSpace(c)) {
firstCharFound = true;
if (c == '/')
closingTag = true;
@@ -980,27 +904,24 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
}
// If it was a closing tag, then read in the closing '>' to clean up the input stream.
// If it was not, the streaming will be done by the tag.
- if (closingTag)
- {
+ if (closingTag) {
if (!in->good())
return;
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
assert(c == '>');
- *tag += (char) c;
+ *tag += (char)c;
// We are done, once we've found our closing tag.
return;
}
- else
- {
+ else {
// If not a closing tag, id it, and stream.
const char* tagloc = tag->c_str() + tagIndex;
TiXmlNode* node = Identify(tagloc, TIXML_DEFAULT_ENCODING);
@@ -1022,64 +943,55 @@ const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco
p = SkipWhiteSpace(p, encoding);
TiXmlDocument* document = GetDocument();
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding);
return 0;
}
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
- if (*p != '<')
- {
+ if (*p != '<') {
if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, p, data, encoding);
return 0;
}
- p = SkipWhiteSpace(p+1, encoding);
+ p = SkipWhiteSpace(p + 1, encoding);
// Read the name.
const char* pErr = p;
- p = ReadName(p, &value, encoding);
- if (!p || !*p)
- {
+ p = ReadName(p, &value, encoding);
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding);
return 0;
}
- TIXML_STRING endTag ("</");
+ TIXML_STRING endTag("</");
endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty
// tag or an end tag.
- while (p && *p)
- {
+ while (p && *p) {
pErr = p;
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding);
return 0;
}
- if (*p == '/')
- {
+ if (*p == '/') {
++p;
// Empty tag.
- if (*p != '>')
- {
- if (document) document->SetError(TIXML_ERROR_PARSING_EMPTY, p, data, encoding);
+ if (*p != '>') {
+ if (document) document->SetError(TIXML_ERROR_PARSING_EMPTY, p, data, encoding);
return 0;
}
- return (p+1);
+ return (p + 1);
}
- else if (*p == '>')
- {
+ else if (*p == '>') {
// Done with attributes (if there were any.)
// Read the value -- which can include other
// elements -- read the end tag, and return.
@@ -1089,33 +1001,28 @@ const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco
return 0;
// We should find the end tag now
- if (StringEqual(p, endTag.c_str(), false, encoding))
- {
+ if (StringEqual(p, endTag.c_str(), false, encoding)) {
p += endTag.length();
return p;
}
- else
- {
+ else {
if (document) document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
return 0;
}
}
- else
- {
+ else {
// Try to read an attribute:
TiXmlAttribute* attrib = new TiXmlAttribute();
- if (!attrib)
- {
+ if (!attrib) {
if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding);
return 0;
}
attrib->SetDocument(document);
- const char* pErr = p;
+ pErr = p;
p = attrib->Parse(p, data, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding);
delete attrib;
return 0;
@@ -1123,8 +1030,7 @@ const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco
// Handle the strange case of double attributes:
TiXmlAttribute* node = attributeSet.Find(attrib->NameTStr());
- if (node)
- {
+ if (node) {
node->SetValue(attrib->Value());
delete attrib;
return 0;
@@ -1145,25 +1051,20 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml
const char* pWithWhiteSpace = p;
p = SkipWhiteSpace(p, encoding);
- while (p && *p)
- {
- if (*p != '<')
- {
+ while (p && *p) {
+ if (*p != '<') {
// Take what we have, make a text element.
TiXmlText* textNode = new TiXmlText("");
- if (!textNode)
- {
+ if (!textNode) {
if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding);
- return 0;
+ return 0;
}
- if (TiXmlBase::IsWhiteSpaceCondensed())
- {
+ if (TiXmlBase::IsWhiteSpaceCondensed()) {
p = textNode->Parse(p, data, encoding);
}
- else
- {
+ else {
// Special case: we want to keep the white space
// so that leading spaces aren't removed.
p = textNode->Parse(pWithWhiteSpace, data, encoding);
@@ -1173,26 +1074,21 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml
LinkEndChild(textNode);
else
delete textNode;
- }
- else
- {
+ }
+ else {
// We hit a '<'
// Have we hit a new element or an end tag? This could also be
// a TiXmlText in the "CDATA" style.
- if (StringEqual(p, "</", false, encoding))
- {
+ if (StringEqual(p, "</", false, encoding)) {
return p;
}
- else
- {
+ else {
TiXmlNode* node = Identify(p, encoding);
- if (node)
- {
+ if (node) {
p = node->Parse(p, data, encoding);
LinkEndChild(node);
- }
- else
- {
+ }
+ else {
return 0;
}
}
@@ -1201,10 +1097,9 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml
p = SkipWhiteSpace(p, encoding);
}
- if (!p)
- {
+ if (!p) {
if (document) document->SetError(TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding);
- }
+ }
return p;
}
@@ -1212,22 +1107,19 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml
#ifdef TIXML_USE_STL
void TiXmlUnknown::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- while (in->good())
- {
- int c = in->get();
- if (c <= 0)
- {
+ while (in->good()) {
+ int c = in->get();
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>')
- {
+ if (c == '>') {
// All is well.
- return;
+ return;
}
}
}
@@ -1239,56 +1131,49 @@ const char* TiXmlUnknown::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco
TiXmlDocument* document = GetDocument();
p = SkipWhiteSpace(p, encoding);
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
- if (!p || !*p || *p != '<')
- {
+ if (!p || !*p || *p != '<') {
if (document) document->SetError(TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding);
return 0;
}
++p;
- value = "";
+ value = "";
- while (p && *p && *p != '>')
- {
+ while (p && *p && *p != '>') {
value += *p;
++p;
}
- if (!p)
- {
+ if (!p) {
if (document) document->SetError(TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding);
}
if (*p == '>')
- return p+1;
+ return p + 1;
return p;
}
#ifdef TIXML_USE_STL
void TiXmlComment::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- while (in->good())
- {
- int c = in->get();
- if (c <= 0)
- {
+ while (in->good()) {
+ int c = in->get();
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>'
- && tag->at(tag->length() - 2) == '-'
- && tag->at(tag->length() - 3) == '-')
- {
+ if (c == '>'
+ && tag->at(tag->length() - 2) == '-'
+ && tag->at(tag->length() - 3) == '-') {
// All is well.
- return;
+ return;
}
}
}
@@ -1302,16 +1187,14 @@ const char* TiXmlComment::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco
p = SkipWhiteSpace(p, encoding);
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
const char* startTag = "<!--";
- const char* endTag = "-->";
+ const char* endTag = "-->";
- if (!StringEqual(p, startTag, false, encoding))
- {
+ if (!StringEqual(p, startTag, false, encoding)) {
document->SetError(TIXML_ERROR_PARSING_COMMENT, p, data, encoding);
return 0;
}
@@ -1326,63 +1209,56 @@ const char* TiXmlAttribute::Parse(const char* p, TiXmlParsingData* data, TiXmlEn
p = SkipWhiteSpace(p, encoding);
if (!p || !*p) return 0;
-// int tabsize = 4;
-// if (document)
-// tabsize = document->TabSize();
+ // int tabsize = 4;
+ // if (document)
+ // tabsize = document->TabSize();
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
// Read the name, the '=' and the value.
const char* pErr = p;
p = ReadName(p, &name, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding);
return 0;
}
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p || *p != '=')
- {
+ if (!p || !*p || *p != '=') {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding);
return 0;
}
++p; // skip '='
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding);
return 0;
}
-
+
const char* end;
const char SINGLE_QUOTE = '\'';
const char DOUBLE_QUOTE = '\"';
- if (*p == SINGLE_QUOTE)
- {
+ if (*p == SINGLE_QUOTE) {
++p;
end = "\'"; // single quote in string
p = ReadText(p, &value, false, end, false, encoding);
}
- else if (*p == DOUBLE_QUOTE)
- {
+ else if (*p == DOUBLE_QUOTE) {
++p;
end = "\""; // double quote in string
p = ReadText(p, &value, false, end, false, encoding);
}
- else
- {
+ else {
// All attribute values should be in single or double quotes.
// But this is such a common error that the parser will try
// its best, even without them.
value = "";
- while ( p && *p // existence
- && !IsWhiteSpace(*p) && *p != '\n' && *p != '\r' // whitespace
- && *p != '/' && *p != '>') // tag end
+ while (p && *p // existence
+ && !IsWhiteSpace(*p) && *p != '\n' && *p != '\r' // whitespace
+ && *p != '/' && *p != '>') // tag end
{
if (*p == SINGLE_QUOTE || *p == DOUBLE_QUOTE) {
// [ 1451649 ] Attribute values with trailing quotes not handled correctly
@@ -1401,43 +1277,37 @@ const char* TiXmlAttribute::Parse(const char* p, TiXmlParsingData* data, TiXmlEn
#ifdef TIXML_USE_STL
void TiXmlText::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- if (cdata)
- {
- int c = in->get();
- if (c <= 0)
- {
+ if (cdata) {
+ int c = in->get();
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>'
- && tag->at(tag->length() - 2) == ']'
- && tag->at(tag->length() - 3) == ']')
- {
+ if (c == '>'
+ && tag->at(tag->length() - 2) == ']'
+ && tag->at(tag->length() - 3) == ']') {
// All is well.
- return;
+ return;
}
}
- else
- {
- while (in->good())
- {
- int c = in->peek();
+ else {
+ while (in->good()) {
+ int c = in->peek();
if (c == '<')
return;
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
in->get();
}
}
@@ -1449,47 +1319,42 @@ const char* TiXmlText::Parse(const char* p, TiXmlParsingData* data, TiXmlEncodin
value = "";
TiXmlDocument* document = GetDocument();
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
const char* const startTag = "<![CDATA[";
- const char* const endTag = "]]>";
+ const char* const endTag = "]]>";
- if (cdata || StringEqual(p, startTag, false, encoding))
- {
+ if (cdata || StringEqual(p, startTag, false, encoding)) {
cdata = true;
- if (!StringEqual(p, startTag, false, encoding))
- {
+ if (!StringEqual(p, startTag, false, encoding)) {
document->SetError(TIXML_ERROR_PARSING_CDATA, p, data, encoding);
return 0;
}
p += mir_strlen(startTag);
// Keep all the white space, ignore the encoding, etc.
- while ( p && *p
- && !StringEqual(p, endTag, false, encoding)
- )
- {
+ while (p && *p
+ && !StringEqual(p, endTag, false, encoding)
+ ) {
value += *p;
++p;
}
- TIXML_STRING dummy;
+ TIXML_STRING dummy;
p = ReadText(p, &dummy, false, endTag, false, encoding);
return p;
}
- else
- {
+ else {
bool ignoreWhite = true;
const char* end = "<";
p = ReadText(p, &value, ignoreWhite, end, false, encoding);
if (p)
- return p-1; // don't truncate the '<'
+ return p - 1; // don't truncate the '<'
return 0;
}
}
@@ -1497,20 +1362,17 @@ const char* TiXmlText::Parse(const char* p, TiXmlParsingData* data, TiXmlEncodin
#ifdef TIXML_USE_STL
void TiXmlDeclaration::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- while (in->good())
- {
+ while (in->good()) {
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>')
- {
+ if (c == '>') {
// All is well.
return;
}
@@ -1524,13 +1386,11 @@ const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXml
// Find the beginning, find the end, and look for
// the stuff in-between.
TiXmlDocument* document = GetDocument();
- if (!p || !*p || !StringEqual(p, "<?xml", true, _encoding))
- {
+ if (!p || !*p || !StringEqual(p, "<?xml", true, _encoding)) {
if (document) document->SetError(TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding);
return 0;
}
- if (data)
- {
+ if (data) {
data->Stamp(p, _encoding);
location = data->Cursor();
}
@@ -1540,35 +1400,29 @@ const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXml
encoding = "";
standalone = "";
- while (p && *p)
- {
- if (*p == '>')
- {
+ while (p && *p) {
+ if (*p == '>') {
++p;
return p;
}
p = SkipWhiteSpace(p, _encoding);
- if (StringEqual(p, "version", true, _encoding))
- {
+ if (StringEqual(p, "version", true, _encoding)) {
TiXmlAttribute attrib;
- p = attrib.Parse(p, data, _encoding);
+ p = attrib.Parse(p, data, _encoding);
version = attrib.Value();
}
- else if (StringEqual(p, "encoding", true, _encoding))
- {
+ else if (StringEqual(p, "encoding", true, _encoding)) {
TiXmlAttribute attrib;
- p = attrib.Parse(p, data, _encoding);
+ p = attrib.Parse(p, data, _encoding);
encoding = attrib.Value();
}
- else if (StringEqual(p, "standalone", true, _encoding))
- {
+ else if (StringEqual(p, "standalone", true, _encoding)) {
TiXmlAttribute attrib;
- p = attrib.Parse(p, data, _encoding);
+ p = attrib.Parse(p, data, _encoding);
standalone = attrib.Value();
}
- else
- {
+ else {
// Read over whatever it is.
while (p && *p && *p != '>' && !IsWhiteSpace(*p))
++p;
@@ -1579,9 +1433,8 @@ const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXml
bool TiXmlText::Blank() const
{
- for (unsigned i=0; i<value.length(); i++)
+ for (unsigned i = 0; i < value.length(); i++)
if (!IsWhiteSpace(value[i]))
return false;
return true;
}
-
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp
index 2898d3980a..7b5ed883ec 100644
--- a/plugins/UserInfoEx/src/mir_db.cpp
+++ b/plugins/UserInfoEx/src/mir_db.cpp
@@ -386,23 +386,26 @@ BYTE ConvertString(DBVARIANT* dbv, const BYTE destType)
if (dbv == NULL)
return 1;
- LPSTR tmpBuf;
switch (dbv->type) {
// source value is of type "ascii"
case DBVT_ASCIIZ:
switch (destType) {
// destination type is "utf8"
case DBVT_UTF8:
- tmpBuf = mir_utf8encode(dbv->pszVal);
- mir_free(dbv->pszVal);
- dbv->pszVal = tmpBuf;
+ {
+ LPSTR tmpBuf = mir_utf8encode(dbv->pszVal);
+ mir_free(dbv->pszVal);
+ dbv->pszVal = tmpBuf;
+ }
dbv->type = (dbv->pszVal) ? destType : DBVT_DELETED;
break;
// destination type is "wchar"
case DBVT_WCHAR:
- LPWSTR tmpBuf = mir_a2u(dbv->pszVal);
- mir_free(dbv->pszVal);
- dbv->pwszVal = tmpBuf;
+ {
+ LPWSTR tmpBuf = mir_a2u(dbv->pszVal);
+ mir_free(dbv->pszVal);
+ dbv->pwszVal = tmpBuf;
+ }
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
}
break;
@@ -425,19 +428,23 @@ BYTE ConvertString(DBVARIANT* dbv, const BYTE destType)
break;
// source value is of type "wchar"
case DBVT_WCHAR:
- switch (destType) {
- // destination type is "ascii"
+ switch (destType) {
+ // destination type is "ascii"
case DBVT_ASCIIZ:
- tmpBuf = mir_u2a(dbv->pwszVal);
- mir_free(dbv->pwszVal);
- dbv->pszVal = tmpBuf;
+ {
+ LPSTR tmpBuf = mir_u2a(dbv->pwszVal);
+ mir_free(dbv->pwszVal);
+ dbv->pszVal = tmpBuf;
+ }
dbv->type = (dbv->pszVal) ? destType : DBVT_DELETED;
break;
- // destination type is "utf8"
+ // destination type is "utf8"
case DBVT_UTF8:
- tmpBuf = mir_utf8encodeW(dbv->pwszVal);
- mir_free(dbv->pwszVal);
- dbv->pszVal = tmpBuf;
+ {
+ LPSTR tmpBuf = mir_utf8encodeW(dbv->pwszVal);
+ mir_free(dbv->pwszVal);
+ dbv->pszVal = tmpBuf;
+ }
dbv->type = (dbv->pszVal) ? destType : DBVT_DELETED;
}
}
@@ -459,8 +466,9 @@ BYTE dbv2String(DBVARIANT* dbv, const BYTE destType)
if (dbv == NULL)
return 1;
- switch (destType) {
+ WCHAR wbuf[32];
CHAR buf[32];
+ switch (destType) {
// destination type is "utf8" or "ascii"
case DBVT_ASCIIZ:
case DBVT_UTF8:
@@ -494,23 +502,22 @@ BYTE dbv2String(DBVARIANT* dbv, const BYTE destType)
// destination type is "wchar"
case DBVT_WCHAR:
switch (dbv->type) {
- WCHAR buf[32];
// source value is of type "byte"
case DBVT_BYTE:
- _ultow(dbv->bVal, buf, 10);
- dbv->pwszVal = mir_wstrdup(buf);
+ _ultow(dbv->bVal, wbuf, 10);
+ dbv->pwszVal = mir_wstrdup(wbuf);
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
break;
// source value is of type "word"
case DBVT_WORD:
- _ultow(dbv->wVal, buf, 10);
- dbv->pwszVal = mir_wstrdup(buf);
+ _ultow(dbv->wVal, wbuf, 10);
+ dbv->pwszVal = mir_wstrdup(wbuf);
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
break;
// source value is of type "dword"
case DBVT_DWORD:
- _ultow(dbv->dVal, buf, 10);
- dbv->pwszVal = mir_wstrdup(buf);
+ _ultow(dbv->dVal, wbuf, 10);
+ dbv->pwszVal = mir_wstrdup(wbuf);
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
break;
// source value is of any string type
diff --git a/plugins/UserInfoEx/src/psp_anniversary.cpp b/plugins/UserInfoEx/src/psp_anniversary.cpp
index e634756e2f..8683a347c7 100644
--- a/plugins/UserInfoEx/src/psp_anniversary.cpp
+++ b/plugins/UserInfoEx/src/psp_anniversary.cpp
@@ -248,7 +248,6 @@ INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
case RADIO_REMIND1:
case RADIO_REMIND2:
case RADIO_REMIND3:
- CAnnivEditCtrl *pDateCtrl = CAnnivEditCtrl::GetObj(hDlg, EDIT_ANNIVERSARY_DATE);
if (PtrIsValid(pDateCtrl) && HIWORD(wParam) == BN_CLICKED)
pDateCtrl->OnReminderChecked();
return FALSE;