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
501a4af9
Commit
501a4af9
authored
Jul 05, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StringUtil: move strip functions to StringStrip.cxx
parent
dad7d7e7
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
199 additions
and
128 deletions
+199
-128
Makefile.am
Makefile.am
+1
-0
LogBackend.cxx
src/LogBackend.cxx
+1
-1
PlaylistDatabase.cxx
src/PlaylistDatabase.cxx
+1
-1
SongSave.cxx
src/SongSave.cxx
+1
-1
ClientRead.cxx
src/client/ClientRead.cxx
+1
-1
ConfigFile.cxx
src/config/ConfigFile.cxx
+1
-1
ExcludeList.cxx
src/db/update/ExcludeList.cxx
+1
-0
RouteFilterPlugin.cxx
src/filter/plugins/RouteFilterPlugin.cxx
+1
-1
StandardDirectory.cxx
src/fs/StandardDirectory.cxx
+1
-1
Request.cxx
src/lib/curl/Request.cxx
+1
-1
CueParser.cxx
src/playlist/cue/CueParser.cxx
+1
-1
ExtM3uPlaylistPlugin.cxx
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
+1
-1
M3uPlaylistPlugin.cxx
src/playlist/plugins/M3uPlaylistPlugin.cxx
+1
-1
PlsPlaylistPlugin.cxx
src/playlist/plugins/PlsPlaylistPlugin.cxx
+1
-1
Config.cxx
src/tag/Config.cxx
+1
-1
Id3Scan.cxx
src/tag/Id3Scan.cxx
+1
-1
DivideString.cxx
src/util/DivideString.cxx
+1
-1
SplitString.cxx
src/util/SplitString.cxx
+1
-1
StringStrip.cxx
src/util/StringStrip.cxx
+85
-0
StringStrip.hxx
src/util/StringStrip.hxx
+95
-0
StringUtil.cxx
src/util/StringUtil.cxx
+0
-53
StringUtil.hxx
src/util/StringUtil.hxx
+0
-58
Tokenizer.cxx
src/util/Tokenizer.cxx
+1
-1
No files found.
Makefile.am
View file @
501a4af9
...
...
@@ -427,6 +427,7 @@ libutil_a_SOURCES = \
src/util/ConcatString.hxx
\
src/util/AllocatedString.cxx src/util/AllocatedString.hxx
\
src/util/TruncateString.cxx src/util/TruncateString.hxx
\
src/util/StringStrip.cxx src/util/StringStrip.hxx
\
src/util/StringUtil.cxx src/util/StringUtil.hxx
\
src/util/StringCompare.cxx src/util/StringCompare.hxx
\
src/util/WStringCompare.cxx src/util/WStringCompare.hxx
\
...
...
src/LogBackend.cxx
View file @
501a4af9
...
...
@@ -21,7 +21,7 @@
#include "LogBackend.hxx"
#include "Log.hxx"
#include "util/Domain.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include <assert.h>
#include <stdio.h>
...
...
src/PlaylistDatabase.cxx
View file @
501a4af9
...
...
@@ -22,7 +22,7 @@
#include "db/PlaylistVector.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/RuntimeError.hxx"
#include <string.h>
...
...
src/SongSave.cxx
View file @
501a4af9
...
...
@@ -27,7 +27,7 @@
#include "tag/ParseName.hxx"
#include "tag/Tag.hxx"
#include "tag/Builder.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/RuntimeError.hxx"
#include <string.h>
...
...
src/client/ClientRead.cxx
View file @
501a4af9
...
...
@@ -22,7 +22,7 @@
#include "Partition.hxx"
#include "Instance.hxx"
#include "event/Loop.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include <string.h>
...
...
src/config/ConfigFile.cxx
View file @
501a4af9
...
...
@@ -24,7 +24,7 @@
#include "Block.hxx"
#include "ConfigTemplates.hxx"
#include "util/Tokenizer.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include "fs/Path.hxx"
...
...
src/db/update/ExcludeList.cxx
View file @
501a4af9
...
...
@@ -28,6 +28,7 @@
#include "fs/NarrowPath.hxx"
#include "fs/io/TextFile.hxx"
#include "system/Error.hxx"
#include "util/StringStrip.hxx"
#include "Log.hxx"
#include <stdexcept>
...
...
src/filter/plugins/RouteFilterPlugin.cxx
View file @
501a4af9
...
...
@@ -48,7 +48,7 @@
#include "filter/FilterRegistry.hxx"
#include "pcm/PcmBuffer.hxx"
#include "pcm/Silence.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/RuntimeError.hxx"
#include "util/ConstBuffer.hxx"
#include "util/WritableBuffer.hxx"
...
...
src/fs/StandardDirectory.cxx
View file @
501a4af9
...
...
@@ -39,7 +39,7 @@
#endif
#ifdef USE_XDG
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/StringCompare.hxx"
#include "io/TextFile.hxx"
#include <string.h>
...
...
src/lib/curl/Request.cxx
View file @
501a4af9
...
...
@@ -33,7 +33,7 @@
#include "Version.hxx"
#include "Handler.hxx"
#include "util/RuntimeError.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/StringView.hxx"
#include "util/CharUtil.hxx"
...
...
src/playlist/cue/CueParser.cxx
View file @
501a4af9
...
...
@@ -21,7 +21,7 @@
#include "CueParser.hxx"
#include "tag/ParseName.hxx"
#include "util/Alloc.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/CharUtil.hxx"
#include <assert.h>
...
...
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
View file @
501a4af9
...
...
@@ -24,7 +24,7 @@
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
#include "tag/Builder.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/StringCompare.hxx"
#include "input/TextInputStream.hxx"
#include "input/InputStream.hxx"
...
...
src/playlist/plugins/M3uPlaylistPlugin.cxx
View file @
501a4af9
...
...
@@ -22,8 +22,8 @@
#include "../PlaylistPlugin.hxx"
#include "../SongEnumerator.hxx"
#include "DetachedSong.hxx"
#include "util/StringUtil.hxx"
#include "input/TextInputStream.hxx"
#include "util/StringStrip.hxx"
class
M3uPlaylist
final
:
public
SongEnumerator
{
TextInputStream
tis
;
...
...
src/playlist/plugins/PlsPlaylistPlugin.cxx
View file @
501a4af9
...
...
@@ -26,7 +26,7 @@
#include "DetachedSong.hxx"
#include "tag/Builder.hxx"
#include "util/ASCII.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "util/DivideString.hxx"
#include <string>
...
...
src/tag/Config.cxx
View file @
501a4af9
...
...
@@ -26,7 +26,7 @@
#include "system/FatalError.hxx"
#include "util/Alloc.hxx"
#include "util/ASCII.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include <stdlib.h>
...
...
src/tag/Id3Scan.cxx
View file @
501a4af9
...
...
@@ -25,7 +25,7 @@
#include "Builder.hxx"
#include "util/Alloc.hxx"
#include "util/ScopeExit.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Strip
.hxx"
#include "Log.hxx"
#include <id3tag.h>
...
...
src/util/DivideString.cxx
View file @
501a4af9
...
...
@@ -18,7 +18,7 @@
*/
#include "DivideString.hxx"
#include "String
Util
.hxx"
#include "String
Strip
.hxx"
#include <string.h>
...
...
src/util/SplitString.cxx
View file @
501a4af9
...
...
@@ -29,7 +29,7 @@
#include "SplitString.hxx"
#include "IterableSplitString.hxx"
#include "String
Util
.hxx"
#include "String
Strip
.hxx"
#include <string.h>
...
...
src/util/StringStrip.cxx
0 → 100644
View file @
501a4af9
/*
* Copyright (C) 2009-2017 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "StringStrip.hxx"
#include "CharUtil.hxx"
#include <string.h>
const
char
*
StripLeft
(
const
char
*
p
)
noexcept
{
while
(
IsWhitespaceNotNull
(
*
p
))
++
p
;
return
p
;
}
const
char
*
StripLeft
(
const
char
*
p
,
const
char
*
end
)
noexcept
{
while
(
p
<
end
&&
IsWhitespaceOrNull
(
*
p
))
++
p
;
return
p
;
}
const
char
*
StripRight
(
const
char
*
p
,
const
char
*
end
)
noexcept
{
while
(
end
>
p
&&
IsWhitespaceOrNull
(
end
[
-
1
]))
--
end
;
return
end
;
}
size_t
StripRight
(
const
char
*
p
,
size_t
length
)
noexcept
{
while
(
length
>
0
&&
IsWhitespaceOrNull
(
p
[
length
-
1
]))
--
length
;
return
length
;
}
void
StripRight
(
char
*
p
)
noexcept
{
size_t
old_length
=
strlen
(
p
);
size_t
new_length
=
StripRight
(
p
,
old_length
);
p
[
new_length
]
=
0
;
}
char
*
Strip
(
char
*
p
)
noexcept
{
p
=
StripLeft
(
p
);
StripRight
(
p
);
return
p
;
}
src/util/StringStrip.hxx
0 → 100644
View file @
501a4af9
/*
* Copyright (C) 2009-2017 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STRING_STRIP_HXX
#define STRING_STRIP_HXX
#include "Compiler.h"
#include <stddef.h>
/**
* Returns a pointer to the first non-whitespace character in the
* string, or to the end of the string.
*/
gcc_pure
const
char
*
StripLeft
(
const
char
*
p
)
noexcept
;
gcc_pure
static
inline
char
*
StripLeft
(
char
*
p
)
noexcept
{
return
const_cast
<
char
*>
(
StripLeft
((
const
char
*
)
p
));
}
gcc_pure
const
char
*
StripLeft
(
const
char
*
p
,
const
char
*
end
)
noexcept
;
/**
* Determine the string's end as if it was stripped on the right side.
*/
gcc_pure
const
char
*
StripRight
(
const
char
*
p
,
const
char
*
end
)
noexcept
;
/**
* Determine the string's end as if it was stripped on the right side.
*/
gcc_pure
static
inline
char
*
StripRight
(
char
*
p
,
char
*
end
)
noexcept
{
return
const_cast
<
char
*>
(
StripRight
((
const
char
*
)
p
,
(
const
char
*
)
end
));
}
/**
* 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
)
noexcept
;
/**
* Strip trailing whitespace by null-terminating the string.
*/
void
StripRight
(
char
*
p
)
noexcept
;
/**
* Skip whitespace at the beginning and terminate the string after the
* last non-whitespace character.
*/
char
*
Strip
(
char
*
p
)
noexcept
;
#endif
src/util/StringUtil.cxx
View file @
501a4af9
...
...
@@ -22,59 +22,6 @@
#include "ASCII.hxx"
#include <assert.h>
#include <string.h>
const
char
*
StripLeft
(
const
char
*
p
)
noexcept
{
while
(
IsWhitespaceNotNull
(
*
p
))
++
p
;
return
p
;
}
const
char
*
StripLeft
(
const
char
*
p
,
const
char
*
end
)
noexcept
{
while
(
p
<
end
&&
IsWhitespaceOrNull
(
*
p
))
++
p
;
return
p
;
}
const
char
*
StripRight
(
const
char
*
p
,
const
char
*
end
)
noexcept
{
while
(
end
>
p
&&
IsWhitespaceOrNull
(
end
[
-
1
]))
--
end
;
return
end
;
}
size_t
StripRight
(
const
char
*
p
,
size_t
length
)
noexcept
{
while
(
length
>
0
&&
IsWhitespaceOrNull
(
p
[
length
-
1
]))
--
length
;
return
length
;
}
void
StripRight
(
char
*
p
)
noexcept
{
size_t
old_length
=
strlen
(
p
);
size_t
new_length
=
StripRight
(
p
,
old_length
);
p
[
new_length
]
=
0
;
}
char
*
Strip
(
char
*
p
)
noexcept
{
p
=
StripLeft
(
p
);
StripRight
(
p
);
return
p
;
}
bool
StringArrayContainsCase
(
const
char
*
const
*
haystack
,
...
...
src/util/StringUtil.hxx
View file @
501a4af9
...
...
@@ -25,64 +25,6 @@
#include <stddef.h>
/**
* Returns a pointer to the first non-whitespace character in the
* string, or to the end of the string.
*/
gcc_pure
const
char
*
StripLeft
(
const
char
*
p
)
noexcept
;
gcc_pure
static
inline
char
*
StripLeft
(
char
*
p
)
noexcept
{
return
const_cast
<
char
*>
(
StripLeft
((
const
char
*
)
p
));
}
gcc_pure
const
char
*
StripLeft
(
const
char
*
p
,
const
char
*
end
)
noexcept
;
/**
* Determine the string's end as if it was stripped on the right side.
*/
gcc_pure
const
char
*
StripRight
(
const
char
*
p
,
const
char
*
end
)
noexcept
;
/**
* Determine the string's end as if it was stripped on the right side.
*/
gcc_pure
static
inline
char
*
StripRight
(
char
*
p
,
char
*
end
)
noexcept
{
return
const_cast
<
char
*>
(
StripRight
((
const
char
*
)
p
,
(
const
char
*
)
end
));
}
/**
* 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
)
noexcept
;
/**
* Strip trailing whitespace by null-terminating the string.
*/
void
StripRight
(
char
*
p
)
noexcept
;
/**
* Skip whitespace at the beginning and terminate the string after the
* last non-whitespace character.
*/
char
*
Strip
(
char
*
p
)
noexcept
;
/**
* Checks whether a string array contains the specified string.
*
* @param haystack a NULL terminated list of strings
...
...
src/util/Tokenizer.cxx
View file @
501a4af9
...
...
@@ -30,7 +30,7 @@
#include "config.h"
#include "Tokenizer.hxx"
#include "CharUtil.hxx"
#include "String
Util
.hxx"
#include "String
Strip
.hxx"
#include <stdexcept>
...
...
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