Compared files  

Left
C:\SDK\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\LexNsis.cxx
Last modified2004-09-28 13:17:24.000 +0200
Size13.2 Kb (487 Lines)
EncodingLatin 1 - ANSI (CP1252) default
Right
C:\SDK\wxWidgets-2.6.3\contrib\src\stc\scintilla\src\LexNsis.cxx
Last modified2006-03-16 13:07:08.000 +0100
Size17.8 Kb (648 Lines)
EncodingLatin 1 - ANSI (CP1252) default


   Comparison Statistics  

Detailed Statistics

All Changes
 BlocksLines
Unchanged46433
Inserted20139
Deleted13
Ignored00
Changed24127



   Comparison Details  

1 skipped line
2 2 /** @file LexNsis.cxx
3 3  ** Lexer for NSIS
4 4  **/
5 // Copyright 2003, 2004 by Angelo Mandato <angelo [at] spaceblue [dot] com> 5 // Copyright 2003 - 2005 by Angelo Mandato <angelo [at] spaceblue [dot] com>
6 // Last Updated: 02/22/2004 6 // Last Updated: 03/13/2005
7 7 // The License.txt file describes the conditions under which this software may be distributed.
8 8 #include <stdlib.h>
9 9 #include <string.h>
28 skipped lines
38 38 #define SCE_NSIS_MACRODEF 12
39 39 #define SCE_NSIS_STRINGVAR 13
40 40 #define SCE_NSIS_NUMBER 14
  41 // ADDED for Scintilla v1.63
  42 #define SCE_NSIS_SECTIONGROUP 15
  43 #define SCE_NSIS_PAGEEX 16
  44 #define SCE_NSIS_FUNCTIONDEF 17
  45 #define SCE_NSIS_COMMENTBOX 18
41 46 */
42 47  
43 48 static bool isNsisNumber(char ch)
11 skipped lines
55 60   return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
56 61 }
57 62  
  63 static bool NsisNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler)
  64 {
  65   int nNextLine = -1;
  66   for( unsigned int i = start; i < end; i++ )
  67   {
24 skipped lines
  92   }
  93  
  94   return false;
  95 }
  96  
58 97 static int NsisCmp( char *s1, char *s2, bool bIgnoreCase )
59 98 {
60 99   if( bIgnoreCase )
2 skipped lines
63 102   return strcmp( s1, s2 );
64 103 }
65 104  
66 static int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel, Accessor &styler ) 105 static int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse, bool foldUtilityCmd )
67 106 {
  107   int style = styler.StyleAt(end);
  108  
68 109   // If the word is too long, it is not what we are looking for
69   if( end - start > 13 ) 110   if( end - start > 20 )
70 111     return foldlevel;
71 112  
  113   if( foldUtilityCmd )
  114   {
72   // Check the style at this point, if it is not valid, then return zero 115     // Check the style at this point, if it is not valid, then return zero
73   if( styler.StyleAt(end) != SCE_NSIS_FUNCTION && styler.StyleAt(end) != SCE_NSIS_SECTIONDEF && 116     if( style != SCE_NSIS_FUNCTIONDEF && style != SCE_NSIS_SECTIONDEF &&
74       styler.StyleAt(end) != SCE_NSIS_SUBSECTIONDEF && styler.StyleAt(end) != SCE_NSIS_IFDEFINEDEF && 117         style != SCE_NSIS_SUBSECTIONDEF && style != SCE_NSIS_IFDEFINEDEF &&
75       styler.StyleAt(end) != SCE_NSIS_MACRODEF ) 118         style != SCE_NSIS_MACRODEF && style != SCE_NSIS_SECTIONGROUP &&
  119         style != SCE_NSIS_PAGEEX )
  120           return foldlevel;
  121   }
  122   else
  123   { 
  124     if( style != SCE_NSIS_FUNCTIONDEF && style != SCE_NSIS_SECTIONDEF &&
  125         style != SCE_NSIS_SUBSECTIONDEF && style != SCE_NSIS_SECTIONGROUP &&
  126         style != SCE_NSIS_PAGEEX )
76         return foldlevel; 127           return foldlevel;
  128   }
77 129  
78 130   int newFoldlevel = foldlevel;
79 131   bool bIgnoreCase = false;
80 132   if( styler.GetPropertyInt("nsis.ignorecase") == 1 )
81 133     bIgnoreCase = true;
82 134  
83   char s[15]; // The key word we are looking for has atmost 13 characters 135   char s[20]; // The key word we are looking for has atmost 13 characters
84   for (unsigned int i = 0; i < end - start + 1 && i < 14; i++) 136   for (unsigned int i = 0; i < end - start + 1 && i < 19; i++)
85 137     {
86 138         s[i] = static_cast<char>( styler[ start + i ] );
87 139         s[i + 1] = '\0';
5 skipped lines
93 145       newFoldlevel++;
94 146     else if( NsisCmp(s, "!endif", bIgnoreCase) == 0 || NsisCmp(s, "!macroend", bIgnoreCase ) == 0 )
95 147       newFoldlevel--;
  148     else if( bElse && NsisCmp(s, "!else", bIgnoreCase) == 0 )
  149       newFoldlevel++;
96 150   }
97 151   else
98 152   {
99     if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SubSection", bIgnoreCase ) == 0 ) 153     if( NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SectionGroup", bIgnoreCase ) == 0 || NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "SubSection", bIgnoreCase ) == 0 || NsisCmp(s, "PageEx", bIgnoreCase ) == 0 )
100 154       newFoldlevel++;
101     else if( NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase ) == 0 ) 155     else if( NsisCmp(s, "SectionGroupEnd", bIgnoreCase ) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "PageExEnd", bIgnoreCase ) == 0 )
102 156       newFoldlevel--;
103 157   }
104   158    
105 159   return newFoldlevel;
106 160 }
107 161  
30 skipped lines
138 192     if( NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
139 193         return SCE_NSIS_IFDEFINEDEF;
140 194  
  195   if( NsisCmp(s, "!else", bIgnoreCase ) == 0 ) // ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
  196         return SCE_NSIS_IFDEFINEDEF;
  197  
  198   if( NsisCmp(s, "SectionGroup", bIgnoreCase) == 0 || NsisCmp(s, "SectionGroupEnd", bIgnoreCase) == 0 ) // Covers SectionGroup and SectionGroupEnd
  199     return SCE_NSIS_SECTIONGROUP;
  200  
141 201     if( NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase) == 0 ) // Covers Section and SectionEnd
142 202         return SCE_NSIS_SECTIONDEF;
143 203  
144 204     if( NsisCmp(s, "SubSection", bIgnoreCase) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase) == 0 ) // Covers SubSection and SubSectionEnd
145 205         return SCE_NSIS_SUBSECTIONDEF;
146 206  
  207   if( NsisCmp(s, "PageEx", bIgnoreCase) == 0 || NsisCmp(s, "PageExEnd", bIgnoreCase) == 0 ) // Covers PageEx and PageExEnd
  208     return SCE_NSIS_PAGEEX;
  209  
147     if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 ) // Covers SubSection and SubSectionEnd 210     if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 ) // Covers Function and FunctionEnd
148         return SCE_NSIS_FUNCTION; 211         return SCE_NSIS_FUNCTIONDEF;
149 212  
150 213     if ( Functions.InList(s) )
151 214         return SCE_NSIS_FUNCTION;
36 skipped lines
188 251     bool bHasSimpleNsisNumber = true;
189 252     for (unsigned int j = 1; j < end - start + 1 && j < 99; j++)
190 253       {
191       if( s[j] == '\0' || s[j] == '\r' || s[j] == '\n' )  
192         break;  
193    
194 254       if( !isNsisNumber( s[j] ) )
195 255       {
196 256         bHasSimpleNsisNumber = false;
11 skipped lines
208 268 static void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
209 269 {
210 270     int state = SCE_NSIS_DEFAULT;
  271   if( startPos > 0 )
  272     state = styler.StyleAt(startPos-1); // Use the style from the previous line, usually default, but could be commentbox
  273  
211 274     styler.StartAt( startPos );
212 275     styler.GetLine( startPos );
213 276  
56 skipped lines
270 333  
271 334         break;
272 335         }
  336  
  337         if( cCurrChar == '/' && cNextChar == '*' )
  338         {
  339           styler.ColourTo(i-1,state);
  340           state = SCE_NSIS_COMMENTBOX;
  341           break;
  342         }
  343  
273 344         break;
274 345         case SCE_NSIS_COMMENT:
275 346         if( cNextChar == '\n' || cNextChar == '\r' )
276 347         {
  348           // Special case:
  349           if( cCurrChar == '\\' )
  350           {
277           styler.ColourTo(i,state); 351             styler.ColourTo(i-2,state);
  352             styler.ColourTo(i,SCE_NSIS_DEFAULT);
  353           }
  354           else
  355           {
  356             styler.ColourTo(i,state);
278           state = SCE_NSIS_DEFAULT; 357             state = SCE_NSIS_DEFAULT;
  358           }
279 359         }
280 360         break;
281 361         case SCE_NSIS_STRINGDQ:
  362       case SCE_NSIS_STRINGLQ:
  363       case SCE_NSIS_STRINGRQ:
  364  
282         if( cCurrChar == '"' || cNextChar == '\r' || cNextChar == '\n' ) 365         if( styler.SafeGetCharAt(i-1) == '\\' && styler.SafeGetCharAt(i-2) == '$' )
  366           break; // Ignore the next character, even if it is a quote of some sort
  367  
  368         if( cCurrChar == '"' && state == SCE_NSIS_STRINGDQ )
283 369         {
284         styler.ColourTo(i,SCE_NSIS_STRINGDQ); 370         styler.ColourTo(i,state);
285 371           state = SCE_NSIS_DEFAULT;
  372           break;
286 373         }
287         break; 374  
288         case SCE_NSIS_STRINGLQ:  
289         if( cCurrChar == '`' || cNextChar == '\r' || cNextChar == '\n' ) 375         if(