HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
671714234[Gecko] [Internet Explorer] [Opera] [Webkit] [Tools] Simplification in the microsyntax parsing rules, which makes non-negative integers accept leading - and + characters (- only for -0 of course).2011-10-20 22:13
@@ -3696,100 +3696,39 @@ is conforming depends on which specs apply, and leaves it at that. -->
   <p>When the attribute is <em>not</em> specified, if there is a
   <i>missing value default</i> state defined, then that is the state
   represented by the (missing) attribute. Otherwise, the absence of
   the attribute means that there is no state represented.</p>
 
   <p class="note">The empty string can be a valid keyword.</p>
 
 
   <h4>Numbers</h4>
 
-  <h5>Non-negative integers</h5>
-
-  <p>A string is a <dfn>valid non-negative integer</dfn> if it
-  consists of one or more characters in the range U+0030 DIGIT ZERO
-  (0) to U+0039 DIGIT NINE (9).</p>
-
-  <p>A <span>valid non-negative integer</span> represents the number
-  that is represented in base ten by that string of digits.</p>
-
-  <div class="impl">
-
-  <p>The <dfn>rules for parsing non-negative integers</dfn> are as
-  given in the following algorithm. When invoked, the steps must be
-  followed in the order given, aborting at the first step that returns
-  a value. This algorithm will return either zero, a positive integer,
-  or an error.</p>
-
-  <ol>
-
-   <li><p>Let <var title="">input</var> be the string being
-   parsed.</p></li>
-
-   <li><p>Let <var title="">position</var> be a pointer into <var
-   title="">input</var>, initially pointing at the start of the
-   string.</p></li>
-
-   <li><p><span>Skip whitespace</span>.</p></li>
-
-   <li><p>If <var title="">position</var> is past the end of <var
-   title="">input</var>, return an error.</p></li>
-
-   <li><p>If the character indicated by <var title="">position</var>
-   is a U+002B PLUS SIGN character (+), advance <var
-   title="">position</var> to the next character. (The "<code
-   title="">+</code>" is ignored, but it is not conforming.)</li>
-
-   <li><p>If <var title="">position</var> is past the end of <var
-   title="">input</var>, return an error.</p></li>
-
-   <li><p>If the character indicated by <var title="">position</var>
-   is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then
-   return an error.</p></li>
-
-   <!-- Ok. At this point we know we have a number. It might have
-   trailing garbage which we'll ignore, but it's a number, and we
-   won't return an error. -->
-
-   <li><p><span>Collect a sequence of characters</span> in the range
-   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
-   resulting sequence as a base-ten integer. Let <var
-   title="">value</var> be that integer.</p></li>
-
-   <li><p>Return <var title="">value</var>.</p></li>
-
-  </ol>
-
-  </div>
-
-
   <h5>Signed integers</h5>
 
   <p>A string is a <dfn>valid integer</dfn> if it consists of one or
   more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
   NINE (9), optionally prefixed with a U+002D HYPHEN-MINUS character
   (-).</p>
 
   <p>A <span>valid integer</span> without a U+002D HYPHEN-MINUS (-)
   prefix represents the number that is represented in base ten by that
   string of digits. A <span>valid integer</span> <em>with</em> a
   U+002D HYPHEN-MINUS (-) prefix represents the number represented in
   base ten by the string of digits that follows the U+002D
   HYPHEN-MINUS, subtracted from zero.</p>
 
   <div class="impl">
 
-  <p>The <dfn>rules for parsing integers</dfn> are similar to the
-  <span title="rules for parsing non-negative integers">rules for
-  non-negative integers</span>, and are as given in the following
-  algorithm. When invoked, the steps must be followed in the order
-  given, aborting at the first step that returns a value. This
+  <p>The <dfn>rules for parsing integers</dfn> are as given in the
+  following algorithm. When invoked, the steps must be followed in the
+  order given, aborting at the first step that returns a value. This
   algorithm will return either an integer or an error.</p>
 
   <ol>
 
    <li><p>Let <var title="">input</var> be the string being
    parsed.</p></li>
 
    <li><p>Let <var title="">position</var> be a pointer into <var
    title="">input</var>, initially pointing at the start of the
    string.</p></li>
@@ -3851,20 +3790,61 @@ is conforming depends on which specs apply, and leaves it at that. -->
 
    <li><p>If <var title="">sign</var> is "positive", return <var
    title="">value</var>, otherwise return the result of subtracting
    <var title="">value</var> from zero.</p></li>
 
   </ol>
 
   </div>
 
 
+  <h5>Non-negative integers</h5>
+
+  <p>A string is a <dfn>valid non-negative integer</dfn> if it
+  consists of one or more characters in the range U+0030 DIGIT ZERO
+  (0) to U+0039 DIGIT NINE (9).</p>
+
+  <p>A <span>valid non-negative integer</span> represents the number
+  that is represented in base ten by that string of digits.</p>
+
+  <div class="impl">
+
+  <p>The <dfn>rules for parsing non-negative integers</dfn> are as
+  given in the following algorithm. When invoked, the steps must be
+  followed in the order given, aborting at the first step that returns
+  a value. This algorithm will return either zero, a positive integer,
+  or an error.</p>
+
+  <ol>
+
+   <li><p>Let <var title="">input</var> be the string being
+   parsed.</p></li>
+
+   <li><p>Let <var title="">value</var> be the result of parsing <var
+   title="">input</var> using the <span>rules for parsing
+   integers</span>.</p></li>
+
+   <li><p>If <var title="">value</var> is an error, return an
+   error.</p></li>
+
+   <li><p>If <var title="">value</var> is less than zero, return an
+   error.</p></li>
+
+   <li><p>Return <var title="">value</var>.</p></li>
+
+  </ol>
+
+  <!-- Implications: A leading + is ignored. A leading - is ignored if the value is zero. -->
+
+  </div>
+
+
   <h5>Floating-point numbers</h5>
 
   <p>A string is a <dfn>valid floating point number</dfn> if it
   consists of:</p>
 
   <ol class="brief">
 
    <li>Optionally, a U+002D HYPHEN-MINUS character (-).</li>
 
    <li>One or both of the following, in the given order:

|