summaryrefslogtreecommitdiffstats
path: root/bin/versinc
blob: 76d07e1b029ba3b8530d3aba0bfa00ca5339fd37 (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
#! /usr/local/bin/perl -w
require 5.003;
use Cwd;

# Get the current directory and build the source files name based on it.
($cwd)=(cwd()=~m#(.*?hdf5)/.*#);

$hdr = "$cwd/src/H5public.h";
$bak = "$cwd/src/H5public.h~";
$tmp = "$cwd/src/H5public.$$";

# Open files
open OLD, $hdr or die "cannot read $hdr";
open NEW, ">$tmp" or die "cannot write to $tmp";

while (<OLD>) {
    if (/^(\#\s*define\s+H5_VERS_RELEASE\s+)(\d+)(.*)/) {
	print NEW $1, $2+1, $3, "\n";
    } elsif (/^(\#\s*define\s+H5_VERS_PATCH\s+)(\d+)(.*)/) {
	print NEW $1, "0", $3, "\n";
    } else {
	print NEW;
    }
}
close OLD;
close NEW;

# Create a backup
rename $hdr, $bak or warn "cannot create backup version";
rename $tmp, $hdr or die "cannot update version number";

exit 0;