From 4d889381ca50725886ead024fa75fd2bcb4bc2e6 Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 27 Feb 2004 14:13:08 +0000 Subject: [PATCH] only append the last part of the path specified using InstallDir if it is not also the first git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3504 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/script.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/script.cpp b/Source/script.cpp index c6593a75..ed156b31 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -1841,14 +1841,16 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) } build_header.install_directory_ptr = add_string(p); build_header.install_directory_auto_append = 0; - if (*p && *CharPrev(p, p + strlen(p)) != '\\') + char *p2 = p + strlen(p); + if (*p && *CharPrev(p, p2) != '\\') { - p = build_strlist.get() + build_header.install_directory_ptr; - char *p2 = p + strlen(p); - while (p2 >= p && *CharPrev(p, p2) != '\\') p2--;; - if (p2) + // we risk hitting $\r or something like $(bla\ad) or ${bla\ad} here, but it's better + // than hitting backslashes in processed strings + while (p2 > p && *p2 != '\\') + p2 = CharPrev(p, p2); + if (*p2 == '\\') { - build_header.install_directory_auto_append = build_header.install_directory_ptr + (p2 - p); + build_header.install_directory_auto_append = add_string(p2 + 1); } } SCRIPT_MSG("InstallDir: \"%s\"\n",line.gettoken_str(1));