From e8a03485701e33b737bbf942708bfcdf841acaac Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 13 Jul 2019 12:31:44 +0800 Subject: add trim --- scripts/installer.nsi | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'scripts') diff --git a/scripts/installer.nsi b/scripts/installer.nsi index c00918fe0..5a5598a29 100644 --- a/scripts/installer.nsi +++ b/scripts/installer.nsi @@ -147,6 +147,39 @@ VIAddVersionKey /LANG=0 ProductVersion ${VERSION_FULL} Var NOADMIN +Function TrimQuote + Exch $R1 ; Original string + Push $R2 + +Loop: + StrCpy $R2 "$R1" 1 + StrCmp "$R2" "$\"" TrimLeft + StrCmp "$R2" "$\r" TrimLeft + StrCmp "$R2" "$\n" TrimLeft + StrCmp "$R2" "$\t" TrimLeft + StrCmp "$R2" " " TrimLeft + GoTo Loop2 +TrimLeft: + StrCpy $R1 "$R1" "" 1 + Goto Loop + +Loop2: + StrCpy $R2 "$R1" 1 -1 + StrCmp "$R2" "$\"" TrimRight + StrCmp "$R2" "$\r" TrimRight + StrCmp "$R2" "$\n" TrimRight + StrCmp "$R2" "$\t" TrimRight + StrCmp "$R2" " " TrimRight + GoTo Done +TrimRight: + StrCpy $R1 "$R1" -1 + Goto Loop2 + +Done: + Pop $R2 + Exch $R1 +FunctionEnd + ; Installer Function .onInit ${GetOptions} $CMDLINE "/NOADMIN" $NOADMIN @@ -172,6 +205,11 @@ Function .onInit ${If} $InstDir == "" StrCpy $InstDir ${PROGRAMFILES}\xmake ${EndIf} + + Push $InstDir + Call TrimQuote + Pop $InstDir + FunctionEnd Section "XMake (required)" InstallExeutable -- cgit v1.3.1