From b0983e8708669fb60ac78ca1248957e1a9d7b84d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 3 Mar 2015 12:39:13 +0100 Subject: fs/Traits: add Find() --- src/fs/Path.hxx | 2 +- src/fs/Traits.hxx | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src/fs') diff --git a/src/fs/Path.hxx b/src/fs/Path.hxx index 962518896..3ff7ddba2 100644 --- a/src/fs/Path.hxx +++ b/src/fs/Path.hxx @@ -129,7 +129,7 @@ public: */ gcc_pure bool HasNewline() const { - return strchr(value, '\n') != nullptr; + return PathTraitsFS::Find(value, '\n') != nullptr; } /** diff --git a/src/fs/Traits.hxx b/src/fs/Traits.hxx index 9591290f7..0860dfb8a 100644 --- a/src/fs/Traits.hxx +++ b/src/fs/Traits.hxx @@ -101,6 +101,16 @@ struct PathTraitsFS { return char_traits::length(p); } + gcc_pure gcc_nonnull_all + static const_pointer Find(const_pointer p, size_t n, value_type ch) { + return char_traits::find(p, n, ch); + } + + gcc_pure gcc_nonnull_all + static const_pointer Find(const_pointer p, value_type ch) { + return strchr(p, ch); + } + /** * Determine the "base" file name of the given native path. * The return value points inside the given string. @@ -195,6 +205,16 @@ struct PathTraitsUTF8 { return char_traits::length(p); } + gcc_pure gcc_nonnull_all + static const_pointer Find(const_pointer p, size_t n, value_type ch) { + return char_traits::find(p, n, ch); + } + + gcc_pure gcc_nonnull_all + static const_pointer Find(const_pointer p, value_type ch) { + return strchr(p, ch); + } + /** * Determine the "base" file name of the given UTF-8 path. * The return value points inside the given string. -- cgit v1.2.3