mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 09:11:27 +00:00
scripts/specialize-patch: Remove #elif 0 sections from the output
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3807 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user