- From: poot <cvsmail@w3.org>
- Date: Sat, 24 Oct 2009 20:20:59 +0900 (JST)
- To: public-html-diffs@w3.org
hixie: Rewrite this algorithm to make Philip` happier (and be more consistent with the other algorithms.) (whatwg r4310) http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.3445&r2=1.3446&f=h http://html5.org/tools/web-apps-tracker?from=4309&to=4310 =================================================================== RCS file: /sources/public/html5/spec/Overview.html,v retrieving revision 1.3445 retrieving revision 1.3446 diff -u -d -r1.3445 -r1.3446 --- Overview.html 24 Oct 2009 11:00:49 -0000 1.3445 +++ Overview.html 24 Oct 2009 11:20:46 -0000 1.3446 @@ -2598,59 +2598,51 @@ <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><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>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>Otherwise, if <var title="">denominator</var> has value, + return <var title="">number1</var> and <var title="">denominator</var> and abort these steps.</li> - <li>Set <var title="">number2</var> to the number returned by the - sub-algorithm in step 9.</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>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><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>, return nothing and abort these - steps.</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>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><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>Otherwise, return <var title="">number1</var> and <var title="">number2</var>.</li> @@ -2659,27 +2651,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>
Received on Saturday, 24 October 2009 11:21:30 UTC