aboutsummaryrefslogtreecommitdiff
path: root/gcc/selftest.h
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/selftest.h
parent7edd4c1885f4ecc31b80f157f7aa96ccd40d1075 (diff)
downloadgcc-dbf96d49454d608b5cb9e39e341e13b60ec7965e.zip
gcc-dbf96d49454d608b5cb9e39e341e13b60ec7965e.tar.gz
gcc-dbf96d49454d608b5cb9e39e341e13b60ec7965e.tar.bz2
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/selftest.h')
-rw-r--r--gcc/selftest.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/selftest.h b/gcc/selftest.h
index d66fb93..54fc488 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -113,6 +113,26 @@ class temp_source_file : public named_temp_file
const char *content);
};
+/* RAII-style class for avoiding introducing locale-specific differences
+ in strings containing localized quote marks, by temporarily overriding
+ the "open_quote" and "close_quote" globals to something hardcoded.
+
+ Specifically, the C locale's values are used:
+ - open_quote becomes "`"
+ - close_quote becomes "'"
+ for the lifetime of the object. */
+
+class auto_fix_quotes
+{
+ public:
+ auto_fix_quotes ();
+ ~auto_fix_quotes ();
+
+ private:
+ const char *m_saved_open_quote;
+ const char *m_saved_close_quote;
+};
+
/* Various selftests involving location-handling require constructing a
line table and one or more line maps within it.