use std chr functions
The ones in std have overloads for const char/char. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
99afe8e6d1
commit
e4dad42ca1
@ -27,12 +27,11 @@
|
|||||||
#include "util/StringView.hxx"
|
#include "util/StringView.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static constexpr char PERMISSION_PASSWORD_CHAR = '@';
|
static constexpr char PERMISSION_PASSWORD_CHAR = '@';
|
||||||
static constexpr char PERMISSION_SEPARATOR = ',';
|
static constexpr char PERMISSION_SEPARATOR = ',';
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ initPermissions(const ConfigData &config)
|
|||||||
permission_default = 0;
|
permission_default = 0;
|
||||||
|
|
||||||
param.With([](const char *value){
|
param.With([](const char *value){
|
||||||
const char *separator = strchr(value,
|
const char *separator = std::strchr(value,
|
||||||
PERMISSION_PASSWORD_CHAR);
|
PERMISSION_PASSWORD_CHAR);
|
||||||
|
|
||||||
if (separator == nullptr)
|
if (separator == nullptr)
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
#include "util/StringStrip.hxx"
|
#include "util/StringStrip.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -49,8 +50,8 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
|
|||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
while ((line = file.ReadLine()) != nullptr &&
|
while ((line = file.ReadLine()) != nullptr &&
|
||||||
strcmp(line, "playlist_end") != 0) {
|
std::strcmp(line, "playlist_end") != 0) {
|
||||||
colon = strchr(line, ':');
|
colon = std::strchr(line, ':');
|
||||||
if (colon == nullptr || colon == line)
|
if (colon == nullptr || colon == line)
|
||||||
throw FormatRuntimeError("unknown line in db: %s",
|
throw FormatRuntimeError("unknown line in db: %s",
|
||||||
line);
|
line);
|
||||||
@ -58,7 +59,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
|
|||||||
*colon++ = 0;
|
*colon++ = 0;
|
||||||
value = StripLeft(colon);
|
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));
|
pm.mtime = std::chrono::system_clock::from_time_t(strtol(value, nullptr, 10));
|
||||||
else
|
else
|
||||||
throw FormatRuntimeError("unknown line in db: %s",
|
throw FormatRuntimeError("unknown line in db: %s",
|
||||||
|
@ -43,8 +43,7 @@
|
|||||||
#include "util/UriExtract.hxx"
|
#include "util/UriExtract.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static const char PLAYLIST_COMMENT = '#';
|
static const char PLAYLIST_COMMENT = '#';
|
||||||
|
|
||||||
@ -81,9 +80,9 @@ spl_valid_name(const char *name_utf8)
|
|||||||
* filenames isn't going to happen, either.
|
* filenames isn't going to happen, either.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return strchr(name_utf8, '/') == nullptr &&
|
return std::strchr(name_utf8, '/') == nullptr &&
|
||||||
strchr(name_utf8, '\n') == nullptr &&
|
std::strchr(name_utf8, '\n') == nullptr &&
|
||||||
strchr(name_utf8, '\r') == nullptr;
|
std::strchr(name_utf8, '\r') == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AllocatedPath &
|
static const AllocatedPath &
|
||||||
|
@ -96,7 +96,7 @@ song_load(TextFile &file, const char *uri,
|
|||||||
char *line;
|
char *line;
|
||||||
while ((line = file.ReadLine()) != nullptr &&
|
while ((line = file.ReadLine()) != nullptr &&
|
||||||
!StringIsEqual(line, SONG_END)) {
|
!StringIsEqual(line, SONG_END)) {
|
||||||
char *colon = strchr(line, ':');
|
char *colon = std::strchr(line, ':');
|
||||||
if (colon == nullptr || colon == line) {
|
if (colon == nullptr || colon == line) {
|
||||||
throw FormatRuntimeError("unknown line in db: %s", line);
|
throw FormatRuntimeError("unknown line in db: %s", line);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ SongPtr
|
|||||||
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
|
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
|
||||||
{
|
{
|
||||||
assert(!uri_has_scheme(path_utf8));
|
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);
|
auto song = std::make_unique<Song>(path_utf8, parent);
|
||||||
if (!song->UpdateFile(storage))
|
if (!song->UpdateFile(storage))
|
||||||
@ -95,7 +95,7 @@ Song::LoadFromArchive(ArchiveFile &archive, const char *name_utf8,
|
|||||||
Directory &parent) noexcept
|
Directory &parent) noexcept
|
||||||
{
|
{
|
||||||
assert(!uri_has_scheme(name_utf8));
|
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);
|
auto song = std::make_unique<Song>(name_utf8, parent);
|
||||||
if (!song->UpdateFileInArchive(archive))
|
if (!song->UpdateFileInArchive(archive))
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "Instance.hxx"
|
#include "Instance.hxx"
|
||||||
#include "util/StringStrip.hxx"
|
#include "util/StringStrip.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
BufferedSocket::InputResult
|
BufferedSocket::InputResult
|
||||||
Client::OnSocketInput(void *data, size_t length) noexcept
|
Client::OnSocketInput(void *data, size_t length) noexcept
|
||||||
@ -32,7 +32,7 @@ Client::OnSocketInput(void *data, size_t length) noexcept
|
|||||||
return InputResult::PAUSE;
|
return InputResult::PAUSE;
|
||||||
|
|
||||||
char *p = (char *)data;
|
char *p = (char *)data;
|
||||||
char *newline = (char *)memchr(p, '\n', length);
|
char *newline = (char *)std::memchr(p, '\n', length);
|
||||||
if (newline == nullptr)
|
if (newline == nullptr)
|
||||||
return InputResult::MORE;
|
return InputResult::MORE;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ gcc_pure
|
|||||||
static bool
|
static bool
|
||||||
skip_path(const char *name_utf8) noexcept
|
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)
|
#if defined(_WIN32) && GCC_CHECK_VERSION(4,6)
|
||||||
@ -185,7 +185,7 @@ handle_mount(Client &client, Request args, Response &r)
|
|||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr(local_uri, '/') != nullptr) {
|
if (std::strchr(local_uri, '/') != nullptr) {
|
||||||
/* allow only top-level mounts for now */
|
/* allow only top-level mounts for now */
|
||||||
/* TODO: eliminate this limitation after ensuring that
|
/* TODO: eliminate this limitation after ensuring that
|
||||||
UpdateQueue::Erase() really gets called for every
|
UpdateQueue::Erase() really gets called for every
|
||||||
|
@ -103,7 +103,7 @@ ParsePath(const char *path)
|
|||||||
|
|
||||||
++path;
|
++path;
|
||||||
} else {
|
} else {
|
||||||
const char *slash = strchr(path, '/');
|
const char *slash = std::strchr(path, '/');
|
||||||
const char *end = slash == nullptr
|
const char *end = slash == nullptr
|
||||||
? path + strlen(path)
|
? path + strlen(path)
|
||||||
: slash;
|
: slash;
|
||||||
|
@ -55,7 +55,7 @@ void
|
|||||||
UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
|
UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
|
||||||
const char *name) noexcept
|
const char *name) noexcept
|
||||||
{
|
{
|
||||||
const char *tmp = strchr(name, '/');
|
const char *tmp = std::strchr(name, '/');
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
const std::string_view child_name(name, tmp - name);
|
const std::string_view child_name(name, tmp - name);
|
||||||
//add dir is not there already
|
//add dir is not there already
|
||||||
|
@ -148,7 +148,7 @@ WatchDirectory::GetUriFS() const noexcept
|
|||||||
static bool skip_path(const char *path)
|
static bool skip_path(const char *path)
|
||||||
{
|
{
|
||||||
return PathTraitsFS::IsSpecialFilename(path) ||
|
return PathTraitsFS::IsSpecialFilename(path) ||
|
||||||
strchr(path, '\n') != nullptr;
|
std::strchr(path, '\n') != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -191,7 +191,7 @@ UpdateWalk::UpdateDirectoryChild(Directory &directory,
|
|||||||
const ExcludeList &exclude_list,
|
const ExcludeList &exclude_list,
|
||||||
const char *name, const StorageFileInfo &info) noexcept
|
const char *name, const StorageFileInfo &info) noexcept
|
||||||
try {
|
try {
|
||||||
assert(strchr(name, '/') == nullptr);
|
assert(std::strchr(name, '/') == nullptr);
|
||||||
|
|
||||||
if (info.IsRegular()) {
|
if (info.IsRegular()) {
|
||||||
UpdateRegularFile(directory, name, info);
|
UpdateRegularFile(directory, name, info);
|
||||||
@ -223,7 +223,7 @@ gcc_pure
|
|||||||
static bool
|
static bool
|
||||||
skip_path(const char *name_utf8) noexcept
|
skip_path(const char *name_utf8) noexcept
|
||||||
{
|
{
|
||||||
return strchr(name_utf8, '\n') != nullptr;
|
return std::strchr(name_utf8, '\n') != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
@ -29,11 +29,10 @@
|
|||||||
#include "util/Math.hxx"
|
#include "util/Math.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <neaacdec.h>
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <string.h>
|
#include <neaacdec.h>
|
||||||
|
|
||||||
static const unsigned adts_sample_rates[] =
|
static const unsigned adts_sample_rates[] =
|
||||||
{ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
|
{ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
|
||||||
@ -72,8 +71,7 @@ adts_find_frame(DecoderBuffer &buffer)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* find the 0xff marker */
|
/* find the 0xff marker */
|
||||||
const auto *p = (const uint8_t *)
|
auto p = (const uint8_t *)std::memchr(data.data, 0xff, data.size);
|
||||||
memchr(data.data, 0xff, data.size);
|
|
||||||
if (p == nullptr) {
|
if (p == nullptr) {
|
||||||
/* no marker - discard the buffer */
|
/* no marker - discard the buffer */
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
|
@ -164,7 +164,7 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
|
|||||||
char *line_end;
|
char *line_end;
|
||||||
// find end of the string
|
// find end of the string
|
||||||
if (quoted) {
|
if (quoted) {
|
||||||
line_end = strrchr(line, '"');
|
line_end = std::strrchr(line, '"');
|
||||||
if (line_end == nullptr)
|
if (line_end == nullptr)
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,7 +196,7 @@ struct PathTraitsUTF8 {
|
|||||||
assert(p != nullptr);
|
assert(p != nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return strrchr(p, SEPARATOR);
|
return std::strrchr(p, SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -133,7 +133,7 @@ parse_cdio_uri(const char *src)
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *slash = strrchr(src, '/');
|
const char *slash = std::strrchr(src, '/');
|
||||||
if (slash == nullptr) {
|
if (slash == nullptr) {
|
||||||
/* play the whole CD in the specified drive */
|
/* play the whole CD in the specified drive */
|
||||||
CopyTruncateString(dest.device, src, sizeof(dest.device));
|
CopyTruncateString(dest.device, src, sizeof(dest.device));
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
NfsFileReader::NfsFileReader() noexcept
|
NfsFileReader::NfsFileReader() noexcept
|
||||||
@ -97,7 +97,7 @@ NfsFileReader::Open(const char *uri)
|
|||||||
|
|
||||||
uri += 6;
|
uri += 6;
|
||||||
|
|
||||||
const char *slash = strchr(uri, '/');
|
const char *slash = std::strchr(uri, '/');
|
||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
throw std::runtime_error("Malformed nfs:// URI");
|
throw std::runtime_error("Malformed nfs:// URI");
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ NfsFileReader::Open(const char *uri)
|
|||||||
new_path = "/";
|
new_path = "/";
|
||||||
path = new_path;
|
path = new_path;
|
||||||
} else {
|
} else {
|
||||||
slash = strrchr(uri + 1, '/');
|
slash = std::strrchr(uri + 1, '/');
|
||||||
if (slash == nullptr || slash[1] == 0)
|
if (slash == nullptr || slash[1] == 0)
|
||||||
throw std::runtime_error("Malformed nfs:// URI");
|
throw std::runtime_error("Malformed nfs:// URI");
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ ExtractHost(const char *src) noexcept
|
|||||||
/* "[hostname]:port" (IPv6?) */
|
/* "[hostname]:port" (IPv6?) */
|
||||||
|
|
||||||
hostname = ++src;
|
hostname = ++src;
|
||||||
const char *end = strchr(hostname, ']');
|
const char *end = std::strchr(hostname, ']');
|
||||||
if (end == nullptr || end == hostname)
|
if (end == nullptr || end == hostname)
|
||||||
/* failed, return nullptr */
|
/* failed, return nullptr */
|
||||||
return result;
|
return result;
|
||||||
|
@ -65,7 +65,7 @@ ai_is_passive(const struct addrinfo *ai)
|
|||||||
static void
|
static void
|
||||||
FindAndResolveInterfaceName(char *host, size_t size)
|
FindAndResolveInterfaceName(char *host, size_t size)
|
||||||
{
|
{
|
||||||
char *percent = strchr(host, '%');
|
char *percent = std::strchr(host, '%');
|
||||||
if (percent == nullptr || percent + 64 > host + size)
|
if (percent == nullptr || percent + 64 > host + size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ SocketAddress::GetLocalPath() const noexcept
|
|||||||
/* must be null-terminated */
|
/* must be null-terminated */
|
||||||
raw.back() == 0 &&
|
raw.back() == 0 &&
|
||||||
/* there must not be any other null byte */
|
/* 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
|
? raw.data
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
@ -49,8 +50,6 @@
|
|||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
|
|
||||||
static std::string
|
static std::string
|
||||||
@ -104,7 +103,7 @@ ToString(SocketAddress address) noexcept
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (strchr(host, ':') != nullptr) {
|
if (std::strchr(host, ':') != nullptr) {
|
||||||
std::string result("[");
|
std::string result("[");
|
||||||
result.append(host);
|
result.append(host);
|
||||||
result.append("]:");
|
result.append("]:");
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
HttpdClient::~HttpdClient() noexcept
|
HttpdClient::~HttpdClient() noexcept
|
||||||
@ -95,7 +95,7 @@ HttpdClient::HandleLine(const char *line) noexcept
|
|||||||
should_reject = true;
|
should_reject = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = strchr(line, ' ');
|
line = std::strchr(line, ' ');
|
||||||
if (line == nullptr || strncmp(line + 1, "HTTP/", 5) != 0) {
|
if (line == nullptr || strncmp(line + 1, "HTTP/", 5) != 0) {
|
||||||
/* HTTP/0.9 without request headers */
|
/* HTTP/0.9 without request headers */
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ HttpdClient::OnSocketInput(void *data, size_t length) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *line = (char *)data;
|
char *line = (char *)data;
|
||||||
char *newline = (char *)memchr(line, '\n', length);
|
char *newline = (char *)std::memchr(line, '\n', length);
|
||||||
if (newline == nullptr)
|
if (newline == nullptr)
|
||||||
return InputResult::MORE;
|
return InputResult::MORE;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ playlist_check_translate_song(DetachedSong &song, std::string_view base_uri,
|
|||||||
const char *uri = song.GetURI();
|
const char *uri = song.GetURI();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#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
|
/* Windows uses the backslash as path separator, but
|
||||||
the MPD protocol uses the (forward) slash by
|
the MPD protocol uses the (forward) slash by
|
||||||
definition; to allow backslashes in relative URIs
|
definition; to allow backslashes in relative URIs
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
#include "util/CharUtil.hxx"
|
#include "util/CharUtil.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@ -49,7 +49,7 @@ cue_next_quoted(char *p, char **pp)
|
|||||||
assert(p >= *pp);
|
assert(p >= *pp);
|
||||||
assert(p[-1] == '"');
|
assert(p[-1] == '"');
|
||||||
|
|
||||||
char *end = strchr(p, '"');
|
char *end = std::strchr(p, '"');
|
||||||
if (end == nullptr) {
|
if (end == nullptr) {
|
||||||
/* syntax error - ignore it silently */
|
/* syntax error - ignore it silently */
|
||||||
*pp = p + strlen(p);
|
*pp = p + strlen(p);
|
||||||
|
@ -175,7 +175,7 @@ static unsigned
|
|||||||
ParseStatus(const char *s)
|
ParseStatus(const char *s)
|
||||||
{
|
{
|
||||||
/* skip the "HTTP/1.1" prefix */
|
/* skip the "HTTP/1.1" prefix */
|
||||||
const char *space = strchr(s, ' ');
|
const char *space = std::strchr(s, ' ');
|
||||||
if (space == nullptr)
|
if (space == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ CreateNfsStorageURI(EventLoop &event_loop, const char *base)
|
|||||||
if (p == nullptr)
|
if (p == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const char *mount = strchr(p, '/');
|
const char *mount = std::strchr(p, '/');
|
||||||
if (mount == nullptr)
|
if (mount == nullptr)
|
||||||
throw std::runtime_error("Malformed nfs:// URI");
|
throw std::runtime_error("Malformed nfs:// URI");
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ CreateUdisksStorageURI(EventLoop &event_loop, const char *base_uri)
|
|||||||
|
|
||||||
std::string id;
|
std::string id;
|
||||||
|
|
||||||
const char *relative_path = strchr(id_begin, '/');
|
const char *relative_path = std::strchr(id_begin, '/');
|
||||||
if (relative_path == nullptr) {
|
if (relative_path == nullptr) {
|
||||||
id = id_begin;
|
id = id_begin;
|
||||||
relative_path = "";
|
relative_path = "";
|
||||||
|
@ -24,10 +24,9 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
struct ApeFooter {
|
struct ApeFooter {
|
||||||
unsigned char id[8];
|
unsigned char id[8];
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
@ -83,7 +82,7 @@ try {
|
|||||||
|
|
||||||
/* get the key */
|
/* get the key */
|
||||||
const char *key = p;
|
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)
|
if (key_end == nullptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
#include "DivideString.hxx"
|
#include "DivideString.hxx"
|
||||||
#include "StringStrip.hxx"
|
#include "StringStrip.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
DivideString::DivideString(const char *s, char separator, bool strip) noexcept
|
DivideString::DivideString(const char *s, char separator, bool strip) noexcept
|
||||||
:first(nullptr)
|
:first(nullptr)
|
||||||
{
|
{
|
||||||
const char *x = strchr(s, separator);
|
const char *x = std::strchr(s, separator);
|
||||||
if (x == nullptr)
|
if (x == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
#include "MimeType.hxx"
|
#include "MimeType.hxx"
|
||||||
#include "SplitString.hxx"
|
#include "SplitString.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
GetMimeTypeBase(const char *s) noexcept
|
GetMimeTypeBase(const char *s) noexcept
|
||||||
{
|
{
|
||||||
const char *semicolon = strchr(s, ';');
|
const char *semicolon = std::strchr(s, ';');
|
||||||
return semicolon != nullptr
|
return semicolon != nullptr
|
||||||
? std::string(s, semicolon)
|
? std::string(s, semicolon)
|
||||||
: std::string(s);
|
: std::string(s);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#include "WStringAPI.hxx"
|
#include "WStringAPI.hxx"
|
||||||
@ -56,42 +56,42 @@ gcc_pure gcc_nonnull_all
|
|||||||
static inline char *
|
static inline char *
|
||||||
StringFind(char *haystack, char needle, size_t size) noexcept
|
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
|
gcc_pure gcc_nonnull_all
|
||||||
static inline const char *
|
static inline const char *
|
||||||
StringFind(const char *haystack, char needle, size_t size) noexcept
|
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
|
gcc_pure gcc_nonnull_all
|
||||||
static inline const char *
|
static inline const char *
|
||||||
StringFind(const char *haystack, char needle) noexcept
|
StringFind(const char *haystack, char needle) noexcept
|
||||||
{
|
{
|
||||||
return strchr(haystack, needle);
|
return std::strchr(haystack, needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
static inline char *
|
static inline char *
|
||||||
StringFind(char *haystack, char needle) noexcept
|
StringFind(char *haystack, char needle) noexcept
|
||||||
{
|
{
|
||||||
return strchr(haystack, needle);
|
return std::strchr(haystack, needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
static inline const char *
|
static inline const char *
|
||||||
StringFindLast(const char *haystack, char needle) noexcept
|
StringFindLast(const char *haystack, char needle) noexcept
|
||||||
{
|
{
|
||||||
return strrchr(haystack, needle);
|
return std::strrchr(haystack, needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
static inline char *
|
static inline char *
|
||||||
StringFindLast(char *haystack, char needle) noexcept
|
StringFindLast(char *haystack, char needle) noexcept
|
||||||
{
|
{
|
||||||
return strrchr(haystack, needle);
|
return std::strrchr(haystack, needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
|
@ -30,14 +30,14 @@
|
|||||||
#ifndef TEXT_FILE_HXX
|
#ifndef TEXT_FILE_HXX
|
||||||
#define TEXT_FILE_HXX
|
#define TEXT_FILE_HXX
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
template<typename B>
|
template<typename B>
|
||||||
char *
|
char *
|
||||||
ReadBufferedLine(B &buffer)
|
ReadBufferedLine(B &buffer)
|
||||||
{
|
{
|
||||||
auto r = buffer.Read();
|
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)
|
if (newline == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ uri_get_path(std::string_view uri) noexcept
|
|||||||
const char *
|
const char *
|
||||||
uri_get_suffix(const char *uri) noexcept
|
uri_get_suffix(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
const char *suffix = strrchr(uri, '.');
|
const char *suffix = std::strrchr(uri, '.');
|
||||||
if (suffix == nullptr || suffix == uri ||
|
if (suffix == nullptr || suffix == uri ||
|
||||||
suffix[-1] == '/' || suffix[-1] == '\\')
|
suffix[-1] == '/' || suffix[-1] == '\\')
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -144,7 +144,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) noexcept
|
|||||||
if (suffix == nullptr)
|
if (suffix == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const char *q = strchr(suffix, '?');
|
const char *q = std::strchr(suffix, '?');
|
||||||
if (q != nullptr && size_t(q - suffix) < sizeof(buffer.data)) {
|
if (q != nullptr && size_t(q - suffix) < sizeof(buffer.data)) {
|
||||||
memcpy(buffer.data, suffix, q - suffix);
|
memcpy(buffer.data, suffix, q - suffix);
|
||||||
buffer.data[q - suffix] = 0;
|
buffer.data[q - suffix] = 0;
|
||||||
@ -157,7 +157,7 @@ uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) noexcept
|
|||||||
const char *
|
const char *
|
||||||
uri_get_fragment(const char *uri) noexcept
|
uri_get_fragment(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
const char *fragment = strchr(uri, '#');
|
const char *fragment = std::strchr(uri, '#');
|
||||||
if (fragment == nullptr)
|
if (fragment == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
#include "ASCII.hxx"
|
#include "ASCII.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
verify_uri_segment(const char *p) noexcept
|
verify_uri_segment(const char *p) noexcept
|
||||||
@ -46,7 +45,7 @@ verify_uri_segment(const char *p) noexcept
|
|||||||
if (dots <= 2 && (*p == 0 || *p == '/'))
|
if (dots <= 2 && (*p == 0 || *p == '/'))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const char *q = strchr(p + 1, '/');
|
const char *q = std::strchr(p + 1, '/');
|
||||||
return q != nullptr ? q : "";
|
return q != nullptr ? q : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +88,11 @@ uri_remove_auth(const char *uri) noexcept
|
|||||||
/* unrecognized URI */
|
/* unrecognized URI */
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
const char *slash = strchr(auth, '/');
|
const char *slash = std::strchr(auth, '/');
|
||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
slash = auth + strlen(auth);
|
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)
|
if (at == nullptr)
|
||||||
/* no auth info present, do nothing */
|
/* no auth info present, do nothing */
|
||||||
return std::string();
|
return std::string();
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <cwchar>
|
||||||
|
|
||||||
gcc_pure gcc_nonnull_all
|
gcc_pure gcc_nonnull_all
|
||||||
static inline size_t
|
static inline size_t
|
||||||
@ -52,14 +52,14 @@ gcc_pure gcc_nonnull_all
|
|||||||
static inline const wchar_t *
|
static inline const wchar_t *
|
||||||
StringFind(const wchar_t *haystack, wchar_t needle, size_t size) noexcept
|
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
|
gcc_pure gcc_nonnull_all
|
||||||
static inline wchar_t *
|
static inline wchar_t *
|
||||||
StringFind(wchar_t *haystack, wchar_t needle, size_t size) noexcept
|
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
|
gcc_pure gcc_nonnull_all
|
||||||
|
Loading…
Reference in New Issue
Block a user