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
daf650c4
Commit
daf650c4
authored
Mar 10, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disallow formatting of multibyte strings into a wide buffer (#606)
parent
ca93be13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
19 deletions
+11
-19
include/fmt/core.h
include/fmt/core.h
+8
-6
test/compile-test/CMakeLists.txt
test/compile-test/CMakeLists.txt
+3
-13
No files found.
include/fmt/core.h
View file @
daf650c4
...
...
@@ -546,7 +546,7 @@ template <typename Context, typename T>
FMT_CONSTEXPR
basic_arg
<
Context
>
make_arg
(
const
T
&
value
);
#define FMT_MAKE_VALUE(TAG, ArgType, ValueType) \
template <typename C
, typename Char = typename C::char_type
> \
template <typename C> \
FMT_CONSTEXPR typed_value<C, TAG> make_value(ArgType val) { \
return static_cast<ValueType>(val); \
}
...
...
@@ -589,20 +589,22 @@ FMT_MAKE_VALUE(long_double_type, long double, long double)
// Formatting of wide strings into a narrow buffer and multibyte strings
// into a wide buffer is disallowed (https://github.com/fmtlib/fmt/pull/606).
FMT_MAKE_VALUE
(
cstring_type
,
Char
*
,
const
Char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
const
Char
*
,
const
Char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
typename
C
::
char_type
*
,
const
typename
C
::
char_type
*
)
FMT_MAKE_VALUE
(
cstring_type
,
const
typename
C
::
char_type
*
,
const
typename
C
::
char_type
*
)
FMT_MAKE_VALUE
(
cstring_type
,
signed
char
*
,
const
signed
char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
const
signed
char
*
,
const
signed
char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
unsigned
char
*
,
const
unsigned
char
*
)
FMT_MAKE_VALUE
(
cstring_type
,
const
unsigned
char
*
,
const
unsigned
char
*
)
FMT_MAKE_VALUE
(
string_type
,
basic_string_view
<
typename
C
::
char_type
>
,
basic_string_view
<
Char
>
)
basic_string_view
<
typename
C
::
char_type
>
)
FMT_MAKE_VALUE
(
string_type
,
typename
basic_string_view
<
typename
C
::
char_type
>::
type
,
basic_string_view
<
Char
>
)
basic_string_view
<
typename
C
::
char_type
>
)
FMT_MAKE_VALUE
(
string_type
,
const
std
::
basic_string
<
typename
C
::
char_type
>&
,
basic_string_view
<
Char
>
)
basic_string_view
<
typename
C
::
char_type
>
)
FMT_MAKE_VALUE
(
pointer_type
,
void
*
,
const
void
*
)
FMT_MAKE_VALUE
(
pointer_type
,
const
void
*
,
const
void
*
)
...
...
test/compile-test/CMakeLists.txt
View file @
daf650c4
...
...
@@ -47,22 +47,12 @@ endfunction ()
# check if the source file skeleton compiles
expect_compile
(
""
)
# MakeArg doesn't accept [const] volatile char *.
expect_compile_error
(
"volatile char s[] =
\"
test
\"
; (fmt::internal::MakeArg<char>)(s);"
)
expect_compile_error
(
"const volatile char s[] =
\"
test
\"
; (fmt::internal::MakeArg<char>)(s);"
)
# MakeArg<char> doesn't accept wchar_t.
expect_compile_error
(
"fmt::internal::MakeValue<char>(L'a');"
)
expect_compile_error
(
"fmt::internal::MakeValue<char>(L
\"
test
\"
);"
)
# Writing a wide character to a character stream Writer is forbidden.
expect_compile_error
(
"fmt::MemoryWriter() << L'a';"
)
expect_compile_error
(
"fmt::MemoryWriter() << fmt::pad(
\"
abc
\"
, 5, L' ');"
)
expect_compile_error
(
"fmt::MemoryWriter() << fmt::pad(42, 5, L' ');"
)
# Formatting a wide character with a narrow format string is forbidden.
expect_compile_error
(
"fmt::format(
\"
{}
\"
, L'a';"
)
# Formatting a wide string with a narrow format string is forbidden.
expect_compile_error
(
"fmt::format(
\"
{}
\"
, L
\"
foo
\"
;"
)
# Make sure that compiler features detected in the header
# match the features detected in CMake.
if
(
SUPPORTS_USER_DEFINED_LITERALS
)
...
...
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