mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-22 13:11:27 +00:00
scripts/specialize-patch: Fix handling of complex #if / #elif / #else / #endif constructs
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6515 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -327,7 +327,6 @@ function handle_if(evaluated)
|
||||
printf "/* debug specialize-patch: (f) %s / %s */\n", \
|
||||
decision[if_nesting_level], inv_decision[if_nesting_level]
|
||||
}
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
return evaluated
|
||||
}
|
||||
|
||||
@@ -346,25 +345,19 @@ function process_preprocessor_statement(evaluated, condition) {
|
||||
}
|
||||
else if (evaluated ~ "^+#elif")
|
||||
{
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
if (debug)
|
||||
printf "/* debug specialize-patch: (g0a) %s: matching_if = %s */\n", \
|
||||
evaluated, matching_if
|
||||
if (if_discarded[if_nesting_level]) {
|
||||
sub("^+#elif", "+#if", input_line[0])
|
||||
if (debug)
|
||||
printf "/* debug specialize-patch: (g0b) -> %s */\n", evaluated
|
||||
printf "/* debug specialize-patch: (g0) -> %s */\n", evaluated
|
||||
}
|
||||
evaluated = handle_if(evaluated)
|
||||
}
|
||||
else if (evaluated ~ "^+#else")
|
||||
{
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
decision[if_nesting_level] = inv_decision[if_nesting_level]
|
||||
}
|
||||
else if (evaluated ~ "^+#endif")
|
||||
{
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
if_nesting_level--
|
||||
}
|
||||
else
|
||||
@@ -399,7 +392,9 @@ function process_preprocessor_statement(evaluated, condition) {
|
||||
discard = 1
|
||||
delete_next_blank_line = 1
|
||||
}
|
||||
else if (output && (!condition || matching_if !~ "^+#(el|)if [01]"))
|
||||
else if (output && (!condition || \
|
||||
decision[if_nesting_level + (evaluated ~ "^+#endif$")] \
|
||||
!~ "^+#(el|)if [01]"))
|
||||
{
|
||||
if (evaluated == "+#if undecided" \
|
||||
|| (evaluated !~ "^+#if" \
|
||||
|
||||
Reference in New Issue
Block a user