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:
committed by
Max Kellermann
parent
99afe8e6d1
commit
e4dad42ca1
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user