OSDN Git Service

CrystalEdit: Prevent comment blocks (<!-- -->) inside <style>...</style> and <script...
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 7 Nov 2020 14:48:11 +0000 (23:48 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sat, 7 Nov 2020 14:48:11 +0000 (23:48 +0900)
Externals/crystaledit/editlib/parsers/asp.cpp
Externals/crystaledit/editlib/parsers/crystallineparser.h
Externals/crystaledit/editlib/parsers/html.cpp
Externals/crystaledit/editlib/parsers/php.cpp

index cf3c5d8..fb3788e 100644 (file)
 
 #include "StdAfx.h"
 #include "crystallineparser.h"
-#include "../SyntaxColors.h"
-#include "../utils/string_util.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-static const TCHAR * s_apszAspKeywordList[] =
-  {
-    _T ("Abs"),
-    _T ("AppActivate"),
-    _T ("As"),
-    _T ("Asc"),
-    _T ("Atn"),
-    _T ("Base"),
-    _T ("Beep"),
-    _T ("CDbl"),
-    _T ("CInt"),
-    _T ("CLng"),
-    _T ("CSng"),
-    _T ("CStr"),
-    _T ("CVar"),
-    _T ("Call"),
-    _T ("ChDir"),
-    _T ("ChDrive"),
-    _T ("CheckBox"),
-    _T ("Chr"),
-    _T ("Close"),
-    _T ("Const"),
-    _T ("Cos"),
-    _T ("CreateObject"),
-    _T ("CreateVerifyItem"),
-    _T ("CurDir"),
-    _T ("Date"),
-    _T ("Declare"),
-    _T ("Dialog"),
-    _T ("Dim"),
-    _T ("Dir"),
-    _T ("DlgEnable"),
-    _T ("DlgText"),
-    _T ("DlgVisible"),
-    _T ("Do"),
-    _T ("Double"),
-    _T ("EOF"),
-    _T ("Else"),
-    _T ("Else"),
-    _T ("End"),
-    _T ("End"),
-    _T ("Erase"),
-    _T ("Error"),
-    _T ("Exit"),
-    _T ("Exp"),
-    _T ("FileCopy"),
-    _T ("FileLen"),
-    _T ("Fix"),
-    _T ("For"),
-    _T ("For"),
-    _T ("Format"),
-    _T ("Function"),
-    _T ("Function"),
-    _T ("GetAttrName"),
-    _T ("GetAttrType"),
-    _T ("GetAttrValBool"),
-    _T ("GetAttrValEnumInt"),
-    _T ("GetAttrValEnumString"),
-    _T ("GetAttrValFloat"),
-    _T ("GetAttrValInt"),
-    _T ("GetAttrValString"),
-    _T ("GetClassId"),
-    _T ("GetGeoType"),
-    _T ("GetObject"),
-    _T ("Global"),
-    _T ("GoSub"),
-    _T ("GoTo"),
-    _T ("Hex"),
-    _T ("Hour"),
-    _T ("If"),
-    _T ("If"),
-    _T ("InStr"),
-    _T ("Input"),
-    _T ("Input#"),
-    _T ("InputBox"),
-    _T ("Int"),
-    _T ("IsDate"),
-    _T ("IsEmpty"),
-    _T ("IsNull"),
-    _T ("IsNumeric"),
-    _T ("Kill"),
-    _T ("LBound"),
-    _T ("LCase"),
-    _T ("LCase$"),
-    _T ("LTrim"),
-    _T ("Left"),
-    _T ("Left$"),
-    _T ("Len"),
-    _T ("Let"),
-    _T ("Line"),
-    _T ("Log"),
-    _T ("Long"),
-    _T ("Loop"),
-    _T ("Mid"),
-    _T ("Minute"),
-    _T ("MkDir"),
-    _T ("Month"),
-    _T ("MsgBox"),
-    _T ("Name"),
-    _T ("Next"),
-    _T ("Next"),
-    _T ("Now"),
-    _T ("Oct"),
-    _T ("On"),
-    _T ("Open"),
-    _T ("Option"),
-    _T ("Print"),
-    _T ("Print"),
-    _T ("RTrim"),
-    _T ("Rem"),
-    _T ("Return"),
-    _T ("Right"),
-    _T ("RmDir"),
-    _T ("Rnd"),
-    _T ("SMDoMenu"),
-    _T ("Second"),
-    _T ("Seek"),
-    _T ("Seek"),
-    _T ("Select Case"),
-    _T ("SendKeys"),
-    _T ("Set"),
-    _T ("SetAttrValBool"),
-    _T ("SetAttrValEnumInt"),
-    _T ("SetAttrValEnumString"),
-    _T ("SetAttrValFloat"),
-    _T ("SetAttrValInt"),
-    _T ("SetAttrValString"),
-    _T ("Shell"),
-    _T ("Sin"),
-    _T ("Space"),
-    _T ("Sqr"),
-    _T ("Static"),
-    _T ("Step"),
-    _T ("Stop"),
-    _T ("Str"),
-    _T ("StrComp"),
-    _T ("String"),
-    _T ("StringFunction"),
-    _T ("Sub"),
-    _T ("Tan"),
-    _T ("Text"),
-    _T ("TextBox"),
-    _T ("Then"),
-    _T ("Time"),
-    _T ("TimeSerial"),
-    _T ("TimeValue"),
-    _T ("To"),
-    _T ("Trim"),
-    _T ("Type"),
-    _T ("UBound"),
-    _T ("UCase"),
-    _T ("Val"),
-    _T ("VarType"),
-    _T ("VerifyCardinalities"),
-    _T ("Wend"),
-    _T ("Wend"),
-    _T ("While"),
-    _T ("While"),
-    _T ("With"),
-    _T ("Write"),
-    _T ("Year"),
-  };
-
-static bool
-IsAspKeyword (const TCHAR *pszChars, int nLength)
-{
-  return ISXKEYWORDI (s_apszAspKeywordList, pszChars, nLength);
-}
 
 unsigned
 CrystalLineParser::ParseLineAsp (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
 {
-  if (nLength == 0)
-    return dwCookie & (COOKIE_EXT_COMMENT|COOKIE_EXT_USER1);
-
-  bool bFirstChar = (dwCookie & ~(COOKIE_EXT_COMMENT|COOKIE_EXT_USER1)) == 0;
-  bool bRedefineBlock = true;
-  bool bDecIndex = false;
-  int nIdentBegin = -1;
-  int nPrevI = -1;
-  int I=0;
-  for (I = 0;; nPrevI = I, I = static_cast<int>(::CharNext(pszChars+I) - pszChars))
-    {
-      if (I == nPrevI)
-        {
-          // CharNext did not advance, so we're at the end of the string
-          // and we already handled this character, so stop
-          break;
-        }
-
-      if (bRedefineBlock)
-        {
-          int nPos = I;
-          if (bDecIndex)
-            nPos = nPrevI;
-          if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
-            {
-              DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
-            }
-          else if (dwCookie & (COOKIE_CHAR | COOKIE_STRING))
-            {
-              DEFINE_BLOCK (nPos, COLORINDEX_STRING);
-            }
-          else if (dwCookie & COOKIE_PREPROCESSOR)
-            {
-              DEFINE_BLOCK (nPos, COLORINDEX_PREPROCESSOR);
-            }
-          else if (dwCookie & COOKIE_EXT_USER1)
-            {
-              DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
-            }
-          else
-            {
-              if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.')
-                {
-                  DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
-                }
-              else
-                {
-                  DEFINE_BLOCK (nPos, COLORINDEX_OPERATOR);
-                  bRedefineBlock = true;
-                  bDecIndex = true;
-                  goto out;
-                }
-            }
-          bRedefineBlock = false;
-          bDecIndex = false;
-        }
-out:
-
-      // Can be bigger than length if there is binary data
-      // See bug #1474782 Crash when comparing SQL with with binary data
-      if (I >= nLength || pszChars[I] == 0)
-        break;
-
-      if (dwCookie & COOKIE_COMMENT)
-        {
-          DEFINE_BLOCK (I, COLORINDEX_COMMENT);
-          dwCookie |= COOKIE_COMMENT;
-          break;
-        }
-
-      //  String constant "...."
-      if (dwCookie & COOKIE_STRING)
-        {
-          if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
-            {
-              dwCookie &= ~COOKIE_STRING;
-              bRedefineBlock = true;
-            }
-          continue;
-        }
-
-      //  Char constant '..'
-      if (dwCookie & COOKIE_CHAR)
-        {
-          if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
-            {
-              dwCookie &= ~COOKIE_CHAR;
-              bRedefineBlock = true;
-            }
-          continue;
-        }
-
-      //  Extended comment <!--....-->
-      if (dwCookie & COOKIE_EXT_COMMENT)
-        {
-          if (!(dwCookie & COOKIE_EXT_USER1))
-            {
-              if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
-                {
-                  dwCookie &= ~COOKIE_EXT_COMMENT;
-                  bRedefineBlock = true;
-                }
-            }
-          continue;
-        }
-
-      if ((dwCookie & COOKIE_EXT_USER1) && pszChars[I] == '\'')
-        {
-          DEFINE_BLOCK (I, COLORINDEX_COMMENT);
-          dwCookie |= COOKIE_COMMENT;
-          break;
-        }
-
-      //  Extended comment <?....?>
-      if (dwCookie & COOKIE_EXT_USER1)
-        {
-          if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-            {
-              dwCookie &= ~COOKIE_EXT_USER1;
-              bRedefineBlock = true;
-              continue;
-            }
-        }
-
-      //  Normal text
-      if ((dwCookie & (COOKIE_PREPROCESSOR|COOKIE_EXT_USER1)) && pszChars[I] == '"')
-        {
-          DEFINE_BLOCK (I, COLORINDEX_STRING);
-          dwCookie |= COOKIE_STRING;
-          continue;
-        }
-
-      if ((dwCookie & (COOKIE_PREPROCESSOR|COOKIE_EXT_USER1)) && pszChars[I] == '\'')
-        {
-          // if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
-          if (!I || !xisalnum (pszChars[nPrevI]))
-            {
-              DEFINE_BLOCK (I, COLORINDEX_STRING);
-              dwCookie |= COOKIE_CHAR;
-              continue;
-            }
-        }
-
-      if (!(dwCookie & COOKIE_EXT_USER1))
-        {
-          if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength - 3 && pszChars[I] == '<' && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-')
-            {
-              DEFINE_BLOCK (I, COLORINDEX_COMMENT);
-              I += 3;
-              dwCookie |= COOKIE_EXT_COMMENT;
-              dwCookie &= ~COOKIE_PREPROCESSOR;
-              continue;
-            }
-        }
-
-      if (bFirstChar)
-        {
-          if (!xisspace (pszChars[I]))
-            bFirstChar = false;
-        }
-
-      //  User1 start: <?
-      if (I < nLength && pszChars[I] == '<' && I < nLength - 1 && (pszChars[I + 1] == '?' || pszChars[I + 1] == '%'))
-        {
-          DEFINE_BLOCK (I, COLORINDEX_NORMALTEXT);
-          dwCookie |= COOKIE_EXT_USER1;
-          nIdentBegin = -1;
-          continue;
-        }
-
-      if (pBuf == nullptr)
-        continue;               //  We don't need to extract keywords,
-      //  for faster parsing skip the rest of loop
-
-      if (xisalnum (pszChars[I]) || pszChars[I] == '.')
-        {
-          if (nIdentBegin == -1)
-            nIdentBegin = I;
-        }
-      else
-        {
-          if (nIdentBegin >= 0)
-            {
-              if (dwCookie & COOKIE_PREPROCESSOR)
-                {
-                  if (IsHtmlKeyword (pszChars + nIdentBegin, I - nIdentBegin) && (pszChars[nIdentBegin - 1] == _T ('<') || pszChars[nIdentBegin - 1] == _T ('/')))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
-                    }
-                  else if (IsHtmlUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1);
-                    }
-                  else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
-                    }
-                  else
-                    {
-                      goto next;
-                    }
-                }
-              else if (dwCookie & COOKIE_EXT_USER1)
-                {
-                  if (IsAspKeyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
-                    }
-                  else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
-                    }
-                  else
-                    {
-                      bool bFunction = false;
-
-                      for (int j = I; j < nLength; j++)
-                        {
-                          if (!xisspace (pszChars[j]))
-                            {
-                              if (pszChars[j] == '(')
-                                {
-                                  bFunction = true;
-                                }
-                              break;
-                            }
-                        }
-                      if (bFunction)
-                        {
-                          DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME);
-                        }
-                      else
-                        {
-                          goto next;
-                        }
-                    }
-                }
-              else if (dwCookie & COOKIE_USER1)
-                {
-                  if (IsHtmlUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2);
-                    }
-                  else
-                    {
-                      goto next;
-                    }
-                }
-              bRedefineBlock = true;
-              bDecIndex = true;
-              nIdentBegin = -1;
-next:
-              ;
-            }
-
-          //  Preprocessor start: < or bracket
-          if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength && pszChars[I] == '<' && !(I < nLength - 3 && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-'))
-            {
-              DEFINE_BLOCK (I, COLORINDEX_OPERATOR);
-              DEFINE_BLOCK (I + 1, COLORINDEX_PREPROCESSOR);
-              dwCookie |= COOKIE_PREPROCESSOR;
-              nIdentBegin = -1;
-              continue;
-            }
-
-          //  User1 end: ?>
-          if (dwCookie & COOKIE_EXT_USER1)
-            {
-              if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-                {
-                  dwCookie &= ~COOKIE_EXT_USER1;
-                  nIdentBegin = -1;
-                  bRedefineBlock = true;
-                  bDecIndex = true;
-                  continue;
-                }
-            }
-
-          //  Preprocessor end: > or bracket
-          if (dwCookie & COOKIE_PREPROCESSOR)
-            {
-              if (pszChars[I] == '>')
-                {
-                  dwCookie &= ~COOKIE_PREPROCESSOR;
-                  nIdentBegin = -1;
-                  bRedefineBlock = true;
-                  bDecIndex = true;
-                  continue;
-                }
-            }
-
-          //  Preprocessor start: &
-          if (!(dwCookie & COOKIE_EXT_USER1) && pszChars[I] == '&')
-            {
-              dwCookie |= COOKIE_USER1;
-              nIdentBegin = -1;
-              continue;
-            }
-
-          //  Preprocessor end: ;
-          if (dwCookie & COOKIE_USER1)
-            {
-              if (pszChars[I] == ';')
-                {
-                  dwCookie &= ~COOKIE_USER1;
-                  nIdentBegin = -1;
-                  continue;
-                }
-            }
-
-        }
-    }
-
-  if (nIdentBegin >= 0 && (dwCookie & COOKIE_PREPROCESSOR))
-    {
-      if (IsHtmlKeyword (pszChars + nIdentBegin, I - nIdentBegin) && (pszChars[nIdentBegin - 1] == _T ('<') || pszChars[nIdentBegin - 1] == _T ('/')))
-        {
-          DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
-        }
-      else if (IsHtmlUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-        {
-          DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1);
-        }
-      else if (IsHtmlUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-        {
-          DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2);
-        }
-      else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
-        {
-          DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
-        }
-      else
-        {
-          bool bFunction = false;
-
-          for (int j = I; j < nLength; j++)
-            {
-              if (!xisspace (pszChars[j]))
-                {
-                  if (pszChars[j] == '(')
-                    {
-                      bFunction = true;
-                    }
-                  break;
-                }
-            }
-          if (bFunction)
-            {
-              DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME);
-            }
-        }
-    }
-  else if (nIdentBegin >= 0 && (dwCookie & COOKIE_EXT_USER1))
-    {
-      if (IsAspKeyword (pszChars + nIdentBegin, I - nIdentBegin))
-        {
-          DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
-        }
-      else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
-        {
-          DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
-        }
-      else
-        {
-          bool bFunction = false;
-
-          for (int j = I; j < nLength; j++)
-            {
-              if (!xisspace (pszChars[j]))
-                {
-                  if (pszChars[j] == '(')
-                    {
-                      bFunction = true;
-                    }
-                  break;
-                }
-            }
-          if (bFunction)
-            {
-              DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME);
-            }
-        }
-    }
-
-  dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_PREPROCESSOR | COOKIE_EXT_USER1);
-  return dwCookie;
+  return ParseLineHtmlEx(dwCookie, pszChars, nLength, pBuf, nActualItems, SRC_BASIC);
 }
index c3a4622..4c78600 100644 (file)
@@ -17,11 +17,14 @@ if (pBuf != nullptr)\
 \r
 #define COOKIE_COMMENT          0x0001\r
 #define COOKIE_PREPROCESSOR     0x0002\r
+#define COOKIE_ELEMENT          0x0002\r
 #define COOKIE_EXT_COMMENT      0x0004\r
 #define COOKIE_STRING           0x0008\r
 #define COOKIE_CHAR             0x0010\r
 #define COOKIE_USER1            0x0020\r
 #define COOKIE_EXT_USER1        0x0040\r
+#define COOKIE_BLOCK_STYLE      0x0080\r
+#define COOKIE_BLOCK_SCRIPT     0x0100\r
 #define COOKIE_SECTION          0x0080\r
 #define COOKIE_KEY              0x0100\r
 #define COOKIE_EXT_COMMENT2     0x0200\r
@@ -142,6 +145,7 @@ unsigned ParseLineDcl(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEX
 unsigned ParseLineFortran(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLineGo(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLineHtml(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
+unsigned ParseLineHtmlEx(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems, int nEmbeddedLanguage);\r
 unsigned ParseLineIni(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLineInnoSetup(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLineIS(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
@@ -152,6 +156,7 @@ unsigned ParseLineNsis(unsigned dwCookie, const TCHAR *pszChars, int nLength, TE
 unsigned ParseLinePascal(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLinePerl(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLinePhp(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
+unsigned ParseLinePhpLanguage(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLinePo(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLinePowerShell(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
 unsigned ParseLinePython(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
index 86d2bff..027b6bb 100644 (file)
 #endif
 
 unsigned
-CrystalLineParser::ParseLineHtml (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
+CrystalLineParser::ParseLineHtmlEx (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems, int nEmbeddedLanguage)
 {
   if (nLength == 0)
-    return dwCookie & (COOKIE_EXT_COMMENT|COOKIE_EXT_USER1);
+    return dwCookie & (COOKIE_EXT_COMMENT|COOKIE_EXT_USER1|COOKIE_ELEMENT|COOKIE_BLOCK_SCRIPT|COOKIE_BLOCK_STYLE);
 
-  bool bFirstChar = (dwCookie & ~(COOKIE_EXT_COMMENT|COOKIE_EXT_USER1)) == 0;
   bool bRedefineBlock = true;
+  if (!(dwCookie & COOKIE_ELEMENT))
+    bRedefineBlock = !(dwCookie & (COOKIE_EXT_USER1|COOKIE_BLOCK_SCRIPT|COOKIE_BLOCK_STYLE));
   bool bDecIndex = false;
   int nIdentBegin = -1;
   int nPrevI = -1;
@@ -49,7 +50,7 @@ CrystalLineParser::ParseLineHtml (unsigned dwCookie, const TCHAR *pszChars, int
           int nPos = I;
           if (bDecIndex)
             nPos = nPrevI;
-          if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
+          if (dwCookie & COOKIE_EXT_COMMENT)
             {
               DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
             }
@@ -57,14 +58,10 @@ CrystalLineParser::ParseLineHtml (unsigned dwCookie, const TCHAR *pszChars, int
             {
               DEFINE_BLOCK (nPos, COLORINDEX_STRING);
             }
-          else if (dwCookie & COOKIE_PREPROCESSOR)
+          else if (dwCookie & COOKIE_ELEMENT)
             {
               DEFINE_BLOCK (nPos, COLORINDEX_PREPROCESSOR);
             }
-          else if (dwCookie & COOKIE_EXT_USER1)
-            {
-              DEFINE_BLOCK (nPos, COLORINDEX_FUNCNAME);
-            }
           else
             {
               if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.')
@@ -89,11 +86,61 @@ out:
       if (I >= nLength || pszChars[I] == 0)
         break;
 
-      if (dwCookie & COOKIE_COMMENT)
+      if (!(dwCookie & COOKIE_ELEMENT) && (dwCookie & (COOKIE_EXT_USER1|COOKIE_BLOCK_SCRIPT|COOKIE_BLOCK_STYLE)))
         {
-          DEFINE_BLOCK (I, COLORINDEX_COMMENT);
-          dwCookie |= COOKIE_COMMENT;
-          break;
+          if (dwCookie & COOKIE_BLOCK_SCRIPT)
+            {
+              const TCHAR *pszEnd = _tcsstr(pszChars + I, _T("</script>"));
+              int nextI = pszEnd ? (pszEnd - pszChars) : nLength;
+              dwCookie = ParseLineJava(dwCookie & ~COOKIE_BLOCK_SCRIPT, pszChars + I, nextI - I, pBuf, nActualItems);
+              if (!pszEnd)
+                dwCookie |= COOKIE_BLOCK_SCRIPT;
+              else
+                {
+                  dwCookie = 0;
+                  bRedefineBlock = true;
+                }
+              I = nextI - 1;
+            }
+          else if (dwCookie & COOKIE_BLOCK_STYLE)
+            {
+              const TCHAR *pszEnd = _tcsstr(pszChars + I, _T("</style>"));
+              int nextI = pszEnd ? (pszEnd - pszChars) : nLength;
+              dwCookie = ParseLineCss(dwCookie & ~COOKIE_BLOCK_STYLE, pszChars + I, nextI - I, pBuf, nActualItems);
+              if (!pszEnd)
+                dwCookie |= COOKIE_BLOCK_STYLE;
+              else
+                {
+                  dwCookie = 0;
+                  bRedefineBlock = true;
+                }
+              I = nextI - 1;
+            }
+          else if ((dwCookie & COOKIE_EXT_USER1))
+            {
+              const TCHAR *pszEnd = _tcsstr(pszChars + I, _T("?>"));
+              if (!pszEnd)
+                pszEnd = _tcsstr(pszChars + I, _T("%>"));
+              int nextI = pszEnd ? (pszEnd - pszChars) : nLength;
+              
+              unsigned (*pParseLineFunc)(unsigned, const TCHAR *, int, TEXTBLOCK *, int &);
+              switch (nEmbeddedLanguage)
+              {
+              case SRC_BASIC: pParseLineFunc = ParseLineBasic; break;
+              case SRC_PHP: pParseLineFunc = ParseLinePhpLanguage; break;
+              default: pParseLineFunc = ParseLineJava; break;
+              }
+              dwCookie = pParseLineFunc(dwCookie & ~COOKIE_EXT_USER1, pszChars + I, nextI - I, pBuf, nActualItems);
+              if (!pszEnd)
+                dwCookie |= COOKIE_EXT_USER1;
+              else
+                {
+                  dwCookie = 0;
+                  bRedefineBlock = true;
+                }
+              I = nextI - 1;
+            }
+          continue;
         }
 
       //  String constant "...."
@@ -129,26 +176,15 @@ out:
           continue;
         }
 
-      //  Extended comment <?....?>
-      if (dwCookie & COOKIE_EXT_USER1)
-        {
-          if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-            {
-              dwCookie &= ~COOKIE_EXT_USER1;
-              bRedefineBlock = true;
-            }
-          continue;
-        }
-
       //  Normal text
-      if ((dwCookie & COOKIE_PREPROCESSOR) && pszChars[I] == '"')
+      if ((dwCookie & COOKIE_ELEMENT) && pszChars[I] == '"')
         {
           DEFINE_BLOCK (I, COLORINDEX_STRING);
           dwCookie |= COOKIE_STRING;
           continue;
         }
 
-      if ((dwCookie & COOKIE_PREPROCESSOR) && pszChars[I] == '\'')
+      if ((dwCookie & COOKIE_ELEMENT) && pszChars[I] == '\'')
         {
           // if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
           if (!I || !xisalnum (pszChars[nPrevI]))
@@ -159,19 +195,22 @@ out:
             }
         }
 
-      if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength - 3 && pszChars[I] == '<' && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-')
+      if (I < nLength - 3 && pszChars[I] == '<' && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-')
         {
           DEFINE_BLOCK (I, COLORINDEX_COMMENT);
           I += 3;
           dwCookie |= COOKIE_EXT_COMMENT;
-          dwCookie &= ~COOKIE_PREPROCESSOR;
+          dwCookie &= ~COOKIE_ELEMENT;
           continue;
         }
 
-      if (bFirstChar)
+      //  User1 start: <?
+      if (I < nLength && pszChars[I] == '<' && I < nLength - 1 && (pszChars[I + 1] == '?' || pszChars[I + 1] == '%'))
         {
-          if (!xisspace (pszChars[I]))
-            bFirstChar = false;
+          DEFINE_BLOCK (I, COLORINDEX_NORMALTEXT);
+          dwCookie |= COOKIE_EXT_USER1;
+          nIdentBegin = -1;
+          continue;
         }
 
       if (pBuf == nullptr)
@@ -187,11 +226,15 @@ out:
         {
           if (nIdentBegin >= 0)
             {
-              if (dwCookie & COOKIE_PREPROCESSOR)
+              if (dwCookie & COOKIE_ELEMENT)
                 {
                   if (IsHtmlKeyword (pszChars + nIdentBegin, I - nIdentBegin) && (pszChars[nIdentBegin - 1] == _T ('<') || pszChars[nIdentBegin - 1] == _T ('/')))
                     {
                       DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
+                      if (nIdentBegin > 0 && _tcsnicmp(pszChars + nIdentBegin - 1, _T("<script"), sizeof(_T("<script") - 1)) == 0)
+                        dwCookie |= COOKIE_BLOCK_SCRIPT;
+                      else if (nIdentBegin > 0 && _tcsnicmp(pszChars + nIdentBegin - 1, _T("<style"), sizeof(_T("<style") - 1)) == 0)
+                        dwCookie |= COOKIE_BLOCK_STYLE;
                     }
                   else if (IsHtmlUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
                     {
@@ -224,44 +267,22 @@ next:
               ;
             }
 
-          //  User1 start: <?
-          if (I < nLength && pszChars[I] == '<' && I < nLength - 1 && (pszChars[I + 1] == '?' || pszChars[I + 1] == '%'))
-            {
-              DEFINE_BLOCK (I, COLORINDEX_FUNCNAME);
-              dwCookie |= COOKIE_EXT_USER1;
-              nIdentBegin = -1;
-              continue;
-            }
-
           //  Preprocessor start: < or bracket
-          if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength && (pszChars[I] == '<' && !(I < nLength - 3 && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-')/* || pszChars[I] == '{'*/))
+          if (I < nLength && pszChars[I] == '<' && !(I < nLength - 3 && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-'))
             {
               DEFINE_BLOCK (I, COLORINDEX_OPERATOR);
               DEFINE_BLOCK (I + 1, COLORINDEX_PREPROCESSOR);
-              dwCookie |= COOKIE_PREPROCESSOR;
+              dwCookie |= COOKIE_ELEMENT;
               nIdentBegin = -1;
               continue;
             }
 
-          //  User1 end: ?>
-          if (dwCookie & COOKIE_EXT_USER1)
-            {
-              if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-                {
-                  dwCookie &= ~COOKIE_EXT_USER1;
-                  nIdentBegin = -1;
-                  bRedefineBlock = true;
-                  bDecIndex = true;
-                  continue;
-                }
-            }
-
           //  Preprocessor end: > or bracket
-          if (dwCookie & COOKIE_PREPROCESSOR)
+          if (dwCookie & COOKIE_ELEMENT)
             {
-              if (pszChars[I] == '>'/* || pszChars[I] == '}'*/)
+              if (pszChars[I] == '>')
                 {
-                  dwCookie &= ~COOKIE_PREPROCESSOR;
+                  dwCookie &= ~COOKIE_ELEMENT;
                   nIdentBegin = -1;
                   bRedefineBlock = true;
                   bDecIndex = true;
@@ -290,11 +311,15 @@ next:
         }
     }
 
-  if (nIdentBegin >= 0 && (dwCookie & COOKIE_PREPROCESSOR))
+  if (nIdentBegin >= 0 && (dwCookie & COOKIE_ELEMENT))
     {
       if (IsHtmlKeyword (pszChars + nIdentBegin, I - nIdentBegin) && (pszChars[nIdentBegin - 1] == _T ('<') || pszChars[nIdentBegin - 1] == _T ('/')))
         {
           DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
+          if (nIdentBegin > 0 && _tcsnicmp(pszChars + nIdentBegin - 1, _T("<script"), sizeof(_T("<script") - 1)) == 0)
+            dwCookie |= COOKIE_BLOCK_SCRIPT;
+          else if (nIdentBegin > 0 && _tcsnicmp(pszChars + nIdentBegin - 1, _T("<style"), sizeof(_T("<style") - 1)) == 0)
+            dwCookie |= COOKIE_BLOCK_STYLE;
         }
       else if (IsHtmlUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
         {
@@ -308,68 +333,14 @@ next:
         {
           DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
         }
-      else
-        {
-          bool bFunction = false;
-
-          for (int j = I; j < nLength; j++)
-            {
-              if (!xisspace (pszChars[j]))
-                {
-                  if (pszChars[j] == '(')
-                    {
-                      bFunction = true;
-                    }
-                  break;
-                }
-            }
-          if (bFunction)
-            {
-              DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME);
-            }
-        }
-    }
-
-  //  User1 start: <?
-  if (I < nLength && pszChars[I] == '<' && I < nLength - 1 && (pszChars[I + 1] == '?' || pszChars[I + 1] == '%'))
-    {
-      DEFINE_BLOCK (I, COLORINDEX_FUNCNAME);
-      dwCookie |= COOKIE_EXT_USER1;
-      nIdentBegin = -1;
-      goto end;
     }
 
-  //  Preprocessor start: < or {
-  if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength && (pszChars[I] == '<' && !(I < nLength - 3 && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-')/* || pszChars[I] == '{'*/))
-    {
-      DEFINE_BLOCK (I, COLORINDEX_OPERATOR);
-      DEFINE_BLOCK (I + 1, COLORINDEX_PREPROCESSOR);
-      dwCookie |= COOKIE_PREPROCESSOR;
-      nIdentBegin = -1;
-      goto end;
-    }
-
-  //  User1 end: ?>
-  if (dwCookie & COOKIE_EXT_USER1)
-    {
-      if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-        {
-          dwCookie &= ~COOKIE_EXT_USER1;
-          nIdentBegin = -1;
-        }
-    }
-
-  //  Preprocessor end: > or }
-  if (dwCookie & COOKIE_PREPROCESSOR)
-    {
-      if (pszChars[I] == '>'/* || pszChars[I] == '}'*/)
-        {
-          dwCookie &= ~COOKIE_PREPROCESSOR;
-          nIdentBegin = -1;
-        }
-    }
-
-end:
-  dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_PREPROCESSOR | COOKIE_EXT_USER1);
+  dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_ELEMENT | COOKIE_EXT_USER1 | COOKIE_BLOCK_SCRIPT | COOKIE_BLOCK_STYLE);
   return dwCookie;
 }
+
+unsigned
+CrystalLineParser::ParseLineHtml (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
+{
+  return ParseLineHtmlEx(dwCookie, pszChars, nLength, pBuf, nActualItems, SRC_JAVA);
+}
index 0b4ddd4..7ab3dda 100644 (file)
@@ -110,12 +110,17 @@ IsPhp2Keyword (const TCHAR *pszChars, int nLength)
 }
 
 unsigned
-CrystalLineParser::ParseLinePhp (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
+CrystalLineParser::ParseLinePhp(unsigned dwCookie, const TCHAR* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems)
+{
+  return ParseLineHtmlEx(dwCookie, pszChars, nLength, pBuf, nActualItems, SRC_PHP);
+}
+
+unsigned
+CrystalLineParser::ParseLinePhpLanguage (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
 {
   if (nLength == 0)
-    return dwCookie & (COOKIE_EXT_COMMENT|COOKIE_EXT_USER1);
+    return dwCookie & (COOKIE_EXT_COMMENT);
 
-  bool bFirstChar = (dwCookie & ~(COOKIE_EXT_COMMENT|COOKIE_EXT_USER1)) == 0;
   const TCHAR *pszCommentBegin = nullptr;
   const TCHAR *pszCommentEnd = nullptr;
   bool bRedefineBlock = true;
@@ -149,10 +154,6 @@ CrystalLineParser::ParseLinePhp (unsigned dwCookie, const TCHAR *pszChars, int n
             {
               DEFINE_BLOCK (nPos, COLORINDEX_PREPROCESSOR);
             }
-          else if (dwCookie & COOKIE_EXT_USER1)
-            {
-              DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
-            }
           else
             {
               if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.')
@@ -209,60 +210,38 @@ out:
       //  Extended comment <!--....-->
       if (dwCookie & COOKIE_EXT_COMMENT)
         {
-          if (dwCookie & COOKIE_EXT_USER1)
-            {
-              if ((pszCommentBegin < pszChars + I) && (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
-                {
-                  dwCookie &= ~COOKIE_EXT_COMMENT;
-                  bRedefineBlock = true;
-                  pszCommentEnd = pszChars + I + 1;
-                }
-            }
-          else
+          if ((pszCommentBegin < pszChars + I) && (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '*'))
             {
-              if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
-                {
-                  dwCookie &= ~COOKIE_EXT_COMMENT;
-                  bRedefineBlock = true;
-                }
+              dwCookie &= ~COOKIE_EXT_COMMENT;
+              bRedefineBlock = true;
+              pszCommentEnd = pszChars + I + 1;
             }
           continue;
         }
 
-      if ((dwCookie & COOKIE_EXT_USER1) && (pszCommentEnd < pszChars + I) && (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/'))
+      if ((pszCommentEnd < pszChars + I) && (I > 0 && pszChars[I] == '/' && pszChars[nPrevI] == '/'))
         {
           DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
           dwCookie |= COOKIE_COMMENT;
           break;
         }
 
-      if ((dwCookie & COOKIE_EXT_USER1) && pszChars[I] == '#')
+      if (pszChars[I] == '#')
         {
           DEFINE_BLOCK (I, COLORINDEX_COMMENT);
           dwCookie |= COOKIE_COMMENT;
           break;
         }
 
-      //  Extended comment <?....?>
-      if (dwCookie & COOKIE_EXT_USER1)
-        {
-          if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-            {
-              dwCookie &= ~COOKIE_EXT_USER1;
-              bRedefineBlock = true;
-              continue;
-            }
-        }
-
       //  Normal text
-      if ((dwCookie & (COOKIE_PREPROCESSOR|COOKIE_EXT_USER1)) && pszChars[I] == '"')
+      if (pszChars[I] == '"')
         {
           DEFINE_BLOCK (I, COLORINDEX_STRING);
           dwCookie |= COOKIE_STRING;
           continue;
         }
 
-      if ((dwCookie & (COOKIE_PREPROCESSOR|COOKIE_EXT_USER1)) && pszChars[I] == '\'')
+      if (pszChars[I] == '\'')
         {
           // if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'')
           if (!I || !xisalnum (pszChars[nPrevI]))
@@ -273,40 +252,11 @@ out:
             }
         }
 
-      if (dwCookie & COOKIE_EXT_USER1)
-        {
-          if ((pszCommentEnd < pszChars + I) && (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/'))
-            {
-              DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
-              dwCookie |= COOKIE_EXT_COMMENT;
-              pszCommentBegin = pszChars + I + 1;
-              continue;
-            }
-        }
-      else
-        {
-          if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength - 3 && pszChars[I] == '<' && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-')
-            {
-              DEFINE_BLOCK (I, COLORINDEX_COMMENT);
-              I += 3;
-              dwCookie |= COOKIE_EXT_COMMENT;
-              dwCookie &= ~COOKIE_PREPROCESSOR;
-              continue;
-            }
-        }
-
-      if (bFirstChar)
+      if ((pszCommentEnd < pszChars + I) && (I > 0 && pszChars[I] == '*' && pszChars[nPrevI] == '/'))
         {
-          if (!xisspace (pszChars[I]))
-            bFirstChar = false;
-        }
-
-      //  User1 start: <?
-      if (I < nLength && pszChars[I] == '<' && I < nLength - 1 && (pszChars[I + 1] == '?' || pszChars[I + 1] == '%'))
-        {
-          DEFINE_BLOCK (I, COLORINDEX_NORMALTEXT);
-          dwCookie |= COOKIE_EXT_USER1;
-          nIdentBegin = -1;
+          DEFINE_BLOCK (nPrevI, COLORINDEX_COMMENT);
+          dwCookie |= COOKIE_EXT_COMMENT;
+          pszCommentBegin = pszChars + I + 1;
           continue;
         }
 
@@ -323,77 +273,44 @@ out:
         {
           if (nIdentBegin >= 0)
             {
-              if (dwCookie & COOKIE_PREPROCESSOR)
+              if (dwCookie & COOKIE_USER2)
                 {
-                  if (IsHtmlKeyword (pszChars + nIdentBegin, I - nIdentBegin) && (pszChars[nIdentBegin - 1] == _T ('<') || pszChars[nIdentBegin - 1] == _T ('/')))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
-                    }
-                  else if (IsHtmlUser1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1);
-                    }
-                  else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
-                    }
-                  else
-                    {
-                      goto next;
-                    }
+                  DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1);
                 }
-              else if (dwCookie & COOKIE_EXT_USER1)
+              if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin))
                 {
-                  if (dwCookie & COOKIE_USER2)
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER1);
-                    }
-                  if (IsPhpKeyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
-                    }
-                  else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR);
-                    }
-                  else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2);
-                    }
-                  else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
-                    {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
-                    }
-                  else
-                    {
-                      bool bFunction = false;
+                  DEFINE_BLOCK (nIdentBegin, COLORINDEX_KEYWORD);
+                }
+              else if (IsPhp1Keyword (pszChars + nIdentBegin, I - nIdentBegin))
+                {
+                  DEFINE_BLOCK (nIdentBegin, COLORINDEX_OPERATOR);
+                }
+              else if (IsPhp2Keyword (pszChars + nIdentBegin, I - nIdentBegin))
+                {
+                  DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2);
+                }
+              else if (IsXNumber (pszChars + nIdentBegin, I - nIdentBegin))
+                {
+                  DEFINE_BLOCK (nIdentBegin, COLORINDEX_NUMBER);
+                }
+              else
+                {
+                  bool bFunction = false;
 
-                      for (int j = I; j < nLength; j++)
+                  for (int j = I; j < nLength; j++)
+                    {
+                      if (!xisspace (pszChars[j]))
                         {
-                          if (!xisspace (pszChars[j]))
+                          if (pszChars[j] == '(')
                             {
-                              if (pszChars[j] == '(')
-                                {
-                                  bFunction = true;
-                                }
-                              break;
+                              bFunction = true;
                             }
-                        }
-                      if (bFunction)
-                        {
-                          DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME);
-                        }
-                      else
-                        {
-                          goto next;
+                          break;
                         }
                     }
-                }
-              else if (dwCookie & COOKIE_USER1)
-                {
-                  if (IsHtmlUser2Keyword (pszChars + nIdentBegin, I - nIdentBegin))
+                  if (bFunction)
                     {
-                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_USER2);
+                      DEFINE_BLOCK (nIdentBegin, COLORINDEX_FUNCNAME);
                     }
                   else
                     {
@@ -407,63 +324,8 @@ next:
               ;
             }
 
-          //  Preprocessor start: < or bracket
-          if (!(dwCookie & COOKIE_EXT_USER1) && I < nLength && pszChars[I] == '<' && !(I < nLength - 3 && pszChars[I + 1] == '!' && pszChars[I + 2] == '-' && pszChars[I + 3] == '-'))
-            {
-              DEFINE_BLOCK (I, COLORINDEX_OPERATOR);
-              DEFINE_BLOCK (I + 1, COLORINDEX_PREPROCESSOR);
-              dwCookie |= COOKIE_PREPROCESSOR;
-              nIdentBegin = -1;
-              continue;
-            }
-
-          //  User1 end: ?>
-          if (dwCookie & COOKIE_EXT_USER1)
-            {
-              if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
-                {
-                  dwCookie &= ~COOKIE_EXT_USER1;
-                  nIdentBegin = -1;
-                  bRedefineBlock = true;
-                  bDecIndex = true;
-                  continue;
-                }
-            }
-
-          //  Preprocessor end: > or bracket
-          if (dwCookie & COOKIE_PREPROCESSOR)
-            {
-              if (pszChars[I] == '>')
-                {
-                  dwCookie &= ~COOKIE_PREPROCESSOR;
-                  nIdentBegin = -1;
-                  bRedefineBlock = true;
-                  bDecIndex = true;
-                  continue;
-                }
-            }
-
-          //  Preprocessor start: &
-          if (!(dwCookie & COOKIE_EXT_USER1) && pszChars[I] == '&')
-            {
-              dwCookie |= COOKIE_USER1;
-              nIdentBegin = -1;
-              continue;
-            }
-
-          //  Preprocessor end: ;
-          if (dwCookie & COOKIE_USER1)
-            {
-              if (pszChars[I] == ';')
-                {
-                  dwCookie &= ~COOKIE_USER1;
-                  nIdentBegin = -1;
-                  continue;
-                }
-            }
-
           //  Preprocessor start: $
-          if ((dwCookie & COOKIE_EXT_USER1) && pszChars[I] == '$')
+          if (pszChars[I] == '$')
             {
               dwCookie |= COOKIE_USER2;
               nIdentBegin = -1;
@@ -562,6 +424,6 @@ next:
         }
     }
 
-  dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING | COOKIE_PREPROCESSOR | COOKIE_EXT_USER1);
+  dwCookie &= (COOKIE_EXT_COMMENT | COOKIE_STRING);
   return dwCookie;
 }