- From: Arve Bersvendsen <arveb@opera.com>
- Date: Wed, 05 Sep 2007 22:13:04 +0200
- To: "public-appformats@w3.org" <public-appformats@w3.org>
Asserting responsibility for this task that was proxy assigned me through
Anne, based on the August 7-9 f2f meeting, here is a new proposal for
version list identifers, including a version list comparison algorithm
Version list and identifier
A string is a valid version list if it consists of one or more valid mix
of strings separated by a U+002E (.) character.
The rules for parsing a version list 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 an ordered list, which may be empty.
1. Let input be the string being parsed.
2. Let version list be an ordered list of unsigned integers which is
initially empty.
3. Split input on U+002E (.) retaining the order the items had in the
original string, while dropping the U+002E (.) character in the process.
If this resulted in two or more items let those be the ordered list
items, in the order left-to-right. If this operation left input
unchanged let items be an ordered list with a single item input.
Comparing version lists
When comparing two different version lists 'n' and 'm', determining
which version identifier is has the greater value, apply the following
algorithm:
1. Let p = 0. Let this be the start index for the indexed item in each
of the lists n and m.
2. Compare the list items n[p] and m[p] using a natural sort algoritm [1]
2.1. If the version list item n[p] is nonexistent, assume that this
item will, in any sort be assumed to be less than any existing
value. Likewise, apply this to list item m[p].
2.2. If the comparison of n[p-1] and m[p-1] has not established
any version order, or the items n[p-1] and m[p-1] do not exist,
and the list items n[p] and m[p] do not exist, consider version
list n to be identical to version list m and exit the comparison.
2.3. If n[p] < m[p], let version list m represent the greater version
identifier and exit the comparison.
2.4. if n[p] > m[p], let version list n represent the greater version
identifier and exit the comparison.
2.5. If n[p] = m[p], let p = p + 1 and go back to item one in the
algorithm.
[1] I am unable to find a formal definition, but
http://www.unicode.org/unicode/reports/tr10/ may come close to meeting
our needs.
--
Arve Bersvendsen
Developer, Opera Software ASA
http://www.opera.com/
Received on Wednesday, 5 September 2007 20:14:33 UTC