peiyongz    2004/08/11 09:08:05

  Modified:    c/src/xercesc/util XMLChar.hpp XMLChar.cpp
  Log:
  isValidNmToken
  
  Revision  Changes    Path
  1.4       +15 -0     xml-xerces/c/src/xercesc/util/XMLChar.hpp
  
  Index: XMLChar.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLChar.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLChar.hpp       29 Jan 2004 11:48:47 -0000      1.3
  +++ XMLChar.hpp       11 Aug 2004 16:08:04 -0000      1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.4  2004/08/11 16:08:04  peiyongz
  + * isValidNmToken
  + *
    * Revision 1.3  2004/01/29 11:48:47  cargilld
    * Code cleanup changes to get rid of various compiler diagnostic messages.
    *
  @@ -108,6 +111,12 @@
           , const unsigned int    count
       );
   
  +    static bool isValidNmtoken
  +    (
  +        const   XMLCh*        const    toCheck
  +      , const   unsigned int           count
  +    );
  +
       static bool isValidName
       (
           const   XMLCh* const    toCheck
  @@ -280,6 +289,12 @@
       (
           const   XMLCh* const    toCheck
           , const unsigned int    count
  +    );
  +
  +    static bool isValidNmtoken
  +    (
  +        const   XMLCh*        const    toCheck
  +      , const   unsigned int           count
       );
   
       static bool isValidName
  
  
  
  1.8       +68 -1     xml-xerces/c/src/xercesc/util/XMLChar.cpp
  
  Index: XMLChar.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLChar.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLChar.cpp       14 Jun 2004 15:14:12 -0000      1.7
  +++ XMLChar.cpp       11 Aug 2004 16:08:04 -0000      1.8
  @@ -126,6 +126,20 @@
       return true;
   }
   
  +bool XMLChar1_0::isValidNmtoken(const   XMLCh*       const    toCheck
  +                              , const   unsigned int          count)
  +{
  +    const XMLCh* curCh = toCheck;
  +    const XMLCh* endPtr = toCheck + count;
  +
  +    while (curCh < endPtr)
  +    {
  +        if (!(fgCharCharsTable1_0[*curCh++] & gNameCharMask))
  +            return false;
  +    }
  +    return true;
  +}
  +
   bool XMLChar1_0::isValidName(const   XMLCh* const    toCheck
                               , const unsigned int    count)
   {
  @@ -4436,7 +4450,60 @@
       return true;
   }
   
  +bool XMLChar1_1::isValidNmtoken(const   XMLCh*        const    toCheck
  +                              , const   unsigned int           count)
  +{
  +    const XMLCh* curCh = toCheck;
  +    const XMLCh* endPtr = toCheck + count;
  +    XMLCh nextCh;
   
  +    bool    gotLeadingSurrogate = false;
  +    while (curCh < endPtr)
  +    {
  +        nextCh = *curCh++;
  +
  +        // Deal with surrogate pairs
  +        if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF))
  +        {
  +            //  Its a leading surrogate. If we already got one, then
  +            //  issue an error, else set leading flag to make sure that
  +            //  we look for a trailing next time.
  +            if (nextCh > 0xDB7F || gotLeadingSurrogate)
  +            {
  +                return false;
  +            }
  +            else
  +                gotLeadingSurrogate = true;
  +        }
  +        else
  +        {
  +            //  If its a trailing surrogate, make sure that we are
  +            //  prepared for that. Else, its just a regular char so make
  +            //  sure that we were not expected a trailing surrogate.
  +            if ((nextCh >= 0xDC00) && (nextCh <= 0xDFFF))
  +            {
  +                // Its trailing, so make sure we were expecting it
  +                if (!gotLeadingSurrogate)
  +                    return false;
  +            }
  +            else
  +            {
  +                //  Its just a char, so make sure we were not expecting a
  +                //  trailing surrogate.
  +                if (gotLeadingSurrogate) {
  +                    return false;
  +                }
  +                // Its got to at least be a valid XML character
  +                else if (!(fgCharCharsTable1_1[nextCh] & gNameCharMask))
  +                {
  +                    return false;
  +                }
  +            }
  +            gotLeadingSurrogate = false;
  +        }
  +    }
  +    return true;
  +}
   
   bool XMLChar1_1::isValidName(const   XMLCh* const    toCheck
                               , const unsigned int    count)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to