Thanks for the response. I confirmed that this would cause a bug in Matlab strings as well. This seems to be an issue with the way the backslash character is handled in
LexMatlab.cxx. BTW, the comments and functions in
LexMatlab.cxx indicate that it is intended to handle both Matlab and Octave source files.
I notice that the C/C++ mode (LexCPP.cxx) in SciTE handles strings like this correctly. Its code handles the backslash character in a different way than the Matlab ( LexMatlab.cxx) mode. That is, it looks ahead to the next character and keeps the current state depending on what the next character is. The LexMatlab.cxx code looks to the previous character, which causes a problem in the case I've run into.
I propose replacing the section of code in LexMatlab.cxx that handles the SCE_MATLAB_STRING and SCE_MATLAB_DOUBLEQUOTESTRING states with the following:
} else if (sc.state == SCE_MATLAB_STRING) {
This is the code in question, which should be replaced by the above:
} else if (sc.state == SCE_MATLAB_STRING) {
Regards,
Bob
I notice that the C/C++ mode (LexCPP.cxx) in SciTE handles strings like this correctly. Its code handles the backslash character in a different way than the Matlab ( LexMatlab.cxx) mode. That is, it looks ahead to the next character and keeps the current state depending on what the next character is. The LexMatlab.cxx code looks to the previous character, which causes a problem in the case I've run into.
I propose replacing the section of code in LexMatlab.cxx that handles the SCE_MATLAB_STRING and SCE_MATLAB_DOUBLEQUOTESTRING states with the following:
} else if (sc.state == SCE_MATLAB_STRING) {
if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\'') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}
} else if (sc.state
== SCE_MATLAB_DOUBLEQUOTESTRING) {if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}} else if (sc.ch == '\"') {
}sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}This is the code in question, which should be replaced by the above:
} else if (sc.state == SCE_MATLAB_STRING) {
if (sc.ch == '\'' && sc.chPrev != '\\') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}
} else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) {if (sc.ch == '"' && sc.chPrev != '\\') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}
}Regards,
Bob
Its unlikely there are many (or any?) other Matlab/Octave users on
the SciTE mailing list. Changing the handling of strings requires some
C++ coding in the file scintilla/src/LexMatlab.cxx file. The first
step would be to check whether this change works for both Matlab and
Octave, perhaps by asking in a language-specific forum. You may also
be able to find a developer with C/C++ skills to make the change.
Neil
_______________________________________________ Scite-interest mailing list [email protected] http://mailman.lyra.org/mailman/listinfo/scite-interest
