diff --git a/scripts/specialize-patch b/scripts/specialize-patch index 0874c1bf9..b925ef986 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -196,6 +196,18 @@ function evaluate(stmnt, pattern, arg, op, result) { stmnt = "+#if " (op[1] != 0 ? op[2] : op[1]) } + pattern="^+#if[ ]*(!*[ ]*defined[ ]*\\([ ]*[A-Za-z_]*[ ]*\\))\\&\\&[ ]*([01])[ ]*$" + while (match(stmnt, pattern, op) != 0) + { + stmnt = "+#if " (op[2] != 0 ? op[1] : op[2]) + } + + pattern="^+#if[ ]*(!*[ ]*[A-Za-z_]*[ ]*)\\&\\&[ ]*([01])[ ]*$" + while (match(stmnt, pattern, op) != 0) + { + stmnt = "+#if " (op[2] != 0 ? op[1] : op[2]) + } + pattern="(-*[0-9]+)[ ]*\\|\\|[ ]*(-*[0-9]+)" while (match(stmnt, pattern, op) != 0) { @@ -254,7 +266,8 @@ function handle_if(evaluated) || ($0 ~ "SCST_IO_CONTEXT" && SCST_IO_CONTEXT != "")) { #print $0 " -> " evaluated - $0 = evaluated + input_line_count = 1 + input_line[0] = evaluated } else { @@ -328,11 +341,12 @@ function process_preprocessor_statement(evaluated, condition) { { output = 1 for (i = if_nesting_level; i >= 0; i--) - { - output = output && decision[i] != "+#if 0" - } + output = output && decision[i] != "+#if 0" && decision[i] != "+#elif 0" if (output) any_section_output[if_nesting_level] = 1 + if (debug) + printf "/* debug specialize-patch: (g) %s: output = %d */\n", \ + evaluated, output } if (evaluated ~ "^+#define SCSI_EXEC_REQ_FIFO_DEFINED$" \ && SCSI_EXEC_REQ_FIFO_DEFINED != "" \ @@ -344,7 +358,9 @@ function process_preprocessor_statement(evaluated, condition) { discard = 1 delete_next_blank_line = 1 } - else if (output && (! condition || condition && matching_if !~ "^+#if [01]")) + else if (output && (! condition \ + || condition && matching_if !~ "^+#if [01]" \ + && matching_if !~ "^+#elif [01]")) { for (i = 0; i < input_line_count; i++) line[lines++] = input_line[i] @@ -518,3 +534,8 @@ END { # Dump processed contents of the last read hunk. dump_lines() } + +# Local variables: +# indent-tabs-mode: nil +# c-basic-offset: 2 +# End: