clang-format: restore lost warning on touching formatted file without check

Consistently only assign something to $clang_format if it's a good
version, and also consistently return undef if we found no good version.

Change-Id: Iadbbb56a5c15dfaeec5c80e3cc8fcc78b787c04b
Reviewed-on: https://gerrit.libreoffice.org/46489
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2017-12-14 22:23:55 +01:00
parent 98de1ed2e2
commit 653b513181
3 changed files with 15 additions and 13 deletions

View File

@@ -133,7 +133,7 @@ sub check_style($)
chomp $filename; chomp $filename;
if ($filename =~ /\.($src)$/ and !exists($blacklist_names->{$filename})) if ($filename =~ /\.($src)$/ and !exists($blacklist_names->{$filename}))
{ {
if (! -x $clang_format) if (!defined($clang_format))
{ {
my $version = ClangFormat::get_wanted_version(); my $version = ClangFormat::get_wanted_version();
my $opt_lo = ClangFormat::get_own_directory(); my $opt_lo = ClangFormat::get_own_directory();

View File

@@ -65,13 +65,13 @@ sub find()
{ {
my $version = get_wanted_version(); my $version = get_wanted_version();
my $opt_lo = get_own_directory(); my $opt_lo = get_own_directory();
my $clang_format = $ENV{CLANG_FORMAT}; my $clang_format;
if (!(defined($clang_format) && is_matching_clang_format_version($clang_format, $version))) if (!(defined($ENV{CLANG_FORMAT}) && is_matching_clang_format_version($ENV{CLANG_FORMAT}, $version)))
{ {
$clang_format = "$opt_lo/clang-format"; my @dirs = split /:/, $ENV{PATH};
if (!is_matching_clang_format_version($clang_format, $version)) unshift(@dirs, $opt_lo);
{
foreach my $dir (split /:/, $ENV{PATH}) foreach my $dir (@dirs)
{ {
if (is_matching_clang_format_version("$dir/clang-format", $version)) if (is_matching_clang_format_version("$dir/clang-format", $version))
{ {
@@ -80,9 +80,12 @@ sub find()
} }
} }
} }
else
{
$clang_format = $ENV{CLANG_FORMAT};
} }
if ($^O eq "cygwin") if ($^O eq "cygwin" && defined($clang_format))
{ {
$clang_format = `cygpath -m '$clang_format'`; $clang_format = `cygpath -m '$clang_format'`;
chomp $clang_format; chomp $clang_format;

View File

@@ -54,7 +54,6 @@
#include <editeng/paravertalignitem.hxx> #include <editeng/paravertalignitem.hxx>
#include <editeng/blinkitem.hxx> #include <editeng/blinkitem.hxx>
#include <editeng/charhiddenitem.hxx> #include <editeng/charhiddenitem.hxx>
#include <svx/fmglob.hxx>
#include <svx/svdouno.hxx> #include <svx/svdouno.hxx>
#include <filter/msfilter/rtfutil.hxx> #include <filter/msfilter/rtfutil.hxx>
#include <sfx2/sfxbasemodel.hxx> #include <sfx2/sfxbasemodel.hxx>