Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
eb2f4556
Commit
eb2f4556
authored
Apr 28, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Exception/TrimSourceFilename test on MSVC.
parent
e4420a4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
exception-test.c++
c++/src/kj/exception-test.c++
+3
-0
exception.c++
c++/src/kj/exception.c++
+14
-2
No files found.
c++/src/kj/exception-test.c++
View file @
eb2f4556
...
...
@@ -28,6 +28,9 @@ namespace _ { // private
namespace
{
TEST
(
Exception
,
TrimSourceFilename
)
{
#if _WIN32
if
(
trimSourceFilename
(
__FILE__
)
!=
"kj
\\
exception-test.c++"
)
#endif
EXPECT_EQ
(
trimSourceFilename
(
__FILE__
),
"kj/exception-test.c++"
);
}
...
...
c++/src/kj/exception.c++
View file @
eb2f4556
...
...
@@ -407,17 +407,29 @@ kj::StringPtr trimSourceFilename(kj::StringPtr filename) {
// To deal with all this, we look for directory names in the path which we recognize to be
// locations that represent roots of the source tree. We strip said root and everything before
// it.
//
// On Windows, we often get filenames containing backslashes. Since we aren't allowed to allocate
// a new string here, we can't do much about this, so our returned "canonical" name will
// unfortunately end up with backslashes.
static
constexpr
const
char
*
ROOTS
[]
=
{
"ekam-provider/canonical/"
,
// Ekam source file.
"ekam-provider/c++header/"
,
// Ekam include file.
"src/"
,
// Non-Ekam source root.
"tmp/"
// Non-Ekam generated code.
"tmp/"
,
// Non-Ekam generated code.
#if _WIN32
"src
\\
"
,
// Win32 source root.
"tmp
\\
"
,
// Win32 generated code.
#endif
};
retry
:
for
(
size_t
i
:
kj
::
indices
(
filename
))
{
if
(
i
==
0
||
filename
[
i
-
1
]
==
'/'
)
{
if
(
i
==
0
||
filename
[
i
-
1
]
==
'/'
#if _WIN32
||
filename
[
i
-
1
]
==
'\\'
#endif
)
{
// We're at the start of a directory name. Check for valid prefixes.
for
(
kj
::
StringPtr
root
:
ROOTS
)
{
if
(
filename
.
slice
(
i
).
startsWith
(
root
))
{
...
...
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