From 99b4f9a98d70032953bbdbc53ec7992907199bed Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Sun, 29 Sep 2024 16:48:01 +0100 Subject: [PATCH] tools/check_curl_symbols.py: add max version (only) handling With a later commit, some options will have only a max version so ensure we handle those cases. Signed-off-by: Emil Velikov --- tools/check_curl_symbols.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/check_curl_symbols.py b/tools/check_curl_symbols.py index 8a81bb893..73e4b8434 100755 --- a/tools/check_curl_symbols.py +++ b/tools/check_curl_symbols.py @@ -55,6 +55,11 @@ WEECHAT_CURL_MIN_VERSION_RE = ( r"/\* (?P[0-9][0-9.]+) \*/" ) +WEECHAT_CURL_MAX_VERSION_RE = ( + r"#if LIBCURL_VERSION_NUM < (?P0x[0-9A-F]+) " + r"/\* < (?P[0-9][0-9.]+) \*/" +) + WEECHAT_CURL_MIN_MAX_VERSION_RE = ( r"#if LIBCURL_VERSION_NUM >= (?P0x[0-9A-F]+) " r"&& LIBCURL_VERSION_NUM < (?P0x[0-9A-F]+) " @@ -148,6 +153,7 @@ def get_weechat_curl_symbols() -> Tuple[List[WeechatCurlSymbol], int]: """ # pylint: disable=too-many-locals,too-many-statements min_version_pattern = re.compile(WEECHAT_CURL_MIN_VERSION_RE) + max_version_pattern = re.compile(WEECHAT_CURL_MAX_VERSION_RE) min_max_version_pattern = re.compile(WEECHAT_CURL_MIN_MAX_VERSION_RE) endif_pattern = re.compile(WEECHAT_ENDIF_RE) constant_pattern = re.compile(WEECHAT_CURL_CONSTANT_RE) @@ -175,6 +181,21 @@ def get_weechat_curl_symbols() -> Tuple[List[WeechatCurlSymbol], int]: ) errors += 1 continue + # max Curl version + match = re.match(max_version_pattern, line) + if match: + hex_max_vers = match["hex_max_version"] + str_max_vers = match["str_max_version"] + v_min, v_max = 0, int(hex_max_vers, 0) + comment_max = curl_version_to_int(str_max_vers) + if v_max != comment_max: + print( + f"{SRC_PATH}:{line_no}: max version not matching " + f"the comment: " + f"{hex_max_vers} != {str_max_vers}" + ) + errors += 1 + continue # min + max Curl version match = re.match(min_max_version_pattern, line) if match: