3 .\" Manual for version number comparison
5 .\" (c) 2007, 2009, 2020, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH versioncmp 3mLib "6 January 2007" "Straylight/Edgeware" "mLib utilities library"
35 .\"--------------------------------------------------------------------------
37 versioncmp \- compare Debian-format version numbers
39 .\"--------------------------------------------------------------------------
43 .B "#include <mLib/versioncmp.h>"
45 .BI "int versioncmp(const char *" va ", const char *" vb ");"
46 .BI "int VERSIONCMP(const char *" va ", " op ", const char *" vb ");"
49 .\"--------------------------------------------------------------------------
54 function compares version strings.
56 The format of version numbers considered is
66 part may contain colons or hyphens if there is an
70 respectively. Version strings are compared componentwise: first epochs,
71 then main parts, and finally subparts.
73 The component comparison is done as follows. First, the initial
74 subsequence of nondigit characters is extracted from each string, and
75 these are compared lexicographically, using ASCII ordering, except that
76 letters precede non-letters. If both are the same, an initial sequence
77 of digits is extracted from the remaining parts of the version strings,
78 and these are compared numerically (an empty sequence being considered
79 to have the value zero). This process is repeated until we have a
80 winner or until both strings are exhausted.
82 The return value is 0 if the two strings are equal, \-1 if
93 macro provides a more convenient syntax for the
95 function, by allowing a relational operator to be written between the
98 .\"--------------------------------------------------------------------------
103 .IR "Debian Policy Manual" .
105 .\"--------------------------------------------------------------------------
108 Mark Wooding, <mdw@distorted.org.uk>
110 .\"----- That's all, folks --------------------------------------------------