There are cases where there is a useless space after ( and before )
if ( something ) {
}
Let's clean those up by removing the spaces.
This can be done with an awk script:
{
open_paren = gensub(/\([ ]*/, "(", "g", $0)
close_paren = gensub(/[ ]*\)/, "\\1)", "g", open_paren)
if (close_paren ~ "^)") {
# Problem is the line is of type [ ]+)<other things>
# Do some replacement to get it to replace subsequent " )".
remove_first_spaces = gensub(/ )/, "#MARKER#)", 1, open_paren)
remaining = gensub(/[ ]*\)/, "\\1)", "g", remove_first_spaces)
close_paren = gensub(/#MARKER#/, " ", 1, remaining)
}
exclamation = gensub(/\![ ]*/, "!", "g", close_paren)
print exclamation
}
if ( something ) {
}
Let's clean those up by removing the spaces.
This can be done with an awk script:
{
open_paren = gensub(/\([ ]*/, "(", "g", $0)
close_paren = gensub(/[ ]*\)/, "\\1)", "g", open_paren)
if (close_paren ~ "^)") {
# Problem is the line is of type [ ]+)<other things>
# Do some replacement to get it to replace subsequent " )".
remove_first_spaces = gensub(/ )/, "#MARKER#)", 1, open_paren)
remaining = gensub(/[ ]*\)/, "\\1)", "g", remove_first_spaces)
close_paren = gensub(/#MARKER#/, " ", 1, remaining)
}
exclamation = gensub(/\![ ]*/, "!", "g", close_paren)
print exclamation
}