- Process the pattern [01] && defined(...) properly.
- Added command-line option -d (debug) to generate-kernel-patch.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1582 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2010-04-04 13:27:24 +00:00
parent 38575b3d34
commit 12b1d9d57e
2 changed files with 27 additions and 2 deletions

View File

@@ -42,6 +42,10 @@ function version_code(kver) {
# it is the same order as the order of operators in C.
function evaluate(stmnt) {
if (debug)
printf "/* debug specialize-patch: (a) %s */\n", stmnt
# Remove C-style comments.
gsub(" *\\/\\*[^*]*\\*\\/ *", "", stmnt)
@@ -123,6 +127,9 @@ function evaluate(stmnt) {
gsub("defined *\\( *CONFIG_SCST_PROC *\\)", 0, stmnt)
}
if (debug)
printf "/* debug specialize-patch: (b) %s */\n", stmnt
do
{
last_stmnt = stmnt
@@ -175,6 +182,12 @@ function evaluate(stmnt) {
sub(pattern, (op[1] != 0) && (op[2] != 0), stmnt)
}
pattern="([01]) *\\&\\& *(!* *defined *\\( *[A-Za-z_]* *\\))"
while (match(stmnt, pattern, op) != 0)
{
sub(pattern, op[1] != 0 ? op[2] : op[1], stmnt)
}
pattern="(-*[0-9]+) *\\|\\| *(-*[0-9]+)"
while (match(stmnt, pattern, op) != 0)
{
@@ -186,6 +199,10 @@ function evaluate(stmnt) {
{
sub(pattern, op[1], stmnt)
}
if (debug)
printf "/* debug specialize-patch: (c) %s -> %s */\n", last_stmnt, stmnt
} while (stmnt != last_stmnt)
return stmnt
@@ -223,7 +240,10 @@ function handle_if()
{
evaluated = "+#if undecided"
}
#printf "%s -> %s\n", $0, evaluated
if (debug)
printf "/* debug specialize-patch: (d) %s -> %s */\n", $0, evaluated
if (evaluated ~ "^+#if")
{
if_stmnt[if_nesting_level] = evaluated