aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlib
diff options
context:
space:
mode:
Diffstat (limited to 'lexlib')
-rw-r--r--lexlib/CharacterCategory.cxx3
-rw-r--r--lexlib/StringCopy.h3
-rw-r--r--lexlib/WordList.cxx3
3 files changed, 7 insertions, 2 deletions
diff --git a/lexlib/CharacterCategory.cxx b/lexlib/CharacterCategory.cxx
index a83776028..765469a3f 100644
--- a/lexlib/CharacterCategory.cxx
+++ b/lexlib/CharacterCategory.cxx
@@ -9,6 +9,7 @@
#include <algorithm>
+#include "StringCopy.h"
#include "CharacterCategory.h"
#ifdef SCI_NAMESPACE
@@ -3275,7 +3276,7 @@ const int catRanges[] = {
const int maxUnicode = 0x10ffff;
const int maskCategory = 0x1F;
-const int nRanges = sizeof(catRanges) / sizeof(catRanges[0]);
+const int nRanges = ELEMENTS(catRanges);
}
diff --git a/lexlib/StringCopy.h b/lexlib/StringCopy.h
index caca49911..1812b4e35 100644
--- a/lexlib/StringCopy.h
+++ b/lexlib/StringCopy.h
@@ -1,6 +1,7 @@
// Scintilla source code edit control
/** @file StringCopy.h
** Safe string copy function which always NUL terminates.
+ ** ELEMENTS macro for determining array sizes.
**/
// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@@ -26,6 +27,8 @@ void StringCopy(T (&dest)[count], const T* source) {
dest[count-1] = 0;
}
+#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
+
#ifdef SCI_NAMESPACE
}
#endif
diff --git a/lexlib/WordList.cxx b/lexlib/WordList.cxx
index e789c0eaf..10b6fe349 100644
--- a/lexlib/WordList.cxx
+++ b/lexlib/WordList.cxx
@@ -13,6 +13,7 @@
#include <algorithm>
+#include "StringCopy.h"
#include "WordList.h"
#ifdef SCI_NAMESPACE
@@ -131,7 +132,7 @@ void WordList::Set(const char *s) {
#else
SortWordList(words, len);
#endif
- for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++)
+ for (unsigned int k = 0; k < ELEMENTS(starts); k++)
starts[k] = -1;
for (int l = len - 1; l >= 0; l--) {
unsigned char indexChar = words[l][0];