summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-11-13 09:08:30 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-11-13 10:43:39 +0100
commit53e13b256fa5082eb29ea2addd1bfa184827e53b (patch)
tree820c9e5ec61ce4cb1c6713a71aedfd8a0383fa01
parent70fa61918415f642228127847491224078532218 (diff)
clang-format: standardize on 5.0.0
Restrict the git hook further to only enforce style in case the found clang-format binary's version matches to avoid output differences with different clang-format version. While at it, move the blacklist reading after the version check to speed up committing a bit when no local enforcement happens. Also add a simple script to list formatted files, since the blacklist is large enough that doing it naively from the shell is too slow. Change-Id: I0bc05961d262cc6bc91c6efdd1b91994ecfc6940 Reviewed-on: https://gerrit.libreoffice.org/44662 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rwxr-xr-x.git-hooks/pre-commit38
-rwxr-xr-xsolenv/clang-format/list-formatted-files40
-rw-r--r--vcl/qt5/Qt5Frame.cxx14
-rw-r--r--vcl/qt5/tst_exclude_posted_events.hxx3
4 files changed, 75 insertions, 20 deletions
diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index b40ad6f004d9..3743f6b79d6c 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -108,6 +108,18 @@ sub check_whitespaces($)
}
}
+# Is this binary the version we standardize on?
+sub is_matching_clang_format_version($$)
+{
+ my ($clang_format, $version) = @_;
+ if (! -x $clang_format)
+ {
+ return 0;
+ }
+
+ return `$clang_format -version` =~ /^clang-format version $version \(tags/;
+}
+
sub check_style($)
{
my ($h) = @_;
@@ -119,35 +131,25 @@ sub check_style($)
# directory.
my $opt_lo = "/opt/lo/bin";
my $clang_format = "$opt_lo/clang-format";
- if (! -x $clang_format)
+ my $version = "5.0.0";
+ if (!is_matching_clang_format_version($clang_format, $version))
{
foreach my $dir (split /:/, $ENV{PATH})
{
$clang_format = "$dir/clang-format";
- if (-x $clang_format)
+ if (is_matching_clang_format_version($clang_format, $version))
{
last;
}
}
}
- # Read the blacklist.
- if (open(LINES, "solenv/clang-format/blacklist"))
- {
- while (my $line = <LINES>)
- {
- chomp $line;
- $blacklist_names{$line} = 1;
- }
- }
-
# Check if clang-format is installed.
if (! -x $clang_format)
{
# As a first step, don't do any checks in this case.
return;
- my $version = "r302580";
my $platform = "linux64";
my $download = "wget";
if ($^O eq "cygwin")
@@ -170,6 +172,16 @@ sub check_style($)
exit(1);
}
+ # Read the blacklist.
+ if (open(LINES, "solenv/clang-format/blacklist"))
+ {
+ while (my $line = <LINES>)
+ {
+ chomp $line;
+ $blacklist_names{$line} = 1;
+ }
+ }
+
if ($^O eq "cygwin")
{
$clang_format = `cygpath -m $clang_format`;
diff --git a/solenv/clang-format/list-formatted-files b/solenv/clang-format/list-formatted-files
new file mode 100755
index 000000000000..4dfd4bfc0c34
--- /dev/null
+++ b/solenv/clang-format/list-formatted-files
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+
+# Lists source files which are not blacklisted. This is interesting if the
+# clang-format version or config changes. To trigger a reformat in that case,
+# you can do:
+#
+# clang-format -i $(solenv/clang-format/list-formatted-files)
+
+sub check_style()
+{
+ my $src = "c|cpp|cxx|h|hxx|inl";
+ my %blacklist_names = ();
+
+ # Read the blacklist.
+ if (open(LINES, "solenv/clang-format/blacklist"))
+ {
+ while (my $line = <LINES>)
+ {
+ chomp $line;
+ $blacklist_names{$line} = 1;
+ }
+ }
+
+ # Get a list of files.
+ open (FILES, "git ls-files |") || die "Cannot run git ls-files.";
+ while (my $filename = <FILES>)
+ {
+ chomp $filename;
+ if ($filename =~ /\.($src)$/ and !exists($blacklist_names{$filename}))
+ {
+ print($filename . "\n");
+ }
+ }
+}
+
+check_style();
+
+exit(0);
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 3f2ea2da7ba3..e853b7d43d9e 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -184,9 +184,10 @@ void Qt5Frame::SetTitle(const OUString& rTitle)
void Qt5Frame::SetIcon(sal_uInt16 nIcon)
{
- if (m_nStyle & (SalFrameStyleFlags::PLUG | SalFrameStyleFlags::SYSTEMCHILD
- | SalFrameStyleFlags::FLOAT | SalFrameStyleFlags::INTRO
- | SalFrameStyleFlags::OWNERDRAWDECORATION)
+ if (m_nStyle
+ & (SalFrameStyleFlags::PLUG | SalFrameStyleFlags::SYSTEMCHILD
+ | SalFrameStyleFlags::FLOAT | SalFrameStyleFlags::INTRO
+ | SalFrameStyleFlags::OWNERDRAWDECORATION)
|| !m_pQWidget->isWindow())
return;
@@ -268,7 +269,7 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt1
if ((nFlags & (SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT))
&& (nWidth > 0 && nHeight > 0) // sometimes stupid things happen
- )
+ )
{
m_bDefaultSize = false;
if (isChild(false) || !m_pQWidget->isMaximized())
@@ -332,8 +333,9 @@ void Qt5Frame::SetWindowState(const SalFrameState* pState)
if ((pState->mnMask & WindowStateMask::State) && (pState->mnState & WindowStateState::Maximized)
&& (pState->mnMask & nMaxGeometryMask) == nMaxGeometryMask)
m_pQWidget->showMaximized();
- else if (pState->mnMask & (WindowStateMask::X | WindowStateMask::Y | WindowStateMask::Width
- | WindowStateMask::Height))
+ else if (pState->mnMask
+ & (WindowStateMask::X | WindowStateMask::Y | WindowStateMask::Width
+ | WindowStateMask::Height))
{
sal_uInt16 nPosSizeFlags = 0;
QPoint aPos = m_pQWidget->pos();
diff --git a/vcl/qt5/tst_exclude_posted_events.hxx b/vcl/qt5/tst_exclude_posted_events.hxx
index d12c012e4547..79c9887f843e 100644
--- a/vcl/qt5/tst_exclude_posted_events.hxx
+++ b/vcl/qt5/tst_exclude_posted_events.hxx
@@ -56,7 +56,8 @@ static int tst_excludePostedEvents()
TestExcludePostedEvents test;
QCoreApplication::postEvent(&test, new QEvent(eventType));
QEventLoop loop;
- loop.processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers
+ loop.processEvents(QEventLoop::ExcludeUserInputEvents
+ | QEventLoop::ExcludeSocketNotifiers
// | QEventLoop::WaitForMoreEvents
| QEventLoop::X11ExcludeTimers);
QVERIFY(!test.processed);