From 4ca1f6d04b36033cfb1cc9d7f17cdbc88ff48ec4 Mon Sep 17 00:00:00 2001 From: kichik Date: Sat, 9 Dec 2006 13:08:05 +0000 Subject: [PATCH] some CEXEBuild::doParse cleanup - removed last_line_had_slash which was always set to zero - moved m_linebuild.resize(0) so it won't free the memory the next condition uses, though the line needs to be 64kb for that to happen - took care of a coupple of comments git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4842 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/script.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/script.cpp b/Source/script.cpp index 2199e2cd..5cc8d78c 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -279,31 +279,34 @@ int CEXEBuild::doParse(const char *str) while (*str == ' ' || *str == '\t') str++; - if (m_linebuild.getlen()>1) m_linebuild.resize(m_linebuild.getlen()-2); + // remove trailing slash and null, if there's a previous line + if (m_linebuild.getlen()>1) + m_linebuild.resize(m_linebuild.getlen()-2); m_linebuild.add(str,strlen(str)+1); - // remove trailing slash and null - if (str[0] && CharPrev(str,str+strlen(str))[0] == '\\') { - last_line_had_slash = 1; + // keep waiting for more lines, if this line ends with a backslash + if (str[0] && CharPrev(str,str+strlen(str))[0] == '\\') return PS_OK; - } - else last_line_had_slash = 0; + // parse before checking if the line should be ignored, so block comments won't be missed res=line.parse((char*)m_linebuild.get(),!strnicmp((char*)m_linebuild.get(),"!define",7)); inside_comment = line.InCommentBlock(); - m_linebuild.resize(0); - // if ignoring, ignore all lines that don't begin with an exclamation mark { bool ignore_line = cur_ifblock && (cur_ifblock->ignore || cur_ifblock->inherited_ignore); char first_char = *(char *) m_linebuild.get(); - if (ignore_line && first_char!='!' && !last_line_had_slash) + if (ignore_line && first_char!='!') + { + m_linebuild.resize(0); return PS_OK; + } } + m_linebuild.resize(0); + if (res) { if (res==-2) ERROR_MSG("Error: unterminated string parsing line at %s:%d\n",curfilename,linecnt);