scripts/specialize-patch: Clamp sublevel to 255 (trunk r9369)

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.5.x@9459 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2021-06-24 03:54:31 +00:00
parent 04b1a0245d
commit c2f3274514

View File

@@ -31,10 +31,14 @@
# Convert a kernel version in the x.y.z format into numeric form, just like
# the KERNEL_VERSION() macro.
function version_number(a, b, c) {
return a * 65536 + b * 256 + (c > 255 ? 255 : c);
}
function version_code(kver, array) {
if (!match(kver, "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$", array))
match(kver, "^([0-9]+)\\.([0-9]+)$", array)
return 65536*array[1] + 256*array[2] + array[3]
return version_number(array[1], array[2], array[3]);
}
@@ -172,7 +176,7 @@ function evaluate(stmnt, pattern, arg, op, result) {
pattern="KERNEL_VERSION\\([[:blank:]]*([0-9]+)[[:blank:]]*,[[:blank:]]*([0-9]+)[[:blank:]]*,[[:blank:]]*([0-9]+)[[:blank:]]*\\)"
while (match(stmnt, pattern, op) != 0)
{
sub(pattern, op[1] * 65536 + op[2] * 256 + op[3], stmnt)
sub(pattern, version_number(op[1], op[2], op[3]), stmnt)
}
gsub("defined\\(INSIDE_KERNEL_TREE\\)", "1", stmnt)