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
2U2U/** @file LexNsis.cxx
3U3U ** Lexer for NSIS
4U4U **/
5C// Copyright 2003, 2004 by Angelo Mandato <angelo [at] spaceblue [dot] com> 5C// Copyright 2003 - 2005 by Angelo Mandato <angelo [at] spaceblue [dot] com>
6C// Last Updated: 02/22/2004 6C// Last Updated: 03/13/2005
7U7U// The License.txt file describes the conditions under which this software may be distributed.
8U8U#include <stdlib.h>
9U9U#include <string.h>
28 skipped lines
38U38U#define SCE_NSIS_MACRODEF 12
39U39U#define SCE_NSIS_STRINGVAR 13
40U40U#define SCE_NSIS_NUMBER 14
  41A// ADDED for Scintilla v1.63
  42A#define SCE_NSIS_SECTIONGROUP 15
  43A#define SCE_NSIS_PAGEEX 16
  44A#define SCE_NSIS_FUNCTIONDEF 17
  45A#define SCE_NSIS_COMMENTBOX 18
41U46U*/
42U47U 
43U48Ustatic bool isNsisNumber(char ch)
11 skipped lines
55U60U  return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
56U61U}
57U62U 
  63Astatic bool NsisNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler)
  64A{
  65A  int nNextLine = -1;
  66A  for( unsigned int i = start; i < end; i++ )
  67A  {
24 skipped lines
  92A  }
  93A 
  94A  return false;
  95A}
  96A 
58U97Ustatic int NsisCmp( char *s1, char *s2, bool bIgnoreCase )
59U98U{
60U99U  if( bIgnoreCase )
2 skipped lines
63U102U  return strcmp( s1, s2 );
64U103U}
65U104U 
66Cstatic int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel, Accessor &styler ) 105Cstatic int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse, bool foldUtilityCmd )
67U106U{
  107A  int style = styler.StyleAt(end);
  108A 
68U109U  // If the word is too long, it is not what we are looking for
69C  if( end - start > 13 ) 110C  if( end - start > 20 )
70U111U    return foldlevel;
71U112U 
  113C  if( foldUtilityCmd )
  114C  {
72C  // Check the style at this point, if it is not valid, then return zero 115C    // Check the style at this point, if it is not valid, then return zero
73C  if( styler.StyleAt(end) != SCE_NSIS_FUNCTION && styler.StyleAt(end) != SCE_NSIS_SECTIONDEF && 116C    if( style != SCE_NSIS_FUNCTIONDEF && style != SCE_NSIS_SECTIONDEF &&
74C      styler.StyleAt(end) != SCE_NSIS_SUBSECTIONDEF && styler.StyleAt(end) != SCE_NSIS_IFDEFINEDEF && 117C        style != SCE_NSIS_SUBSECTIONDEF && style != SCE_NSIS_IFDEFINEDEF &&
75C      styler.StyleAt(end) != SCE_NSIS_MACRODEF ) 118C        style != SCE_NSIS_MACRODEF && style != SCE_NSIS_SECTIONGROUP &&
  119C        style != SCE_NSIS_PAGEEX )
  120C          return foldlevel;
  121C  }
  122C  else
  123C  { 
  124C    if( style != SCE_NSIS_FUNCTIONDEF && style != SCE_NSIS_SECTIONDEF &&
  125C        style != SCE_NSIS_SUBSECTIONDEF && style != SCE_NSIS_SECTIONGROUP &&
  126C        style != SCE_NSIS_PAGEEX )
76C        return foldlevel; 127C          return foldlevel;
  128C  }
77U129U 
78U130U  int newFoldlevel = foldlevel;
79U131U  bool bIgnoreCase = false;
80U132U  if( styler.GetPropertyInt("nsis.ignorecase") == 1 )
81U133U    bIgnoreCase = true;
82U134U 
83C  char s[15]; // The key word we are looking for has atmost 13 characters 135C  char s[20]; // The key word we are looking for has atmost 13 characters
84C  for (unsigned int i = 0; i < end - start + 1 && i < 14; i++) 136C  for (unsigned int i = 0; i < end - start + 1 && i < 19; i++)
85U137U    {
86U138U        s[i] = static_cast<char>( styler[ start + i ] );
87U139U        s[i + 1] = '\0';
5 skipped lines
93U145U      newFoldlevel++;
94U146U    else if( NsisCmp(s, "!endif", bIgnoreCase) == 0 || NsisCmp(s, "!macroend", bIgnoreCase ) == 0 )
95U147U      newFoldlevel--;
  148A    else if( bElse && NsisCmp(s, "!else", bIgnoreCase) == 0 )
  149A      newFoldlevel++;
96U150U  }
97U151U  else
98U152U  {
99C    if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SubSection", bIgnoreCase ) == 0 ) 153C    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 )
100U154U      newFoldlevel++;
101C    else if( NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase ) == 0 ) 155C    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 )
102U156U      newFoldlevel--;
103U157U  }
104C  158C   
105U159U  return newFoldlevel;
106U160U}
107U161U 
30 skipped lines
138U192U    if( NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
139U193U        return SCE_NSIS_IFDEFINEDEF;
140U194U 
  195A  if( NsisCmp(s, "!else", bIgnoreCase ) == 0 ) // ||  NsisCmp(s, "!ifndef", bIgnoreCase) == 0 ||  NsisCmp(s, "!endif", bIgnoreCase) == 0 )
  196A        return SCE_NSIS_IFDEFINEDEF;
  197A 
  198A  if( NsisCmp(s, "SectionGroup", bIgnoreCase) == 0 || NsisCmp(s, "SectionGroupEnd", bIgnoreCase) == 0 ) // Covers SectionGroup and SectionGroupEnd
  199A    return SCE_NSIS_SECTIONGROUP;
  200A 
141U201U    if( NsisCmp(s, "Section", bIgnoreCase ) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase) == 0 ) // Covers Section and SectionEnd
142U202U        return SCE_NSIS_SECTIONDEF;
143U203U 
144U204U    if( NsisCmp(s, "SubSection", bIgnoreCase) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase) == 0 ) // Covers SubSection and SubSectionEnd
145U205U        return SCE_NSIS_SUBSECTIONDEF;
146U206U 
  207C  if( NsisCmp(s, "PageEx", bIgnoreCase) == 0 || NsisCmp(s, "PageExEnd", bIgnoreCase) == 0 ) // Covers PageEx and PageExEnd
  208C    return SCE_NSIS_PAGEEX;
  209C 
147C    if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 ) // Covers SubSection and SubSectionEnd 210C    if( NsisCmp(s, "Function", bIgnoreCase) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 ) // Covers Function and FunctionEnd
148C        return SCE_NSIS_FUNCTION; 211C        return SCE_NSIS_FUNCTIONDEF;
149U212U 
150U213U    if ( Functions.InList(s) )
151U214U        return SCE_NSIS_FUNCTION;
36 skipped lines
188U251U    bool bHasSimpleNsisNumber = true;
189U252U    for (unsigned int j = 1; j < end - start + 1 && j < 99; j++)
190U253U      {
191R      if( s[j] == '\0' || s[j] == '\r' || s[j] == '\n' )  
192R        break;  
193R   
194U254U      if( !isNsisNumber( s[j] ) )
195U255U      {
196U256U        bHasSimpleNsisNumber = false;
11 skipped lines
208U268Ustatic void ColouriseNsisDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
209U269U{
210U270U    int state = SCE_NSIS_DEFAULT;
  271A  if( startPos > 0 )
  272A    state = styler.StyleAt(startPos-1); // Use the style from the previous line, usually default, but could be commentbox
  273A 
211U274U    styler.StartAt( startPos );
212U275U    styler.GetLine( startPos );
213U276U 
56 skipped lines
270U333U 
271U334U        break;
272U335U        }
  336A 
  337A        if( cCurrChar == '/' && cNextChar == '*' )
  338A        {
  339A          styler.ColourTo(i-1,state);
  340A          state = SCE_NSIS_COMMENTBOX;
  341A          break;
  342A        }
  343A 
273U344U        break;
274U345U        case SCE_NSIS_COMMENT:
275U346U        if( cNextChar == '\n' || cNextChar == '\r' )
276U347U        {
  348C          // Special case:
  349C          if( cCurrChar == '\\' )
  350C          {
277C          styler.ColourTo(i,state); 351C            styler.ColourTo(i-2,state);
  352C            styler.ColourTo(i,SCE_NSIS_DEFAULT);
  353C          }
  354C          else
  355C          {
  356C            styler.ColourTo(i,state);
278C          state = SCE_NSIS_DEFAULT; 357C            state = SCE_NSIS_DEFAULT;
  358C          }
279U359U        }
280U360U        break;
281U361U        case SCE_NSIS_STRINGDQ:
  362C      case SCE_NSIS_STRINGLQ:
  363C      case SCE_NSIS_STRINGRQ:
  364C 
282C        if( cCurrChar == '"' || cNextChar == '\r' || cNextChar == '\n' ) 365C        if( styler.SafeGetCharAt(i-1) == '\\' && styler.SafeGetCharAt(i-2) == '$' )
  366C          break; // Ignore the next character, even if it is a quote of some sort
  367C 
  368C        if( cCurrChar == '"' && state == SCE_NSIS_STRINGDQ )
283U369U        {
284C        styler.ColourTo(i,SCE_NSIS_STRINGDQ); 370C        styler.ColourTo(i,state);
285U371U          state = SCE_NSIS_DEFAULT;
  372A          break;
286U373U        }
287C        break; 374C 
288C        case SCE_NSIS_STRINGLQ:  
289C        if( cCurrChar == '`' || cNextChar == '\r' || cNextChar == '\n' ) 375C        if( cCurrChar == '`' && state == SCE_NSIS_STRINGLQ )
290C        { 376C        {
291C        styler.ColourTo(i,SCE_NSIS_STRINGLQ); 377C        styler.ColourTo(i,state);
292U378U          state = SCE_NSIS_DEFAULT;
  379A          break;
293U380U        }
294C        break; 381C 
295C        case SCE_NSIS_STRINGRQ:  
296C        if( cCurrChar == '\'' || cNextChar == '\r' || cNextChar == '\n' ) 382C        if( cCurrChar == '\'' && state == SCE_NSIS_STRINGRQ )
297U383U        {
298C        styler.ColourTo(i,SCE_NSIS_STRINGRQ); 384C        styler.ColourTo(i,state);
299U385U          state = SCE_NSIS_DEFAULT;
  386A          break;
300U387U        }
  388A 
  389A        if( cNextChar == '\r' || cNextChar == '\n' )
  390A        {
  391A          int nCurLine = styler.GetLine(i+1);
  392A          int nBack = i;
26 skipped lines
  419A          {
  420A            styler.ColourTo(i,state);
  421A            state = SCE_NSIS_DEFAULT;
  422A          }
  423A        }
301U424U        break;
  425A 
302U426U        case SCE_NSIS_FUNCTION:
303U427U 
304U428U        // NSIS KeyWord:
3 skipped lines
308U432U          state = SCE_NSIS_DEFAULT;
309U433U        else if( (isNsisChar(cCurrChar) && !isNsisChar( cNextChar) && cNextChar != '}') || cCurrChar == '}' )
310U434U        {
311C        state = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler); 435C        state = classifyWordNsis( styler.GetStartSegment(), i, keywordLists, styler );
312U436U        styler.ColourTo( i, state);
313U437U        state = SCE_NSIS_DEFAULT;
314U438U        }
28 skipped lines
343U467U          }
344U468U        }
345U469U        break;
  470A      case SCE_NSIS_COMMENTBOX:
  471A 
  472A        if( styler.SafeGetCharAt(i-1) == '*' && cCurrChar == '/' )
  473A        {
  474A          styler.ColourTo(i,state);
  475A          state = SCE_NSIS_DEFAULT;
  476A        }
  477A        break;
346U478U        }
347U479U 
348C        if( state == SCE_NSIS_COMMENT ) 480C        if( state == SCE_NSIS_COMMEN|| state == SCE_NSIS_COMMENTBOX )
349U481U        {
350U482U        styler.ColourTo(i,state);
351U483U        }
9 skipped lines
361U493U        bVarInString = false;
362U494U        bIngoreNextDollarSign = true;
363U495U      }
364C      else if( bVarInString && cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) ) 496C      else if( bVarInString && cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't|| cNextChar == '"' || cNextChar == '`' || cNextChar == '\'' ) )
365U497U      {
  498A        styler.ColourTo( i+1, SCE_NSIS_STRINGVAR);
366U499U        bVarInString = false;
367C        bIngoreNextDollarSign = true; 500C        bIngoreNextDollarSign = false;
368U501U      }
369U502U 
370U503U      // Covers "$INSTDIR and user vars like $MYVAR"
30 skipped lines
401U534U    }
402U535U 
403U536U  // Colourise remaining document
404C  switch( state )  
405C  {  
406C    case SCE_NSIS_COMMENT:  
407C    case SCE_NSIS_STRINGDQ:  
408C    case SCE_NSIS_STRINGLQ:  
409C    case SCE_NSIS_STRINGRQ:  
410C    case SCE_NSIS_VARIABLE:  
411C    case SCE_NSIS_STRINGVAR:  
412C      styler.ColourTo(nLengthDoc-1,state); break; 537C    styler.ColourTo(nLengthDoc-1,state);
413C   
414C    default:  
415C      styler.ColourTo(nLengthDoc-1,SCE_NSIS_DEFAULT); break;  
416C  }  
417U538U}
418U539U 
419U540Ustatic void FoldNsisDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
2 skipped lines
422U543U    if( styler.GetPropertyInt("fold") == 0 )
423U544U        return;
424U545U 
  546A  bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) == 1;
  547A  bool foldUtilityCmd = styler.GetPropertyInt("nsis.foldutilcmd", 1) == 1;
  548A  bool blockComment = false;
  549A 
425U550U  int lineCurrent = styler.GetLine(startPos);
426U551U  unsigned int safeStartPos = styler.LineStart( lineCurrent );
427U552U 
4 skipped lines
432U557U    if (lineCurrent > 0)
433U558U        levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
434U559U    int levelNext = levelCurrent;
  560A  int style = styler.StyleAt(safeStartPos);
  561A  if( style == SCE_NSIS_COMMENTBOX )
  562A  {
  563A    if( styler.SafeGetCharAt(safeStartPos) == '/' && styler.SafeGetCharAt(safeStartPos+1) == '*' )
  564A      levelNext++;
  565A    blockComment = true;
  566A  }
435U567U 
436U568U  for (unsigned int i = safeStartPos; i < startPos + length; i++)
437U569U    {
438U570U    char chCurr = styler.SafeGetCharAt(i);
  571A    style = styler.StyleAt(i);
  572A    if( blockComment && style != SCE_NSIS_COMMENTBOX )
  573A    {
  574A      levelNext--;
  575A      blockComment = false;
  576A    }
  577A    else if( !blockComment && style == SCE_NSIS_COMMENTBOX )
  578A    {
  579A      levelNext++;
  580A      blockComment = true;
  581A    }
439U582U 
440C    if( bArg) //&& chCurr != '\n' ) 583C    if( bArg&& !blockComment)
441U584U    {
442U585U      if( nWordStart == -1 && (isNsisLetter(chCurr) || chCurr == '!') )
  586A      {
443U587U        nWordStart = i;
  588C      }
444C      else if( !isNsisLetter(chCurr) && nWordStart > -1 ) 589C      else if( isNsisLetter(chCurr) == false && nWordStart > -1 )
445U590U      {
446C        int newLevel = calculateFoldNsis( nWordStart, i-1, levelNext, styler ); 591C        int newLevel = calculateFoldNsis( nWordStart, i-1, levelNext, styler, foldAtElse, foldUtilityCmd );
  592C 
447C        if( newLevel !levelNext ) 593C        if( newLevel =levelNext )
  594C        {
  595C          if( foldAtElse && foldUtilityCmd )
  596C          {
  597C            if( NsisNextLineHasElse(i, startPos + length, styler) )
  598C              levelNext--;
  599C          }
  600C        }
  601C        else
448U602U          levelNext = newLevel;
449U603U        bArg1 = false;
450U604U      }
1 skipped line
452U606U 
453U607U    if( chCurr == '\n' )
454U608U    {
  609A      if( bArg1 && foldAtElse && foldUtilityCmd && !blockComment )
  610A      {
  611A        if( NsisNextLineHasElse(i, startPos + length, styler) )
  612A          levelNext--;
  613A      }
  614A 
455U615U      // If we are on a new line...
456U616U      int levelUse = levelCurrent;
457U617U        int lev = levelUse | levelNext << 16;
458C        if (levelUse < levelNext) 618C      if (levelUse < levelNext )
459U619U        lev |= SC_FOLDLEVELHEADERFLAG;
460U620U        if (lev != styler.LevelAt(lineCurrent))
461U621U        styler.SetLevel(lineCurrent, lev);
22 skipped lines
484U644U 
485U645U 
486U646ULexerModule lmNsis(SCLEX_NSIS, ColouriseNsisDoc, "nsis", FoldNsisDoc, nsisWordLists);
  647A 
487U648U 

   Text comparison Options  

Match character case: yes.
Match line endings: no.
Match spaces

At start of lines: yes,
In middle of lines: yes,
At end of lines: yes.
Blank lines as empty lines: no.
Activate comparison algorithm
At word level: yes,
At character level: no.


   Legend  

UExample of unchanged line
CExample of modified line
AExample of added line
RExample of removed line
IExample of ignored line
Modified text
Added text
Removed text

This report has been generated by Ellié Computing Merge on 2006-09-07 16:23:39.001 +0200.
© 2005-2006 Ellié Computing http://www.elliecomputing.com. All rights reserved.