OSDN Git Service

PATCH: [ 968285 ] DBCS fixes from Sawanaka
authorPerry Rapp <elsapo@users.sourceforge.net>
Sat, 5 Mar 2005 18:10:17 +0000 (18:10 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Sat, 5 Mar 2005 18:10:17 +0000 (18:10 +0000)
  Applied asp & basic portions (there are many more)
  editlib: asp.cpp basic.cpp

Src/editlib/asp.cpp
Src/editlib/basic.cpp
Src/readme.txt

index d25751e..d4e0324 100644 (file)
@@ -543,13 +543,14 @@ ParseLineAsp (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItem
   BOOL bRedefineBlock = TRUE;
   BOOL bDecIndex = FALSE;
   int nIdentBegin = -1;
-  for (int I = 0;; I++)
+  int nPrevI = -1;
+  for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
     {
       if (bRedefineBlock)
         {
           int nPos = I;
           if (bDecIndex)
-            nPos--;
+            nPos = nPrevI;
           if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
             {
               DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
@@ -598,7 +599,7 @@ out:
       //  String constant "...."
       if (dwCookie & COOKIE_STRING)
         {
-          if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+          if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
             {
               dwCookie &= ~COOKIE_STRING;
               bRedefineBlock = TRUE;
@@ -609,7 +610,7 @@ out:
       //  Char constant '..'
       if (dwCookie & COOKIE_CHAR)
         {
-          if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+          if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
             {
               dwCookie &= ~COOKIE_CHAR;
               bRedefineBlock = TRUE;
@@ -622,7 +623,7 @@ out:
         {
           if (!(dwCookie & COOKIE_EXT_USER1))
             {
-              if (I > 1 && pszChars[I] == '>' && pszChars[I - 1] == '-' && pszChars[I - 2] == '-')
+              if (I > 1 && pszChars[I] == '>' && pszChars[nPrevI] == '-' && *::CharPrev(pszChars, pszChars + nPrevI) == '-')
                 {
                   dwCookie &= ~COOKIE_EXT_COMMENT;
                   bRedefineBlock = TRUE;
@@ -641,7 +642,7 @@ out:
       //  Extended comment <?....?>
       if (dwCookie & COOKIE_EXT_USER1)
         {
-          if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+          if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
             {
               dwCookie &= ~COOKIE_EXT_USER1;
               bRedefineBlock = TRUE;
@@ -660,7 +661,7 @@ out:
       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[I - 1]))
+          if (!I || !xisalnum (pszChars[nPrevI]))
             {
               DEFINE_BLOCK (I, COLORINDEX_STRING);
               dwCookie |= COOKIE_CHAR;
@@ -682,7 +683,7 @@ out:
 
       if (bFirstChar)
         {
-          if (!_istspace (pszChars[I]))
+          if (!xisspace (pszChars[I]))
             bFirstChar = FALSE;
         }
 
@@ -734,7 +735,7 @@ out:
 
                       for (int j = I; j < nLength; j++)
                         {
-                          if (!_istspace (pszChars[j]))
+                          if (!xisspace (pszChars[j]))
                             {
                               if (pszChars[j] == '(')
                                 {
@@ -792,7 +793,7 @@ next:
           //  User1 end: ?>
           if (dwCookie & COOKIE_EXT_USER1)
             {
-              if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+              if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
                 {
                   dwCookie &= ~COOKIE_EXT_USER1;
                   nIdentBegin = -1;
@@ -861,7 +862,7 @@ next:
 
           for (int j = I; j < nLength; j++)
             {
-              if (!_istspace (pszChars[j]))
+              if (!xisspace (pszChars[j]))
                 {
                   if (pszChars[j] == '(')
                     {
@@ -892,7 +893,7 @@ next:
 
           for (int j = I; j < nLength; j++)
             {
-              if (!_istspace (pszChars[j]))
+              if (!xisspace (pszChars[j]))
                 {
                   if (pszChars[j] == '(')
                     {
@@ -929,7 +930,7 @@ next:
   //  User1 end: ?>
   if (dwCookie & COOKIE_EXT_USER1)
     {
-      if (I > 0 && pszChars[I] == '>' && (pszChars[I - 1] == '?' || pszChars[I - 1] == '%'))
+      if (I > 0 && pszChars[I] == '>' && (pszChars[nPrevI] == '?' || pszChars[nPrevI] == '%'))
         {
           dwCookie &= ~COOKIE_EXT_USER1;
           nIdentBegin = -1;
index a1e5331..57186a9 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "stdafx.h"
 #include "ccrystaltextview.h"
+#include "ccrystaltextbuffer.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -75,6 +76,7 @@ static LPTSTR s_apszBasicKeywordList[] =
     _T ("CStr"),
     _T ("CVar"),
     _T ("CurDir"),
+    _T ("Currency"),
     _T ("Date"),
     _T ("Declare"),
     _T ("Dialog"),
@@ -93,6 +95,7 @@ static LPTSTR s_apszBasicKeywordList[] =
     _T ("Erase"),
     _T ("Exit"),
     _T ("Exp"),
+    _T ("Explicit"),
     _T ("False"),
     _T ("FileCopy"),
     _T ("FileLen"),
@@ -102,6 +105,7 @@ static LPTSTR s_apszBasicKeywordList[] =
     _T ("Step"),
     _T ("Next"),
     _T ("Format"),
+    _T ("Friend"),
     _T ("Function"),
     _T ("Get"),
     _T ("GetObject"),
@@ -112,6 +116,7 @@ static LPTSTR s_apszBasicKeywordList[] =
     _T ("Hex"),
     _T ("Hour"),
     _T ("If"),
+    _T ("In"),
     _T ("Then"),
     _T ("Else"),
     _T ("ElseIf"),
@@ -134,6 +139,7 @@ static LPTSTR s_apszBasicKeywordList[] =
     _T ("Left$"),
     _T ("Len"),
     _T ("Let"),
+    _T ("Like"),
     _T ("Lib"),
     _T ("Line"),
     _T ("Input#"),
@@ -158,6 +164,8 @@ static LPTSTR s_apszBasicKeywordList[] =
     _T ("Optional"),
     _T ("Base"),
     _T ("Print"),
+    _T ("Private"),
+    _T ("Property"),
     _T ("Public"),
     _T ("Private"),
     _T ("Property"),
@@ -281,13 +289,14 @@ ParseLineBasic (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualIt
   BOOL bRedefineBlock = TRUE;
   BOOL bDecIndex = FALSE;
   int nIdentBegin = -1;
-  for (int I = 0;; I++)
+  int nPrevI = -1;
+  for (int I = 0;; nPrevI = I, I = ::CharNext(pszChars+I) - pszChars)
     {
       if (bRedefineBlock)
         {
           int nPos = I;
           if (bDecIndex)
-            nPos--;
+            nPos = nPrevI;
           if (dwCookie & (COOKIE_COMMENT | COOKIE_EXT_COMMENT))
             {
               DEFINE_BLOCK (nPos, COLORINDEX_COMMENT);
@@ -303,7 +312,7 @@ ParseLineBasic (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualIt
             }
             else
             {
-              if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (pszChars[nPos - 1]) && !xisalpha (pszChars[nPos + 1])))
+              if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos))))
                 {
                   DEFINE_BLOCK (nPos, COLORINDEX_NORMALTEXT);
                 }
@@ -333,7 +342,7 @@ out:
       //  String constant "...."
       if (dwCookie & COOKIE_STRING)
         {
-          if (pszChars[I] == '"')
+          if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
             {
               dwCookie &= ~COOKIE_STRING;
               bRedefineBlock = TRUE;
@@ -344,7 +353,7 @@ out:
       //  Char constant '..'
       if (dwCookie & COOKIE_CHAR)
         {
-          if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[I - 1] != '\\' || I >= 2 && (pszChars[I - 1] != '\\' || pszChars[I - 1] == '\\' && pszChars[I - 2] == '\\')))
+          if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\')))
             {
               dwCookie &= ~COOKIE_CHAR;
               bRedefineBlock = TRUE;
@@ -355,14 +364,14 @@ out:
       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[I - 1]))
+          if (!I || !xisalnum (pszChars[nPrevI]))
             {
               DEFINE_BLOCK (I, COLORINDEX_STRING);
               dwCookie |= COOKIE_CHAR;
               continue;
             }
         }
-      if (I > 2 && !xisalnum (pszChars[I]) && (pszChars[I - 1] == 'M' || pszChars[I - 1] == 'm') && (pszChars[I - 2] == 'E' || pszChars[I - 2] == 'e') && (pszChars[I - 3] == 'R' || pszChars[I - 3] == 'r'))
+      if (I > 2 && !xisalnum (pszChars[I]) && (pszChars[nPrevI] == 'M' || pszChars[nPrevI] == 'm') && (*::CharPrev(pszChars, pszChars + nPrevI) == 'E' || *::CharPrev(pszChars, pszChars + nPrevI) == 'e') && (pszChars[I - 3] == 'R' || pszChars[I - 3] == 'r'))
         {
           DEFINE_BLOCK (I - 3, COLORINDEX_COMMENT);
           dwCookie |= COOKIE_COMMENT;
@@ -380,7 +389,7 @@ out:
 
       if (bFirstChar)
         {
-          if (!_istspace (pszChars[I]))
+          if (!xisspace (pszChars[I]))
             bFirstChar = FALSE;
         }
 
@@ -388,7 +397,7 @@ out:
         continue;               //  We don't need to extract keywords,
       //  for faster parsing skip the rest of loop
 
-      if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[I - 1]) && !xisalpha (pszChars[I + 1])))
+      if (xisalnum (pszChars[I]) || pszChars[I] == '.' && I > 0 && (!xisalpha (pszChars[nPrevI]) && !xisalpha (pszChars[I + 1])))
         {
           if (nIdentBegin == -1)
             nIdentBegin = I;
@@ -411,7 +420,7 @@ out:
 
                   for (int j = I; j < nLength; j++)
                     {
-                      if (!_istspace (pszChars[j]))
+                      if (!xisspace (pszChars[j]))
                         {
                           if (pszChars[j] == '(')
                             {
@@ -448,7 +457,7 @@ out:
 
           for (int j = I; j < nLength; j++)
             {
-              if (!_istspace (pszChars[j]))
+              if (!xisspace (pszChars[j]))
                 {
                   if (pszChars[j] == '(')
                     {
@@ -464,7 +473,7 @@ out:
         }
     }
 
-  if (pszChars[nLength - 1] != '\\')
+  if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1))
     dwCookie &= COOKIE_EXT_COMMENT;
   return dwCookie;
 }
index 2f37db6..91d9461 100644 (file)
@@ -13,6 +13,9 @@
   Src/Languages/Spanish: MergeSpanish.rc
  PATCH: [ 1157145 ] FileFilterHelper doesn't have boilerplate new redefinition
   Src: FileFilterHelper.cpp
+ PATCH: [ 968285 ] DBCS fixes from Sawanaka
+  Applied asp & basic portions (there are many more)
+  editlib: asp.cpp basic.cpp
 
 2005-03-04 Perry
  PATCH: [ 1147039 ] experimental patch for colored word diff