[html5] r4310 - [e] (0) Rewrite this algorithm to make Philip` happier (and be more consistent w [...]

whatwg at whatwg.org whatwg at whatwg.org
Sat Oct 24 04:34:12 PDT 2009


Author: ianh
Date: 2009-10-24 04:34:07 -0700 (Sat, 24 Oct 2009)
New Revision: 4310

Modified:
   complete.html
   index
   source
Log:
[e] (0) Rewrite this algorithm to make Philip` happier (and be more consistent with the other algorithms.)
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=8015

Modified: complete.html
===================================================================
--- complete.html	2009-10-24 11:14:10 UTC (rev 4309)
+++ complete.html	2009-10-24 11:34:07 UTC (rev 4310)
@@ -3072,60 +3072,52 @@
   <p>The <dfn id=steps-for-finding-one-or-two-numbers-of-a-ratio-in-a-string>steps for finding one or two numbers of a ratio in a
   string</dfn> are as follows:</p>
 
-  <ol><li>If the string is empty, then return nothing and abort these
-   steps.</li>
+  <ol><li><p>Let <var title="">input</var> be the string being
+   parsed.</li>
 
-   <li><a href=#find-a-number>Find a number</a> in the string according to the
-   algorithm below, starting at the start of the string.</li>
+   <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
+   string.</li>
 
-   <li>If the sub-algorithm in step 2 returned nothing or returned an
-   error condition, return nothing and abort these steps.</li>
+   <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return nothing and abort these
+   steps.</li>
 
-   <li>Set <var title="">number1</var> to the number returned by the
-   sub-algorithm in step 2.</li>
+   <li><p><a href=#find-a-number>Find a number</a> in the string according to the
+   algorithm below. If this returns a number, let <var title="">number1</var> be that number. Otherwise, if it returned
+   nothing or returned an error condition, return nothing and abort
+   these steps.</li>
 
-   <li>Starting with the character immediately after the last one
-   collected by the sub-algorithm in step 2, skip all
-   <a href=#white_space>White_Space</a> characters in the string (this might match
-   zero characters).</li>
+   <li><p><a href=#skip-white_space-characters>Skip White_Space characters</a>.</li>
 
-   <li>If there are still further characters in the string, and the
-   next character in the string is a <a href=#valid-denominator-punctuation-character>valid denominator
-   punctuation character</a>, set <var title="">denominator</var>
-   to that character.</li>
+   <li><p>If the character indicated by <var title="">position</var>
+   (if any) is a <a href=#valid-denominator-punctuation-character>valid denominator punctuation character</a>,
+   let <var title="">denominator</var> be that character. Otherwise,
+   <var title="">denominator</var> has no value.</li>
 
-   <li>If the string contains any other characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9), but <var title="">denominator</var> was given a value in the step 6, return
+   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
+   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
+   after the character indicated by <var title="">position</var> (if
+   any), but <var title="">denominator</var> has a value, return
    nothing and abort these steps.</li>
 
-   <li>Otherwise, if <var title="">denominator</var> was given a value
-   in step 6, return <var title="">number1</var> and <var title="">denominator</var> and abort these steps.</li>
+   <li><p>Otherwise, if <var title="">denominator</var> has value,
+   return <var title="">number1</var> and <var title="">denominator</var> and abort these steps.</li>
 
-   <li><a href=#find-a-number>Find a number</a> in the string again, starting
-   immediately after the last character that was collected by the
-   sub-algorithm in step 2.</li>
+   <li><p><a href=#find-a-number>Find a number</a> in the string again. If this
+   returns a number, let <var title="">number2</var> be that
+   number. Otherwise, if it returned nothing or an error condition,
+   return <var title="">number1</var> and abort these steps.</li>
 
-   <li>If the sub-algorithm in step 9 returned nothing or an error
-   condition, return <var title="">number1</var> and abort these
-   steps.</li>
+   <li><p><a href=#skip-white_space-characters>Skip White_Space characters</a>.</li>
 
-   <li>Set <var title="">number2</var> to the number returned by the
-   sub-algorithm in step 9.</li>
+   <li><p>If the character indicated by <var title="">position</var>
+   (if any) is a <a href=#valid-denominator-punctuation-character>valid denominator punctuation character</a>,
+   return nothing and abort these steps.</li>
 
-   <li>Starting with the character immediately after the last one
-   collected by the sub-algorithm in step 9, skip all
-   <a href=#white_space>White_Space</a> characters in the string (this might match
-   zero characters).</li>
+   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
+   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
+   after the character indicated by <var title="">position</var> (if
+   any), return nothing and abort these steps.</li>
 
-   <li>If there are still further characters in the string, and the
-   next character in the string is a <a href=#valid-denominator-punctuation-character>valid denominator
-   punctuation character</a>, return nothing and abort these
-   steps.</li>
-
-   <li>If the string contains any other characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return nothing and abort
-   these steps.</li>
-
    <li>Otherwise, return <var title="">number1</var> and
    <var title="">number2</var>.</li>
 
@@ -3133,27 +3125,25 @@
   given a string and a starting position, and returns either nothing,
   a number, or an error condition.</p>
 
-  <ol><li>Starting at the given starting position, ignore all characters
-   in the given string until the first character that is either a
-   U+002E FULL STOP or one of the ten characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li>
+  <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not
+   U+002E FULL STOP characters (.) and are not characters in the range
+   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li>
 
-   <li>If there are no such characters, return nothing and abort these
+   <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return nothing and abort these
    steps.</li>
 
-   <li>Starting with the character matched in step 1, collect all the
-   consecutive characters that are either a U+002E FULL STOP or one of
-   the ten characters in the range U+0030 DIGIT ZERO (0) to U+0039
-   DIGIT NINE (9), and assign this string of one or more characters to
-   <var title="">string</var>.</li>
+   <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are
+   either U+002E FULL STOP characters (.) or characters in the range
+   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let that be
+   <var title="">s</var>.</li>
 
-   <li>If the first character or the last character of <var title="">string</var> is a U+002E FULL STOP character, or if <var title="">string</var> contains more than one U+002E FULL STOP
-   character, then return an error condition and abort these
-   steps.</li>
+   <li><p>If the first character or the last character of <var title="">s</var> is a U+002E FULL STOP character (.), or if <var title="">s</var> contains more than one U+002E FULL STOP character
+   (.), then return an error condition and abort these steps.</li>
 
-   <li>Parse <var title="">string</var> according to the <a href=#rules-for-parsing-floating-point-number-values>rules
-   for parsing floating point number values</a>, to obtain <var title="">number</var>. This step cannot fail (<var title="">string</var> is guaranteed to be a <a href=#valid-floating-point-number>valid floating
-   point number</a>).</li>
+   <li><p>Parse <var title="">s</var> according to the <a href=#rules-for-parsing-floating-point-number-values>rules for
+   parsing floating point number values</a>, to obtain <var title="">number</var>. This step cannot fail (<var title="">s</var>
+   is guaranteed to be a <a href=#valid-floating-point-number>valid floating point
+   number</a>).</li>
 
    <li>Return <var title="">number</var>.</li>
 

Modified: index
===================================================================
--- index	2009-10-24 11:14:10 UTC (rev 4309)
+++ index	2009-10-24 11:34:07 UTC (rev 4310)
@@ -2882,60 +2882,52 @@
   <p>The <dfn id=steps-for-finding-one-or-two-numbers-of-a-ratio-in-a-string>steps for finding one or two numbers of a ratio in a
   string</dfn> are as follows:</p>
 
-  <ol><li>If the string is empty, then return nothing and abort these
-   steps.</li>
+  <ol><li><p>Let <var title="">input</var> be the string being
+   parsed.</li>
 
-   <li><a href=#find-a-number>Find a number</a> in the string according to the
-   algorithm below, starting at the start of the string.</li>
+   <li><p>Let <var title="">position</var> be a pointer into <var title="">input</var>, initially pointing at the start of the
+   string.</li>
 
-   <li>If the sub-algorithm in step 2 returned nothing or returned an
-   error condition, return nothing and abort these steps.</li>
+   <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return nothing and abort these
+   steps.</li>
 
-   <li>Set <var title="">number1</var> to the number returned by the
-   sub-algorithm in step 2.</li>
+   <li><p><a href=#find-a-number>Find a number</a> in the string according to the
+   algorithm below. If this returns a number, let <var title="">number1</var> be that number. Otherwise, if it returned
+   nothing or returned an error condition, return nothing and abort
+   these steps.</li>
 
-   <li>Starting with the character immediately after the last one
-   collected by the sub-algorithm in step 2, skip all
-   <a href=#white_space>White_Space</a> characters in the string (this might match
-   zero characters).</li>
+   <li><p><a href=#skip-white_space-characters>Skip White_Space characters</a>.</li>
 
-   <li>If there are still further characters in the string, and the
-   next character in the string is a <a href=#valid-denominator-punctuation-character>valid denominator
-   punctuation character</a>, set <var title="">denominator</var>
-   to that character.</li>
+   <li><p>If the character indicated by <var title="">position</var>
+   (if any) is a <a href=#valid-denominator-punctuation-character>valid denominator punctuation character</a>,
+   let <var title="">denominator</var> be that character. Otherwise,
+   <var title="">denominator</var> has no value.</li>
 
-   <li>If the string contains any other characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9), but <var title="">denominator</var> was given a value in the step 6, return
+   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
+   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
+   after the character indicated by <var title="">position</var> (if
+   any), but <var title="">denominator</var> has a value, return
    nothing and abort these steps.</li>
 
-   <li>Otherwise, if <var title="">denominator</var> was given a value
-   in step 6, return <var title="">number1</var> and <var title="">denominator</var> and abort these steps.</li>
+   <li><p>Otherwise, if <var title="">denominator</var> has value,
+   return <var title="">number1</var> and <var title="">denominator</var> and abort these steps.</li>
 
-   <li><a href=#find-a-number>Find a number</a> in the string again, starting
-   immediately after the last character that was collected by the
-   sub-algorithm in step 2.</li>
+   <li><p><a href=#find-a-number>Find a number</a> in the string again. If this
+   returns a number, let <var title="">number2</var> be that
+   number. Otherwise, if it returned nothing or an error condition,
+   return <var title="">number1</var> and abort these steps.</li>
 
-   <li>If the sub-algorithm in step 9 returned nothing or an error
-   condition, return <var title="">number1</var> and abort these
-   steps.</li>
+   <li><p><a href=#skip-white_space-characters>Skip White_Space characters</a>.</li>
 
-   <li>Set <var title="">number2</var> to the number returned by the
-   sub-algorithm in step 9.</li>
+   <li><p>If the character indicated by <var title="">position</var>
+   (if any) is a <a href=#valid-denominator-punctuation-character>valid denominator punctuation character</a>,
+   return nothing and abort these steps.</li>
 
-   <li>Starting with the character immediately after the last one
-   collected by the sub-algorithm in step 9, skip all
-   <a href=#white_space>White_Space</a> characters in the string (this might match
-   zero characters).</li>
+   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
+   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
+   after the character indicated by <var title="">position</var> (if
+   any), return nothing and abort these steps.</li>
 
-   <li>If there are still further characters in the string, and the
-   next character in the string is a <a href=#valid-denominator-punctuation-character>valid denominator
-   punctuation character</a>, return nothing and abort these
-   steps.</li>
-
-   <li>If the string contains any other characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return nothing and abort
-   these steps.</li>
-
    <li>Otherwise, return <var title="">number1</var> and
    <var title="">number2</var>.</li>
 
@@ -2943,27 +2935,25 @@
   given a string and a starting position, and returns either nothing,
   a number, or an error condition.</p>
 
-  <ol><li>Starting at the given starting position, ignore all characters
-   in the given string until the first character that is either a
-   U+002E FULL STOP or one of the ten characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li>
+  <ol><li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are not
+   U+002E FULL STOP characters (.) and are not characters in the range
+   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li>
 
-   <li>If there are no such characters, return nothing and abort these
+   <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return nothing and abort these
    steps.</li>
 
-   <li>Starting with the character matched in step 1, collect all the
-   consecutive characters that are either a U+002E FULL STOP or one of
-   the ten characters in the range U+0030 DIGIT ZERO (0) to U+0039
-   DIGIT NINE (9), and assign this string of one or more characters to
-   <var title="">string</var>.</li>
+   <li><p><a href=#collect-a-sequence-of-characters>Collect a sequence of characters</a> that are
+   either U+002E FULL STOP characters (.) or characters in the range
+   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let that be
+   <var title="">s</var>.</li>
 
-   <li>If the first character or the last character of <var title="">string</var> is a U+002E FULL STOP character, or if <var title="">string</var> contains more than one U+002E FULL STOP
-   character, then return an error condition and abort these
-   steps.</li>
+   <li><p>If the first character or the last character of <var title="">s</var> is a U+002E FULL STOP character (.), or if <var title="">s</var> contains more than one U+002E FULL STOP character
+   (.), then return an error condition and abort these steps.</li>
 
-   <li>Parse <var title="">string</var> according to the <a href=#rules-for-parsing-floating-point-number-values>rules
-   for parsing floating point number values</a>, to obtain <var title="">number</var>. This step cannot fail (<var title="">string</var> is guaranteed to be a <a href=#valid-floating-point-number>valid floating
-   point number</a>).</li>
+   <li><p>Parse <var title="">s</var> according to the <a href=#rules-for-parsing-floating-point-number-values>rules for
+   parsing floating point number values</a>, to obtain <var title="">number</var>. This step cannot fail (<var title="">s</var>
+   is guaranteed to be a <a href=#valid-floating-point-number>valid floating point
+   number</a>).</li>
 
    <li>Return <var title="">number</var>.</li>
 

Modified: source
===================================================================
--- source	2009-10-24 11:14:10 UTC (rev 4309)
+++ source	2009-10-24 11:34:07 UTC (rev 4310)
@@ -2051,62 +2051,56 @@
 
   <ol>
 
-   <li>If the string is empty, then return nothing and abort these
-   steps.</li>
+   <li><p>Let <var title="">input</var> be the string being
+   parsed.</p></li>
 
-   <li><span>Find a number</span> in the string according to the
-   algorithm below, starting at the start of the string.</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>If the sub-algorithm in step 2 returned nothing or returned an
-   error condition, return nothing and abort these steps.</li>
+   <li><p>If <var title="">position</var> is past the end of <var
+   title="">input</var>, then return nothing and abort these
+   steps.</p></li>
 
-   <li>Set <var title="">number1</var> to the number returned by the
-   sub-algorithm in step 2.</li>
+   <li><p><span>Find a number</span> in the string according to the
+   algorithm below. If this returns a number, let <var
+   title="">number1</var> be that number. Otherwise, if it returned
+   nothing or returned an error condition, return nothing and abort
+   these steps.</p></li>
 
-   <li>Starting with the character immediately after the last one
-   collected by the sub-algorithm in step 2, skip all
-   <span>White_Space</span> characters in the string (this might match
-   zero characters).</li>
+   <li><p><span>Skip White_Space characters</span>.</p></li>
 
-   <li>If there are still further characters in the string, and the
-   next character in the string is a <span>valid denominator
-   punctuation character</span>, set <var title="">denominator</var>
-   to that character.</li>
+   <li><p>If the character indicated by <var title="">position</var>
+   (if any) is a <span>valid denominator punctuation character</span>,
+   let <var title="">denominator</var> be that character. Otherwise,
+   <var title="">denominator</var> has no value.</p></li>
 
-   <li>If the string contains any other characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9), but <var
-   title="">denominator</var> was given a value in the step 6, return
-   nothing and abort these steps.</li>
+   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
+   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
+   after the character indicated by <var title="">position</var> (if
+   any), but <var title="">denominator</var> has a value, return
+   nothing and abort these steps.</p></li>
 
-   <li>Otherwise, if <var title="">denominator</var> was given a value
-   in step 6, return <var title="">number1</var> and <var
-   title="">denominator</var> and abort these steps.</li>
+   <li><p>Otherwise, if <var title="">denominator</var> has value,
+   return <var title="">number1</var> and <var
+   title="">denominator</var> and abort these steps.</p></li>
 
-   <li><span>Find a number</span> in the string again, starting
-   immediately after the last character that was collected by the
-   sub-algorithm in step 2.</li>
+   <li><p><span>Find a number</span> in the string again. If this
+   returns a number, let <var title="">number2</var> be that
+   number. Otherwise, if it returned nothing or an error condition,
+   return <var title="">number1</var> and abort these steps.</p></li>
 
-   <li>If the sub-algorithm in step 9 returned nothing or an error
-   condition, return <var title="">number1</var> and abort these
-   steps.</li>
+   <li><p><span>Skip White_Space characters</span>.</p></li>
 
-   <li>Set <var title="">number2</var> to the number returned by the
-   sub-algorithm in step 9.</li>
+   <li><p>If the character indicated by <var title="">position</var>
+   (if any) is a <span>valid denominator punctuation character</span>,
+   return nothing and abort these steps.</li>
 
-   <li>Starting with the character immediately after the last one
-   collected by the sub-algorithm in step 9, skip all
-   <span>White_Space</span> characters in the string (this might match
-   zero characters).</li>
+   <li><p>If there are any characters in the range U+0030 DIGIT ZERO
+   (0) to U+0039 DIGIT NINE (9) in <var title="">input</var> at or
+   after the character indicated by <var title="">position</var> (if
+   any), return nothing and abort these steps.</p></li>
 
-   <li>If there are still further characters in the string, and the
-   next character in the string is a <span>valid denominator
-   punctuation character</span>, return nothing and abort these
-   steps.</li>
-
-   <li>If the string contains any other characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return nothing and abort
-   these steps.</li>
-
    <li>Otherwise, return <var title="">number1</var> and
    <var title="">number2</var>.</li>
 
@@ -2118,31 +2112,29 @@
 
   <ol>
 
-   <li>Starting at the given starting position, ignore all characters
-   in the given string until the first character that is either a
-   U+002E FULL STOP or one of the ten characters in the range U+0030
-   DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</li>
+   <li><p><span>Collect a sequence of characters</span> that are not
+   U+002E FULL STOP characters (.) and are not characters in the range
+   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).</p></li>
 
-   <li>If there are no such characters, return nothing and abort these
-   steps.</li>
+   <li><p>If <var title="">position</var> is past the end of <var
+   title="">input</var>, then return nothing and abort these
+   steps.</p></li>
 
-   <li>Starting with the character matched in step 1, collect all the
-   consecutive characters that are either a U+002E FULL STOP or one of
-   the ten characters in the range U+0030 DIGIT ZERO (0) to U+0039
-   DIGIT NINE (9), and assign this string of one or more characters to
-   <var title="">string</var>.</li>
+   <li><p><span>Collect a sequence of characters</span> that are
+   either U+002E FULL STOP characters (.) or characters in the range
+   U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and let that be
+   <var title="">s</var>.</p></li>
 
-   <li>If the first character or the last character of <var
-   title="">string</var> is a U+002E FULL STOP character, or if <var
-   title="">string</var> contains more than one U+002E FULL STOP
-   character, then return an error condition and abort these
-   steps.</li>
+   <li><p>If the first character or the last character of <var
+   title="">s</var> is a U+002E FULL STOP character (.), or if <var
+   title="">s</var> contains more than one U+002E FULL STOP character
+   (.), then return an error condition and abort these steps.</p></li>
 
-   <li>Parse <var title="">string</var> according to the <span>rules
-   for parsing floating point number values</span>, to obtain <var
-   title="">number</var>. This step cannot fail (<var
-   title="">string</var> is guaranteed to be a <span>valid floating
-   point number</span>).</li>
+   <li><p>Parse <var title="">s</var> according to the <span>rules for
+   parsing floating point number values</span>, to obtain <var
+   title="">number</var>. This step cannot fail (<var title="">s</var>
+   is guaranteed to be a <span>valid floating point
+   number</span>).</p></li>
 
    <li>Return <var title="">number</var>.</li>
 




More information about the Commit-Watchers mailing list