Author: cargilld
Date: Mon Aug 15 11:58:08 2005
New Revision: 232854

URL: http://svn.apache.org/viewcvs?rev=232854&view=rev
Log:
Schema errata e2-67 fix, ported from java to allow [^+-].

Modified:
    xerces/c/branches/xerces-2.7/src/xercesc/util/regx/ParserForXMLSchema.cpp

Modified: 
xerces/c/branches/xerces-2.7/src/xercesc/util/regx/ParserForXMLSchema.cpp
URL: 
http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/util/regx/ParserForXMLSchema.cpp?rev=232854&r1=232853&r2=232854&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/util/regx/ParserForXMLSchema.cpp 
(original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/util/regx/ParserForXMLSchema.cpp 
Mon Aug 15 11:58:08 2005
@@ -120,9 +120,12 @@
 
     int type;
     bool firstLoop = true;
+    bool wasDecoded;
 
     while ( (type = getState()) != REGX_T_EOF) {
 
+        wasDecoded = false;
+
         // single range | from-to-range | subtraction
         if (type == REGX_T_CHAR && getCharData() == chCloseSquare && 
!firstLoop) {
 
@@ -175,6 +178,9 @@
                     end = true;
                 }
                 break;
+            case chDash:
+                wasDecoded = true;
+                // fall thru to default.
             default:
                 ch = decodeEscaped();
             }
@@ -200,22 +206,19 @@
 
         if (!end) {
 
-            // handle '-' when appearing at the beginning of a positive 
character group
-            if (firstLoop && !isNRange && type == REGX_T_CHAR && ch == chDash)
-            {
-                tok->addRange(chDash, chDash);
-                firstLoop=false;
-                continue;
-            }
-
             if (type == REGX_T_CHAR
                 && (ch == chOpenSquare
                     || ch == chCloseSquare
-                    || ch == chDash)) {
+                    || (ch == chDash && getCharData() == chCloseSquare && 
firstLoop))) {
+                // if regex = [-] then invalid...
                 // '[', ']', '-' not allowed and should be esacaped
                 XMLCh chStr[] = { ch, chNull };
                 ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, 
chStr, chStr, getMemoryManager());
             }
+            if (ch == chDash && getCharData() == chDash && getState() != 
REGX_T_BACKSOLIDUS && !wasDecoded) {
+                XMLCh chStr[] = { ch, chNull };
+                ThrowXMLwithMemMgr2(ParseException,XMLExcepts::Parser_CC6, 
chStr, chStr, getMemoryManager());
+            }
 
             if (getState() != REGX_T_CHAR || getCharData() != chDash) {
                 tok->addRange(ch, ch);
@@ -226,13 +229,11 @@
                 if ((type = getState()) == REGX_T_EOF)
                     ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_CC2, 
getMemoryManager());
 
-                // handle '-' when appearing at the end of a positive 
character group
-                if (!isNRange && type == REGX_T_CHAR && getCharData() == 
chCloseSquare) {
+                if (type == REGX_T_CHAR && getCharData() == chCloseSquare) {
                     tok->addRange(ch, ch);
                     tok->addRange(chDash, chDash);
                 }
-                else if((type == REGX_T_CHAR && getCharData() == chCloseSquare)
-                        || type == REGX_T_XMLSCHEMA_CC_SUBTRACTION) {
+                else if (type == REGX_T_XMLSCHEMA_CC_SUBTRACTION) {
 
                     static const XMLCh dashStr[] = { chDash, chNull};
                     ThrowXMLwithMemMgr2(ParseException, 
XMLExcepts::Parser_CC6, dashStr, dashStr, getMemoryManager());



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

Reply via email to