Browse Source

Added maximum number of items when matching identifier.

Бранимир Караџић 7 years ago
parent
commit
c90debcfff
2 changed files with 4 additions and 3 deletions
  1. 1 1
      include/bx/string.h
  2. 3 2
      src/string.cpp

+ 1 - 1
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

+ 3 - 2
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() )