From f7fe678a4ada859a2e4fbbeeb0b1dff5b5887227 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 11 May 2016 17:35:35 -0700 Subject: Add much-needed Find() method for CFX_*StringC BUG=pdfium:493 Review-Url: https://codereview.chromium.org/1968233002 --- core/fxcrt/include/fx_string.h | 12 ++++++++++++ core/fxcrt/include/fx_system.h | 3 --- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'core/fxcrt/include') diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index 66a8039a8d..fbfb91f759 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -100,6 +100,12 @@ class CFX_ByteStringC { uint8_t GetAt(FX_STRSIZE index) const { return m_Ptr[index]; } + FX_STRSIZE Find(FX_CHAR ch) const { + const uint8_t* found = + static_cast(memchr(m_Ptr, ch, m_Length)); + return found ? found - m_Ptr : -1; + } + CFX_ByteStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const { if (index < 0) { index = 0; @@ -417,6 +423,12 @@ class CFX_WideStringC { return CFX_WideStringC(m_Ptr, count); } + FX_STRSIZE Find(FX_WCHAR ch) const { + const FX_WCHAR* found = + static_cast(wmemchr(m_Ptr, ch, m_Length)); + return found ? found - m_Ptr : -1; + } + CFX_WideStringC Mid(FX_STRSIZE index, FX_STRSIZE count = -1) const { if (index < 0) { index = 0; diff --git a/core/fxcrt/include/fx_system.h b/core/fxcrt/include/fx_system.h index 795a0c2794..b4659d14e4 100644 --- a/core/fxcrt/include/fx_system.h +++ b/core/fxcrt/include/fx_system.h @@ -123,7 +123,6 @@ void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE -#define FXSYS_strchr strchr #define FXSYS_strncmp strncmp #define FXSYS_strcmp strcmp #define FXSYS_strcpy strcpy @@ -166,7 +165,6 @@ extern "C" { #endif #define FXSYS_wcscmp wcscmp -#define FXSYS_wcschr wcschr #define FXSYS_wcsstr wcsstr #define FXSYS_wcsncmp wcsncmp #define FXSYS_vswprintf vswprintf @@ -176,7 +174,6 @@ extern "C" { #define FXSYS_memcpy memcpy #define FXSYS_memmove memmove #define FXSYS_memset memset -#define FXSYS_memchr memchr #define FXSYS_qsort qsort #define FXSYS_bsearch bsearch -- cgit v1.2.3