From 6577ff4f14728a0e6f5698caf4aefe29800a2edf Mon Sep 17 00:00:00 2001 From: kichik Date: Fri, 10 Oct 2008 20:57:08 +0000 Subject: [PATCH] fixed bug #2067946 - GetParameters returns an incorrect result in some situation. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5748 212acab6-be3b-0410-9dea-997c60f758d6 --- Include/FileFunc.nsh | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/Include/FileFunc.nsh b/Include/FileFunc.nsh index 745d1e10..ff649a7f 100644 --- a/Include/FileFunc.nsh +++ b/Include/FileFunc.nsh @@ -1410,33 +1410,51 @@ RefreshShellIcons !define ${_FILEFUNC_UN}GetParameters `!insertmacro ${_FILEFUNC_UN}GetParametersCall` Function ${_FILEFUNC_UN}GetParameters - Push $0 - Push $1 - Push $2 + ;cmdline-check + StrCmp $CMDLINE "" 0 +3 + Push "" + Return - StrCpy $1 1 - StrCpy $0 $CMDLINE 1 - StrCmp $0 '"' 0 +3 - StrCpy $2 '"' - goto +2 - StrCpy $2 ' ' + ;vars + Push $0 ;tmp + Push $1 ;length + Push $2 ;parameter offset + Push $3 ;separator - IntOp $1 $1 + 1 - StrCpy $0 $CMDLINE 1 $1 - StrCmp $0 $2 +2 - StrCmp $0 '' end -3 + ;length/offset + StrLen $1 $CMDLINE + StrCpy $2 2 ;start with third character - IntOp $1 $1 + 1 - StrCpy $0 $CMDLINE 1 $1 - StrCmp $0 ' ' -2 - StrCpy $0 $CMDLINE '' $1 + ;separator + StrCpy $3 $CMDLINE 1 ;first character + StrCmp $3 '"' +2 + StrCpy $3 ' ' + token: ;finding second separator + IntCmp $2 $1 strip 0 strip + StrCpy $0 $CMDLINE 1 $2 + IntOp $2 $2 + 1 + StrCmp $3 $0 0 token + + strip: ;strip white space + IntCmp $2 $1 copy 0 copy + StrCpy $0 $CMDLINE 1 $2 + StrCmp $0 ' ' 0 copy + IntOp $2 $2 + 1 + Goto strip + + copy: + StrCpy $0 $CMDLINE "" $2 + + ;strip white spaces from end + rstrip: StrCpy $1 $0 1 -1 - StrCmp $1 ' ' 0 +3 + StrCmp $1 ' ' 0 done StrCpy $0 $0 -1 - goto -3 + Goto rstrip - end: + done: + Pop $3 Pop $2 Pop $1 Exch $0