(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.32.2.1

version 1.18.6.1, 2003/07/29 15:08:29 version 1.32.2.1, 2005/09/28 02:07:30
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 23 
Line 29 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By:  // Modified By: David Dillard, VERITAS Software Corp.
   //                  (david.dillard@veritas.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 93 
Line 100 
 #include "XmlParser.h" #include "XmlParser.h"
 #include "Logger.h" #include "Logger.h"
 #include "ExceptionRep.h" #include "ExceptionRep.h"
   #include "CharSet.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 139 
Line 147 
     { "'", 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 inline int _isspace(char c)
   {
       return CharSet::is_space(c);
   }
   
 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:
  
 static void _normalize(char* text) static void _normalize(char* text)
 { {
     Uint32 length = strlen(text);  
     char* p = text;     char* p = text;
     char* end = p + length;      char* end = p + strlen(text);
  
     // Remove leading spaces:     // Remove leading spaces:
  
     while (isspace(*p))      while (_isspace(*p))
         p++;         p++;
  
     if (p != text)     if (p != text)
Line 165 
Line 186 
     {     {
         // 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 196 
  
         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 188 
Line 209 
  
         // Remove the redundant spaces:         // Remove the redundant spaces:
  
         Uint32 n = p - q;          const size_t n = p - q;
  
         if (n > 1)         if (n > 1)
         {         {
Line 247 
Line 268 
     "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 332 
     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 498 
  
 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 509 
  
 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 543 
 { {
     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 583 
  
 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 663 
Line 705 
  
 void XmlParser::_substituteReferences(char* text) void XmlParser::_substituteReferences(char* text)
 { {
     Uint32 rem = strlen(text);      size_t rem = strlen(text);
  
     for (char* p = text; *p; p++, rem--)     for (char* p = text; *p; p++, rem--)
     {     {
Line 867 
Line 909 
  
         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 968 
         {         {
             // 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 1054 
 { {
     first = str;     first = str;
  
     while (isspace(*first))      while (_isspace(*first))
         first++;         first++;
  
     if (!*first)     if (!*first)
Line 1021 
Line 1065 
  
     last = first + strlen(first);     last = first + strlen(first);
  
     while (last != first && isspace(last[-1]))      while (last != first && _isspace(last[-1]))
         last--;         last--;
 } }
  
Line 1067 
Line 1111 
     if (!end || end != last)     if (!end || end != last)
         return false;         return false;
  
     value = Uint32(tmp);      value = static_cast<Real32>(tmp);
     return true;     return true;
 } }
  
Line 1091 
Line 1135 
     if (!getAttributeValue(name, tmp))     if (!getAttributeValue(name, tmp))
         return false;         return false;
  
     value = tmp;      value = String(tmp);
     return true;     return true;
 } }
  
 void XmlAppendCString(Array<Sint8>& out, const char* str)  void XmlAppendCString(Array<char>& out, const char* str)
 { {
     out.append(str, strlen(str));      out.append(str, static_cast<Uint32>(strlen(str)));
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2