aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lexers/LexHTML.cxx22
-rw-r--r--test/examples/x.html1
-rw-r--r--test/examples/x.html.styled1
3 files changed, 13 insertions, 11 deletions
diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx
index 546f5ad96..8e6b37434 100644
--- a/lexers/LexHTML.cxx
+++ b/lexers/LexHTML.cxx
@@ -318,19 +318,19 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
static void classifyWordHTJS(unsigned int start, unsigned int end,
WordList &keywords, Accessor &styler, script_mode inScriptType) {
+ char s[30 + 1];
+ unsigned int i = 0;
+ for (; i < end - start + 1 && i < 30; i++) {
+ s[i] = styler[start + i];
+ }
+ s[i] = '\0';
+
char chAttr = SCE_HJ_WORD;
- bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.');
- if (wordIsNumber)
+ bool wordIsNumber = IsADigit(s[0]) || ((s[0] == '.') && IsADigit(s[1]));
+ if (wordIsNumber) {
chAttr = SCE_HJ_NUMBER;
- else {
- char s[30 + 1];
- unsigned int i = 0;
- for (; i < end - start + 1 && i < 30; i++) {
- s[i] = styler[start + i];
- }
- s[i] = '\0';
- if (keywords.InList(s))
- chAttr = SCE_HJ_KEYWORD;
+ } else if (keywords.InList(s)) {
+ chAttr = SCE_HJ_KEYWORD;
}
styler.ColourTo(end, statePrintForState(chAttr, inScriptType));
}
diff --git a/test/examples/x.html b/test/examples/x.html
index 7fa1a9f0e..caebcf41a 100644
--- a/test/examples/x.html
+++ b/test/examples/x.html
@@ -1,5 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">
+var b = /abc/i.test('abc');
'x\
</t>'
</script>
diff --git a/test/examples/x.html.styled b/test/examples/x.html.styled
index 5a6aebe5e..3e50a1147 100644
--- a/test/examples/x.html.styled
+++ b/test/examples/x.html.styled
@@ -1,5 +1,6 @@
{1}<html{8} {3}xmlns{8}={6}"http://www.w3.org/1999/xhtml"{1}>{0}
{1}<script{8} {3}type{8}={6}"text/javascript"{1}>{40}
+{46}var{41} {46}b{41} {50}={41} {52}/abc/i{46}.test{50}({49}'abc'{50});{41}
{49}'x\
</t>'{41}
{1}</script>{0}