version 1.25, 2003/08/15 01:17:59
|
version 1.26, 2003/09/03 18:56:45
|
|
|
{ "'", 6, '\'' } | { "'", 6, '\'' } |
}; | }; |
| |
|
|
|
// Implements a check for a whitespace character, without calling |
|
// isspace( ). The isspace( ) function is locale-sensitive, |
|
// and incorrectly flags some chars above 0x7f as whitespace. This |
|
// causes the XmlParser to incorrectly parse UTF-8 data. |
|
// |
|
// Section 2.3 of XML 1.0 Standard (http://www.w3.org/TR/REC-xml) |
|
// defines white space as: |
|
// S ::= (#x20 | #x9 | #xD | #xA)+ |
|
static int _isspace(char c) |
|
{ |
|
if (c == ' ' || c == '\r' || c == '\t' || c == '\n') |
|
return 1; |
|
return 0; |
|
} |
|
|
|
|
static Uint32 _REFERENCES_SIZE = (sizeof(_references) / sizeof(_references[0])); | static Uint32 _REFERENCES_SIZE = (sizeof(_references) / sizeof(_references[0])); |
| |
// Remove all redundant spaces from the given string: | // Remove all redundant spaces from the given string: |
|
|
| |
// Remove leading spaces: | // Remove leading spaces: |
| |
while (isspace(*p)) |
while (_isspace(*p)) |
p++; | p++; |
| |
if (p != text) | if (p != text) |
|
|
{ | { |
// Advance to the next space: | // Advance to the next space: |
| |
while (*p && !isspace(*p)) |
while (*p && !_isspace(*p)) |
p++; | p++; |
| |
if (!*p) | if (!*p) |
|
|
| |
char* q = p++; | char* q = p++; |
| |
while (isspace(*p)) |
while (_isspace(*p)) |
p++; | p++; |
| |
// Discard trailing spaces (if we are at the end): | // Discard trailing spaces (if we are at the end): |
|
|
| |
void XmlParser::_skipWhitespace(char*& p) | void XmlParser::_skipWhitespace(char*& p) |
{ | { |
while (*p && isspace(*p)) |
while (*p && _isspace(*p)) |
{ | { |
if (*p == '\n') | if (*p == '\n') |
_line++; | _line++; |
|
|
| |
// The next character must be a space: | // The next character must be a space: |
| |
if (isspace(*p)) |
if (_isspace(*p)) |
{ | { |
*p++ = '\0'; | *p++ = '\0'; |
_skipWhitespace(p); | _skipWhitespace(p); |
|
|
| |
// The next character must be a space: | // The next character must be a space: |
| |
if (isspace(*p)) |
if (_isspace(*p)) |
{ | { |
*p++ = '\0'; | *p++ = '\0'; |
_skipWhitespace(p); | _skipWhitespace(p); |
|
|
{ | { |
// The next thing must a space or a "?>": | // The next thing must a space or a "?>": |
| |
if (!(p[0] == '?' && p[1] == '>') && !isspace(*p)) |
if (!(p[0] == '?' && p[1] == '>') && !_isspace(*p)) |
{ | { |
throw XmlException( | throw XmlException( |
XmlException::BAD_ATTRIBUTE_VALUE, _line); | XmlException::BAD_ATTRIBUTE_VALUE, _line); |
} | } |
} | } |
else if (!(*p == '>' || (p[0] == '/' && p[1] == '>') || isspace(*p))) |
else if (!(*p == '>' || (p[0] == '/' && p[1] == '>') || _isspace(*p))) |
{ | { |
// The next thing must be a space or a '>': | // The next thing must be a space or a '>': |
| |
|
|
{ | { |
first = str; | first = str; |
| |
while (isspace(*first)) |
while (_isspace(*first)) |
first++; | first++; |
| |
if (!*first) | if (!*first) |
|
|
| |
last = first + strlen(first); | last = first + strlen(first); |
| |
while (last != first && isspace(last[-1])) |
while (last != first && _isspace(last[-1])) |
last--; | last--; |
} | } |
| |