summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2019-04-17 18:04:28 +0200
committerJan Niklas Hasse <jhasse@bixense.com>2019-04-17 18:04:54 +0200
commit71b96489325e5e2629464687c60f20d9905ab51c (patch)
tree8ab2373f170b346ebd018c8e70ff43699b29f716
parentb344c799788426b3b26eabcbef5728955e8e2703 (diff)
downloadninja-71b96489325e5e2629464687c60f20d9905ab51c.tar.gz
Remove trailing whitespace from all files
-rw-r--r--.travis.yml1
-rwxr-xr-xconfigure.py2
-rwxr-xr-xmisc/ci.py41
-rw-r--r--src/clean_test.cc2
-rw-r--r--src/deps_log.cc4
-rw-r--r--src/getopt.c2
6 files changed, 47 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml
index 19a9b28..f76b982 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,7 @@ matrix:
sudo: false
language: cpp
script:
+ - ./misc/ci.py
- ./configure.py --bootstrap
- ./ninja all
- ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots
diff --git a/configure.py b/configure.py
index 78cd1de..20b389d 100755
--- a/configure.py
+++ b/configure.py
@@ -508,7 +508,7 @@ for name in ['build',
'string_piece_util',
'util',
'version']:
- objs += cxx(name, variables=cxxvariables)
+ objs += cxx(name, variables=cxxvariables)
if platform.is_windows():
for name in ['subprocess-win32',
'includes_normalize-win32',
diff --git a/misc/ci.py b/misc/ci.py
new file mode 100755
index 0000000..17cbf14
--- /dev/null
+++ b/misc/ci.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import os
+
+ignores = [
+ '.git/',
+ 'misc/afl-fuzz-tokens/',
+ 'ninja_deps',
+ 'src/depfile_parser.cc',
+ 'src/lexer.cc',
+]
+
+error_count = 0
+
+def error(path, msg):
+ global error_count
+ error_count += 1
+ print('\x1b[1;31m{}\x1b[0;31m{}\x1b[0m'.format(path, msg))
+
+for root, directory, filenames in os.walk('.'):
+ for filename in filenames:
+ path = os.path.join(root, filename)[2:]
+ if any([path.startswith(x) for x in ignores]):
+ continue
+ with open(path, 'rb') as file:
+ line_nr = 1
+ try:
+ for line in [x.decode() for x in file.readlines()]:
+ if len(line) == 0 or line[-1] != '\n':
+ error(path, ' missing newline at end of file.')
+ if len(line) > 1:
+ if line[-2] == '\r':
+ error(path, ' has Windows line endings.')
+ break
+ if line[-2] == ' ' or line[-2] == '\t':
+ error(path, ':{} has trailing whitespace.'.format(line_nr))
+ line_nr += 1
+ except UnicodeError:
+ pass # binary file
+
+exit(error_count)
diff --git a/src/clean_test.cc b/src/clean_test.cc
index 395343b..63734ac 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -325,7 +325,7 @@ TEST_F(CleanTest, CleanRsp) {
Cleaner cleaner(&state_, config_, &fs_);
ASSERT_EQ(0, cleaner.cleaned_files_count());
ASSERT_EQ(0, cleaner.CleanTarget("out1"));
- EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
ASSERT_EQ(0, cleaner.CleanTarget("in2"));
EXPECT_EQ(2, cleaner.cleaned_files_count());
ASSERT_EQ(0, cleaner.CleanRule("cat_rsp"));
diff --git a/src/deps_log.cc b/src/deps_log.cc
index 0bb96f3..4aaffeb 100644
--- a/src/deps_log.cc
+++ b/src/deps_log.cc
@@ -48,7 +48,7 @@ bool DepsLog::OpenForWrite(const string& path, string* err) {
if (!Recompact(path, err))
return false;
}
-
+
file_ = fopen(path.c_str(), "ab");
if (!file_) {
*err = strerror(errno);
@@ -331,7 +331,7 @@ bool DepsLog::Recompact(const string& path, string* err) {
// will refer to the ordering in new_log, not in the current log.
for (vector<Node*>::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
(*i)->set_id(-1);
-
+
// Write out all deps again.
for (int old_id = 0; old_id < (int)deps_.size(); ++old_id) {
Deps* deps = deps_[old_id];
diff --git a/src/getopt.c b/src/getopt.c
index 0c2ef35..861f07f 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -75,7 +75,7 @@ COPYRIGHT NOTICE AND DISCLAIMER:
Copyright (C) 1997 Gregory Pietsch
-This file and the accompanying getopt.h header file are hereby placed in the
+This file and the accompanying getopt.h header file are hereby placed in the
public domain without restrictions. Just give the author credit, don't
claim you wrote it or prevent anyone else from using it.