Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tiger
nolimips
Commits
0703bb7c
Commit
0703bb7c
authored
May 23, 2012
by
Roland Levillain
Browse files
Do not use locale in misc::escape.
* src/misc/escape.hh (operator<<(std::ostream&, const escape&)): Here.
parent
9c67b2b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
0703bb7c
2012-05-23 Roland Levillain <roland@lrde.epita.fr>
Do not use locale in misc::escape.
* src/misc/escape.hh (operator<<(std::ostream&, const escape&)):
Here.
2012-05-22 Roland Levillain <roland@lrde.epita.fr>
Fix the handling of `.half' assembler directives.
...
...
src/misc/escape.hh
View file @
0703bb7c
//
// escape.hh: escaping special characters for output
// Copyright (C) 2003, 2004 Akim Demaille <akim@epita.fr> and
// Benoit Perrot <benoit@lrde.epita.fr>
// Copyright (C) 2003, 2004
, 2012
Akim Demaille <akim@epita.fr> and
//
Benoit Perrot <benoit@lrde.epita.fr>
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
...
...
@@ -24,7 +24,6 @@
# include <iostream>
# include <string>
# include <cctype>
# include <locale>
class
escape
{
...
...
@@ -39,7 +38,22 @@ public:
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
const
escape
&
e
)
{
static
std
::
locale
locale
(
""
);
/* For some reason, when we use std::locale on Mac OS X, the
following exception may be thrown:
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
A workaround is to unset the environment variable `LANG' prior to
using std::locale, but this is cumbersome.
So we use the C locale-agnostic version of isprint() from header
`cctype', instead of C++ isprint() from header `locale' taking a
locale as second argument.
See also
http://stackoverflow.com/questions/1745045/stdlocale-breakage-on-macos-10-6-with-lang-en-us-utf-8
on this topic. */
std
::
ios_base
::
fmtflags
flags
=
o
.
flags
(
std
::
ios_base
::
hex
);
for
(
std
::
string
::
const_iterator
p
=
e
.
s_
.
begin
();
p
!=
e
.
s_
.
end
();
++
p
)
switch
(
*
p
)
...
...
@@ -54,7 +68,7 @@ operator<<(std::ostream& o, const escape& e)
case
'\\'
:
o
<<
"
\\\\
"
;
break
;
case
'\"'
:
o
<<
"
\\\"
"
;
break
;
default:
if
(
std
::
isprint
(
*
p
,
locale
))
if
(
std
::
isprint
(
*
p
))
o
<<
*
p
;
else
o
<<
"
\\
x"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment