Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
3f1ee32c
Unverified
Commit
3f1ee32c
authored
Mar 05, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better trim
parent
cd28ab58
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
src/text.cpp
+29
-10
No files found.
src/text.cpp
View file @
3f1ee32c
...
...
@@ -190,22 +190,41 @@ std::string trim_left_copy(std::string_view s)
void
trim_left
(
std
::
string
&
s
)
{
auto
b
=
s
.
begin
();
while
(
b
!=
s
.
end
())
auto
in
=
s
.
begin
(),
out
=
s
.
begin
();
while
(
in
!=
s
.
end
()
and
std
::
isspace
(
*
in
))
++
in
;
if
(
in
==
s
.
end
())
s
.
clear
();
else
if
(
in
!=
out
)
{
if
(
not
std
::
isspace
(
*
b
))
break
;
b
=
std
::
next
(
b
);
while
(
in
!=
s
.
end
())
*
out
++
=
*
in
++
;
s
.
erase
(
out
,
s
.
end
());
}
s
.
erase
(
s
.
begin
(),
b
);
}
void
trim
(
std
::
string
&
s
)
{
trim_right
(
s
);
trim_left
(
s
);
auto
in
=
s
.
begin
(),
out
=
s
.
begin
(),
end
=
s
.
end
();
while
(
end
!=
s
.
begin
()
and
std
::
isspace
(
*
(
end
-
1
)))
--
end
;
while
(
in
!=
end
and
std
::
isspace
(
*
in
))
++
in
;
if
(
in
==
end
)
s
.
clear
();
else
if
(
in
!=
out
)
{
while
(
in
!=
end
)
*
out
++
=
*
in
++
;
s
.
erase
(
out
,
s
.
end
());
}
else
if
(
end
!=
s
.
end
())
s
.
erase
(
end
,
s
.
end
());
}
std
::
string
trim_copy
(
std
::
string_view
s
)
...
...
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