chiark / gitweb /
daemonize, versioncmp: Generally useful functions from tripe.
[mLib] / man / versioncmp.3
diff --git a/man/versioncmp.3 b/man/versioncmp.3
new file mode 100644 (file)
index 0000000..0a4c6d7
--- /dev/null
@@ -0,0 +1,56 @@
+.\" -*-nroff-*-
+.TH versioncmp 3 "6 January 2007" "Straylight/Edgeware" "mLib utilities library"
+.SH NAME
+versioncmp \- compare Debian-format version numbers
+.\" @versioncmp
+.SH SYNOPSIS
+.nf
+.B "#include <mLib/versioncmp.h>"
+
+.BI "int versioncmp(const char *" va ", const char *" vb ");"
+.fi
+.SH DESCRIPTION
+The
+.B versioncmp
+function compares version strings.
+.PP
+The format of version numbers considered is
+.IP
+.RI [ epoch
+.BR : ]
+.I main
+.RB [ \-
+.IR sub ]
+.PP
+The
+.I main
+part may contain colons or hyphens if there is an
+.I epoch
+or
+.IR sub ,
+respectively.  Version strings are compared componentwise: first epochs,
+then main parts, and finally subparts.
+.PP
+The component comparison is done as follows.  First, the initial
+subsequence of nondigit characters is extracted from each string, and
+these are compared lexicographically, using ASCII ordering, except that
+letters precede non-letters.  If both are the same, an initial sequence
+of digits is extracted from the remaining parts of the version strings,
+and these are compared numerically (an empty sequence being considered
+to have the value zero).  This process is repeated until we have a
+winner or until both strings are exhausted.
+.PP
+The return value is 0 if the two strings are equal, \-1 if 
+.I va
+is older than
+.IR vb ,
+or +1 if
+.I va
+is newer than
+.IR vb .
+.SH SEE ALSO
+.BR mLib (3).
+.PP
+.IR "Debian Policy Manual" .
+.SH AUTHOR
+Mark Wooding, <mdw@distorted.org.uk>