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
5bb04e19
Commit
5bb04e19
authored
Aug 23, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed possible overflow
parent
360c43b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
40 deletions
+46
-40
src/demangle.cpp
src/demangle.cpp
+46
-40
No files found.
src/demangle.cpp
View file @
5bb04e19
...
...
@@ -9,47 +9,53 @@
namespace
cppa
{
namespace
detail
{
std
::
string
demangle
(
const
char
*
typeid_name
)
std
::
string
demangle
(
const
char
*
decorated
)
{
size_t
size
;
int
status
;
char
*
undecorated
=
abi
::
__cxa_demangle
(
typeid_name
,
NULL
,
&
size
,
&
status
);
if
(
status
!=
0
)
{
std
::
string
error_msg
=
"Could not demangle type name "
;
error_msg
+=
typeid_name
;
throw
std
::
logic_error
(
error_msg
);
}
std
::
string
result
;
// the undecorated typeid name
result
.
reserve
(
size
);
const
char
*
cstr
=
undecorated
;
// this loop filter unnecessary characters from undecorated
for
(
char
c
=
*
cstr
;
c
!=
'\0'
;
c
=
*++
cstr
)
{
if
(
c
==
' '
)
{
char
previous_c
=
result
.
empty
()
?
' '
:
*
(
result
.
rbegin
());
// get next non-space character
do
{
c
=
*++
cstr
;
}
while
(
c
==
' '
);
// skip whitespace unless it separates two alphanumeric
// characters (such as in "unsigned int")
if
(
isalnum
(
c
)
&&
isalnum
(
previous_c
))
{
result
+=
' '
;
result
+=
c
;
}
else
{
result
+=
c
;
}
}
else
{
result
+=
c
;
}
}
free
(
undecorated
);
return
result
;
size_t
size
;
int
status
;
char
*
undecorated
=
abi
::
__cxa_demangle
(
decorated
,
nullptr
,
&
size
,
&
status
);
if
(
status
!=
0
)
{
std
::
string
error_msg
=
"Could not demangle type name "
;
error_msg
+=
decorated
;
throw
std
::
logic_error
(
error_msg
);
}
std
::
string
result
;
// the undecorated typeid name
result
.
reserve
(
size
);
const
char
*
cstr
=
undecorated
;
// filter unnecessary characters from undecorated
char
c
=
*
cstr
;
while
(
c
!=
'\0'
)
{
if
(
c
==
' '
)
{
char
previous_c
=
result
.
empty
()
?
' '
:
*
(
result
.
rbegin
());
// get next non-space character
for
(
c
=
*++
cstr
;
c
==
' '
;
c
=
*++
cstr
)
{
}
if
(
c
!=
'\0'
)
{
// skip whitespace unless it separates two alphanumeric
// characters (such as in "unsigned int")
if
(
isalnum
(
c
)
&&
isalnum
(
previous_c
))
{
result
+=
' '
;
result
+=
c
;
}
else
{
result
+=
c
;
}
c
=
*++
cstr
;
}
}
else
{
result
+=
c
;
c
=
*++
cstr
;
}
}
free
(
undecorated
);
return
result
;
}
}
}
// namespace cppa::detail
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