mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 01:01:27 +00:00
scripts/filter-trace-entry-exit: Filter out "return;" statements at the end of a function that are not preceeded by a label.
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3811 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -23,6 +23,9 @@ function categorize_line(line) {
|
||||
is_blank = 0
|
||||
is_trace_entry = 0
|
||||
is_trace_exit = 0
|
||||
is_label = 0
|
||||
is_return_void = 0
|
||||
is_brace_at_start_of_line = 0
|
||||
if (line ~ "^+$")
|
||||
is_blank = 1
|
||||
else if (line ~ "^+\tTRACE_ENTRY\\(\\);$")
|
||||
@@ -31,6 +34,12 @@ function categorize_line(line) {
|
||||
|| line ~ "^+\tTRACE_EXIT_RES\\(.*\\);$" \
|
||||
|| line ~ "^+\tTRACE_EXIT_HRES\\(.*\\);$")
|
||||
is_trace_exit = 1
|
||||
else if (line ~ ":$")
|
||||
is_label = 1
|
||||
else if (line ~ "^+\treturn;$")
|
||||
is_return_void = 1
|
||||
else if (line ~ "^+}$")
|
||||
is_brace_at_start_of_line = 1
|
||||
}
|
||||
|
||||
# Leave out TRACE_ENTRY() and the blank line below it and also TRACE_EXIT()
|
||||
@@ -39,10 +48,14 @@ function print_conditionally() {
|
||||
if (previous_is_trace_entry \
|
||||
|| (before_previous_is_trace_entry && previous_is_blank) \
|
||||
|| previous_is_trace_exit \
|
||||
|| (previous_is_blank && is_trace_exit))
|
||||
|| (previous_is_blank && is_trace_exit) \
|
||||
|| (!before_previous_is_label \
|
||||
&& previous_is_return_void \
|
||||
&& is_brace_at_start_of_line))
|
||||
{
|
||||
# print "deleted", previous_line
|
||||
lines_deleted++
|
||||
reverse_shift_state_variables()
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -56,9 +69,19 @@ function shift_state_variables(line) {
|
||||
before_previous_is_blank = previous_is_blank
|
||||
before_previous_is_trace_entry = previous_is_trace_entry
|
||||
before_previous_is_trace_exit = previous_is_trace_exit
|
||||
before_previous_is_label = previous_is_label
|
||||
previous_is_blank = is_blank
|
||||
previous_is_trace_entry = is_trace_entry
|
||||
previous_is_trace_exit = is_trace_exit
|
||||
previous_is_label = is_label
|
||||
previous_is_return_void = is_return_void
|
||||
}
|
||||
|
||||
function reverse_shift_state_variables() {
|
||||
previous_is_blank = before_previous_is_blank
|
||||
previous_is_trace_entry = before_previous_is_trace_entry
|
||||
previous_is_trace_exit = before_previous_is_trace_exit
|
||||
previous_is_label = before_previous_is_label
|
||||
}
|
||||
|
||||
function reset_hunk_state_variables() {
|
||||
@@ -68,9 +91,12 @@ function reset_hunk_state_variables() {
|
||||
before_previous_is_blank = 0
|
||||
before_previous_is_trace_entry = 0
|
||||
before_previous_is_trace_exit = 0
|
||||
before_previous_is_label = 0
|
||||
previous_is_blank = 0
|
||||
previous_is_trace_entry = 0
|
||||
previous_is_trace_exit = 0
|
||||
previous_is_label = 0
|
||||
previous_is_return_void = 0
|
||||
}
|
||||
|
||||
function dump_lines() {
|
||||
@@ -130,3 +156,8 @@ END {
|
||||
print_conditionally()
|
||||
dump_lines()
|
||||
}
|
||||
|
||||
# Local variables:
|
||||
# indent-tabs-mode: nil
|
||||
# c-basic-offset: 2
|
||||
# End:
|
||||
|
||||
Reference in New Issue
Block a user