]>
git.ipfire.org Git - thirdparty/gcc.git/blob - contrib/check-internal-format-escaping.py
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%>.
6 # This file is part of GCC.
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
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
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/>. */
28 parser
= argparse
.ArgumentParser(description
='')
29 parser
.add_argument('file', help = 'pot file')
31 args
= parser
.parse_args()
36 lines
= open(args
.file).readlines()
37 for i
, l
in enumerate(lines
):
40 if l
.startswith('#: '):
42 elif '#, gcc-internal-format' in l
:
44 if l
.startswith(s
) and origin
and internal
:
46 while not lines
[i
+ j
].startswith('msgstr'):
50 text
= l
.strip('"').strip()
52 parts
= text
.split(' ')
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
))
59 if re
.search("[^%]'", p
):
60 print('%s: %s' % (origin
, text
))
61 # %< should not be preceded by a non-punctuation
63 if re
.search("[a-zA-Z0-9]%<", p
):
64 print('%s: %s' % (origin
, text
))