Bug 1441523 - Remove the first declaration of "start" and set it in each condition r=erahm
authorVictor <miraty@lilo.org>
Tue, 27 Feb 2018 14:37:19 +0100
changeset 762205 01d017ee38c0491e353ead6d274e16d658a719f4
parent 762204 3ce55799da20fcf99ceb7a209db65b2830f38630
child 762206 2e915e01f05d02c2e39161733615af6f16982f29
push id101102
push userbmo:jkt@mozilla.com
push dateThu, 01 Mar 2018 22:11:20 +0000
reviewerserahm
bugs1441523
milestone60.0a1
Bug 1441523 - Remove the first declaration of "start" and set it in each condition r=erahm
dom/xslt/xpath/txExprLexer.cpp
--- a/dom/xslt/xpath/txExprLexer.cpp
+++ b/dom/xslt/xpath/txExprLexer.cpp
@@ -89,18 +89,18 @@ txExprLexer::nextIsOperatorToken(Token* 
 }
 
 /**
  * Parses the given string into a sequence of Tokens
  */
 nsresult
 txExprLexer::parse(const nsAString& aPattern)
 {
-  iterator start, end;
-  start = aPattern.BeginReading(mPosition);
+  iterator end;
+  aPattern.BeginReading(mPosition);
   aPattern.EndReading(end);
 
   //-- initialize previous token, this will automatically get
   //-- deleted when it goes out of scope
   Token nullToken(nullptr, nullptr, Token::NULL_TOKEN);
 
   Token::Type defType;
   Token* newToken = nullptr;
@@ -120,17 +120,17 @@ txExprLexer::parse(const nsAString& aPat
     }
     // just reuse the QName parsing, which will use defType
     // the token to construct
 
     if (XMLUtils::isLetter(*mPosition)) {
       // NCName, can get QName or OperatorName;
       //  FunctionName, NodeName, and AxisSpecifier may want whitespace,
       //  and are dealt with below
-      start = mPosition;
+      iterator start = mPosition;
       while (++mPosition < end && XMLUtils::isNCNameChar(*mPosition)) {
         /* just go */
       }
       if (mPosition < end && *mPosition == COLON) {
         // try QName or wildcard, might need to step back for axis
         if (++mPosition == end) {
           return NS_ERROR_XPATH_UNEXPECTED_END;
         }
@@ -165,17 +165,17 @@ txExprLexer::parse(const nsAString& aPat
           // XXX QUESTION: spec is not too precise
           // badops is sure an error, but is bad:ops, too? We say yes!
           return NS_ERROR_XPATH_OPERATOR_EXPECTED;
         }
       }
       newToken = new Token(start, mPosition, defType);
     }
     else if (isXPathDigit(*mPosition)) {
-      start = mPosition;
+      iterator start = mPosition;
       while (++mPosition < end && isXPathDigit(*mPosition)) {
         /* just go */
       }
       if (mPosition < end && *mPosition == '.') {
         while (++mPosition < end && isXPathDigit(*mPosition)) {
           /* just go */
         }
       }
@@ -188,34 +188,36 @@ txExprLexer::parse(const nsAString& aPat
       case TX_TAB:
       case TX_CR:
       case TX_LF:
         ++mPosition;
         isToken = false;
         break;
       case S_QUOTE :
       case D_QUOTE :
-        start = mPosition;
+      {
+        iterator start = mPosition;
         while (++mPosition < end && *mPosition != *start) {
           // eat literal
         }
         if (mPosition == end) {
           mPosition = start;
           return NS_ERROR_XPATH_UNCLOSED_LITERAL;
         }
         newToken = new Token(start + 1, mPosition, Token::LITERAL);
         ++mPosition;
-        break;
+      }
+      break;
       case PERIOD:
         // period can be .., .(DIGITS)+ or ., check next
         if (++mPosition == end) {
           newToken = new Token(mPosition - 1, Token::SELF_NODE);
         }
         else if (isXPathDigit(*mPosition)) {
-          start = mPosition - 1;
+          iterator start = mPosition - 1;
           while (++mPosition < end && isXPathDigit(*mPosition)) {
             /* just go */
           }
           newToken = new Token(start, mPosition, Token::NUMBER);
         }
         else if (*mPosition == PERIOD) {
           ++mPosition;
           newToken = new Token(mPosition - 2, mPosition, Token::PARENT_NODE);