author Gregory Szorc <gps@mozilla.com>
Wed, 28 Jan 2015 13:37:00 -0800
changeset 110559 3ba2371322adf61607b0d2271d05b401237026b8
parent 99299 7c3cd4824f94609d4ad714bea9c687227c641e63
permissions -rw-r--r--
Close old release branch GECKO1703_2013021512_RELBRANCH

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import sys
import re

# Define RegEx for finding and breaking apart SQLITE_VERSION string
versionString = "^#define SQLITE_VERSION\D*(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?\D*"

#Use command line argument pointing to sqlite3.h to open the file and use
#the RegEx to search for the line #define SQLITE_VERSION. When the RegEx
#matches and the line is found, print the version strings to the console
#with #definey goodness.
for line in open(sys.argv[1]):
    result = re.search(versionString, line)
    if result is not None:    #If RegEx matches, print version numbers and stop
        splitVersion = list(result.groups())
        if splitVersion[3] is None:       #Make 4th list element 0 if undefined
            splitVersion[3:] = ['0']
        print "#define SQLITE_VERSION_MAJOR " + splitVersion[0]
        print "#define SQLITE_VERSION_MINOR " + splitVersion[1]
        print "#define SQLITE_VERSION_PATCH " + splitVersion[2]
        print "#define SQLITE_VERSION_SUBPATCH " + splitVersion[3]