summaryrefslogtreecommitdiff
path: root/contrib/check_GNU_style_lib.py
diff options
context:
space:
mode:
authorTom de Vries <tom@codesourcery.com>2017-05-29 07:31:02 +0000
committerTom de Vries <vries@gcc.gnu.org>2017-05-29 07:31:02 +0000
commit75017bb9750fdbed1ab51c99a7306976a9fa83c2 (patch)
treec01f020ebfc7f2853ae2895bca929f360c8b5748 /contrib/check_GNU_style_lib.py
parent76baf5ca9d58cfde6c015cc1162c39a9aec60771 (diff)
downloadgcc-75017bb9750fdbed1ab51c99a7306976a9fa83c2.tar.gz
check_GNU_style.py: Read stdin if file argument is '-'
2017-05-29 Tom de Vries <tom@codesourcery.com> * check_GNU_style_lib.py (check_GNU_style_file): Treat file argument as file handle. Add and handle file_encoding argument. * check_GNU_style.py (main): Handle '-' file argument. Call check_GNU_style_file with file handle as argument. From-SVN: r248555
Diffstat (limited to 'contrib/check_GNU_style_lib.py')
-rwxr-xr-xcontrib/check_GNU_style_lib.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py
index d924e68ecbc..e1031dfcd92 100755
--- a/contrib/check_GNU_style_lib.py
+++ b/contrib/check_GNU_style_lib.py
@@ -223,7 +223,7 @@ class LineLengthTest(unittest.TestCase):
self.assertEqual(r.console_error,
self.check.limit * 'a' + error_string(' = 123;'))
-def check_GNU_style_file(file, format):
+def check_GNU_style_file(file, file_encoding, format):
checks = [LineLengthCheck(), SpacesCheck(), TrailingWhitespaceCheck(),
SentenceSeparatorCheck(), SentenceEndOfCommentCheck(),
SentenceDotEndCheck(), FunctionParenthesisCheck(),
@@ -231,8 +231,7 @@ def check_GNU_style_file(file, format):
BracesOnSeparateLineCheck(), TrailinigOperatorCheck()]
errors = []
- with open(file, 'rb') as diff_file:
- patch = PatchSet(diff_file, encoding = 'utf-8')
+ patch = PatchSet(file, encoding=file_encoding)
for pfile in patch.added_files + patch.modified_files:
t = pfile.target_file.lstrip('b/')