From f7c1f0a43d24b4ce15f40640b3162a30c0b33665 Mon Sep 17 00:00:00 2001 From: ramon18 Date: Sat, 19 Jul 2003 00:39:03 +0000 Subject: [PATCH] Uservars names not found in strings when names are very similar. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2751 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/build.cpp | 3 --- Source/strlist.h | 8 +++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/build.cpp b/Source/build.cpp index 0075124c..6761fb68 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -539,10 +539,7 @@ int CEXEBuild::preprocess_string(char *out, const char *in) while ( pUserVarName > p ) { - char b = ((char*)p)[pUserVarName-p]; - ((char*)p)[pUserVarName-p] = 0; int idxUserVar = m_UserVarNames.get((char*)p, pUserVarName-p); - ((char*)p)[pUserVarName-p] = b; if ( idxUserVar >= 0 ) { // Well, using variables inside string formating doens't mean diff --git a/Source/strlist.h b/Source/strlist.h index 6f3d7a7f..294895e1 100644 --- a/Source/strlist.h +++ b/Source/strlist.h @@ -304,7 +304,7 @@ class SortedStringListND // no delete - can be placed in GrowBuf { int res; const char *pCurr = (char*)strings.get() + data[nextpos].name; - if (n_chars == -1 || n_chars != strlen(pCurr) ) + if (n_chars == -1 ) { if (case_sensitive) res=strcmp(str, pCurr); @@ -314,9 +314,11 @@ class SortedStringListND // no delete - can be placed in GrowBuf else { if (case_sensitive) - res=strncmp(str, pCurr, n_chars); + res=strncmp(str, pCurr, min(n_chars, strlen(pCurr))); else - res=strnicmp(str, pCurr, n_chars); + res=strnicmp(str, pCurr, min(n_chars, strlen(pCurr))); + if ( res == 0 && n_chars != -1 && n_chars != strlen(pCurr) ) + res = n_chars - strlen(pCurr); } if (res==0)