changeset 4340:c202df909032

sqcintilla: add patch for proper matlab block comment detection (Bug #50060) * src/qscintilla-3-matlab-block-comment.patch: new patc file * dist-files.mk: added qscintilla-3-matlab-block-comment.patch
author John D
date Thu, 19 Jan 2017 07:57:27 -0500
parents 07671a76e291
children 6e4a1de60e8b
files dist-files.mk src/qscintilla-3-matlab-block-comment.patch
diffstat 2 files changed, 67 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dist-files.mk	Thu Jan 19 07:43:05 2017 -0500
+++ b/dist-files.mk	Thu Jan 19 07:57:27 2017 -0500
@@ -568,6 +568,7 @@
   qrupdate-1-fixes.patch \
   qrupdate.mk \
   qscintilla-1-fixes.patch \
+  qscintilla-3-matlab-block-comment.patch \
   qscintilla.mk \
   qt-1-cherrypicks.patch \
   qt-2-shared-tools-fixes.patch \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qscintilla-3-matlab-block-comment.patch	Thu Jan 19 07:57:27 2017 -0500
@@ -0,0 +1,66 @@
+diff -ur QScintilla_gpl-2.9.3.orig/lexers/LexMatlab.cpp QScintilla_gpl-2.9.3/lexers/LexMatlab.cpp
+--- QScintilla_gpl-2.9.3.orig/lexers/LexMatlab.cpp	2017-01-18 08:06:39.577378613 -0500
++++ QScintilla_gpl-2.9.3/lexers/LexMatlab.cpp	2017-01-18 08:21:30.775353161 -0500
+@@ -71,6 +71,16 @@
+ 		return -1;
+ 	return 0;
+ }
++
++static bool IsSpaceToEOL(unsigned int startPos, Accessor &styler) {
++        int line = styler.GetLine(startPos);
++	unsigned int eol_pos = styler.LineStart(line + 1) - 1;
++	for (unsigned int i = startPos; i < eol_pos; i++) {
++		char ch = styler[i];
++		if(!IsASpace(ch)) return false;
++	}
++	return true;
++}
+  
+ static void ColouriseMatlabOctaveDoc(
+             unsigned int startPos, int length, int initStyle,
+@@ -178,7 +188,7 @@
+ 			}
+ 		} else if (sc.state == SCE_MATLAB_COMMENT) {
+ 			// end or start of a nested a block comment?
+-			if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column) {
++			if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) {
+                            	if(commentDepth > 0) commentDepth --;
+  
+ 				curLine = styler.GetLine(sc.currentPos);
+@@ -190,7 +200,7 @@
+ 					transpose = false;
+ 				}
+                         }
+-                        else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column)
++                        else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler))
+                         {
+  				commentDepth ++;
+ 
+@@ -211,9 +221,12 @@
+ 		// check start of a new state
+ 		if (sc.state == SCE_MATLAB_DEFAULT) {
+ 			if (IsCommentChar(sc.ch)) {
+-				// ncrement depth if we are a block comment
+-				if(sc.chNext == '{' && nonSpaceColumn == column)
+-					commentDepth ++;
++				// Increment depth if we are a block comment
++				if(sc.chNext == '{' && nonSpaceColumn == column) {
++					if(IsSpaceToEOL(sc.currentPos+2, styler)) {
++						commentDepth ++;
++					}
++				}
+ 				curLine = styler.GetLine(sc.currentPos);
+ 				styler.SetLineState(curLine, commentDepth);
+ 				sc.SetState(SCE_MATLAB_COMMENT);
+@@ -287,9 +300,9 @@
+ 		// a line that starts with a comment
+ 		if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) {
+ 			// start/end of block comment 
+-			if (chNext == '{')
++			if (chNext == '{' && IsSpaceToEOL(i+2, styler))
+ 				levelNext ++;
+-			if (chNext == '}')
++			if (chNext == '}' && IsSpaceToEOL(i+2, styler))
+ 				levelNext --;
+ 		}
+ 		// keyword