2017-05-19 13:47:53 +00:00
|
|
|
#!/usr/bin/env python3
|
2022-12-14 12:50:03 +00:00
|
|
|
|
2024-01-03 11:19:35 +00:00
|
|
|
# Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
2017-05-19 13:47:53 +00:00
|
|
|
#
|
|
|
|
# Checks some of the GNU style formatting rules in a set of patches.
|
|
|
|
# The script is a rewritten of the same bash script and should eventually
|
|
|
|
# replace the former script.
|
|
|
|
#
|
|
|
|
# This file is part of GCC.
|
|
|
|
#
|
|
|
|
# GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU General Public License as published by the Free
|
|
|
|
# Software Foundation; either version 3, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GCC; see the file COPYING3. If not see
|
2024-01-04 15:01:20 +00:00
|
|
|
# <http://www.gnu.org/licenses/>.
|
2017-05-19 13:47:53 +00:00
|
|
|
|
|
|
|
import argparse
|
2017-05-29 07:31:02 +00:00
|
|
|
import sys
|
2017-05-24 08:49:56 +00:00
|
|
|
from check_GNU_style_lib import check_GNU_style_file
|
2017-05-19 13:47:53 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(description='Check GNU coding style.')
|
|
|
|
parser.add_argument('file', help = 'File with a patch')
|
|
|
|
parser.add_argument('-f', '--format', default = 'stdio',
|
|
|
|
help = 'Display format',
|
|
|
|
choices = ['stdio', 'quickfix'])
|
|
|
|
args = parser.parse_args()
|
2017-05-29 07:31:02 +00:00
|
|
|
filename = args.file
|
|
|
|
format = args.format
|
|
|
|
|
|
|
|
if filename == '-':
|
2022-12-11 16:18:12 +00:00
|
|
|
check_GNU_style_file(sys.stdin, format)
|
2017-05-29 07:31:02 +00:00
|
|
|
else:
|
2022-12-11 16:18:12 +00:00
|
|
|
with open(filename, newline='\n') as diff_file:
|
|
|
|
check_GNU_style_file(diff_file, format)
|
2017-05-19 13:47:53 +00:00
|
|
|
|
2017-05-24 08:49:56 +00:00
|
|
|
main()
|