diff options
Diffstat (limited to '')
-rw-r--r-- | src/decoder/FlacMetadata.cxx | 3 | ||||
-rw-r--r-- | src/decoder/VorbisComments.cxx | 3 | ||||
-rw-r--r-- | src/mixer/OssMixerPlugin.cxx | 5 | ||||
-rw-r--r-- | src/output/HttpdClient.cxx | 6 | ||||
-rw-r--r-- | src/pcm/PcmResampleLibsamplerate.cxx | 5 | ||||
-rw-r--r-- | src/util/ASCII.hxx | 12 |
6 files changed, 23 insertions, 11 deletions
diff --git a/src/decoder/FlacMetadata.cxx b/src/decoder/FlacMetadata.cxx index 99659d143..a9c57d926 100644 --- a/src/decoder/FlacMetadata.cxx +++ b/src/decoder/FlacMetadata.cxx @@ -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] == '=') { diff --git a/src/decoder/VorbisComments.cxx b/src/decoder/VorbisComments.cxx index 773eca261..44648884a 100644 --- a/src/decoder/VorbisComments.cxx +++ b/src/decoder/VorbisComments.cxx @@ -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; diff --git a/src/mixer/OssMixerPlugin.cxx b/src/mixer/OssMixerPlugin.cxx index 5b533470b..0a459bc97 100644 --- a/src/mixer/OssMixerPlugin.cxx +++ b/src/mixer/OssMixerPlugin.cxx @@ -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; diff --git a/src/output/HttpdClient.cxx b/src/output/HttpdClient.cxx index 9595e47f6..6d0d468a7 100644 --- a/src/output/HttpdClient.cxx +++ b/src/output/HttpdClient.cxx @@ -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 */ diff --git a/src/pcm/PcmResampleLibsamplerate.cxx b/src/pcm/PcmResampleLibsamplerate.cxx index 2ffe4b8c4..1986e8821 100644 --- a/src/pcm/PcmResampleLibsamplerate.cxx +++ b/src/pcm/PcmResampleLibsamplerate.cxx @@ -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; } diff --git a/src/util/ASCII.hxx b/src/util/ASCII.hxx index 0d4c8f35b..adea6dceb 100644 --- a/src/util/ASCII.hxx +++ b/src/util/ASCII.hxx @@ -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 |