Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
5069443f
Commit
5069443f
authored
Jan 15, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix escaping of \r and other special characters
parent
b51414da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
28 deletions
+19
-28
libcaf_core/caf/detail/print.hpp
libcaf_core/caf/detail/print.hpp
+18
-2
libcaf_core/src/detail/stringification_inspector.cpp
libcaf_core/src/detail/stringification_inspector.cpp
+1
-26
No files found.
libcaf_core/caf/detail/print.hpp
View file @
5069443f
...
...
@@ -26,17 +26,33 @@ void print_escaped(Buffer& buf, string_view str) {
default:
buf
.
push_back
(
c
);
break
;
case
'\\'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
'\\'
);
break
;
case
'\b'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
'b'
);
break
;
case
'\f'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
'f'
);
break
;
case
'\n'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
'n'
);
break
;
case
'\r'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
'r'
);
break
;
case
'\t'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
't'
);
break
;
case
'\\'
:
buf
.
push_back
(
'\\'
);
case
'\v'
:
buf
.
push_back
(
'\\'
);
buf
.
push_back
(
'v'
);
break
;
case
'"'
:
buf
.
push_back
(
'\\'
);
...
...
libcaf_core/src/detail/stringification_inspector.cpp
View file @
5069443f
...
...
@@ -9,30 +9,6 @@
#include <algorithm>
#include <ctime>
namespace
{
void
escape
(
std
::
string
&
result
,
char
c
)
{
switch
(
c
)
{
default:
result
+=
c
;
break
;
case
'\n'
:
result
+=
R"(\n)"
;
break
;
case
'\t'
:
result
+=
R"(\t)"
;
break
;
case
'\\'
:
result
+=
R"(\\)"
;
break
;
case
'"'
:
result
+=
R"(\")"
;
break
;
}
}
}
// namespace
namespace
caf
::
detail
{
bool
stringification_inspector
::
begin_object
(
type_id_t
,
string_view
name
)
{
...
...
@@ -181,8 +157,7 @@ bool stringification_inspector::value(string_view str) {
if
(
always_quote_strings
||
std
::
any_of
(
str
.
begin
(),
str
.
end
(),
needs_escaping
))
{
result_
+=
'"'
;
for
(
char
c
:
str
)
escape
(
result_
,
c
);
detail
::
print_escaped
(
result_
,
str
);
result_
+=
'"'
;
}
else
{
result_
.
insert
(
result_
.
end
(),
str
.
begin
(),
str
.
end
());
...
...
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