function strip(input) { sub("^ +", "", input) sub(" +$", "", input) return input } function check_compatible_le(version_arr, len_version_arr, require_arr, len_require_arr, i) { for (i = 1; i <= len_require_arr; i++) { if (require_arr[i] == "") { continue } # len_version_arr lt len_require_arr if (i > len_version_arr) { return 1 } if (version_arr[i] < require_arr[i]) { return 1 } if (version_arr[i] > require_arr[i]) { return 0 } } if (len_version_arr > len_require_arr) { return 1 } # len_version_arr eq len_require_arr return 1 } function check_compatible_lt(version_arr, len_version_arr, require_arr, len_require_arr, i) { for (i = 1; i <= len_require_arr; i++) { if (require_arr[i] == "") { continue } # len_version_arr lt len_require_arr if (i > len_version_arr) { return 1 } if (version_arr[i] < require_arr[i]) { return 1 } if (version_arr[i] > require_arr[i]) { return 0 } } if (len_version_arr > len_require_arr) { return 0 } # len_version_arr eq len_require_arr return 0 } function check_compatible_ge(version_arr, len_version_arr, require_arr, len_require_arr, i) { for (i = 1; i <= len_require_arr; i++) { if (require_arr[i] == "") { continue } # len_version_arr lt len_require_arr if (i > len_version_arr) { return 0 } if (version_arr[i] < require_arr[i]) { return 0 } if (version_arr[i] > require_arr[i]) { return 1 } } if (len_version_arr > len_require_arr) { return 1 } # len_version_arr eq len_require_arr return 1 } function check_compatible_gt(version_arr, len_version_arr, require_arr, len_require_arr, i) { for (i = 1; i <= len_require_arr; i++) { if (require_arr[i] == "") { continue } # len_version_arr lt len_require_arr if (i > len_version_arr) { return 0 } if (version_arr[i] < require_arr[i]) { return 0 } if (version_arr[i] > require_arr[i]) { return 1 } } if (len_version_arr > len_require_arr) { return 1 } # len_version_arr eq len_require_arr return 0 } function check_compatible_eq(version_arr, len_version_arr, require_arr, len_require_arr, i) { for (i = 1; i <= len_require_arr; i++) { if (require_arr[i] == "") { continue } # len_version_arr lt len_require_arr if (i > len_version_arr) { return 0 } if (version_arr[i] != require_arr[i]) { return 0 } } if (len_version_arr > len_require_arr) { return 1 } # len_version_arr eq len_require_arr return 1 } function check_compatible(version_arr, len_version_arr, require, require_arr, len_require_arr, pos) { len_require_arr = split(require, require_arr, ".") pos = match(require_arr[1], /^>=/) if (pos != 0) { require_arr[1] = substr(require_arr[1], pos + RLENGTH) return check_compatible_ge(version_arr, len_version_arr, require_arr, len_require_arr) } pos = match(require_arr[1], /^>/) if (pos != 0) { require_arr[1] = substr(require_arr[1], pos + RLENGTH) return check_compatible_gt(version_arr, len_version_arr, require_arr, len_require_arr) } pos = match(require_arr[1], /^<=/) if (pos != 0) { require_arr[1] = substr(require_arr[1], pos + RLENGTH) return check_compatible_le(version_arr, len_version_arr, require_arr, len_require_arr) } pos = match(require_arr[1], /^ 0) compated = 0 else # no required compated = 1 in_gt = 0 matched_gt = 0 len_version_arr = split(version, version_arr, ".") for (i = 1; i <= len_all_required_arr; i++) { all_required_arr[i] = strip(all_required_arr[i]) one_compated = check_compatible(version_arr, len_version_arr, all_required_arr[i]) pos = match(all_required_arr[i], /^>/) if (pos != 0) { gt_require = 1 lt_require = 0 eq_require = 0 } else { pos = match(all_required_arr[i], /^