gcc/contrib/check-internal-format-escaping.py
Martin Liska 93964ebd2f Wrap apostrophes in gcc internal format with %'.
2019-03-11  Martin Liska  <mliska@suse.cz>

	* check-internal-format-escaping.py: Uncomment apostrophes
	check.
2019-03-11  Martin Liska  <mliska@suse.cz>

	* collect-utils.c (collect_wait): Wrap apostrophes
	in gcc internal format with %'.
	* collect2.c (main): Likewise.
	(scan_prog_file): Likewise.
	(scan_libraries): Likewise.
	* config/i386/i386.c (ix86_expand_call): Likewise.
	(ix86_handle_interrupt_attribute): Likewise.
	* config/nds32/nds32-intrinsic.c (nds32_expand_builtin_impl): Likewise.
	* config/nds32/nds32.c (nds32_insert_attributes): Likewise.
	* config/rl78/rl78.c (rl78_handle_saddr_attribute): Likewise.
	* lto-wrapper.c (find_crtoffloadtable): Likewise.
	* symtab.c (symtab_node::verify_base): Likewise.
	* tree-cfg.c (verify_gimple_label): Likewise.
	* tree.c (verify_type_variant): Likewise.
2019-03-11  Martin Liska  <mliska@suse.cz>

	* c-opts.c (c_common_post_options): Wrap apostrophes
	in gcc internal format with %'.
2019-03-11  Martin Liska  <mliska@suse.cz>

	* cvt.c (build_expr_type_conversion): Wrap apostrophes
	in gcc internal format with %'.
	* decl.c (check_no_redeclaration_friend_default_args): Likewise.
	(grokfndecl): Likewise.
	* name-lookup.c (do_pushtag): Likewise.
	* pt.c (unify_parameter_deduction_failure): Likewise.
	(unify_template_deduction_failure): Likewise.

From-SVN: r269587
2019-03-11 13:59:04 +00:00

65 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Check gcc.pot file for gcc-internal-format and print all strings
# that contain an option that is not wrapped by %<-option_name%>.
#
# 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
# <http://www.gnu.org/licenses/>. */
#
#
#
import argparse
import re
parser = argparse.ArgumentParser(description='')
parser.add_argument('file', help = 'pot file')
args = parser.parse_args()
origin = None
internal = False
lines = open(args.file).readlines()
for i, l in enumerate(lines):
l = l.strip()
s = 'msgid '
if l.startswith('#: '):
origin = l
elif '#, gcc-internal-format' in l:
internal = True
if l.startswith(s) and origin and internal:
j = 0
while not lines[i + j].startswith('msgstr'):
l = lines[i + j]
if l.startswith(s):
l = l[len(s):]
text = l.strip('"').strip()
if text:
parts = text.split(' ')
for p in parts:
if p.startswith('-'):
if len(p) >= 2 and (p[1].isalpha() and p != '-INF'):
print('%s: %s' % (origin, text))
elif p.startswith('__builtin_'):
print('%s: %s' % (origin, text))
if re.search("[a-zA-Z]'[a-zA-Z]", p):
print('%s: %s' % (origin, text))
j += 1
origin = None
internal = False