Fixed comment handling.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4328 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b8991b1482
commit
174feaed16
3 changed files with 368 additions and 324 deletions
|
@ -391,6 +391,14 @@ cfg.Add(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cfg.Add(
|
||||||
|
BoolOption(
|
||||||
|
'NSIS_FIX_COMMENT_HANDLING',
|
||||||
|
'fixes comment handling',
|
||||||
|
'yes'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
### Generate help
|
### Generate help
|
||||||
|
|
||||||
Help(cfg.GenerateHelpText(defenv))
|
Help(cfg.GenerateHelpText(defenv))
|
||||||
|
@ -458,3 +466,4 @@ AddBoolDefine('NSIS_FIX_DEFINES_IN_STRINGS')
|
||||||
AddBoolDefine('NSIS_SUPPORT_STANDARD_PREDEFINES')
|
AddBoolDefine('NSIS_SUPPORT_STANDARD_PREDEFINES')
|
||||||
AddBoolDefine('NSIS_LOCKWINDOW_SUPPORT')
|
AddBoolDefine('NSIS_LOCKWINDOW_SUPPORT')
|
||||||
AddBoolDefine('NSIS_CONFIG_PLUGIN_SUPPORT')
|
AddBoolDefine('NSIS_CONFIG_PLUGIN_SUPPORT')
|
||||||
|
AddBoolDefine('NSIS_FIX_COMMENT_HANDLING')
|
||||||
|
|
|
@ -224,6 +224,10 @@ CEXEBuild::CEXEBuild() :
|
||||||
// Added by Sunil Kamath 11 June 2003
|
// Added by Sunil Kamath 11 June 2003
|
||||||
definedlist.add("NSIS_SUPPORT_STANDARD_PREDEFINES");
|
definedlist.add("NSIS_SUPPORT_STANDARD_PREDEFINES");
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef NSIS_FIX_COMMENT_HANDLING
|
||||||
|
// Added by Sunil Kamath 15 October 2005
|
||||||
|
definedlist.add("NSIS_FIX_COMMENT_HANDLING");
|
||||||
|
#endif
|
||||||
|
|
||||||
// no more optional
|
// no more optional
|
||||||
definedlist.add("NSIS_SUPPORT_NAMED_USERVARS");
|
definedlist.add("NSIS_SUPPORT_NAMED_USERVARS");
|
||||||
|
|
|
@ -124,6 +124,7 @@ void LineParser::freetokens()
|
||||||
int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
||||||
{
|
{
|
||||||
m_nt=0;
|
m_nt=0;
|
||||||
|
#ifndef NSIS_FIX_COMMENT_HANDLING
|
||||||
if ( m_bCommentBlock )
|
if ( m_bCommentBlock )
|
||||||
{
|
{
|
||||||
while ( *line )
|
while ( *line )
|
||||||
|
@ -137,17 +138,40 @@ int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
while (*line == ' ' || *line == '\t') line++;
|
while (*line == ' ' || *line == '\t') line++;
|
||||||
while (*line)
|
while (*line)
|
||||||
{
|
{
|
||||||
|
#ifdef NSIS_FIX_COMMENT_HANDLING
|
||||||
|
if ( m_bCommentBlock )
|
||||||
|
{
|
||||||
|
while ( *line )
|
||||||
|
{
|
||||||
|
if ( *line == '*' && *(line+1) == '/' )
|
||||||
|
{
|
||||||
|
m_bCommentBlock=false; // Found end of comment block
|
||||||
|
line+=2;
|
||||||
|
while (*line == ' ' || *line == '\t') line++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else line++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#endif
|
||||||
int lstate=0; // 1=", 2=`, 4='
|
int lstate=0; // 1=", 2=`, 4='
|
||||||
if (*line == ';' || *line == '#') break;
|
if (*line == ';' || *line == '#') break;
|
||||||
if (*line == '/' && *(line+1) == '*')
|
if (*line == '/' && *(line+1) == '*')
|
||||||
{
|
{
|
||||||
m_bCommentBlock = true;
|
m_bCommentBlock = true;
|
||||||
line+=2;
|
line+=2;
|
||||||
|
#ifndef NSIS_FIX_COMMENT_HANDLING
|
||||||
return doline(line, ignore_escaping);
|
return doline(line, ignore_escaping);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef NSIS_FIX_COMMENT_HANDLING
|
||||||
|
else {
|
||||||
|
#endif
|
||||||
if (*line == '\"') lstate=1;
|
if (*line == '\"') lstate=1;
|
||||||
else if (*line == '\'') lstate=2;
|
else if (*line == '\'') lstate=2;
|
||||||
else if (*line == '`') lstate=4;
|
else if (*line == '`') lstate=4;
|
||||||
|
@ -170,6 +194,9 @@ int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
||||||
if (lstate==2 && *line =='\'') break;
|
if (lstate==2 && *line =='\'') break;
|
||||||
if (lstate==4 && *line =='`') break;
|
if (lstate==4 && *line =='`') break;
|
||||||
if (!lstate && (*line == ' ' || *line == '\t')) break;
|
if (!lstate && (*line == ' ' || *line == '\t')) break;
|
||||||
|
#ifdef NSIS_FIX_COMMENT_HANDLING
|
||||||
|
if (!lstate && (*line == ';' || *line == '#' || (*line == '/' && *(line+1) == '*'))) break;
|
||||||
|
#endif
|
||||||
line++;
|
line++;
|
||||||
nc++;
|
nc++;
|
||||||
}
|
}
|
||||||
|
@ -197,6 +224,10 @@ int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
||||||
else return -2;
|
else return -2;
|
||||||
}
|
}
|
||||||
while (*line == ' ' || *line == '\t') line++;
|
while (*line == ' ' || *line == '\t') line++;
|
||||||
|
#ifdef NSIS_FIX_COMMENT_HANDLING
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue