annotate contrib/check_GNU_style.py @ 115:4cb7a319550d

fix c-parser.c
author mir3636
date Tue, 28 Nov 2017 19:31:15 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 #!/usr/bin/env python3
kono
parents:
diff changeset
2 #
kono
parents:
diff changeset
3 # Checks some of the GNU style formatting rules in a set of patches.
kono
parents:
diff changeset
4 # The script is a rewritten of the same bash script and should eventually
kono
parents:
diff changeset
5 # replace the former script.
kono
parents:
diff changeset
6 #
kono
parents:
diff changeset
7 # This file is part of GCC.
kono
parents:
diff changeset
8 #
kono
parents:
diff changeset
9 # GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
10 # the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
11 # Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
12 # version.
kono
parents:
diff changeset
13 #
kono
parents:
diff changeset
14 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
16 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
17 # for more details.
kono
parents:
diff changeset
18 #
kono
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
20 # along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
21 # <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 import argparse
kono
parents:
diff changeset
24 import sys
kono
parents:
diff changeset
25 from check_GNU_style_lib import check_GNU_style_file
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 def main():
kono
parents:
diff changeset
28 parser = argparse.ArgumentParser(description='Check GNU coding style.')
kono
parents:
diff changeset
29 parser.add_argument('file', help = 'File with a patch')
kono
parents:
diff changeset
30 parser.add_argument('-f', '--format', default = 'stdio',
kono
parents:
diff changeset
31 help = 'Display format',
kono
parents:
diff changeset
32 choices = ['stdio', 'quickfix'])
kono
parents:
diff changeset
33 args = parser.parse_args()
kono
parents:
diff changeset
34 filename = args.file
kono
parents:
diff changeset
35 format = args.format
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 if filename == '-':
kono
parents:
diff changeset
38 check_GNU_style_file(sys.stdin, None, format)
kono
parents:
diff changeset
39 else:
kono
parents:
diff changeset
40 with open(filename, 'rb') as diff_file:
kono
parents:
diff changeset
41 check_GNU_style_file(diff_file, 'utf-8', format)
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 main()