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

Diff for /pegasus/src/Pegasus/Common/XmlReader.cpp between version 1.36 and 1.37

version 1.36, 2002/03/07 22:21:17 version 1.37, 2002/03/20 03:21:07
Line 695 
Line 695 
  
     const char* last = p;     const char* last = p;
  
       // Build the Sint64 as a negative number, regardless of the eventual sign
       x = -(*first++ - '0');
   
     while (first != last)     while (first != last)
         x = 10 * x + (*first++ - '0');      {
           if (x < -922337203685477580 /* -(1<<63) / 10 */)
           {
               return false;
           }
           x = 10 * x;
           Sint64 newDigit = (*first++ - '0');
           if (-9223372036854775808 - x > -newDigit)
           {
               return false;
           }
           x = x - newDigit;
       }
  
     if (negative)      if (!negative)
       {
           if (x == -9223372036854775808)
           {
               return false;
           }
         x = -x;         x = -x;
       }
     return true;     return true;
 } }
  
Line 708 
Line 728 
 // //
 // stringToUnsignedInteger // stringToUnsignedInteger
 // //
 //      [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" )  //      [ "+" ] ( positiveDecimalDigit *decimalDigit | "0" )
 // //
 // ATTN-B: handle conversion from hexadecimal. // ATTN-B: handle conversion from hexadecimal.
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 756 
Line 776 
     const char* last = p;     const char* last = p;
  
     while (first != last)     while (first != last)
         x = 10 * x + (*first++ - '0');      {
           if (x > 1844674407370955161 /* (1<<64 - 1) / 10 */)
           {
               return false;
           }
           x = 10 * x;
           Uint64 newDigit = (*first++ - '0');
           if (18446744073709551615 - x < newDigit)
           {
               return false;
           }
           x = x + newDigit;
       }
  
     return true;     return true;
 } }
Line 765 
Line 797 
 // //
 // stringToValue() // stringToValue()
 // //
 // ATTN-C: note that integers are truncated without warning. What should be  
 // done in this case? In C they are truncated without warning by design.  
 //  
 // Return: CIMValue. If the string input is zero length creates a CIMValue // Return: CIMValue. If the string input is zero length creates a CIMValue
 //         with value defined by the type.  Else the value is inserted. //         with value defined by the type.  Else the value is inserted.
 // //
Line 846 
Line 875 
  
             switch (type)             switch (type)
             {             {
                 case CIMType::UINT8: return CIMValue(Uint8(x));                  case CIMType::UINT8:
                 case CIMType::UINT16: return CIMValue(Uint16(x));                  {
                 case CIMType::UINT32: return CIMValue(Uint32(x));                      if (x >= (Uint64(1)<<8))
                       {
                           throw XmlSemanticError(
                               lineNumber, "Uint8 value out of range");
                       }
                       return CIMValue(Uint8(x));
                   }
                   case CIMType::UINT16:
                   {
                       if (x >= (Uint64(1)<<16))
                       {
                           throw XmlSemanticError(
                               lineNumber, "Uint16 value out of range");
                       }
                       return CIMValue(Uint16(x));
                   }
                   case CIMType::UINT32:
                   {
                       if (x >= (Uint64(1)<<32))
                       {
                           throw XmlSemanticError(
                               lineNumber, "Uint32 value out of range");
                       }
                       return CIMValue(Uint32(x));
                   }
                 case CIMType::UINT64: return CIMValue(Uint64(x));                 case CIMType::UINT64: return CIMValue(Uint64(x));
                 default: break;                 default: break;
             }             }
Line 869 
Line 922 
  
             switch (type)             switch (type)
             {             {
                 case CIMType::SINT8: return CIMValue(Sint8(x));                  case CIMType::SINT8:
                 case CIMType::SINT16: return CIMValue(Sint16(x));                  {
                 case CIMType::SINT32: return CIMValue(Sint32(x));                      if(  (x >= (Sint64(1)<<7)) || (x < (-(Sint64(1)<<7))) )
                       {
                           throw XmlSemanticError(
                               lineNumber, "Sint8 value out of range");
                       }
                       return CIMValue(Sint8(x));
                   }
                   case CIMType::SINT16:
                   {
                       if(  (x >= (Sint64(1)<<15)) || (x < (-(Sint64(1)<<15))) )
                       {
                           throw XmlSemanticError(
                               lineNumber, "Sint16 value out of range");
                       }
                       return CIMValue(Sint16(x));
                   }
                   case CIMType::SINT32:
                   {
                       if(  (x >= (Sint64(1)<<31)) || (x < (-(Sint64(1)<<31))) )
                       {
                           throw XmlSemanticError(
                               lineNumber, "Sint32 value out of range");
                       }
                       return CIMValue(Sint32(x));
                   }
                 case CIMType::SINT64: return CIMValue(Sint64(x));                 case CIMType::SINT64: return CIMValue(Sint64(x));
                 default: break;                 default: break;
             }             }
Line 900 
Line 977 
             if (!stringToReal(valueString, x))             if (!stringToReal(valueString, x))
                 throw XmlSemanticError(lineNumber, "Bad real value");                 throw XmlSemanticError(lineNumber, "Bad real value");
  
               // ATTN-RK-P3-20010319: This value gets truncated.
             return CIMValue(Real32(x));             return CIMValue(Real32(x));
         }         }
  


Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2