summaryrefslogtreecommitdiff
path: root/gcc/pretty-print.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-07-02 20:05:21 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-07-02 20:05:21 +0000
commitdbf96d49454d608b5cb9e39e341e13b60ec7965e (patch)
tree2cefe7783c5b50896e82533f6e80f65347c8ef70 /gcc/pretty-print.c
parent7edd4c1885f4ecc31b80f157f7aa96ccd40d1075 (diff)
selftest: introduce class auto_fix_quotes
This patch moves a workaround for locale differences from a selftest in pretty-print.c to selftest.h/c to make it reusable; I need this for a selftest in a followup patch. gcc/ChangeLog: * pretty-print.c (selftest::test_pp_format): Move save and restore of quotes to class auto_fix_quotes, and add an instance. * selftest.c: Include "intl.h". (selftest::auto_fix_quotes::auto_fix_quotes): New ctor. (selftest::auto_fix_quotes::~auto_fix_quotes): New dtor. * selftest.h (selftest::auto_fix_quotes): New class. From-SVN: r262317
Diffstat (limited to 'gcc/pretty-print.c')
-rw-r--r--gcc/pretty-print.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 8babbffda71..df3ee811fd5 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -2102,10 +2102,7 @@ test_pp_format ()
{
/* Avoid introducing locale-specific differences in the results
by hardcoding open_quote and close_quote. */
- const char *old_open_quote = open_quote;
- const char *old_close_quote = close_quote;
- open_quote = "`";
- close_quote = "'";
+ auto_fix_quotes fix_quotes;
/* Verify that plain text is passed through unchanged. */
assert_pp_format (SELFTEST_LOCATION, "unformatted", "unformatted");
@@ -2187,10 +2184,6 @@ test_pp_format ()
assert_pp_format (SELFTEST_LOCATION, "item 3 of 7", "item %i of %i", 3, 7);
assert_pp_format (SELFTEST_LOCATION, "problem with `bar' at line 10",
"problem with %qs at line %i", "bar", 10);
-
- /* Restore old values of open_quote and close_quote. */
- open_quote = old_open_quote;
- close_quote = old_close_quote;
}
/* Run all of the selftests within this file. */