!define lines will keep escaping as they are

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1903 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-12-06 14:18:18 +00:00
parent 2211407ccf
commit 93505a844c
2 changed files with 8 additions and 8 deletions

View file

@ -15,15 +15,15 @@ class LineParser {
freetokens(); freetokens();
} }
int parse(char *line) // returns -1 on error int parse(char *line, int ignore_escaping=0) // returns -1 on error
{ {
freetokens(); freetokens();
int n=doline(line); int n=doline(line, ignore_escaping);
if (n) return n; if (n) return n;
if (m_nt) if (m_nt)
{ {
m_tokens=(char**)malloc(sizeof(char*)*m_nt); m_tokens=(char**)malloc(sizeof(char*)*m_nt);
n=doline(line); n=doline(line, ignore_escaping);
if (n) if (n)
{ {
freetokens(); freetokens();
@ -104,7 +104,7 @@ class LineParser {
m_nt=0; m_nt=0;
} }
int doline(char *line) int doline(char *line, int ignore_escaping=0)
{ {
m_nt=0; m_nt=0;
while (*line == ' ' || *line == '\t') line++; while (*line == ' ' || *line == '\t') line++;
@ -125,8 +125,9 @@ class LineParser {
case '"': case '"':
case '\'': case '\'':
case '`': case '`':
nc += 1; nc += ignore_escaping ? 3 : 1;
line += 3; line += 3;
continue;
} }
} }
if (lstate==1 && *line =='\"') break; if (lstate==1 && *line =='\"') break;
@ -141,7 +142,7 @@ class LineParser {
int i; int i;
m_tokens[m_nt]=(char*)malloc(nc+1); m_tokens[m_nt]=(char*)malloc(nc+1);
for (i = 0; p < line; i++, p++) { for (i = 0; p < line; i++, p++) {
if (p[0] == '$' && p[1] == '\\') { if (!ignore_escaping && p[0] == '$' && p[1] == '\\') {
switch (p[2]) { switch (p[2]) {
case '"': case '"':
case '\'': case '\'':
@ -151,7 +152,6 @@ class LineParser {
} }
m_tokens[m_nt][i] = *p; m_tokens[m_nt][i] = *p;
} }
//strncpy(m_tokens[m_nt],line-nc,nc);
m_tokens[m_nt][nc]=0; m_tokens[m_nt][nc]=0;
} }
m_nt++; m_nt++;

View file

@ -66,7 +66,7 @@ int CEXEBuild::doParse(const char *str, FILE *fp, const char *curfilename, int *
// remove trailing slash and null // remove trailing slash and null
if (str[0] && CharPrev(str,str+strlen(str))[0] == '\\') return PS_OK; if (str[0] && CharPrev(str,str+strlen(str))[0] == '\\') return PS_OK;
res=line.parse((char*)m_linebuild.get()); res=line.parse((char*)m_linebuild.get(),!strnicmp(str,"!define",7));
m_linebuild.resize(0); m_linebuild.resize(0);