From de8bc79ae0f7dad61c2eee6a051338034db6314c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 16 Aug 2011 12:20:25 +0000 Subject: [PATCH] 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 --- scripts/filter-trace-entry-exit | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/scripts/filter-trace-entry-exit b/scripts/filter-trace-entry-exit index 6d9c49dd3..0ce861cc1 100755 --- a/scripts/filter-trace-entry-exit +++ b/scripts/filter-trace-entry-exit @@ -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: