Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
f860a2fb
Commit
f860a2fb
authored
Aug 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StringUtil: move code to StripRight()
parent
87bcf739
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
6 deletions
+31
-6
StringUtil.cxx
src/util/StringUtil.cxx
+17
-6
StringUtil.hxx
src/util/StringUtil.hxx
+14
-0
No files found.
src/util/StringUtil.cxx
View file @
f860a2fb
...
...
@@ -35,17 +35,28 @@ StripLeft(const char *p)
return
p
;
}
char
*
Strip
(
char
*
p
)
size_t
Strip
Right
(
const
char
*
p
,
size_t
length
)
{
p
=
StripLeft
(
p
);
size_t
length
=
strlen
(
p
);
while
(
length
>
0
&&
IsWhitespaceNotNull
(
p
[
length
-
1
]))
--
length
;
p
[
length
]
=
0
;
return
length
;
}
void
StripRight
(
char
*
p
)
{
size_t
old_length
=
strlen
(
p
);
size_t
new_length
=
StripRight
(
p
,
old_length
);
p
[
new_length
]
=
0
;
}
char
*
Strip
(
char
*
p
)
{
p
=
StripLeft
(
p
);
StripRight
(
p
);
return
p
;
}
...
...
src/util/StringUtil.hxx
View file @
f860a2fb
...
...
@@ -40,6 +40,20 @@ StripLeft(char *p)
}
/**
* Determine the string's length as if it was stripped on the right
* side.
*/
gcc_pure
size_t
StripRight
(
const
char
*
p
,
size_t
length
);
/**
* Strip trailing whitespace by null-terminating the string.
*/
void
StripRight
(
char
*
p
);
/**
* Skip whitespace at the beginning and terminate the string after the
* last non-whitespace character.
*/
...
...
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