mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Another small tweak to whitespace tool
clang-format doesn't appear to reindent multi line #define statements correctly - so this hopefully will clean those up. The included whitespace corrections to the code should stay in place when using the updated tool. This includes cleaning up some multi-line comments that were messed up the last time around as well as a few other minor changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
13a2f14be0
commit
1b103c5c69
9 changed files with 69 additions and 54 deletions
|
@ -934,8 +934,7 @@ bool TreeItem::setData(const QModelIndex &index, const QVariant &value, int role
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
|
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
const
|
|
||||||
{
|
{
|
||||||
if (!hasIndex(row, column, parent))
|
if (!hasIndex(row, column, parent))
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
|
@ -11,9 +11,25 @@ $source =~ s/^(\s*static\s+struct[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||||
$source =~ s/^(\s*union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(\s*union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||||
$source =~ s/^(\s*static\s+union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(\s*static\s+union[^()\n]*)\n\s*{\s*$/$1 {/img;
|
||||||
$source =~ s/^(\s*class.*)\n\s*{\s*$/$1 {/img;
|
$source =~ s/^(\s*class.*)\n\s*{\s*$/$1 {/img;
|
||||||
|
# colon goes at the end of a line
|
||||||
$source =~ s/^(\S*::\S*.*)\n\s*: /$1 : /img;
|
$source =~ s/^(\S*::\S*.*)\n\s*: /$1 : /img;
|
||||||
|
# odd indentations from flang-format:
|
||||||
|
# six spaces or four spaces after tabs (for continuation strings)
|
||||||
$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
|
$source =~ s/(?:\G|^)[ ]{6}/\t/mg;
|
||||||
$source =~ s/(?:\G|^)(\t*)[ ]{4}"/$1\t"/mg;
|
$source =~ s/(?:\G|^)(\t*)[ ]{4}"/$1\t"/mg;
|
||||||
|
# the next ones are rather awkward
|
||||||
|
# they capture multi line #define and #if definded statements
|
||||||
|
# that clang-format messes up (where does that 4 space indentation come
|
||||||
|
# from?
|
||||||
|
# I couldn't figure out how to make it apply to an arbitrary number of
|
||||||
|
# intermediate lines, so I hardcoded 0 through 5 lines between the #define
|
||||||
|
# or #id defined statements and the end of the multi line statement
|
||||||
|
$source =~ s/^(#(?:if |)define.*)\n +([^*].*)$/$1\n\t$2/mg;
|
||||||
|
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){1})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||||
|
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){2})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||||
|
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){3})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||||
|
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){4})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||||
|
$source =~ s/^(#(?:if |)define.*)((?:\\\n.*){5})\n +([^*].*)$/$1$2\n\t$3/mg;
|
||||||
# don't put line break before the last single term argument of a
|
# don't put line break before the last single term argument of a
|
||||||
# calculation
|
# calculation
|
||||||
$source =~ s/(?:\G|^)(.*[+-])\n\s*(\S*\;)$/$1 $2/mg;
|
$source =~ s/(?:\G|^)(.*[+-])\n\s*(\S*\;)$/$1 $2/mg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue