summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-04-30 19:25:55 -0700
committerMax Kellermann <max@musicpd.org>2020-05-30 13:36:53 +0200
commite4dad42ca123b9f0f987218c68c42422d6735c0a (patch)
tree6cf4c3d28e251b285cfe5a30e842edfc3080d6bc
parent99afe8e6d1157c0d443ccbe4b571797cce5b2304 (diff)
use std chr functions
The ones in std have overloads for const char/char. Signed-off-by: Rosen Penev <rosenp@gmail.com>
-rw-r--r--src/Permission.cxx5
-rw-r--r--src/PlaylistDatabase.cxx9
-rw-r--r--src/PlaylistFile.cxx9
-rw-r--r--src/SongSave.cxx2
-rw-r--r--src/SongUpdate.cxx4
-rw-r--r--src/client/Read.cxx4
-rw-r--r--src/command/StorageCommands.cxx4
-rw-r--r--src/config/Path.cxx2
-rw-r--r--src/db/update/Archive.cxx2
-rw-r--r--src/db/update/InotifyUpdate.cxx2
-rw-r--r--src/db/update/Walk.cxx4
-rw-r--r--src/decoder/plugins/FaadDecoderPlugin.cxx8
-rw-r--r--src/fs/StandardDirectory.cxx2
-rw-r--r--src/fs/Traits.hxx2
-rw-r--r--src/input/plugins/CdioParanoiaInputPlugin.cxx2
-rw-r--r--src/lib/nfs/FileReader.cxx6
-rw-r--r--src/net/HostParser.cxx2
-rw-r--r--src/net/Resolver.cxx2
-rw-r--r--src/net/SocketAddress.cxx2
-rw-r--r--src/net/ToString.cxx5
-rw-r--r--src/output/plugins/httpd/HttpdClient.cxx6
-rw-r--r--src/playlist/PlaylistSong.cxx2
-rw-r--r--src/playlist/cue/CueParser.cxx4
-rw-r--r--src/storage/plugins/CurlStorage.cxx2
-rw-r--r--src/storage/plugins/NfsStorage.cxx2
-rw-r--r--src/storage/plugins/UdisksStorage.cxx2
-rw-r--r--src/tag/ApeLoader.cxx5
-rw-r--r--src/util/DivideString.cxx4
-rw-r--r--src/util/MimeType.cxx4
-rw-r--r--src/util/StringAPI.hxx14
-rw-r--r--src/util/TextFile.hxx4
-rw-r--r--src/util/UriExtract.cxx6
-rw-r--r--src/util/UriUtil.cxx9
-rw-r--r--src/util/WStringAPI.hxx6
34 files changed, 71 insertions, 77 deletions
diff --git a/src/Permission.cxx b/src/Permission.cxx
index b4b6d01a7..69d22834e 100644
--- a/src/Permission.cxx
+++ b/src/Permission.cxx
@@ -27,12 +27,11 @@
#include "util/StringView.hxx"
#include <cassert>
+#include <cstring>
#include <map>
#include <string>
#include <utility>
-#include <string.h>
-
static constexpr char PERMISSION_PASSWORD_CHAR = '@';
static constexpr char PERMISSION_SEPARATOR = ',';
@@ -89,7 +88,7 @@ initPermissions(const ConfigData &config)
permission_default = 0;
param.With([](const char *value){
- const char *separator = strchr(value,
+ const char *separator = std::strchr(value,
PERMISSION_PASSWORD_CHAR);
if (separator == nullptr)
diff --git a/src/PlaylistDatabase.cxx b/src/PlaylistDatabase.cxx
index 1ec3543fb..24635708b 100644
--- a/src/PlaylistDatabase.cxx
+++ b/src/PlaylistDatabase.cxx
@@ -25,7 +25,8 @@
#include "util/StringStrip.hxx"
#include "util/RuntimeError.hxx"
-#include <string.h>
+#include <cstring>
+
#include <stdlib.h>
void
@@ -49,8 +50,8 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
const char *value;
while ((line = file.ReadLine()) != nullptr &&
- strcmp(line, "playlist_end") != 0) {
- colon = strchr(line, ':');
+ std::strcmp(line, "playlist_end") != 0) {
+ colon = std::strchr(line, ':');
if (colon == nullptr || colon == line)
throw FormatRuntimeError("unknown line in db: %s",
line);
@@ -58,7 +59,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
*colon++ = 0;
value = StripLeft(colon);
- if (strcmp(line, "mtime") == 0)
+ if (std::strcmp(line, "mtime") == 0)
pm.mtime = std::chrono::system_clock::from_time_t(strtol(value, nullptr, 10));
else
throw FormatRuntimeError("unknown line in db: %s",
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx
index aa67a4ae4..bf37c0ef7 100644
--- a/src/PlaylistFile.cxx
+++ b/src/PlaylistFile.cxx
@@ -43,8 +43,7 @@
#include "util/UriExtract.hxx"
#include <cassert>
-
-#include <string.h>
+#include <cstring>
static const char PLAYLIST_COMMENT = '#';
@@ -81,9 +80,9 @@ spl_valid_name(const char *name_utf8)
* filenames isn't going to happen, either.
*/
- return strchr(name_utf8, '/') == nullptr &&
- strchr(name_utf8, '\n') == nullptr &&
- strchr(name_utf8, '\r') == nullptr;
+ return std::strchr(name_utf8, '/') == nullptr &&
+ std::strchr(name_utf8, '\n') == nullptr &&
+ std::strchr(name_utf8, '\r') == nullptr;
}
static const AllocatedPath &
diff --git a/src/SongSave.cxx b/src/SongSave.cxx
index c123ffb19..26ccee72c 100644
--- a/src/SongSave.cxx
+++ b/src/SongSave.cxx
@@ -96,7 +96,7 @@ song_load(TextFile &file, const char *uri,
char *line;
while ((line = file.ReadLine()) != nullptr &&
!StringIsEqual(line, SONG_END)) {
- char *colon = strchr(line, ':');
+ char *colon = std::strchr(line, ':');
if (colon == nullptr || colon == line) {
throw FormatRuntimeError("unknown line in db: %s", line);
}
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index bce944315..30cd699e0 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -44,7 +44,7 @@ SongPtr
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
{
assert(!uri_has_scheme(path_utf8));
- assert(strchr(path_utf8, '\n') == nullptr);
+ assert(std::strchr(path_utf8, '\n') == nullptr);
auto song = std::make_unique<Song>(path_utf8, parent);
if (!song->UpdateFile(storage))
@@ -95,7 +95,7 @@ Song::LoadFromArchive(ArchiveFile &archive, const char *name_utf8,
Directory &parent) noexcept
{
assert(!uri_has_scheme(name_utf8));
- assert(strchr(name_utf8, '\n') == nullptr);
+ assert(std::strchr(name_utf8, '\n') == nullptr);
auto song = std::make_unique<Song>(name_utf8, parent);
if (!song->UpdateFileInArchive(archive))
diff --git a/src/client/Read.cxx b/src/client/Read.cxx
index 62c6e8017..c78ebd9e7 100644
--- a/src/client/Read.cxx
+++ b/src/client/Read.cxx
@@ -23,7 +23,7 @@
#include "Instance.hxx"
#include "util/StringStrip.hxx"
-#include <string.h>
+#include <cstring>
BufferedSocket::InputResult
Client::OnSocketInput(void *data, size_t length) noexcept
@@ -32,7 +32,7 @@ Client::OnSocketInput(void *data, size_t length) noexcept
return InputResult::PAUSE;
char *p = (char *)data;
- char *newline = (char *)memchr(p, '\n', length);
+ char *newline = (char *)std::memchr(p, '\n', length);
if (newline == nullptr)
return InputResult::MORE;
diff --git a/src/command/StorageCommands.cxx b/src/command/StorageCommands.cxx
index 8809fa995..5dbff101f 100644
--- a/src/command/StorageCommands.cxx
+++ b/src/command/StorageCommands.cxx
@@ -44,7 +44,7 @@ gcc_pure
static bool
skip_path(const char *name_utf8) noexcept
{
- return strchr(name_utf8, '\n') != nullptr;
+ return std::strchr(name_utf8, '\n') != nullptr;
}
#if defined(_WIN32) && GCC_CHECK_VERSION(4,6)
@@ -185,7 +185,7 @@ handle_mount(Client &client, Request args, Response &r)
return CommandResult::ERROR;
}
- if (strchr(local_uri, '/') != nullptr) {
+ if (std::strchr(local_uri, '/') != nullptr) {
/* allow only top-level mounts for now */
/* TODO: eliminate this limitation after ensuring that
UpdateQueue::Erase() really gets called for every
diff --git a/src/config/Path.cxx b/src/config/Path.cxx
index 4c372942b..011aa6e69 100644
--- a/src/config/Path.cxx
+++ b/src/config/Path.cxx
@@ -103,7 +103,7 @@ ParsePath(const char *path)
++path;
} else {
- const char *slash = strchr(path, '/');
+ const char *slash = std::strchr(path, '/');
const char *end = slash == nullptr
? path + strlen(path)
: slash;
diff --git a/src/db/update/Archive.cxx b/src/db/update/Archive.cxx
index 9baab7b63..53bb8660d 100644
--- a/src/db/update/Archive.cxx
+++ b/src/db/update/Archive.cxx
@@ -55,7 +55,7 @@ void
UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
const char *name) noexcept
{
- const char *tmp = strchr(name, '/');
+ const char *tmp = std::strchr(name, '/');
if (tmp) {
const std::string_view child_name(name, tmp - name);
//add dir is not there already
diff --git a/src/db/update/InotifyUpdate.cxx b/src/db/update/InotifyUpdate.cxx
index 8df7bad8d..ff6257b99 100644
--- a/src/db/update/InotifyUpdate.cxx
+++ b/src/db/update/InotifyUpdate.cxx
@@ -148,7 +148,7 @@ WatchDirectory::GetUriFS() const noexcept
static bool skip_path(const char *path)
{
return PathTraitsFS::IsSpecialFilename(path) ||
- strchr(path, '\n') != nullptr;
+ std::strchr(path, '\n') != nullptr;
}
static void
diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx
index a5840a535..1cb1538dc 100644
--- a/src/db/update/Walk.cxx
+++ b/src/db/update/Walk.cxx
@@ -191,7 +191,7 @@ UpdateWalk::UpdateDirectoryChild(Directory &directory,
const ExcludeList &exclude_list,
const char *name, const StorageFileInfo &info) noexcept
try {
- assert(strchr(name, '/') == nullptr);
+ assert(std::strchr(name, '/') == nullptr);
if (info.IsRegular()) {
UpdateRegularFile(directory, name, info);
@@ -223,7 +223,7 @@ gcc_pure
static bool
skip_path(const char *name_utf8) noexcept
{
- return strchr(name_utf8, '\n') != nullptr;
+ return std::strchr(name_utf8, '\n') != nullptr;
}
gcc_pure
diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx
index 40072f953..a3884adec 100644
--- a/src/decoder/plugins/FaadDecoderPlugin.cxx
+++ b/src/decoder/plugins/FaadDecoderPlugin.cxx
@@ -29,11 +29,10 @@
#include "util/Math.hxx"
#include "Log.hxx"
-#include <neaacdec.h>
-
#include <cassert>
+#include <cstring>
-#include <string.h>
+#include <neaacdec.h>
static const unsigned adts_sample_rates[] =
{ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
@@ -72,8 +71,7 @@ adts_find_frame(DecoderBuffer &buffer)
return 0;
/* find the 0xff marker */
- const auto *p = (const uint8_t *)
- memchr(data.data, 0xff, data.size);
+ auto p = (const uint8_t *)std::memchr(data.data, 0xff, data.size);
if (p == nullptr) {
/* no marker - discard the buffer */
buffer.Clear();
diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx
index c80ebdeef..55c02c5fc 100644
--- a/src/fs/StandardDirectory.cxx
+++ b/src/fs/StandardDirectory.cxx
@@ -164,7 +164,7 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
char *line_end;
// find end of the string
if (quoted) {
- line_end = strrchr(line, '"');
+ line_end = std::strrchr(line, '"');
if (line_end == nullptr)
return true;
} else {
diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx
index bcb432f60..da899df63 100644
--- a/src/fs/Traits.hxx
+++ b/src/fs/Traits.hxx
@@ -196,7 +196,7 @@ struct PathTraitsUTF8 {
assert(p != nullptr);
#endif
- return strrchr(p, SEPARATOR);
+ return std::strrchr(p, SEPARATOR);
}
#ifdef _WIN32
diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx
index dc33c362e..fff854b24 100644
--- a/src/input/plugins/CdioParanoiaInputPlugin.cxx
+++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx
@@ -133,7 +133,7 @@ parse_cdio_uri(const char *src)
return dest;
}
- const char *slash = strrchr(src, '/');
+ const char *slash = std::strrchr(src, '/');
if (slash == nullptr) {
/* play the whole CD in the specified drive */
CopyTruncateString(dest.device, src, sizeof(dest.device));
diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx
index 5307a33ff..4a4e6457e 100644
--- a/src/lib/nfs/FileReader.cxx
+++ b/src/lib/nfs/FileReader.cxx
@@ -25,10 +25,10 @@
#include "util/ASCII.hxx"
#include <cassert>
+#include <cstring>
#include <stdexcept>
#include <utility>
-#include <string.h>
#include <fcntl.h>
NfsFileReader::NfsFileReader() noexcept
@@ -97,7 +97,7 @@ NfsFileReader::Open(const char *uri)
uri += 6;
- const char *slash = strchr(uri, '/');
+ const char *slash = std::strchr(uri, '/');
if (slash == nullptr)
throw std::runtime_error("Malformed nfs:// URI");
@@ -112,7 +112,7 @@ NfsFileReader::Open(const char *uri)
new_path = "/";
path = new_path;
} else {
- slash = strrchr(uri + 1, '/');
+ slash = std::strrchr(uri + 1, '/');
if (slash == nullptr || slash[1] == 0)
throw std::runtime_error("Malformed nfs:// URI");
diff --git a/src/net/HostParser.cxx b/src/net/HostParser.cxx
index 1f639aded..19e13ca10 100644
--- a/src/net/HostParser.cxx
+++ b/src/net/HostParser.cxx
@@ -124,7 +124,7 @@ ExtractHost(const char *src) noexcept
/* "[hostname]:port" (IPv6?) */
hostname = ++src;
- const char *end = strchr(hostname, ']');
+ const char *end = std::strchr(hostname, ']');
if (end == nullptr || end == hostname)
/* failed, return nullptr */
return result;
diff --git a/src/net/Resolver.cxx b/src/net/Resolver.cxx
index 5b7adcb82..b513b5a79 100644
--- a/src/net/Resolver.cxx
+++ b/src/net/Resolver.cxx
@@ -65,7 +65,7 @@ ai_is_passive(const struct addrinfo *ai)
static void
FindAndResolveInterfaceName(char *host, size_t size)
{
- char *percent = strchr(host, '%');
+ char *percent = std::strchr(host, '%');
if (percent == nullptr || percent + 64 > host + size)
return;
diff --git a/src/net/SocketAddress.cxx b/src/net/SocketAddress.cxx
index 9261519cd..3635d13dd 100644
--- a/src/net/SocketAddress.cxx
+++ b/src/net/SocketAddress.cxx
@@ -84,7 +84,7 @@ SocketAddress::GetLocalPath() const noexcept
/* must be null-terminated */
raw.back() == 0 &&
/* there must not be any other null byte */
- memchr(raw.data, 0, raw.size - 1) == nullptr
+ std::memchr(raw.data, 0, raw.size - 1) == nullptr
? raw.data
: nullptr;
}
diff --git a/src/net/ToString.cxx b/src/net/ToString.cxx
index d15812457..7d89cd3a8 100644
--- a/src/net/ToString.cxx
+++ b/src/net/ToString.cxx
@@ -35,6 +35,7 @@
#include <algorithm>
#include <cassert>
+#include <cstring>
#ifdef _WIN32
#include <ws2tcpip.h>
@@ -49,8 +50,6 @@
#include <sys/un.h>
#endif
-#include <string.h>
-
#ifdef HAVE_UN
static std::string
@@ -104,7 +103,7 @@ ToString(SocketAddress address) noexcept
return "unknown";
#ifdef HAVE_IPV6
- if (strchr(host, ':') != nullptr) {
+ if (std::strchr(host, ':') != nullptr) {
std::string result("[");
result.append(host);
result.append("]:");
diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx
index 5d4ef90b6..fceb58f39 100644
--- a/src/output/plugins/httpd/HttpdClient.cxx
+++ b/src/output/plugins/httpd/HttpdClient.cxx
@@ -28,8 +28,8 @@
#include "Log.hxx"
#include <cassert>
+#include <cstring>
-#include <string.h>
#include <stdio.h>
HttpdClient::~HttpdClient() noexcept
@@ -95,7 +95,7 @@ HttpdClient::HandleLine(const char *line) noexcept
should_reject = true;
}
- line = strchr(line, ' ');
+ line = std::strchr(line, ' ');
if (line == nullptr || strncmp(line + 1, "HTTP/", 5) != 0) {
/* HTTP/0.9 without request headers */
@@ -413,7 +413,7 @@ HttpdClient::OnSocketInput(void *data, size_t length) noexcept
}
char *line = (char *)data;
- char *newline = (char *)memchr(line, '\n', length);
+ char *newline = (char *)std::memchr(line, '\n', length);
if (newline == nullptr)
return InputResult::MORE;
diff --git a/src/playlist/PlaylistSong.cxx b/src/playlist/PlaylistSong.cxx
index fdd12bad9..a0fac3317 100644
--- a/src/playlist/PlaylistSong.cxx
+++ b/src/playlist/PlaylistSong.cxx
@@ -78,7 +78,7 @@ playlist_check_translate_song(DetachedSong &song, std::string_view base_uri,
const char *uri = song.GetURI();
#ifdef _WIN32
- if (!PathTraitsUTF8::IsAbsolute(uri) && strchr(uri, '\\') != nullptr) {
+ if (!PathTraitsUTF8::IsAbsolute(uri) && std::strchr(uri, '\\') != nullptr) {
/* Windows uses the backslash as path separator, but
the MPD protocol uses the (forward) slash by
definition; to allow backslashes in relative URIs
diff --git a/src/playlist/cue/CueParser.cxx b/src/playlist/cue/CueParser.cxx
index 736a0314c..a402508e2 100644
--- a/src/playlist/cue/CueParser.cxx
+++ b/src/playlist/cue/CueParser.cxx
@@ -24,8 +24,8 @@
#include "util/CharUtil.hxx"
#include <cassert>
+#include <cstring>
-#include <string.h>
#include <stdlib.h>
static const char *
@@ -49,7 +49,7 @@ cue_next_quoted(char *p, char **pp)
assert(p >= *pp);
assert(p[-1] == '"');
- char *end = strchr(p, '"');
+ char *end = std::strchr(p, '"');
if (end == nullptr) {
/* syntax error - ignore it silently */
*pp = p + strlen(p);
diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx
index 356fa8b58..e6de47f11 100644
--- a/src/storage/plugins/CurlStorage.cxx
+++ b/src/storage/plugins/CurlStorage.cxx
@@ -175,7 +175,7 @@ static unsigned
ParseStatus(const char *s)
{
/* skip the "HTTP/1.1" prefix */
- const char *space = strchr(s, ' ');
+ const char *space = std::strchr(s, ' ');
if (space == nullptr)
return 0;
diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx
index 5c44591fc..a93ccefb9 100644
--- a/src/storage/plugins/NfsStorage.cxx
+++ b/src/storage/plugins/NfsStorage.cxx
@@ -412,7 +412,7 @@ CreateNfsStorageURI(EventLoop &event_loop, const char *base)
if (p == nullptr)
return nullptr;
- const char *mount = strchr(p, '/');
+ const char *mount = std::strchr(p, '/');
if (mount == nullptr)
throw std::runtime_error("Malformed nfs:// URI");
diff --git a/src/storage/plugins/UdisksStorage.cxx b/src/storage/plugins/UdisksStorage.cxx
index 8f87a933e..206369ea9 100644
--- a/src/storage/plugins/UdisksStorage.cxx
+++ b/src/storage/plugins/UdisksStorage.cxx
@@ -357,7 +357,7 @@ CreateUdisksStorageURI(EventLoop &event_loop, const char *base_uri)
std::string id;
- const char *relative_path = strchr(id_begin, '/');
+ const char *relative_path = std::strchr(id_begin, '/');
if (relative_path == nullptr) {
id = id_begin;
relative_path = "";
diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx
index 67daa1e96..144f91b96 100644
--- a/src/tag/ApeLoader.cxx
+++ b/src/tag/ApeLoader.cxx
@@ -24,10 +24,9 @@
#include <cassert>
#include <cstdint>
+#include <cstring>
#include <memory>
-#include <string.h>
-
struct ApeFooter {
unsigned char id[8];
uint32_t version;
@@ -83,7 +82,7 @@ try {
/* get the key */
const char *key = p;
- const char *key_end = (const char *)memchr(p, '\0', remaining);
+ const char *key_end = (const char *)std::memchr(p, '\0', remaining);
if (key_end == nullptr)
break;
diff --git a/src/util/DivideString.cxx b/src/util/DivideString.cxx
index 124ce0411..2e8e1b08b 100644
--- a/src/util/DivideString.cxx
+++ b/src/util/DivideString.cxx
@@ -20,12 +20,12 @@
#include "DivideString.hxx"
#include "StringStrip.hxx"
-#include <string.h>
+#include <cstring>
DivideString::DivideString(const char *s, char separator, bool strip) noexcept
:first(nullptr)
{
- const char *x = strchr(s, separator);
+ const char *x = std::strchr(s, separator);
if (x == nullptr)
return;
diff --git a/src/util/MimeType.cxx b/src/util/MimeType.cxx
index 8d1979877..f73c37557 100644
--- a/src/util/MimeType.cxx
+++ b/src/util/MimeType.cxx
@@ -20,12 +20,12 @@
#include "MimeType.hxx"
#include "SplitString.hxx"
-#include <string.h>
+#include <cstring>
std::string
GetMimeTypeBase(const char *s) noexcept
{
- const char *semicolon = strchr(s, ';');
+ const char *semicolon = std::strchr(s, ';');
return semicolon != nullptr
? std::string(s, semicolon)
: std::string(s);
diff --git a/src/util/StringAPI.hxx b/src/util/StringAPI.hxx
index fdb918389..6f44f115b 100644
--- a/src/util/StringAPI.hxx
+++ b/src/util/StringAPI.hxx
@@ -32,7 +32,7 @@
#include "Compiler.h"
-#include <string.h>
+#include <cstring>
#ifdef _UNICODE
#include "WStringAPI.hxx"
@@ -56,42 +56,42 @@ gcc_pure gcc_nonnull_all
static inline char *
StringFind(char *haystack, char needle, size_t size) noexcept
{
- return (char *)memchr(haystack, needle, size);
+ return (char *)std::memchr(haystack, needle, size);
}
gcc_pure gcc_nonnull_all
static inline const char *
StringFind(const char *haystack, char needle, size_t size) noexcept
{
- return (const char *)memchr(haystack, needle, size);
+ return (const char *)std::memchr(haystack, needle, size);
}
gcc_pure gcc_nonnull_all
static inline const char *
StringFind(const char *haystack, char needle) noexcept
{
- return strchr(haystack, needle);
+ return std::strchr(haystack, needle);
}
gcc_pure gcc_nonnull_all
static inline char *
StringFind(char *haystack, char needle) noexcept
{
- return strchr(haystack, needle);
+ return std::strchr(haystack, needle);
}
gcc_pure gcc_nonnull_all
static inline const char *
StringFindLast(const char *haystack, char needle) noexcept
{
- return strrchr(haystack, needle);
+ return std::strrchr(haystack, needle);
}
gcc_pure gcc_nonnull_all
static inline char *
StringFindLast(char *haystack, char needle) noexcept
{
- return strrchr(haystack, needle);
+ return std::strrchr(haystack, needle);
}
gcc_pure gcc_nonnull_all
diff --git a/src/util/TextFile.hxx b/src/util/TextFile.hxx
index 691b472a0..1867f7774 100644
--- a/src/util/TextFile.hxx
+++ b/src/util/TextFile.hxx
@@ -30,14 +30,14 @@
#ifndef TEXT_FILE_HXX
#define TEXT_FILE_HXX
-#include <string.h>
+#include <cstring>
template<typename B>
char *
ReadBufferedLine(B &buffer)
{
auto r = buffer.Read();
- char *newline = reinterpret_cast<char*>(memchr(r.data, '\n', r.size));
+ char *newline = reinterpret_cast<char*>(std::memchr(r.data, '\n', r.size));
if (newline == nullptr)
return nullptr;
diff --git a/src/util/UriExtract.cxx b/src/util/UriExtract.cxx
index c78bd9e8f..053c20cc7 100644
--- a/src/util/UriExtract.cxx
+++ b/src/util/UriExtract.cxx
@@ -124,7 +124,7 @@ uri_get_path(std::string_view uri) noexcept
const char *
uri_get_suffix(const char *uri) noexcept
{
- const char *suffix = strrchr(uri, '.');
+ const char *suffix = std::strrchr(uri, '.');
if (suffix == nullptr || suffix == uri ||
suffix[-1] == '/' || suffix[-1] == '\\')
return nullptr;
@@ -144,7 +144,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) noexcept
if (suffix == nullptr)
return nullptr;
- const char *q = strchr(suffix, '?');
+ const char *q = std::strchr(suffix, '?');
if (q != nullptr && size_t(q - suffix) < sizeof(buffer.data)) {
memcpy(buffer.data, suffix, q - suffix);
buffer.data[q - suffix] = 0;
@@ -157,7 +157,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) noexcept
const char *
uri_get_fragment(const char *uri) noexcept
{
- const char *fragment = strchr(uri, '#');
+ const char *fragment = std::strchr(uri, '#');
if (fragment == nullptr)
return nullptr;
diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx
index d962934a5..a780b9d2d 100644
--- a/src/util/UriUtil.cxx
+++ b/src/util/UriUtil.cxx
@@ -31,8 +31,7 @@
#include "ASCII.hxx"
#include <cassert>
-
-#include <string.h>
+#include <cstring>
static const char *
verify_uri_segment(const char *p) noexcept
@@ -46,7 +45,7 @@ verify_uri_segment(const char *p) noexcept
if (dots <= 2 && (*p == 0 || *p == '/'))
return nullptr;
- const char *q = strchr(p + 1, '/');
+ const char *q = std::strchr(p + 1, '/');
return q != nullptr ? q : "";
}
@@ -89,11 +88,11 @@ uri_remove_auth(const char *uri) noexcept
/* unrecognized URI */
return std::string();
- const char *slash = strchr(auth, '/');
+ const char *slash = std::strchr(auth, '/');
if (slash == nullptr)
slash = auth + strlen(auth);
- const char *at = (const char *)memchr(auth, '@', slash - auth);
+ const char *at = (const char *)std::memchr(auth, '@', slash - auth);
if (at == nullptr)
/* no auth info present, do nothing */
return std::string();
diff --git a/src/util/WStringAPI.hxx b/src/util/WStringAPI.hxx
index 82864a9a5..3b02c47ea 100644
--- a/src/util/WStringAPI.hxx
+++ b/src/util/WStringAPI.hxx
@@ -32,7 +32,7 @@
#include "Compiler.h"
-#include <wchar.h>
+#include <cwchar>
gcc_pure gcc_nonnull_all
static inline size_t
@@ -52,14 +52,14 @@ gcc_pure gcc_nonnull_all
static inline const wchar_t *
StringFind(const wchar_t *haystack, wchar_t needle, size_t size) noexcept
{
- return wmemchr(haystack, needle, size);
+ return std::wmemchr(haystack, needle, size);
}
gcc_pure gcc_nonnull_all
static inline wchar_t *
StringFind(wchar_t *haystack, wchar_t needle, size_t size) noexcept
{
- return wmemchr(haystack, needle, size);
+ return std::wmemchr(haystack, needle, size);
}
gcc_pure gcc_nonnull_all