(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.46 and 1.46.4.3

version 1.46, 2008/06/18 18:12:00 version 1.46.4.3, 2009/02/09 11:36:51
Line 375 
Line 375 
 #pragma optimize( "", on ) #pragma optimize( "", on )
 #endif #endif
  
 static inline int _getCharRef(char*& p, bool hex)  static inline int _getCharRef(char*& p)
 { {
     char* end;     char* end;
     unsigned long ch;     unsigned long ch;
       Boolean hex = false;
  
     if (hex)      if (*p == 'x')
     {     {
         ch = strtoul(p, &end, 16);          hex = true;
           ch = strtoul(++p, &end, 16);
     }     }
     else     else
     {     {
Line 404 
Line 406 
     return ch;     return ch;
 } }
  
 static void _normalize(Uint32& line, char*& p, char end_char, char*& start)  // Parse an entity reference or a character reference
   static inline int _getRef(Uint32 line, char*& p)
 { {
     // Skip over leading whitespace:      int ch;
  
     _skipWhitespace(line, p);      if (*p == '#')
     start = p;      {
           ch = _getCharRef(++p);
       }
       else
       {
           ch = _getEntityRef(p);
       }
   
       if (ch == -1)
       {
           throw XmlException(XmlException::MALFORMED_REFERENCE, line);
       }
  
       return ch;
   }
   
   static inline void _normalizeElementValue(
       Uint32& line,
       char*& p,
       Uint32 &textLen)
   {
     // Process one character at a time:     // Process one character at a time:
  
     char* q = p;     char* q = p;
       char *start = p;
  
     while (*p && (*p != end_char))      while (*p && (*p != '<'))
     {     {
         if (_isspace(*p))         if (_isspace(*p))
         {         {
             // Compress sequences of whitespace characters to a single space              // Trim whitespace from the end of the value, but do not compress
             // character. Update line number when newlines encountered.              // whitespace within the value.
   
               const char* start = p;
  
             if (*p++ == '\n')             if (*p++ == '\n')
             {             {
                 line++;                 line++;
             }             }
  
             *q++ = ' ';  
   
             _skipWhitespace(line, p);             _skipWhitespace(line, p);
         }  
         else if (*p == '&')  
         {  
             // Process entity characters and entity references:  
  
             p++;              if (*p && (*p != '<'))
             int ch;  
   
             if (*p == '#')  
             {             {
                 *p++;                  // Transfer internal whitespace to q without compressing it.
                   const char* i = start;
                 if (*p == 'x')                  while (i < p)
                 {                 {
                     p++;                      *q++ = *i++;
                     ch = _getCharRef(p, true);                  }
                 }                 }
                 else                 else
                 {                 {
                     ch = _getCharRef(p, false);                  // Do not transfer trailing whitespace to q.
                   break;
               }
                 }                 }
           else if (*p == '&')
           {
               // Process an entity reference or a character reference.
   
               *q++ = _getRef(line, ++p);
             }             }
             else             else
             {             {
                 ch = _getEntityRef(p);              *q++ = *p++;
           }
             }             }
  
             if (ch == -1)      // If q got behind p, it is safe and necessary to null-terminate q
   
       if (q != p)
             {             {
                 throw XmlException(XmlException::MALFORMED_REFERENCE, line);          *q = '\0';
       }
       textLen = (Uint32)(q - start);
   }
   
   static inline void _normalizeAttributeValue(
       Uint32& line,
       char*& p,
       char end_char,
       char*& start)
   {
       // Skip over leading whitespace:
   
       _skipWhitespace(line, p);
       start = p;
   
       // Process one character at a time:
   
       char* q = p;
   
       while (*p && (*p != end_char))
       {
           if (_isspace(*p))
           {
               // Compress sequences of whitespace characters to a single space
               // character. Update line number when newlines encountered.
   
               if (*p++ == '\n')
               {
                   line++;
               }
   
               *q++ = ' ';
   
               _skipWhitespace(line, p);
             }             }
           else if (*p == '&')
           {
               // Process an entity reference or a character reference.
  
             *q++ = ch;              *q++ = _getRef(line, ++p);
         }         }
         else         else
         {         {
Line 579 
Line 642 
         {         {
             // Normalize the content:             // Normalize the content:
  
             char* start;              char* start = _current;
             _normalize(_line, _current, '<', start);              Uint32 textLen;
               _normalizeElementValue(_line, _current, textLen);
  
             // Get the content:             // Get the content:
  
             entry.type = XmlEntry::CONTENT;             entry.type = XmlEntry::CONTENT;
             entry.text = start;             entry.text = start;
               entry.textLen = textLen;
  
             // Overwrite '<' with a null character (temporarily).             // Overwrite '<' with a null character (temporarily).
  
Line 749 
Line 814 
     1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,     1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,      0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 }; };
  
 inline Boolean _getQName(char*& p, const char*& localName) inline Boolean _getQName(char*& p, const char*& localName)
Line 761 
Line 826 
  
     p++;     p++;
  
     while (*p && _isInnerElementChar[Uint8(*p)])      // No explicit test for NULL termination is needed.
       // On position 0 of the array false is returned.
       while (_isInnerElementChar[Uint8(*p)])
         p++;         p++;
  
     // We've validated the prefix, now validate the local name     // We've validated the prefix, now validate the local name
Line 773 
Line 840 
             return false;             return false;
  
         p++;         p++;
           // No explicit test for NULL termination is needed.
         while (*p && _isInnerElementChar[Uint8(*p)])          // On position 0 of the array false is returned.
           while (_isInnerElementChar[Uint8(*p)])
             p++;             p++;
     }     }
  
Line 955 
Line 1023 
             entry.type = XmlEntry::CDATA;             entry.type = XmlEntry::CDATA;
             entry.text = p;             entry.text = p;
             _getCData(p);             _getCData(p);
               entry.textLen = strlen(entry.text);
             return;             return;
         }         }
         else if (memcmp(p, "DOCTYPE", 7) == 0)         else if (memcmp(p, "DOCTYPE", 7) == 0)
Line 976 
Line 1045 
  
         return;         return;
     }     }
     else if ((((*p >= 'A') && (*p <= 'Z')) ||      else if (CharSet::isAlphaUnder(Uint8(*p)))
               ((*p >= 'a') && (*p <= 'z')) ||  
               (*p == '_')))  
     {     {
         entry.type = XmlEntry::START_TAG;         entry.type = XmlEntry::START_TAG;
         entry.text = p;         entry.text = p;
Line 1036 
Line 1103 
             char quote = *p++;             char quote = *p++;
  
             char* start;             char* start;
             _normalize(_line, p, quote, start);              _normalizeAttributeValue(_line, p, quote, start);
             attr.value = start;             attr.value = start;
  
             if (*p != quote)             if (*p != quote)


Legend:
Removed from v.1.46  
changed lines
  Added in v.1.46.4.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2