utils/versioncmp.h: Add a wrapper macro for `versioncmp'.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 8 May 2020 19:15:30 +0000 (20:15 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 May 2020 19:15:30 +0000 (20:15 +0100)
Similar to the macros introduced for `strcmp' end friends in
3618811496a6d131fd4bffa19e262c521d39e819.

utils/versioncmp.3
utils/versioncmp.h

index f3afc18..15d1593 100644 (file)
@@ -3,11 +3,13 @@
 .SH NAME
 versioncmp \- compare Debian-format version numbers
 .\" @versioncmp
+.\" @VERSIONCMP
 .SH SYNOPSIS
 .nf
 .B "#include <mLib/versioncmp.h>"
 
 .BI "int versioncmp(const char *" va ", const char *" vb ");"
+.BI "int VERSIONCMP(const char *" va ", " op ", const char *" vb ");"
 .fi
 .SH DESCRIPTION
 The
@@ -48,6 +50,13 @@ or +1 if
 .I va
 is newer than
 .IR vb .
+.PP
+The
+.B VERSIONCMP
+macro provides a more convenient syntax for the
+.B versioncmp
+function, by allowing a relational operator to be written between the
+operands.
 .SH SEE ALSO
 .BR mLib (3).
 .PP
index efcb322..1990cc3 100644 (file)
@@ -66,6 +66,7 @@
  */
 
 extern int versioncmp(const char */*va*/, const char */*vb*/);
+#define VERSIONCMP(x, op, y) (versioncmp((x), (y)) op 0)
 
 /*----- That's all, folks -------------------------------------------------*/