Removed bogus comment about possible string prefix bug

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6491 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2014-06-15 13:58:04 +00:00
parent 8ed10146ef
commit 5574a0e7a2

View file

@ -603,7 +603,6 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
else else
{ {
// starts with a $ but not $$. // starts with a $ but not $$.
{ // block - why do we need this extra {?
bool bProceced=false; bool bProceced=false;
if ( *p ) if ( *p )
{ {
@ -616,19 +615,11 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
if (m_ShellConstants.get(p, BUGBUG64TRUNCATE(int, pUserVarName-p)) >= 0) if (m_ShellConstants.get(p, BUGBUG64TRUNCATE(int, pUserVarName-p)) >= 0)
break; // Woops it's a shell constant break; // Woops it's a shell constant
// Jim Park: The following line could be a source of bugs for
// variables where one variable name is a prefix of another
// variable name. For example, if you are searching for
// variable 'UserVar', you can get 'UserVariable' instead.
// Suggest that we do:
// TCHAR varname[NSIS_MAX_STRLEN];
// _tcsncpy(varname, p, pUserVarName-p);
// int idxUserVar = m_UserVarNames.get(varname);
int idxUserVar = m_UserVarNames.get(p, BUGBUG64TRUNCATE(int, pUserVarName-p)); int idxUserVar = m_UserVarNames.get(p, BUGBUG64TRUNCATE(int, pUserVarName-p));
if (idxUserVar >= 0) if (idxUserVar >= 0)
{ {
// Well, using variables inside string formating doens't mean // Well, using variables inside string formating doens't mean
// using the variable, beacuse it will be always an empty string // using the variable, because it will be always an empty string
// which is also memory wasting // which is also memory wasting
// So the line below must be commented !?? // So the line below must be commented !??
//m_UserVarNames.inc_reference(idxUserVar); //m_UserVarNames.inc_reference(idxUserVar);
@ -702,16 +693,12 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
continue; // outermost while continue; // outermost while
else else
{ {
TCHAR tbuf[64]; TCHAR tbuf[64], cBracket = _T('\0');
TCHAR cBracket = _T('\0');
bool bDoWarning = true; bool bDoWarning = true;
if ( *p == _T('[') ) if ( *p == _T('[') ) cBracket = _T(']');
cBracket = _T(']'); else if ( *p == _T('(') ) cBracket = _T(')');
else if ( *p == _T('(') ) else if ( *p == _T('{') ) cBracket = _T('}');
cBracket = _T(')');
else if ( *p == _T('{') )
cBracket = _T('}');
my_strncpy(tbuf,p,COUNTOF(tbuf)); my_strncpy(tbuf,p,COUNTOF(tbuf));
@ -732,13 +719,10 @@ int CEXEBuild::preprocess_string(TCHAR *out, const TCHAR *in, WORD codepage/*=CP
} }
if ( bDoWarning ) if ( bDoWarning )
warning_fl(_T("unknown variable/constant \"%") NPRIs _T("\" detected, ignoring"),tbuf); warning_fl(_T("unknown variable/constant \"%") NPRIs _T("\" detected, ignoring"),tbuf);
i = _T('$'); // redundant since i is already '$' and has i = _T('$'); // redundant since i is already '$' and has not changed.
// not changed.
} }
} // block
} // else } // else
} // else if (i == _T('$')) } // else if (i == _T('$'))
*out++=(TCHAR)i; *out++=(TCHAR)i;
} // outside while } // outside while
*out=0; *out=0;