From dbf96d49454d608b5cb9e39e341e13b60ec7965e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 2 Jul 2018 20:05:21 +0000 Subject: 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 --- gcc/pretty-print.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'gcc/pretty-print.c') 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. */ -- cgit v1.2.3