Jim Park's Unicode NSIS merging - Step 1 : switch to TCHARs where relevant.
Compiler output is identical before & after this step git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/branches/wizou@6036 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
4e48722b63
commit
752d7d239a
209 changed files with 9698 additions and 7658 deletions
|
@ -12,13 +12,16 @@
|
|||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty.
|
||||
*
|
||||
* Unicode support by Jim Park -- 08/09/2007
|
||||
*/
|
||||
|
||||
#include "lineparse.h"
|
||||
#include "Platform.h"
|
||||
|
||||
#include "tchar.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
//#include "tstring.h"
|
||||
|
||||
LineParser::LineParser(bool bCommentBlock)
|
||||
{
|
||||
|
@ -43,7 +46,7 @@ bool LineParser::inCommentBlock()
|
|||
return m_incommentblock;
|
||||
}
|
||||
|
||||
int LineParser::parse(char *line, int ignore_escaping/*=0*/) // returns -1 on error
|
||||
int LineParser::parse(TCHAR *line, int ignore_escaping/*=0*/) // returns -1 on error
|
||||
{
|
||||
freetokens();
|
||||
bool bPrevCB=m_incommentblock;
|
||||
|
@ -52,7 +55,7 @@ int LineParser::parse(char *line, int ignore_escaping/*=0*/) // returns -1 on er
|
|||
if (m_nt)
|
||||
{
|
||||
m_incommentblock=bPrevCB;
|
||||
m_tokens=(char**)malloc(sizeof(char*)*m_nt);
|
||||
m_tokens=(TCHAR**)malloc(sizeof(TCHAR*)*m_nt);
|
||||
n=doline(line, ignore_escaping);
|
||||
if (n)
|
||||
{
|
||||
|
@ -83,15 +86,15 @@ double LineParser::gettoken_float(int token, int *success/*=0*/)
|
|||
}
|
||||
if (success)
|
||||
{
|
||||
char *t=m_tokens[token];
|
||||
TCHAR *t=m_tokens[token];
|
||||
*success=*t?1:0;
|
||||
while (*t)
|
||||
{
|
||||
if ((*t < '0' || *t > '9')&&*t != '.') *success=0;
|
||||
if ((*t < _T('0') || *t > _T('9'))&&*t != _T('.')) *success=0;
|
||||
t++;
|
||||
}
|
||||
}
|
||||
return atof(m_tokens[token]);
|
||||
return _tstof(m_tokens[token]);
|
||||
}
|
||||
|
||||
int LineParser::gettoken_int(int token, int *success/*=0*/)
|
||||
|
@ -102,29 +105,29 @@ int LineParser::gettoken_int(int token, int *success/*=0*/)
|
|||
if (success) *success=0;
|
||||
return 0;
|
||||
}
|
||||
char *tmp;
|
||||
TCHAR *tmp;
|
||||
int l;
|
||||
if (m_tokens[token][0] == '-') l=strtol(m_tokens[token],&tmp,0);
|
||||
else l=(int)strtoul(m_tokens[token],&tmp,0);
|
||||
if (m_tokens[token][0] == _T('-')) l=_tcstol(m_tokens[token],&tmp,0);
|
||||
else l=(int)_tcstoul(m_tokens[token],&tmp,0);
|
||||
if (success) *success=! (int)(*tmp);
|
||||
return l;
|
||||
}
|
||||
|
||||
char* LineParser::gettoken_str(int token)
|
||||
TCHAR* LineParser::gettoken_str(int token)
|
||||
{
|
||||
token+=m_eat;
|
||||
if (token < 0 || token >= m_nt) return (char*)"";
|
||||
if (token < 0 || token >= m_nt) return (TCHAR*)_T("");
|
||||
return m_tokens[token];
|
||||
}
|
||||
|
||||
int LineParser::gettoken_enum(int token, const char *strlist) // null seperated list
|
||||
int LineParser::gettoken_enum(int token, const TCHAR *strlist) // null seperated list
|
||||
{
|
||||
int x=0;
|
||||
char *tt=gettoken_str(token);
|
||||
TCHAR *tt=gettoken_str(token);
|
||||
if (tt && *tt) while (*strlist)
|
||||
{
|
||||
if (!stricmp(tt,strlist)) return x;
|
||||
strlist+=strlen(strlist)+1;
|
||||
strlist+=_tcsclen(strlist)+1;
|
||||
x++;
|
||||
}
|
||||
return -1;
|
||||
|
@ -143,22 +146,22 @@ void LineParser::freetokens()
|
|||
m_nt=0;
|
||||
}
|
||||
|
||||
int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
||||
int LineParser::doline(TCHAR *line, int ignore_escaping/*=0*/)
|
||||
{
|
||||
m_nt=0;
|
||||
m_incomment = false;
|
||||
while (*line == ' ' || *line == '\t') line++;
|
||||
while (*line == _T(' ') || *line == _T('\t')) line++;
|
||||
while (*line)
|
||||
{
|
||||
if ( m_incommentblock )
|
||||
{
|
||||
while ( *line )
|
||||
{
|
||||
if ( *line == '*' && *(line+1) == '/' )
|
||||
if ( *line == _T('*') && *(line+1) == _T('/') )
|
||||
{
|
||||
m_incommentblock=false; // Found end of comment block
|
||||
line+=2;
|
||||
while (*line == ' ' || *line == '\t') line++;
|
||||
while (*line == _T(' ') || *line == _T('\t')) line++;
|
||||
break;
|
||||
}
|
||||
else line++;
|
||||
|
@ -166,41 +169,41 @@ int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
|||
}
|
||||
else {
|
||||
int lstate=0; // 1=", 2=`, 4='
|
||||
if (*line == ';' || *line == '#')
|
||||
if (*line == _T(';') || *line == _T('#'))
|
||||
{
|
||||
m_incomment = true;
|
||||
break;
|
||||
}
|
||||
if (*line == '/' && *(line+1) == '*')
|
||||
if (*line == _T('/') && *(line+1) == _T('*'))
|
||||
{
|
||||
m_incommentblock = true;
|
||||
line+=2;
|
||||
}
|
||||
else {
|
||||
if (*line == '\"') lstate=1;
|
||||
else if (*line == '\'') lstate=2;
|
||||
else if (*line == '`') lstate=4;
|
||||
if (*line == _T('\"')) lstate=1;
|
||||
else if (*line == _T('\'')) lstate=2;
|
||||
else if (*line == _T('`')) lstate=4;
|
||||
if (lstate) line++;
|
||||
int nc=0;
|
||||
char *p = line;
|
||||
TCHAR *p = line;
|
||||
while (*line)
|
||||
{
|
||||
if (line[0] == '$' && line[1] == '\\') {
|
||||
if (line[0] == _T('$') && line[1] == _T('\\')) {
|
||||
switch (line[2]) {
|
||||
case '"':
|
||||
case '\'':
|
||||
case '`':
|
||||
case _T('"'):
|
||||
case _T('\''):
|
||||
case _T('`'):
|
||||
nc += ignore_escaping ? 3 : 1;
|
||||
line += 3;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (lstate==1 && *line =='\"') break;
|
||||
if (lstate==2 && *line =='\'') break;
|
||||
if (lstate==4 && *line =='`') break;
|
||||
if (!lstate && (*line == ' ' || *line == '\t')) break;
|
||||
if (lstate==1 && *line ==_T('\"')) break;
|
||||
if (lstate==2 && *line ==_T('\'')) break;
|
||||
if (lstate==4 && *line ==_T('`')) break;
|
||||
if (!lstate && (*line == _T(' ') || *line == _T('\t'))) break;
|
||||
#ifdef NSIS_FIX_COMMENT_HANDLING
|
||||
if (!lstate && (*line == ';' || *line == '#' || (*line == '/' && *(line+1) == '*'))) break;
|
||||
if (!lstate && (*line == _T(';') || *line == _T('#') || (*line == _T('/') && *(line+1) == _T('*')))) break;
|
||||
#endif
|
||||
line++;
|
||||
nc++;
|
||||
|
@ -208,13 +211,13 @@ int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
|||
if (m_tokens)
|
||||
{
|
||||
int i;
|
||||
m_tokens[m_nt]=(char*)malloc(nc+1);
|
||||
m_tokens[m_nt]=(TCHAR*)malloc((nc+1)*sizeof(TCHAR));
|
||||
for (i = 0; p < line; i++, p++) {
|
||||
if (!ignore_escaping && p[0] == '$' && p[1] == '\\') {
|
||||
if (!ignore_escaping && p[0] == _T('$') && p[1] == _T('\\')) {
|
||||
switch (p[2]) {
|
||||
case '"':
|
||||
case '\'':
|
||||
case '`':
|
||||
case _T('"'):
|
||||
case _T('\''):
|
||||
case _T('`'):
|
||||
p += 2;
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +231,7 @@ int LineParser::doline(char *line, int ignore_escaping/*=0*/)
|
|||
if (*line) line++;
|
||||
else return -2;
|
||||
}
|
||||
while (*line == ' ' || *line == '\t') line++;
|
||||
while (*line == _T(' ') || *line == _T('\t')) line++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue