Toolkit version format

  • Revision slug: Toolkit_version_format
  • Revision title: Toolkit version format
  • Revision id: 73823
  • Created:
  • Creator: Jez
  • Is current revision? No
  • Comment /* Comparing version parts */

Revision Content

This document is a reference for the version format, as used in Firefox 1.5 (XULRunner 1.8) and later. This format is used by the Extension Manager, Software Update, and other parts of the platform. Versions in at least the following places must conform to this format:

You can use nsIVersionComparator to compare versions from your application.

See {{template.Anch("Older version formats")}} below for description of the older version format used in Firefox/Thunderbird 1.0.

Version format

A version string consists of one or more version parts, separated with dots.

Each version part is itself parsed as a sequence of four parts: <tt><number-a><string-b><number-c><string-d></tt>. Each of the parts is optional. Numbers are integers base 10 (may be negative), strings are ASCII.

A few examples of valid version parts:

  • <tt>0</tt> (as in <tt>1.0</tt>): <tt><number-a>=0</tt>
  • <tt>5a</tt> (as in <tt>1.5a</tt>): <tt><number-a>=5</tt>, <tt><string-b>=a</tt>
  • <tt>5pre4</tt> (as in <tt>3.5pre4</tt>): <tt><number-a>=5</tt>, <tt><string-b>=pre</tt>, <tt><number-c>=4</tt>
  • <tt>*</tt> (as in <tt>1.0.*</tt>): <tt><string-b>=*</tt>

A few special parsing rules are applied for backwards compatibility and readability:

  • if the version part is a single asterix, it is interpreted as an infinitely-large number:
    <tt>1.5.0.*</tt> is the same as <tt>1.5.0.(infinity)</tt>
  • if string-b is a plus sign, number-a is incremented to be compatible with the Firefox 1.0.x version format:
    <tt>1.0+</tt> is the same as <tt>1.1pre</tt>

The rationale behind splitting a version part into a sequence of strings and numbers is that when comparing version parts, the numeric parts are compared as numbers, e.g. '1.0pre1' < '1.0pre10', while the strings are compared bytewise. See the next section for details on how versions are compared.

Comparing versions

When two version strings are compared, their version parts are compared left to right. An empty or missing version part is equivalent to 0.

If at some point a version part of one version string is greater than the corresponding version part of another version string, then the first version string is greater than the other one.

Otherwise, the version strings are equal. Note, that since missing version parts are treated as if they were 0, the following version strings are equal: 1, 1.0, 1.0., 1.0.0, and even 1.0...

Comparing version parts

Version parts are also compared left to right, parts A and C are compared as numbers, while parts B and D are compared bytewise. A string-part that exists is always less-then a nonexisting string-part (<tt>1.6a</tt> is less than <tt>1.6</tt>).

If you wish to specify that any 'flavour' of a certain version number shall be compatible, you should use '!' as the string for the B part. This will almost always evaluate to earlier than the compared version, as its ASCII value is so low.

Examples

1.-1
< 1 == 1. == 1.0 == 1.0.0
< 1.1a < 1.1aa < 1.1ab < 1.1b < 1.1c
< 1.1whatever
< 1.1pre == 1.1pre0 == 1.0+
< 1.1pre1a < 1.1pre1aa < 1.1pre1b < 1.1pre1
< 1.1pre2
< 1.1pre10
< 1.1.-1
< 1.1 == 1.1.0 == 1.1.00
< 1.10
< 1.* < 1.*.1
< 2.0

Older version formats

Firefox and Thundebird 1.0 used a simpler version format, namely

major[.minor[.release[.build]]][+]

where <tt>{{mediawiki.external('..')}}</tt> denotes an optional component, and <tt>major</tt>, <tt>minor</tt>, <tt>release</tt>, and <tt>build</tt> are all non-negative integers.

Revision Source

<p>This document is a reference for the version format, as used in Firefox 1.5 (<a href="en/XULRunner">XULRunner</a> 1.8) and later. This format is used by the Extension Manager, Software Update, and other parts of the platform. Versions in at least the following places must conform to this format:
</p>
<ul><li> <a href="en/Install_Manifests#version">Addon's</a> and <a href="en/Install_Manifests#targetApplication">target application's</a> version in <a href="en/Install_Manifests">install</a> and <a href="en/Update_Manifest">update</a> manifests.
</li><li> The following preferences: <code>app.extensions.version</code>, <code>extensions.lastAppVersion</code>
</li><li> Versions returned by <a href="en/NsIXULAppInfo">nsIXULAppInfo</a>.
</li><li> <a href="en/XUL_Application_Packaging"><code>application.ini</code></a> in <a href="en/XULRunner">XULRunner</a> applications
</li><li> <a href="en/Chrome_Registration#appversion">appversion flag</a> in <a href="en/Chrome_Registration">chrome manifests</a>.
</li></ul>
<p>You can use <a href="en/NsIVersionComparator">nsIVersionComparator</a> to compare versions from your application.
</p><p>See {{template.Anch("Older version formats")}} below for description of the older version format used in Firefox/Thunderbird 1.0.
</p>
<h3 name="Version_format"> Version format </h3>
<p>A <b>version string</b> consists of one or more <i>version parts</i>, separated with dots. 
</p><p>Each <b>version part</b> is itself parsed as a sequence of four parts: <tt>&lt;number-a&gt;&lt;string-b&gt;&lt;number-c&gt;&lt;string-d&gt;</tt>. Each of the parts is optional. Numbers are integers base 10 (may be negative), strings are ASCII.
</p><p>A few examples of valid version parts:
</p>
<ul><li> <tt>0</tt> (as in <tt>1.0</tt>): <tt>&lt;number-a&gt;=0</tt>
</li><li> <tt>5a</tt> (as in <tt>1.5a</tt>): <tt>&lt;number-a&gt;=5</tt>, <tt>&lt;string-b&gt;=a</tt>
</li><li> <tt>5pre4</tt> (as in <tt>3.5pre4</tt>): <tt>&lt;number-a&gt;=5</tt>, <tt>&lt;string-b&gt;=pre</tt>, <tt>&lt;number-c&gt;=4</tt>
</li><li> <tt>*</tt> (as in <tt>1.0.*</tt>): <tt>&lt;string-b&gt;=*</tt>
</li></ul>
<p>A few special parsing rules are applied for backwards compatibility and readability:
</p>
<ul><li> if the version part is a single asterix, it is interpreted as an infinitely-large number:<br><tt>1.5.0.*</tt> is the same as <tt>1.5.0.<i>(infinity)</i></tt>
</li><li> if string-b is a plus sign, number-a is incremented to be compatible with the Firefox 1.0.x version format:<br><tt>1.0+</tt> is the same as <tt>1.1pre</tt>
</li></ul>
<p>The rationale behind splitting a version part into a sequence of strings and numbers is that when comparing version parts, the numeric parts are compared as numbers, e.g. '1.0pre1' &lt; '1.0pre10', while the strings are compared bytewise. See the next section for details on how versions are compared.
</p>
<h3 name="Comparing_versions"> Comparing versions </h3>
<p>When two version strings are compared, their version parts are compared left to right. An empty or missing version part is equivalent to <code>0</code>.
</p><p>If at some point a version part of one version string is greater than the corresponding version part of another version string, then the first version string is greater than the other one.
</p><p>Otherwise, the version strings are equal. Note, that since missing version parts are treated as if they were <code>0</code>, the following version strings are equal: <code>1</code>, <code>1.0</code>, <code>1.0.</code>, <code>1.0.0</code>, and even <code>1.0...</code>
</p>
<h4 name="Comparing_version_parts"> Comparing version parts </h4>
<p>Version parts are also compared left to right, parts A and C are compared as numbers, while parts B and D are compared bytewise. A string-part that exists is always less-then a nonexisting string-part (<tt>1.6a</tt> is less than <tt>1.6</tt>).
</p><p>If you wish to specify that any 'flavour' of a certain version number shall be compatible, you should use '!' as the string for the B part.  This will almost always evaluate to earlier than the compared version, as its ASCII value is so low.
</p>
<h3 name="Examples"> Examples </h3>
<pre class="eval">1.-1
&lt; 1 == 1. == 1.0 == 1.0.0
&lt; 1.1a &lt; 1.1aa &lt; 1.1ab &lt; 1.1b &lt; 1.1c
&lt; 1.1whatever
&lt; 1.1pre == 1.1pre0 == 1.0+
&lt; 1.1pre1a &lt; 1.1pre1aa &lt; 1.1pre1b &lt; 1.1pre1
&lt; 1.1pre2
&lt; 1.1pre10
&lt; 1.1.-1
&lt; 1.1 == 1.1.0 == 1.1.00
&lt; 1.10
&lt; 1.* &lt; 1.*.1
&lt; 2.0
</pre>
<h3 name="Older_version_formats"> Older version formats </h3>
<p>Firefox and Thundebird 1.0 used a simpler version format, namely
</p>
<pre class="eval">major[.minor[.release[.build]]][+]
</pre>
<p>where <tt>{{mediawiki.external('..')}}</tt> denotes an optional component, and <tt>major</tt>, <tt>minor</tt>, <tt>release</tt>, and <tt>build</tt> are all non-negative integers.
</p>
Revert to this revision