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
222dc8a2
Commit
222dc8a2
authored
Oct 21, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Util/ASCII: add StringEqualsCaseASCII() overload with length
Replaces GLib's g_ascii_strncasecmp().
parent
0e4d2e72
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
11 deletions
+23
-11
FlacMetadata.cxx
src/decoder/FlacMetadata.cxx
+2
-1
VorbisComments.cxx
src/decoder/VorbisComments.cxx
+2
-1
OssMixerPlugin.cxx
src/mixer/OssMixerPlugin.cxx
+2
-3
HttpdClient.cxx
src/output/HttpdClient.cxx
+3
-3
PcmResampleLibsamplerate.cxx
src/pcm/PcmResampleLibsamplerate.cxx
+2
-3
ASCII.hxx
src/util/ASCII.hxx
+12
-0
No files found.
src/decoder/FlacMetadata.cxx
View file @
222dc8a2
...
...
@@ -25,6 +25,7 @@
#include "tag/TagTable.hxx"
#include "tag/TagBuilder.hxx"
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
#include <glib.h>
...
...
@@ -135,7 +136,7 @@ flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
const
char
*
comment
=
(
const
char
*
)
entry
->
entry
;
if
(
entry
->
length
<=
name_length
||
g_ascii_strncasecmp
(
comment
,
name
,
name_length
)
!=
0
)
StringEqualsCaseASCII
(
comment
,
name
,
name_length
)
)
return
nullptr
;
if
(
comment
[
name_length
]
==
'='
)
{
...
...
src/decoder/VorbisComments.cxx
View file @
222dc8a2
...
...
@@ -25,6 +25,7 @@
#include "tag/TagHandler.hxx"
#include "tag/TagBuilder.hxx"
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
#include <glib.h>
...
...
@@ -38,7 +39,7 @@ vorbis_comment_value(const char *comment, const char *needle)
{
size_t
len
=
strlen
(
needle
);
if
(
g_ascii_strncasecmp
(
comment
,
needle
,
len
)
==
0
&&
if
(
StringEqualsCaseASCII
(
comment
,
needle
,
len
)
&&
comment
[
len
]
==
'='
)
return
comment
+
len
+
1
;
...
...
src/mixer/OssMixerPlugin.cxx
View file @
222dc8a2
...
...
@@ -21,12 +21,11 @@
#include "MixerInternal.hxx"
#include "OutputAPI.hxx"
#include "system/fd_util.h"
#include "util/ASCII.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <sys/stat.h>
...
...
@@ -71,7 +70,7 @@ oss_find_mixer(const char *name)
size_t
name_length
=
strlen
(
name
);
for
(
unsigned
i
=
0
;
i
<
SOUND_MIXER_NRDEVICES
;
i
++
)
{
if
(
g_ascii_strncasecmp
(
name
,
labels
[
i
],
name_length
)
==
0
&&
if
(
StringEqualsCaseASCII
(
name
,
labels
[
i
],
name_length
)
&&
(
labels
[
i
][
name_length
]
==
0
||
labels
[
i
][
name_length
]
==
' '
))
return
i
;
...
...
src/output/HttpdClient.cxx
View file @
222dc8a2
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "HttpdClient.hxx"
#include "HttpdInternal.hxx"
#include "util/
fifo_buffer.h
"
#include "util/
ASCII.hxx
"
#include "Page.hxx"
#include "IcyMetaDataServer.hxx"
#include "system/SocketError.hxx"
...
...
@@ -102,13 +102,13 @@ HttpdClient::HandleLine(const char *line)
return
true
;
}
if
(
g_ascii_strncasecmp
(
line
,
"Icy-MetaData: 1"
,
15
)
==
0
)
{
if
(
StringEqualsCaseASCII
(
line
,
"Icy-MetaData: 1"
,
15
)
)
{
/* Send icy metadata */
metadata_requested
=
metadata_supported
;
return
true
;
}
if
(
g_ascii_strncasecmp
(
line
,
"transferMode.dlna.org: Streaming"
,
32
)
==
0
)
{
if
(
StringEqualsCaseASCII
(
line
,
"transferMode.dlna.org: Streaming"
,
32
)
)
{
/* Send as dlna */
dlna_streaming_requested
=
true
;
/* metadata is not supported by dlna streaming, so disable it */
...
...
src/pcm/PcmResampleLibsamplerate.cxx
View file @
222dc8a2
...
...
@@ -19,12 +19,11 @@
#include "config.h"
#include "PcmResampleInternal.hxx"
#include "util/ASCII.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <glib.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
...
...
@@ -54,7 +53,7 @@ lsr_parse_converter(const char *s)
if
(
name
==
nullptr
)
break
;
if
(
g_ascii_strncasecmp
(
s
,
name
,
length
)
==
0
)
{
if
(
StringEqualsCaseASCII
(
s
,
name
,
length
)
)
{
lsr_converter
=
i
;
return
true
;
}
...
...
src/util/ASCII.hxx
View file @
222dc8a2
...
...
@@ -51,4 +51,16 @@ StringEqualsCaseASCII(const char *a, const char *b)
return
strcasecmp
(
a
,
b
)
==
0
;
}
gcc_pure
gcc_nonnull_all
static
inline
bool
StringEqualsCaseASCII
(
const
char
*
a
,
const
char
*
b
,
size_t
n
)
{
assert
(
a
!=
nullptr
);
assert
(
b
!=
nullptr
);
/* note: strcasecmp() depends on the locale, but for ASCII-only
strings, it's safe to use */
return
strncasecmp
(
a
,
b
,
n
)
==
0
;
}
#endif
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