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 | |
| 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')
| -rw-r--r-- | src/CallTip.cxx | 8 | ||||
| -rw-r--r-- | src/CaseConvert.cxx | 4 | ||||
| -rw-r--r-- | src/Editor.cxx | 7 | ||||
| -rw-r--r-- | src/LineMarker.cxx | 20 | 
4 files changed, 18 insertions, 21 deletions
| diff --git a/src/CallTip.cxx b/src/CallTip.cxx index c12a6e8eb..7dc23a4ac 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -14,6 +14,8 @@  #include "Platform.h"  #include "Scintilla.h" + +#include "StringCopy.h"  #include "CallTip.h"  #ifdef SCI_NAMESPACE @@ -125,16 +127,14 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,      						Point(centreX + halfWidth, centreY + halfWidth / 2),      						Point(centreX, centreY - halfWidth + halfWidth / 2),  						}; -						surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -                 						colourBG, colourBG); +						surface->Polygon(pts, ELEMENTS(pts), colourBG, colourBG);  					} else {            // Down arrow  						Point pts[] = {      						Point(centreX - halfWidth, centreY - halfWidth / 2),      						Point(centreX + halfWidth, centreY - halfWidth / 2),      						Point(centreX, centreY + halfWidth - halfWidth / 2),  						}; -						surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -                 						colourBG, colourBG); +						surface->Polygon(pts, ELEMENTS(pts), colourBG, colourBG);  					}  				}  				xEnd = rcClient.right; diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx index badaca411..e8f533d5c 100644 --- a/src/CaseConvert.cxx +++ b/src/CaseConvert.cxx @@ -509,7 +509,7 @@ void AddSymmetric(enum CaseConversion conversion, int lower,int upper) {  void SetupConversions(enum CaseConversion conversion) {  	// First initialize for the symmetric ranges -	for (size_t i=0; i<sizeof(symmetricCaseConversionRanges)/sizeof(symmetricCaseConversionRanges[0]);) { +	for (size_t i=0; i<ELEMENTS(symmetricCaseConversionRanges);) {  		int lower = symmetricCaseConversionRanges[i++];  		int upper = symmetricCaseConversionRanges[i++];  		int length = symmetricCaseConversionRanges[i++]; @@ -519,7 +519,7 @@ void SetupConversions(enum CaseConversion conversion) {  		}  	}  	// Add the symmetric singletons -	for (size_t i=0; i<sizeof(symmetricCaseConversions)/sizeof(symmetricCaseConversions[0]);) { +	for (size_t i=0; i<ELEMENTS(symmetricCaseConversions);) {  		int lower = symmetricCaseConversions[i++];  		int upper = symmetricCaseConversions[i++];  		AddSymmetric(conversion, lower, upper); 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"; diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index cf44928b4..708e6a320 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -14,6 +14,8 @@  #include "Platform.h"  #include "Scintilla.h" + +#include "StringCopy.h"  #include "XPM.h"  #include "LineMarker.h" @@ -141,8 +143,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac      		Point(centreX - dimOn4, centreY + dimOn2),      		Point(centreX + dimOn2 - dimOn4, centreY),  		}; -		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -                 		fore, back); +		surface->Polygon(pts, ELEMENTS(pts), fore, back);  	} else if (markType == SC_MARK_ARROWDOWN) {  		Point pts[] = { @@ -150,8 +151,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac      		Point(centreX + dimOn2, centreY - dimOn4),      		Point(centreX, centreY + dimOn2 - dimOn4),  		}; -		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -                 		fore, back); +		surface->Polygon(pts, ELEMENTS(pts), fore, back);  	} else if (markType == SC_MARK_PLUS) {  		Point pts[] = { @@ -168,8 +168,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac      		Point(centreX - 1, centreY + 1),      		Point(centreX - armSize, centreY + 1),  		}; -		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -                 		fore, back); +		surface->Polygon(pts, ELEMENTS(pts), fore, back);  	} else if (markType == SC_MARK_MINUS) {  		Point pts[] = { @@ -178,8 +177,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac      		Point(centreX + armSize, centreY +1),      		Point(centreX - armSize, centreY + 1),  		}; -		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -                 		fore, back); +		surface->Polygon(pts, ELEMENTS(pts), fore, back);  	} else if (markType == SC_MARK_SMALLRECT) {  		PRectangle rcSmall; @@ -374,8 +372,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac  			Point(centreX, centreY + dimOn4),  			Point(centreX, centreY + dimOn2),  		}; -		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -				fore, back); +		surface->Polygon(pts, ELEMENTS(pts), fore, back);  	} else if (markType == SC_MARK_LEFTRECT) {  		PRectangle rcLeft = rcWhole;  		rcLeft.right = rcLeft.left + 4; @@ -389,8 +386,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac  			Point(rc.right-3, centreY+halfHeight),  			Point(rc.left, centreY+halfHeight),  		}; -		surface->Polygon(pts, sizeof(pts) / sizeof(pts[0]), -				fore, back); +		surface->Polygon(pts, ELEMENTS(pts), fore, back);  	} else { // SC_MARK_FULLRECT  		surface->FillRectangle(rcWhole, back);  	} | 
