Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
731d908c
Commit
731d908c
authored
May 28, 2020
by
Derek Mauro
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2677 from IYP-Programer-Yeah:fix-file-path-normalize-function
PiperOrigin-RevId: 312486861
parents
99ea9ca3
c09fbb23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
24 deletions
+12
-24
gtest-filepath.cc
googletest/src/gtest-filepath.cc
+12
-24
No files found.
googletest/src/gtest-filepath.cc
View file @
731d908c
...
@@ -349,33 +349,21 @@ FilePath FilePath::RemoveTrailingPathSeparator() const {
...
@@ -349,33 +349,21 @@ FilePath FilePath::RemoveTrailingPathSeparator() const {
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// For example, "bar///foo" becomes "bar/foo". Does not eliminate other
// redundancies that might be in a pathname involving "." or "..".
// redundancies that might be in a pathname involving "." or "..".
void
FilePath
::
Normalize
()
{
void
FilePath
::
Normalize
()
{
if
(
pathname_
.
c_str
()
==
nullptr
)
{
std
::
string
normalized_pathname
;
pathname_
=
""
;
normalized_pathname
.
reserve
(
pathname_
.
length
());
return
;
}
for
(
const
char
character
:
pathname_
)
{
const
char
*
src
=
pathname_
.
c_str
();
if
(
!
IsPathSeparator
(
character
))
{
char
*
const
dest
=
new
char
[
pathname_
.
length
()
+
1
];
normalized_pathname
.
push_back
(
character
);
char
*
dest_ptr
=
dest
;
}
else
if
(
normalized_pathname
.
empty
()
||
memset
(
dest_ptr
,
0
,
pathname_
.
length
()
+
1
);
normalized_pathname
.
back
()
!=
kPathSeparator
)
{
normalized_pathname
.
push_back
(
kPathSeparator
);
while
(
*
src
!=
'\0'
)
{
*
dest_ptr
=
*
src
;
if
(
!
IsPathSeparator
(
*
src
))
{
src
++
;
}
else
{
}
else
{
#if GTEST_HAS_ALT_PATH_SEP_
continue
;
if
(
*
dest_ptr
==
kAlternatePathSeparator
)
{
*
dest_ptr
=
kPathSeparator
;
}
#endif
while
(
IsPathSeparator
(
*
src
))
src
++
;
}
}
dest_ptr
++
;
}
}
*
dest_ptr
=
'\0'
;
pathname_
=
dest
;
pathname_
=
normalized_pathname
;
delete
[]
dest
;
}
}
}
// namespace internal
}
// namespace internal
...
...
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