]>
Commit | Line | Data |
---|---|---|
a3f9f006 ML |
1 | #!/usr/bin/env python3 |
2 | # | |
3 | # Check gcc.pot file for gcc-internal-format and print all strings | |
4 | # that contain an option that is not wrapped by %<-option_name%>. | |
5 | # | |
6 | # This file is part of GCC. | |
7 | # | |
8 | # GCC is free software; you can redistribute it and/or modify it under | |
9 | # the terms of the GNU General Public License as published by the Free | |
10 | # Software Foundation; either version 3, or (at your option) any later | |
11 | # version. | |
12 | # | |
13 | # GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | # for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with GCC; see the file COPYING3. If not see | |
20 | # <http://www.gnu.org/licenses/>. */ | |
21 | # | |
22 | # | |
23 | # | |
24 | ||
25 | import argparse | |
26 | import re | |
27 | ||
28 | parser = argparse.ArgumentParser(description='') | |
29 | parser.add_argument('file', help = 'pot file') | |
30 | ||
31 | args = parser.parse_args() | |
32 | ||
33 | origin = None | |
34 | internal = False | |
35 | ||
36 | lines = open(args.file).readlines() | |
37 | for i, l in enumerate(lines): | |
38 | l = l.strip() | |
39 | s = 'msgid ' | |
40 | if l.startswith('#: '): | |
41 | origin = l | |
42 | elif '#, gcc-internal-format' in l: | |
43 | internal = True | |
44 | if l.startswith(s) and origin and internal: | |
45 | j = 0 | |
46 | while not lines[i + j].startswith('msgstr'): | |
47 | l = lines[i + j] | |
48 | if l.startswith(s): | |
49 | l = l[len(s):] | |
50 | text = l.strip('"').strip() | |
51 | if text: | |
52 | parts = text.split(' ') | |
53 | for p in parts: | |
54 | if p.startswith('-'): | |
55 | if len(p) >= 2 and (p[1].isalpha() and p != '-INF'): | |
56 | print('%s: %s' % (origin, text)) | |
57 | elif p.startswith('__builtin_'): | |
58 | print('%s: %s' % (origin, text)) | |
93964ebd ML |
59 | if re.search("[a-zA-Z]'[a-zA-Z]", p): |
60 | print('%s: %s' % (origin, text)) | |
a3f9f006 ML |
61 | j += 1 |
62 | ||
63 | origin = None | |
64 | internal = False |