import sys
import regex
import string

fd = open ('version.h', 'r')

v_reg = regex.compile ('#define WINVN_VERSION "WinVN \([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)"')

line = fd.readline()

if v_reg.match(line) == -1:
	print 'something is wrong with version.h'
	sys.exit()

fd.close()

fd = open ('version.h', 'w')

new_ver = '#define WINVN_VERSION \"WinVN ' \
	+ v_reg.group(1) \
	+ "." + v_reg.group(2) \
	+ "." + str(string.atoi(v_reg.group(3)) + 1) \
	+ '"\n'

fd.write(new_ver)
fd.close()
