Fixed POSIX !searchparse bug (patch #251) and hopefully better compatibility with 2.46
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6485 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
881fa61896
commit
0bcb8f40ed
7 changed files with 31 additions and 49 deletions
|
@ -6,6 +6,10 @@ Released on ?, 2014
|
||||||
|
|
||||||
\S1{v3.0b1-cl} Changelog
|
\S1{v3.0b1-cl} Changelog
|
||||||
|
|
||||||
|
\S2{} Minor Changes
|
||||||
|
|
||||||
|
\b Fixed POSIX !searchparse bug (\W{http://sf.net/p/nsis/patches/251}{patch #251})
|
||||||
|
|
||||||
\S2{} Translations
|
\S2{} Translations
|
||||||
|
|
||||||
\b Added Armenian (Hrant Ohanyan)
|
\b Added Armenian (Hrant Ohanyan)
|
||||||
|
|
|
@ -848,7 +848,7 @@ static void CreatePlatformStrfmt(const TCHAR *templ, TCHAR *out) {
|
||||||
if (*out == L'%' && *templ == L's')
|
if (*out == L'%' && *templ == L's')
|
||||||
{
|
{
|
||||||
out++, templ++;
|
out++, templ++;
|
||||||
unsigned int cch = my_strncpy(out, NPRIs, -1);
|
size_t cch = my_strncpy(out, NPRIs, -1);
|
||||||
out += --cch; // --cch because for loop does out++
|
out += --cch; // --cch because for loop does out++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3470,13 +3470,8 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<list->getnum(); i ++)
|
for (i=0;i<list->getnum(); i ++)
|
||||||
{
|
{
|
||||||
TCHAR *def=list->getname(i);
|
TCHAR *def=list->getname(i), *val=list->getvalue(i);
|
||||||
TCHAR *val=list->getvalue(i);
|
if (def && val) definedlist.set(def,val);
|
||||||
if (def && val)
|
|
||||||
{
|
|
||||||
if (definedlist.find(def)) definedlist.del(def);
|
|
||||||
definedlist.add(def,val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete list;
|
delete list;
|
||||||
|
@ -6791,6 +6786,7 @@ int CEXEBuild::do_add_file_create_dir(const tstring& local_dir, const tstring& d
|
||||||
|
|
||||||
DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&line, int parmOffs, bool ignCase, bool noErrors, UINT*failParam)
|
DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&line, int parmOffs, bool ignCase, bool noErrors, UINT*failParam)
|
||||||
{
|
{
|
||||||
|
const bool allowEmptyFirstTok = true;
|
||||||
if (failParam) *failParam = 0;
|
if (failParam) *failParam = 0;
|
||||||
DefineList *ret = NULL;
|
DefineList *ret = NULL;
|
||||||
const TCHAR *defout = 0, *src_start = 0, *tok;
|
const TCHAR *defout = 0, *src_start = 0, *tok;
|
||||||
|
@ -6799,7 +6795,7 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&
|
||||||
{
|
{
|
||||||
tok = line.gettoken_str(parmOffs++);
|
tok = line.gettoken_str(parmOffs++);
|
||||||
const bool lasttoken = parmOffs > line.getnumtokens();
|
const bool lasttoken = parmOffs > line.getnumtokens();
|
||||||
if (!tok || !*tok)
|
if (!*tok)
|
||||||
tok = 0, maxlen = -1; // No more tokens to search for, save the rest of the string
|
tok = 0, maxlen = -1; // No more tokens to search for, save the rest of the string
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -6813,17 +6809,10 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&
|
||||||
if (maxlen < 0)
|
if (maxlen < 0)
|
||||||
ret->add(defout,src_start);
|
ret->add(defout,src_start);
|
||||||
else
|
else
|
||||||
{
|
ret->addn(defout,maxlen,src_start);
|
||||||
TCHAR *p = _tcsdup(src_start);
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
p[maxlen] = 0;
|
|
||||||
ret->add(defout,p);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!*source_string || (!tok && !lasttoken)) // We did not find the requested token!
|
if (!tok && lasttoken) break;
|
||||||
|
if (!*source_string || (allowEmptyFirstTok ? false : !tok)) // We did not find the requested token!
|
||||||
{
|
{
|
||||||
if (failParam) *failParam = ret ? ret->getnum() : 0;
|
if (failParam) *failParam = ret ? ret->getnum() : 0;
|
||||||
if (noErrors) break; // Caller is OK with a incomplete list of matched strings
|
if (noErrors) break; // Caller is OK with a incomplete list of matched strings
|
||||||
|
@ -6832,7 +6821,6 @@ DefineList *CEXEBuild::searchParseString(const TCHAR *source_string, LineParser&
|
||||||
delete ret;
|
delete ret;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (maxlen < 0) break;
|
|
||||||
defout = line.gettoken_str(parmOffs++), src_start = source_string += toklen;
|
defout = line.gettoken_str(parmOffs++), src_start = source_string += toklen;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
|
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
#include "utf.h"
|
#include "utf.h"
|
||||||
#ifndef NDEBUG
|
|
||||||
#include "util.h" // For PrintColorFmtMsg_ERR
|
#include "util.h" // For PrintColorFmtMsg_ERR
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
char* convert_processed_string_to_ansi(char *out, const TCHAR *in, WORD codepage); // defined in build.cpp
|
char* convert_processed_string_to_ansi(char *out, const TCHAR *in, WORD codepage); // defined in build.cpp
|
||||||
|
@ -300,38 +298,37 @@ DefineList::~DefineList()
|
||||||
struct define *s=(struct define*) m_gr.get();
|
struct define *s=(struct define*) m_gr.get();
|
||||||
int num=m_gr.getlen()/sizeof(struct define);
|
int num=m_gr.getlen()/sizeof(struct define);
|
||||||
|
|
||||||
for (int i=0; i<num; i++) {
|
for (int i=0; i<num; i++) free(s[i].value);
|
||||||
free(s[i].value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefineList::add(const TCHAR *name, const TCHAR *value/*=_T("")*/)
|
int DefineList::addn(const TCHAR *name, size_t maxvallen, const TCHAR *value)
|
||||||
{
|
{
|
||||||
int pos=SortedStringList<struct define>::add(name);
|
int pos=SortedStringList<struct define>::add(name);
|
||||||
if (pos == -1)
|
if (pos == -1) return 1;
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
size_t cbVal = ++maxvallen * sizeof(TCHAR);
|
||||||
TCHAR **newvalue=&(((struct define*) m_gr.get())[pos].value);
|
TCHAR **newvalue=&(((struct define*) m_gr.get())[pos].value);
|
||||||
size_t size_in_bytes = (_tcslen(value) + 1) * sizeof(TCHAR);
|
|
||||||
|
|
||||||
*newvalue=(TCHAR*)malloc(size_in_bytes);
|
|
||||||
|
|
||||||
|
*newvalue = (TCHAR*)malloc(cbVal);
|
||||||
if (!(*newvalue))
|
if (!(*newvalue))
|
||||||
{
|
{
|
||||||
extern int g_display_errors;
|
extern int g_display_errors;
|
||||||
extern void quit();
|
extern void quit();
|
||||||
if (g_display_errors)
|
if (g_display_errors)
|
||||||
{
|
{
|
||||||
PrintColorFmtMsg_ERR(_T("\nInternal compiler error #12345: DefineList malloc(%lu) failed.\n"), (unsigned long) size_in_bytes);
|
PrintColorFmtMsg_ERR(_T("\nInternal compiler error #12345: DefineList malloc(%lu) failed.\n"), BUGBUG64TRUNCATE(unsigned long,cbVal));
|
||||||
}
|
}
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
_tcscpy(*newvalue,value);
|
my_strncpy(*newvalue, value, maxvallen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DefineList::add(const TCHAR *name, const TCHAR *value/*=_T("")*/)
|
||||||
|
{
|
||||||
|
return addn(name, _tcslen(value), value);
|
||||||
|
}
|
||||||
|
|
||||||
void DefineList::set(const TCHAR *name, const TCHAR *value/*=_T("")*/)
|
void DefineList::set(const TCHAR *name, const TCHAR *value/*=_T("")*/)
|
||||||
{
|
{
|
||||||
del(name);
|
del(name);
|
||||||
|
|
|
@ -476,6 +476,7 @@ class DefineList : public SortedStringList<struct define>
|
||||||
* general program exit with error logging.
|
* general program exit with error logging.
|
||||||
*/
|
*/
|
||||||
int add(const TCHAR *name, const TCHAR *value=_T(""));
|
int add(const TCHAR *name, const TCHAR *value=_T(""));
|
||||||
|
int addn(const TCHAR *name, size_t maxvallen, const TCHAR *value); // maxvallen does not include \0
|
||||||
void set(const TCHAR *name, const TCHAR *value=_T(""));
|
void set(const TCHAR *name, const TCHAR *value=_T(""));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,21 +67,13 @@ double my_wtof(const wchar_t *str)
|
||||||
return atof(buf);
|
return atof(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int my_strncpy(TCHAR*Dest, const TCHAR*Src, unsigned int cchMax)
|
size_t my_strncpy(TCHAR*Dest, const TCHAR*Src, size_t cchMax)
|
||||||
{
|
{
|
||||||
// Dest and Src must be valid, Dest is always \0 terminated.
|
// Dest and Src must be valid, Dest is always \0 terminated.
|
||||||
// Returns number of TCHARs copied to Dest; min(strlen(Src),cchMax-1).
|
// Returns number of TCHARs copied to Dest (not counting \0); min(strlen(Src),cchMax-1).
|
||||||
unsigned int cch = 0;
|
size_t cch = 0;
|
||||||
if (cchMax)
|
if (cchMax) for (TCHAR c; --cchMax;) if (!(c = Src[cch])) break; else Dest[cch++] = c;
|
||||||
{
|
Dest[cch] = _T('\0');
|
||||||
for(;--cchMax;)
|
|
||||||
{
|
|
||||||
TCHAR ch = Src[cch];
|
|
||||||
if (!ch) break;
|
|
||||||
Dest[cch++] = ch;
|
|
||||||
}
|
|
||||||
Dest[cch] = _T('\0');
|
|
||||||
}
|
|
||||||
return cch;
|
return cch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
extern double my_wtof(const wchar_t *str);
|
extern double my_wtof(const wchar_t *str);
|
||||||
extern unsigned int my_strncpy(TCHAR*Dest, const TCHAR*Src, unsigned int cchMax);
|
extern size_t my_strncpy(TCHAR*Dest, const TCHAR*Src, size_t cchMax);
|
||||||
size_t my_strftime(TCHAR *s, size_t max, const TCHAR *fmt, const struct tm *tm);
|
size_t my_strftime(TCHAR *s, size_t max, const TCHAR *fmt, const struct tm *tm);
|
||||||
|
|
||||||
// Adds the bitmap in filename using resource editor re as id id.
|
// Adds the bitmap in filename using resource editor re as id id.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue