summarylogtreecommitdiffstats
path: root/missing_getver.patch
blob: c69ea3047c3e9c55b1be5decd8a99644074716f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
diff -ruNa libgd-2.1.1.orig/config/getver.pl libgd-2.1.1/config/getver.pl
--- libgd-2.1.1.orig/config/getver.pl	1970-01-01 01:00:00.000000000 +0100
+++ libgd-2.1.1/config/getver.pl	2015-07-23 05:23:49.932676287 +0200
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+
+# Simple script to extract the version number parts from src/gd.h.  If
+# called with the middle word of the version macro, it prints the
+# value of that macro.  If called with no argument, it outputs a
+# human-readable version string.  This must be run in the project
+# root.  It is used by configure.ac and docs/naturaldocs/run_docs.sh.
+
+use strict;
+
+my $key = shift;
+my @version_parts = ();
+
+open FH, "<src/gd.h"   # old-style filehandle for max. portability
+  or die "Unable to open 'version.h' for reading.\n";
+
+while(<FH>) {
+  next unless m{version605b5d1778};
+  next unless /^#define\s+GD_([A-Z0-9]+)_VERSION+\s+(\S+)/;
+  my ($lk, $lv) = ($1, $2);
+  if ($lk eq $key) {
+    chomp $lv;
+    $lv =~ s/"//g;
+
+    print $lv;   # no newline
+    exit(0);    # success!
+  }
+
+  push @version_parts, $lv if (!$key);
+}
+
+close(FH);
+
+if (scalar @version_parts == 4) {
+  my $result = join(".", @version_parts[0..2]);
+  $result .= $version_parts[3];
+  $result =~ s/"//g;
+  print $result;
+  exit(0);
+}
+
+exit(1);        # failure