mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-17 04:36:22 +00:00
Changes:
- Process #elif directives correctly (doesn't affect the current SCST source code). - Do not remove double blank lines from documentation files. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2278 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+35
-20
@@ -256,27 +256,16 @@ function handle_if()
|
||||
if (debug)
|
||||
printf "/* debug specialize-patch: (d) %s -> %s */\n", $0, evaluated
|
||||
|
||||
if (evaluated ~ "^+#if")
|
||||
{
|
||||
if_stmnt[if_nesting_level] = evaluated
|
||||
any_section_output[if_nesting_level] = 0
|
||||
}
|
||||
else
|
||||
{
|
||||
sub("^+#elif ",
|
||||
sprintf("+#if ! %d \\&\\& ", decision[if_nesting_level]),
|
||||
evaluated)
|
||||
evaluated = evaluate(evaluated)
|
||||
}
|
||||
decision[if_nesting_level] = evaluated
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
if_stmnt[if_elif_nesting_level] = evaluated
|
||||
any_section_output[if_elif_nesting_level] = 0
|
||||
decision[if_elif_nesting_level] = evaluated
|
||||
matching_if = if_stmnt[if_elif_nesting_level]
|
||||
}
|
||||
|
||||
|
||||
# Decide whether or not to print the preprocessor statement $0.
|
||||
|
||||
function process_preprocessor_statement() {
|
||||
last_if_nesting_level = if_nesting_level
|
||||
orig_stmnt = $0
|
||||
evaluated = evaluate($0)
|
||||
condition = 1
|
||||
@@ -284,20 +273,28 @@ function process_preprocessor_statement() {
|
||||
if (evaluated ~ "^+#if")
|
||||
{
|
||||
if_nesting_level++
|
||||
if_elif_nesting_level++
|
||||
contiguous_if_elif_count[if_nesting_level] = 1
|
||||
handle_if()
|
||||
}
|
||||
else if (evaluated ~ "^+#elif")
|
||||
{
|
||||
matching_if = if_stmnt[if_elif_nesting_level]
|
||||
decision[if_elif_nesting_level] = invert(decision[if_elif_nesting_level])
|
||||
if_elif_nesting_level++
|
||||
contiguous_if_elif_count[if_nesting_level]++
|
||||
sub("^+#elif ", "+#if ", evaluated)
|
||||
handle_if()
|
||||
}
|
||||
else if (evaluated ~ "^+#else")
|
||||
{
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
decision[if_nesting_level] = invert(decision[if_nesting_level])
|
||||
matching_if = if_stmnt[if_elif_nesting_level]
|
||||
decision[if_elif_nesting_level] = invert(decision[if_elif_nesting_level])
|
||||
}
|
||||
else if (evaluated ~ "^+#endif")
|
||||
{
|
||||
matching_if = if_stmnt[if_nesting_level]
|
||||
matching_if = if_stmnt[if_elif_nesting_level]
|
||||
if_elif_nesting_level -= contiguous_if_elif_count[if_nesting_level]
|
||||
if_nesting_level--
|
||||
}
|
||||
else
|
||||
@@ -307,12 +304,12 @@ function process_preprocessor_statement() {
|
||||
if (condition)
|
||||
{
|
||||
output = 1
|
||||
for (i = if_nesting_level; i >= 0; i--)
|
||||
for (i = if_elif_nesting_level; i >= 0; i--)
|
||||
{
|
||||
output = output && decision[i] != "+#if 0"
|
||||
}
|
||||
if (output)
|
||||
any_section_output[if_nesting_level] = 1
|
||||
any_section_output[if_elif_nesting_level] = 1
|
||||
}
|
||||
if (evaluated ~ "^+#define SCSI_EXEC_REQ_FIFO_DEFINED$" \
|
||||
&& SCSI_EXEC_REQ_FIFO_DEFINED != "" \
|
||||
@@ -352,7 +349,9 @@ function reset_hunk_state_variables() {
|
||||
lines_deleted = 0
|
||||
output = 1
|
||||
if_nesting_level = -1
|
||||
if_elif_nesting_level = -1
|
||||
delete_next_blank_line = 0
|
||||
h[0] = ""
|
||||
}
|
||||
|
||||
function dump_lines() {
|
||||
@@ -400,11 +399,27 @@ BEGIN {
|
||||
config_scst_proc_undefined = 0
|
||||
|
||||
# Variable initialization.
|
||||
is_c_source = 0
|
||||
reset_hunk_state_variables()
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
if (match($0, "^diff [^ ]* [^ ]* ([^ ]*)$", filename) \
|
||||
|| match($0, "^\\+\\+\\+\t([^ ]*)\t", filename))
|
||||
{
|
||||
# Start of new file.
|
||||
dump_lines()
|
||||
reset_hunk_state_variables()
|
||||
is_c_source = match(filename[1], "\\.[ch]$") != 0
|
||||
}
|
||||
|
||||
if (!is_c_source)
|
||||
{
|
||||
print
|
||||
next
|
||||
}
|
||||
|
||||
if (!config_scst_proc_undefined)
|
||||
{
|
||||
gsub("^+/\\* #define CONFIG_SCST_PROC \\*/$", "+#define CONFIG_SCST_PROC")
|
||||
|
||||
Reference in New Issue
Block a user