Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
144e1fbb
Commit
144e1fbb
authored
Jul 04, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow formatting of wide strings when using a narrow string formatter.
parent
270ed1cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
format.h
format.h
+7
-2
test/CMakeLists.txt
test/CMakeLists.txt
+1
-0
No files found.
format.h
View file @
144e1fbb
...
...
@@ -361,7 +361,10 @@ class CharTraits<char> : public BasicCharTraits<char> {
// Conversion from wchar_t to char is not allowed.
static
char
ConvertChar
(
wchar_t
);
public:
// Conversion from const wchar_t * to const char * is not allowed.
static
const
wchar_t
*
check
(
const
wchar_t
*
s
);
public:
typedef
const
wchar_t
*
UnsupportedStrType
;
static
char
ConvertChar
(
char
value
)
{
return
value
;
}
...
...
@@ -386,6 +389,8 @@ class CharTraits<wchar_t> : public BasicCharTraits<wchar_t> {
static
StringValue
<
wchar_t
>
convert
(
StringValue
<
wchar_t
>
s
)
{
return
s
;
}
static
const
wchar_t
*
check
(
const
wchar_t
*
s
)
{
return
s
;
}
template
<
typename
T
>
static
int
FormatFloat
(
wchar_t
*
buffer
,
std
::
size_t
size
,
const
wchar_t
*
format
,
unsigned
width
,
int
precision
,
T
value
);
...
...
@@ -636,7 +641,7 @@ class MakeArg : public Arg {
void
SetString
(
WStringRef
str
)
{
type
=
WSTRING
;
wstring
.
value
=
str
.
c_str
(
);
wstring
.
value
=
CharTraits
<
Char
>::
check
(
str
.
c_str
()
);
wstring
.
size
=
str
.
size
();
}
...
...
test/CMakeLists.txt
View file @
144e1fbb
...
...
@@ -35,6 +35,7 @@ expect_compile_error("const volatile char s[] = \"test\"; (fmt::internal::MakeAr
# MakeArg<char> doesn't accept wchar_t.
expect_compile_error
(
"fmt::internal::MakeArg<char>(L'a');"
)
expect_compile_error
(
"fmt::internal::MakeArg<char>(L
\"
test
\"
);"
)
# Writing a wide character to a character stream Writer is forbidden.
expect_compile_error
(
"fmt::Writer() << L'a';"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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