Kaydet (Commit) 653b5131 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/46489Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 98de1ed2
...@@ -133,7 +133,7 @@ sub check_style($) ...@@ -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();
......
...@@ -65,24 +65,27 @@ sub find() ...@@ -65,24 +65,27 @@ 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 (@dirs)
{ {
foreach my $dir (split /:/, $ENV{PATH}) if (is_matching_clang_format_version("$dir/clang-format", $version))
{ {
if (is_matching_clang_format_version("$dir/clang-format", $version)) $clang_format = "$dir/clang-format";
{ last;
$clang_format = "$dir/clang-format";
last;
}
} }
} }
} }
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;
......
...@@ -54,7 +54,6 @@ ...@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment