maint: Fix generating version number.

Signed-off-by: Simon Josefsson <simon@josefsson.org>
diff --git a/configure.ac b/configure.ac
index 5389656..4df249c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,7 @@
 
 AC_SUBST([MAJOR_VERSION], [`echo $PACKAGE_VERSION|cut -d'.' -f1`])
 AC_SUBST([MINOR_VERSION], [`echo $PACKAGE_VERSION|cut -d'.' -f2`])
-AC_SUBST([PATCH_VERSION], [`echo $PACKAGE_VERSION|cut -d'.' -f3`])
+AC_SUBST([PATCH_VERSION], [`echo $PACKAGE_VERSION.0|cut -d. -f3|cut -d- -f1`])
 AC_SUBST([NUMBER_VERSION], [`printf '0x%02x%02x%02x' $MAJOR_VERSION $MINOR_VERSION $PATCH_VERSION`])
 
 AC_MSG_NOTICE([$PACKAGE_NAME $PACKAGE_VERSION $PACKAGE_TARNAME $MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION $NUMBER_VERSION $LT_CURRENT:$LT_REVISION:$LT_AGE $DLL_VERSION])
diff --git a/tests/reproducers.c b/tests/reproducers.c
index daac910..cac6296 100644
--- a/tests/reproducers.c
+++ b/tests/reproducers.c
@@ -34,8 +34,8 @@
  * The following translates into a single node with all pointers
  * (right,left,down) set to NULL. */
 const asn1_static_node endless_asn1_tab[] = {
-  { "TEST_TREE", 536875024, NULL },
-  { NULL, 0, NULL }
+  {"TEST_TREE", 536875024, NULL},
+  {NULL, 0, NULL}
 };
 
 /* produces memory leak (fixed by f16d1ff9):
@@ -46,10 +46,10 @@
  *    by 0x10923B: main (single_node.c:67)
  */
 const asn1_static_node tab[] = {
-{ "a", CONST_DOWN, "" },
-{ "b", 0, "" },
-{ "c", 0, "" },
-{ NULL, 0, NULL }
+  {"a", CONST_DOWN, ""},
+  {"b", 0, ""},
+  {"c", 0, ""},
+  {NULL, 0, NULL}
 };
 
 int
@@ -58,6 +58,62 @@
   int result, verbose = 0;
   asn1_node definitions = NULL;
   char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
+  char *out = errorDescription;
+  int i;
+
+  printf ("Header version %s library version %s\n",
+	  ASN1_VERSION, asn1_check_version (NULL));
+
+  if (!asn1_check_version (ASN1_VERSION))
+    {
+      printf ("asn1_check_version failure\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!asn1_check_version ("4.17.0"))
+    {
+      printf ("asn1_check_version(4.17.0) failure\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!asn1_check_version ("4.17"))
+    {
+      printf ("asn1_check_version(4.17) failure\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (strcmp (ASN1_VERSION, asn1_check_version (NULL)) != 0)
+    {
+      printf ("header version mismatch library version\n");
+      exit (EXIT_FAILURE);
+    }
+
+  i = ASN1_VERSION_MAJOR * 256 * 256 +
+    ASN1_VERSION_MINOR * 256 + ASN1_VERSION_PATCH;
+
+  snprintf (out, ASN1_MAX_ERROR_DESCRIPTION_SIZE - 1, "%d.%d.%d",
+	    ASN1_VERSION_MAJOR, ASN1_VERSION_MINOR, ASN1_VERSION_PATCH);
+
+  printf ("Header version %s number %x derived %x\n", out,
+	  (unsigned) ASN1_VERSION_NUMBER, (unsigned) i);
+
+  if (ASN1_VERSION_NUMBER != i)
+    {
+      printf ("header version number mismatch\n");
+      exit (EXIT_FAILURE);
+    }
+
+  if (!asn1_check_version (out))
+    {
+      printf ("asn1_check_version(%s) failure\n", out);
+      exit (EXIT_FAILURE);
+    }
+
+  if (strncmp (ASN1_VERSION, out, strlen (out)) != 0)
+    {
+      printf ("header version numbers mismatch library version\n");
+      exit (EXIT_FAILURE);
+    }
 
   if (argc > 1)
     verbose = 1;