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
733989a2
Commit
733989a2
authored
Nov 06, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StringUtil: move comparison functions to StringCompare.cxx
parent
493f74d9
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
199 additions
and
119 deletions
+199
-119
Makefile.am
Makefile.am
+4
-3
LocateUri.cxx
src/LocateUri.cxx
+1
-1
PlaylistFile.cxx
src/PlaylistFile.cxx
+1
-1
DatabaseSave.cxx
src/db/plugins/simple/DatabaseSave.cxx
+1
-1
DirectorySave.cxx
src/db/plugins/simple/DirectorySave.cxx
+1
-1
MadDecoderPlugin.cxx
src/decoder/plugins/MadDecoderPlugin.cxx
+1
-1
StandardDirectory.cxx
src/fs/StandardDirectory.cxx
+1
-0
Traits.cxx
src/fs/Traits.cxx
+1
-1
InputStream.cxx
src/input/InputStream.cxx
+1
-1
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+1
-1
CdioParanoiaInputPlugin.cxx
src/input/plugins/CdioParanoiaInputPlugin.cxx
+1
-0
FfmpegInputPlugin.cxx
src/input/plugins/FfmpegInputPlugin.cxx
+1
-1
MmsInputPlugin.cxx
src/input/plugins/MmsInputPlugin.cxx
+1
-1
NfsInputPlugin.cxx
src/input/plugins/NfsInputPlugin.cxx
+1
-1
SmbclientInputPlugin.cxx
src/input/plugins/SmbclientInputPlugin.cxx
+1
-1
FileReader.cxx
src/lib/nfs/FileReader.cxx
+1
-1
ls.cxx
src/ls.cxx
+1
-1
Volume.cxx
src/mixer/Volume.cxx
+1
-1
OutputState.cxx
src/output/OutputState.cxx
+1
-1
WinmmOutputPlugin.cxx
src/output/plugins/WinmmOutputPlugin.cxx
+1
-1
ExtM3uPlaylistPlugin.cxx
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
+1
-0
SoundCloudPlaylistPlugin.cxx
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+1
-1
PlaylistState.cxx
src/queue/PlaylistState.cxx
+1
-1
QueueSave.cxx
src/queue/QueueSave.cxx
+1
-1
StringCompare.cxx
src/util/StringCompare.cxx
+82
-0
StringCompare.hxx
src/util/StringCompare.hxx
+64
-0
StringUtil.cxx
src/util/StringUtil.cxx
+0
-48
StringUtil.hxx
src/util/StringUtil.hxx
+0
-29
WStringCompare.cxx
src/util/WStringCompare.cxx
+1
-4
WStringCompare.hxx
src/util/WStringCompare.hxx
+25
-15
No files found.
Makefile.am
View file @
733989a2
...
@@ -406,7 +406,8 @@ libutil_a_SOURCES = \
...
@@ -406,7 +406,8 @@ libutil_a_SOURCES = \
src/util/StringView.cxx src/util/StringView.hxx
\
src/util/StringView.cxx src/util/StringView.hxx
\
src/util/AllocatedString.cxx src/util/AllocatedString.hxx
\
src/util/AllocatedString.cxx src/util/AllocatedString.hxx
\
src/util/StringUtil.cxx src/util/StringUtil.hxx
\
src/util/StringUtil.cxx src/util/StringUtil.hxx
\
src/util/WStringUtil.cxx src/util/WStringUtil.hxx
\
src/util/StringCompare.cxx src/util/StringCompare.hxx
\
src/util/WStringCompare.cxx src/util/WStringCompare.hxx
\
src/util/StringAPI.hxx
\
src/util/StringAPI.hxx
\
src/util/WStringAPI.hxx
\
src/util/WStringAPI.hxx
\
src/util/DivideString.cxx src/util/DivideString.hxx
\
src/util/DivideString.cxx src/util/DivideString.hxx
\
...
@@ -1761,10 +1762,10 @@ test_run_gzip_SOURCES = test/run_gzip.cxx
...
@@ -1761,10 +1762,10 @@ test_run_gzip_SOURCES = test/run_gzip.cxx
test_run_gunzip_SOURCES
=
test
/run_gunzip.cxx
\
test_run_gunzip_SOURCES
=
test
/run_gunzip.cxx
\
src/Log.cxx src/LogBackend.cxx
src/Log.cxx src/LogBackend.cxx
test_run_gunzip_LDADD
=
\
test_run_gunzip_LDADD
=
\
libutil.a
\
$(FS_LIBS)
\
$(FS_LIBS)
\
$(ICU_LDADD)
\
$(ICU_LDADD)
\
libsystem.a
libsystem.a
\
libutil.a
endif
endif
...
...
src/LocateUri.cxx
View file @
733989a2
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include "fs/AllocatedPath.hxx"
#include "fs/AllocatedPath.hxx"
#include "ls.hxx"
#include "ls.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
...
...
src/PlaylistFile.cxx
View file @
733989a2
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
#include "fs/FileInfo.hxx"
#include "fs/FileInfo.hxx"
#include "fs/DirectoryReader.hxx"
#include "fs/DirectoryReader.hxx"
#include "util/Macros.hxx"
#include "util/Macros.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
...
...
src/db/plugins/simple/DatabaseSave.cxx
View file @
733989a2
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "tag/Settings.hxx"
#include "tag/Settings.hxx"
#include "fs/Charset.hxx"
#include "fs/Charset.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "Log.hxx"
...
...
src/db/plugins/simple/DirectorySave.cxx
View file @
733989a2
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "PlaylistDatabase.hxx"
#include "PlaylistDatabase.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/NumberParser.hxx"
#include "util/NumberParser.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
...
...
src/decoder/plugins/MadDecoderPlugin.cxx
View file @
733989a2
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "tag/ReplayGain.hxx"
#include "tag/ReplayGain.hxx"
#include "tag/MixRamp.hxx"
#include "tag/MixRamp.hxx"
#include "CheckAudioFormat.hxx"
#include "CheckAudioFormat.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/ASCII.hxx"
#include "util/ASCII.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
...
...
src/fs/StandardDirectory.cxx
View file @
733989a2
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#ifdef USE_XDG
#ifdef USE_XDG
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/StringUtil.hxx"
#include "util/StringUtil.hxx"
#include "util/StringCompare.hxx"
#include "io/TextFile.hxx"
#include "io/TextFile.hxx"
#include <string.h>
#include <string.h>
#include <utility>
#include <utility>
...
...
src/fs/Traits.cxx
View file @
733989a2
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "config.h"
#include "Traits.hxx"
#include "Traits.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include <string.h>
#include <string.h>
...
...
src/input/InputStream.cxx
View file @
733989a2
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "config.h"
#include "InputStream.hxx"
#include "InputStream.hxx"
#include "thread/Cond.hxx"
#include "thread/Cond.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include <assert.h>
#include <assert.h>
...
...
src/input/plugins/AlsaInputPlugin.cxx
View file @
733989a2
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include "../InputStream.hxx"
#include "../InputStream.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/ReusableArray.hxx"
#include "util/ReusableArray.hxx"
#include "Log.hxx"
#include "Log.hxx"
...
...
src/input/plugins/CdioParanoiaInputPlugin.cxx
View file @
733989a2
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "../InputStream.hxx"
#include "../InputStream.hxx"
#include "../InputPlugin.hxx"
#include "../InputPlugin.hxx"
#include "util/StringUtil.hxx"
#include "util/StringUtil.hxx"
#include "util/StringCompare.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "system/ByteOrder.hxx"
#include "system/ByteOrder.hxx"
...
...
src/input/plugins/FfmpegInputPlugin.cxx
View file @
733989a2
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include "lib/ffmpeg/Error.hxx"
#include "lib/ffmpeg/Error.hxx"
#include "../InputStream.hxx"
#include "../InputStream.hxx"
#include "../InputPlugin.hxx"
#include "../InputPlugin.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
extern
"C"
{
extern
"C"
{
...
...
src/input/plugins/MmsInputPlugin.cxx
View file @
733989a2
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include "MmsInputPlugin.hxx"
#include "MmsInputPlugin.hxx"
#include "input/ThreadInputStream.hxx"
#include "input/ThreadInputStream.hxx"
#include "input/InputPlugin.hxx"
#include "input/InputPlugin.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
...
...
src/input/plugins/NfsInputPlugin.cxx
View file @
733989a2
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include "lib/nfs/Glue.hxx"
#include "lib/nfs/Glue.hxx"
#include "lib/nfs/FileReader.hxx"
#include "lib/nfs/FileReader.hxx"
#include "util/HugeAllocator.hxx"
#include "util/HugeAllocator.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include <string.h>
#include <string.h>
...
...
src/input/plugins/SmbclientInputPlugin.cxx
View file @
733989a2
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include "lib/smbclient/Mutex.hxx"
#include "lib/smbclient/Mutex.hxx"
#include "../InputStream.hxx"
#include "../InputStream.hxx"
#include "../InputPlugin.hxx"
#include "../InputPlugin.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include <libsmbclient.h>
#include <libsmbclient.h>
...
...
src/lib/nfs/FileReader.cxx
View file @
733989a2
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#include "Domain.hxx"
#include "Domain.hxx"
#include "event/Call.hxx"
#include "event/Call.hxx"
#include "IOThread.hxx"
#include "IOThread.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include <utility>
#include <utility>
...
...
src/ls.cxx
View file @
733989a2
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "config.h"
#include "ls.hxx"
#include "ls.hxx"
#include "client/Response.hxx"
#include "client/Response.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include <assert.h>
#include <assert.h>
...
...
src/mixer/Volume.cxx
View file @
733989a2
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include "Volume.hxx"
#include "Volume.hxx"
#include "output/MultipleOutputs.hxx"
#include "output/MultipleOutputs.hxx"
#include "Idle.hxx"
#include "Idle.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "system/PeriodClock.hxx"
#include "system/PeriodClock.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
...
...
src/output/OutputState.cxx
View file @
733989a2
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "Domain.hxx"
#include "Domain.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include <assert.h>
#include <assert.h>
#include <stdlib.h>
#include <stdlib.h>
...
...
src/output/plugins/WinmmOutputPlugin.cxx
View file @
733989a2
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "util/Macros.hxx"
#include "util/Macros.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
...
...
src/playlist/plugins/ExtM3uPlaylistPlugin.cxx
View file @
733989a2
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/TagBuilder.hxx"
#include "util/StringUtil.hxx"
#include "util/StringUtil.hxx"
#include "util/StringCompare.hxx"
#include "input/TextInputStream.hxx"
#include "input/TextInputStream.hxx"
#include <string.h>
#include <string.h>
...
...
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
View file @
733989a2
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "config/Block.hxx"
#include "config/Block.hxx"
#include "input/InputStream.hxx"
#include "input/InputStream.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/TagBuilder.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Alloc.hxx"
#include "util/Alloc.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
...
...
src/queue/PlaylistState.cxx
View file @
733989a2
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "config/ConfigGlobal.hxx"
#include "config/ConfigGlobal.hxx"
#include "config/ConfigOption.hxx"
#include "config/ConfigOption.hxx"
#include "util/CharUtil.hxx"
#include "util/CharUtil.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include <string.h>
#include <string.h>
...
...
src/queue/QueueSave.cxx
View file @
733989a2
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include "playlist/PlaylistSong.hxx"
#include "playlist/PlaylistSong.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/String
Util
.hxx"
#include "util/String
Compare
.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "fs/Traits.hxx"
#include "fs/Traits.hxx"
#include "Log.hxx"
#include "Log.hxx"
...
...
src/util/StringCompare.cxx
0 → 100644
View file @
733989a2
/*
* Copyright (C) 2013-2015 Max Kellermann <max@duempel.org>
*
* 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 "StringCompare.hxx"
#include "StringAPI.hxx"
#include <assert.h>
#include <string.h>
bool
StringStartsWith
(
const
char
*
haystack
,
const
char
*
needle
)
{
const
size_t
length
=
strlen
(
needle
);
return
memcmp
(
haystack
,
needle
,
length
)
==
0
;
}
bool
StringEndsWith
(
const
char
*
haystack
,
const
char
*
needle
)
{
const
size_t
haystack_length
=
strlen
(
haystack
);
const
size_t
needle_length
=
strlen
(
needle
);
return
haystack_length
>=
needle_length
&&
memcmp
(
haystack
+
haystack_length
-
needle_length
,
needle
,
needle_length
)
==
0
;
}
const
char
*
StringAfterPrefix
(
const
char
*
string
,
const
char
*
prefix
)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert
(
string
!=
nullptr
);
assert
(
prefix
!=
nullptr
);
#endif
size_t
prefix_length
=
strlen
(
prefix
);
return
StringIsEqual
(
string
,
prefix
,
prefix_length
)
?
string
+
prefix_length
:
nullptr
;
}
const
char
*
FindStringSuffix
(
const
char
*
p
,
const
char
*
suffix
)
{
const
size_t
p_length
=
strlen
(
p
);
const
size_t
suffix_length
=
strlen
(
suffix
);
if
(
p_length
<
suffix_length
)
return
nullptr
;
const
char
*
q
=
p
+
p_length
-
suffix_length
;
return
memcmp
(
q
,
suffix
,
suffix_length
)
==
0
?
q
:
nullptr
;
}
src/util/StringCompare.hxx
0 → 100644
View file @
733989a2
/*
* Copyright (C) 2013-2015 Max Kellermann <max@duempel.org>
*
* 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_COMPARE_HXX
#define STRING_COMPARE_HXX
#include "Compiler.h"
#ifdef _UNICODE
#include "WStringCompare.hxx"
#endif
gcc_pure
bool
StringStartsWith
(
const
char
*
haystack
,
const
char
*
needle
);
gcc_pure
bool
StringEndsWith
(
const
char
*
haystack
,
const
char
*
needle
);
/**
* Returns the portion of the string after a prefix. If the string
* does not begin with the specified prefix, this function returns
* nullptr.
*/
gcc_pure
gcc_nonnull_all
const
char
*
StringAfterPrefix
(
const
char
*
string
,
const
char
*
prefix
);
/**
* Check if the given string ends with the specified suffix. If yes,
* returns the position of the suffix, and nullptr otherwise.
*/
gcc_pure
const
char
*
FindStringSuffix
(
const
char
*
p
,
const
char
*
suffix
);
#endif
src/util/StringUtil.cxx
View file @
733989a2
...
@@ -27,54 +27,6 @@
...
@@ -27,54 +27,6 @@
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
bool
StringStartsWith
(
const
char
*
haystack
,
const
char
*
needle
)
{
const
size_t
length
=
strlen
(
needle
);
return
memcmp
(
haystack
,
needle
,
length
)
==
0
;
}
bool
StringEndsWith
(
const
char
*
haystack
,
const
char
*
needle
)
{
const
size_t
haystack_length
=
strlen
(
haystack
);
const
size_t
needle_length
=
strlen
(
needle
);
return
haystack_length
>=
needle_length
&&
memcmp
(
haystack
+
haystack_length
-
needle_length
,
needle
,
needle_length
)
==
0
;
}
const
char
*
StringAfterPrefix
(
const
char
*
string
,
const
char
*
prefix
)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert
(
string
!=
nullptr
);
assert
(
prefix
!=
nullptr
);
#endif
size_t
prefix_length
=
strlen
(
prefix
);
return
StringIsEqual
(
string
,
prefix
,
prefix_length
)
?
string
+
prefix_length
:
nullptr
;
}
const
char
*
FindStringSuffix
(
const
char
*
p
,
const
char
*
suffix
)
{
const
size_t
p_length
=
strlen
(
p
);
const
size_t
suffix_length
=
strlen
(
suffix
);
if
(
p_length
<
suffix_length
)
return
nullptr
;
const
char
*
q
=
p
+
p_length
-
suffix_length
;
return
memcmp
(
q
,
suffix
,
suffix_length
)
==
0
?
q
:
nullptr
;
}
char
*
char
*
CopyString
(
char
*
gcc_restrict
dest
,
const
char
*
gcc_restrict
src
,
size_t
size
)
CopyString
(
char
*
gcc_restrict
dest
,
const
char
*
gcc_restrict
src
,
size_t
size
)
{
{
...
...
src/util/StringUtil.hxx
View file @
733989a2
...
@@ -24,35 +24,6 @@
...
@@ -24,35 +24,6 @@
#include <stddef.h>
#include <stddef.h>
#ifdef _UNICODE
#include "WStringUtil.hxx"
#endif
gcc_pure
bool
StringStartsWith
(
const
char
*
haystack
,
const
char
*
needle
);
gcc_pure
bool
StringEndsWith
(
const
char
*
haystack
,
const
char
*
needle
);
/**
* Returns the portion of the string after a prefix. If the string
* does not begin with the specified prefix, this function returns
* nullptr.
*/
gcc_pure
gcc_nonnull_all
const
char
*
StringAfterPrefix
(
const
char
*
string
,
const
char
*
prefix
);
/**
* Check if the given string ends with the specified suffix. If yes,
* returns the position of the suffix, and nullptr otherwise.
*/
gcc_pure
const
char
*
FindStringSuffix
(
const
char
*
p
,
const
char
*
suffix
);
/**
/**
* Copy a string. If the buffer is too small, then the string is
* Copy a string. If the buffer is too small, then the string is
* truncated. This is a safer version of strncpy().
* truncated. This is a safer version of strncpy().
...
...
src/util/WString
Util
.cxx
→
src/util/WString
Compare
.cxx
View file @
733989a2
...
@@ -17,11 +17,8 @@
...
@@ -17,11 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
*/
#include "WString
Util
.hxx"
#include "WString
Compare
.hxx"
#include "WStringAPI.hxx"
#include "WStringAPI.hxx"
#include "ASCII.hxx"
#include <algorithm>
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
...
...
src/util/WString
Util
.hxx
→
src/util/WString
Compare
.hxx
View file @
733989a2
/*
/*
* Copyright (C) 2003-2015 The Music Player Daemon Project
* Copyright (C) 2013-2015 Max Kellermann <max@duempel.org>
* http://www.musicpd.org
*
*
* This program is free software; you can redistribute it and/or modify
* Redistribution and use in source and binary forms, with or without
* it under the terms of the GNU General Public License as published by
* modification, are permitted provided that the following conditions
* the Free Software Foundation; either version 2 of the License, or
* are met:
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* - Redistributions of source code must retain the above copyright
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* notice, this list of conditions and the following disclaimer.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License along
* - Redistributions in binary form must reproduce the above copyright
* with this program; if not, write to the Free Software Foundation, Inc.,
* notice, this list of conditions and the following disclaimer in the
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 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 WSTRING_
UTIL
_HXX
#ifndef WSTRING_
COMPARE
_HXX
#define WSTRING_
UTIL
_HXX
#define WSTRING_
COMPARE
_HXX
#include "Compiler.h"
#include "Compiler.h"
...
...
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