diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2014-01-21 09:45:29 +1100 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2014-01-21 09:45:29 +1100 |
commit | 2bd8a54e0624143ee5128d1e224b1635b2c5d1f4 (patch) | |
tree | 6acd5402304cd8f9efc400d11ca32dab95d5410d /src/Editor.cxx | |
parent | 56d581a730cd2c5dd0959c6b3bd532c9f5ad42e2 (diff) | |
download | scintilla-mirror-2bd8a54e0624143ee5128d1e224b1635b2c5d1f4.tar.gz |
Added ELEMENTS macro and use it to clarify determining size of arrays.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 833f60d9a..6694cbbb3 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -23,6 +23,7 @@ #include "ILexer.h" #include "Scintilla.h" +#include "StringCopy.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -250,7 +251,7 @@ void Editor::SetRepresentations() { "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; - for (size_t j=0; j < (sizeof(reps) / sizeof(reps[0])); j++) { + for (size_t j=0; j < ELEMENTS(reps); j++) { char c[2] = { static_cast<char>(j), 0 }; reprs.SetRepresentation(c, reps[j]); } @@ -264,7 +265,7 @@ void Editor::SetRepresentations() { "DCS", "PU1", "PU2", "STS", "CCH", "MW", "SPA", "EPA", "SOS", "SGCI", "SCI", "CSI", "ST", "OSC", "PM", "APC" }; - for (size_t j=0; j < (sizeof(repsC1) / sizeof(repsC1[0])); j++) { + for (size_t j=0; j < ELEMENTS(repsC1); j++) { char c1[3] = { '\xc2', static_cast<char>(0x80+j), 0 }; reprs.SetRepresentation(c1, repsC1[j]); } @@ -426,7 +427,7 @@ const char *ControlCharacterString(unsigned char ch) { "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; - if (ch < (sizeof(reps) / sizeof(reps[0]))) { + if (ch < ELEMENTS(reps)) { return reps[ch]; } else { return "BAD"; |