From c90debcfff5dcadfc64112825b1deaae2cb3a3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Wed, 16 Jan 2019 16:09:54 -0800 Subject: [PATCH] Added maximum number of items when matching identifier. --- include/bx/string.h | 2 +- src/string.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/bx/string.h b/include/bx/string.h index 25665bf..5fffe67 100644 --- a/include/bx/string.h +++ b/include/bx/string.h @@ -261,7 +261,7 @@ namespace bx StringView findIdentifierMatch(const StringView& _str, const StringView& _word); /// Finds any identifier from NULL terminated array of identifiers. - StringView findIdentifierMatch(const StringView& _str, const char** _words); + StringView findIdentifierMatch(const StringView& _str, const char** _words, int32_t _num = INT32_MAX); /// Cross platform implementation of vsnprintf that returns number of /// characters which would have been written to the final string if diff --git a/src/string.cpp b/src/string.cpp index f85c82f..cdc2a91 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -687,9 +687,10 @@ namespace bx return StringView(_str.getTerm(), _str.getTerm() ); } - StringView findIdentifierMatch(const StringView& _str, const char** _words) + StringView findIdentifierMatch(const StringView& _str, const char** _words, int32_t _num) { - for (StringView word = *_words; !word.isEmpty(); ++_words, word = *_words) + int32_t ii = 0; + for (StringView word = *_words; ii < _num && !word.isEmpty(); ++ii, ++_words, word = *_words) { StringView match = findIdentifierMatch(_str, word); if (!match.isEmpty() )