(file) Return to XmlParser.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/XmlParser.cpp between version 1.18.6.1 and 1.26

version 1.18.6.1, 2003/07/29 15:08:29 version 1.26, 2003/09/03 18:56:45
Line 139 
Line 139 
     { "'", 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:
Line 151 
Line 168 
  
     // Remove leading spaces:     // Remove leading spaces:
  
     while (isspace(*p))      while (_isspace(*p))
         p++;         p++;
  
     if (p != text)     if (p != text)
Line 165 
Line 182 
     {     {
         // Advance to the next space:         // Advance to the next space:
  
         while (*p && !isspace(*p))          while (*p && !_isspace(*p))
             p++;             p++;
  
         if (!*p)         if (!*p)
Line 175 
Line 192 
  
         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):
Line 247 
Line 264 
     "Common.XmlParser.SEMANTIC_ERROR"     "Common.XmlParser.SEMANTIC_ERROR"
 }; };
  
 // l10n TODO replace _formMessage with the commented one and uncomment  // l10n replace _formMessage (comment out the old one)
 // the new constructors  
 /* /*
 static String _formMessage(Uint32 code, Uint32 line, const String& message) static String _formMessage(Uint32 code, Uint32 line, const String& message)
 { {
Line 312 
Line 328 
     MessageLoaderParms& msgParms)     MessageLoaderParms& msgParms)
     : Exception(_formPartialMessage(code, lineNumber))     : Exception(_formPartialMessage(code, lineNumber))
 { {
           if (msgParms.default_msg.size())
       {
           msgParms.default_msg = ": " + msgParms.default_msg;
       }
         _rep->message.append(MessageLoader::getMessage(msgParms));         _rep->message.append(MessageLoader::getMessage(msgParms));
 } }
  
Line 474 
Line 494 
  
 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++;
Line 485 
Line 505 
  
 Boolean XmlParser::_getElementName(char*& p) Boolean XmlParser::_getElementName(char*& p)
 { {
     if (!isalpha(*p) && *p != '_')      if (!(((*p >= 'A') && (*p <= 'Z')) ||
             ((*p >= 'a') && (*p <= 'z')) ||
             (*p == '_')))
         throw XmlException(XmlException::BAD_START_TAG, _line);         throw XmlException(XmlException::BAD_START_TAG, _line);
       p++;
  
     while (*p &&      while ((*p) &&
         (isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.'))             (((*p >= 'A') && (*p <= 'Z')) ||
               ((*p >= 'a') && (*p <= 'z')) ||
               ((*p >= '0') && (*p <= '9')) ||
               *p == '_' || *p == '-' || *p == ':' || *p == '.'))
         p++;         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);
Line 513 
Line 539 
 { {
     openCloseElement = false;     openCloseElement = false;
  
     if (!isalpha(*p) && *p != '_')      if (!(((*p >= 'A') && (*p <= 'Z')) ||
             ((*p >= 'a') && (*p <= 'z')) ||
             (*p == '_')))
         throw XmlException(XmlException::BAD_START_TAG, _line);         throw XmlException(XmlException::BAD_START_TAG, _line);
       p++;
  
     while (*p &&      while ((*p) &&
         (isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.'))             (((*p >= 'A') && (*p <= 'Z')) ||
               ((*p >= 'a') && (*p <= 'z')) ||
               ((*p >= '0') && (*p <= '9')) ||
               *p == '_' || *p == '-' || *p == ':' || *p == '.'))
         p++;         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);
Line 547 
Line 579 
  
 void XmlParser::_getAttributeNameAndEqual(char*& p) void XmlParser::_getAttributeNameAndEqual(char*& p)
 { {
     if (!isalpha(*p) && *p != '_')      if (!(((*p >= 'A') && (*p <= 'Z')) ||
             ((*p >= 'a') && (*p <= 'z')) ||
             (*p == '_')))
         throw XmlException(XmlException::BAD_ATTRIBUTE_NAME, _line);         throw XmlException(XmlException::BAD_ATTRIBUTE_NAME, _line);
       p++;
  
     while (*p &&      while ((*p) &&
         (isalnum(*p) || *p == '_' || *p == '-' || *p == ':' || *p == '.'))             (((*p >= 'A') && (*p <= 'Z')) ||
               ((*p >= 'a') && (*p <= 'z')) ||
               ((*p >= '0') && (*p <= '9')) ||
               *p == '_' || *p == '-' || *p == ':' || *p == '.'))
         p++;         p++;
  
     char* term = p;     char* term = p;
Line 867 
Line 905 
  
         return;         return;
     }     }
     else if (isalpha(*p) || *p == '_')      else if ((((*p >= 'A') && (*p <= 'Z')) ||
                 ((*p >= 'a') && (*p <= 'z')) ||
                 (*p == '_')))
     {     {
         entry.type = XmlEntry::START_TAG;         entry.type = XmlEntry::START_TAG;
         entry.text = p;         entry.text = p;
Line 924 
Line 964 
         {         {
             // 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 '>':
  
Line 1010 
Line 1050 
 { {
     first = str;     first = str;
  
     while (isspace(*first))      while (_isspace(*first))
         first++;         first++;
  
     if (!*first)     if (!*first)
Line 1021 
Line 1061 
  
     last = first + strlen(first);     last = first + strlen(first);
  
     while (last != first && isspace(last[-1]))      while (last != first && _isspace(last[-1]))
         last--;         last--;
 } }
  
Line 1091 
Line 1131 
     if (!getAttributeValue(name, tmp))     if (!getAttributeValue(name, tmp))
         return false;         return false;
  
     value = tmp;      value = String(tmp,STRING_FLAG_UTF8);
     return true;     return true;
 } }
  


Legend:
Removed from v.1.18.6.1  
changed lines
  Added in v.1.26

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2