improved GetParant, GetParameters
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2918 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
f5046135d9
commit
624f7225f4
1 changed files with 47 additions and 42 deletions
|
@ -13,23 +13,25 @@
|
|||
\c ; Pop $R0
|
||||
\c ; ; at this point $R0 will equal "C:\Program Files\Directory"
|
||||
\c
|
||||
\c Function GetParent
|
||||
\c Exch $R0 ; old $R0 is on top of stack
|
||||
\c Push $R1
|
||||
\c Push $R2
|
||||
\c StrCpy $R1 -1
|
||||
\c loop:
|
||||
\c StrCpy $R2 $R0 1 $R1
|
||||
\c StrCmp $R2 "" exit
|
||||
\c StrCmp $R2 "\" exit
|
||||
\c IntOp $R1 $R1 - 1
|
||||
\c Goto loop
|
||||
\c exit:
|
||||
\c StrCpy $R0 $R0 $R1
|
||||
\c Pop $R2
|
||||
\c Pop $R1
|
||||
\c Exch $R0 ; put $R0 on top of stack, restore $R0 to original value
|
||||
\c FunctionEnd
|
||||
\c Function GetParent
|
||||
\c Exch $R0 ; old $R0 is on top of stack
|
||||
\c Push $R1
|
||||
\c Push $R2
|
||||
\c Push $R3
|
||||
\c StrLen $R3 $R0
|
||||
\c loop:
|
||||
\c IntOp $R1 $R1 - 1
|
||||
\c IntCmp $R1 -$R3 exit exit
|
||||
\c StrCpy $R2 $R0 1 $R1
|
||||
\c StrCmp $R2 "\" exit
|
||||
\c Goto loop
|
||||
\c exit:
|
||||
\c StrCpy $R0 $R0 $R1
|
||||
\c Pop $R3
|
||||
\c Pop $R2
|
||||
\c Pop $R1
|
||||
\c Exch $R0 ; put $R0 on top of stack, restore $R0 to original value
|
||||
\c FunctionEnd
|
||||
|
||||
\H{trimnewlines} Trim newlines
|
||||
|
||||
|
@ -67,30 +69,33 @@
|
|||
\c ; output, top of stack (replaces, with e.g. whatever)
|
||||
\c ; modifies no other variables.
|
||||
\c
|
||||
\c Function GetParameters
|
||||
\c Push $R0
|
||||
\c Push $R1
|
||||
\c Push $R2
|
||||
\c StrCpy $R0 $CMDLINE 1
|
||||
\c StrCpy $R1 '"'
|
||||
\c StrCpy $R2 1
|
||||
\c StrCmp $R0 '"' loop
|
||||
\c StrCpy $R1 ' ' ; we're scanning for a space instead of a quote
|
||||
\c loop:
|
||||
\c StrCpy $R0 $CMDLINE 1 $R2
|
||||
\c StrCmp $R0 $R1 loop2
|
||||
\c StrCmp $R0 "" loop2
|
||||
\c IntOp $R2 $R2 + 1
|
||||
\c Goto loop
|
||||
\c loop2:
|
||||
\c IntOp $R2 $R2 + 1
|
||||
\c StrCpy $R0 $CMDLINE 1 $R2
|
||||
\c StrCmp $R0 " " loop2
|
||||
\c StrCpy $R0 $CMDLINE "" $R2
|
||||
\c Pop $R2
|
||||
\c Pop $R1
|
||||
\c Exch $R0
|
||||
\c FunctionEnd
|
||||
\c Function GetParameters
|
||||
\c Push $R0
|
||||
\c Push $R1
|
||||
\c Push $R2
|
||||
\c Push $R3
|
||||
\c StrCpy $R0 $CMDLINE 1
|
||||
\c StrCpy $R1 '"'
|
||||
\c StrCpy $R2 1
|
||||
\c StrLen $R3 $CMDLINE
|
||||
\c StrCmp $R0 '"' loop
|
||||
\c StrCpy $R1 ' ' ; we're scanning for a space instead of a quote
|
||||
\c loop:
|
||||
\c StrCpy $R0 $CMDLINE 1 $R2
|
||||
\c StrCmp $R0 $R1 loop2
|
||||
\c StrCmp $R2 $R3 loop2
|
||||
\c IntOp $R2 $R2 + 1
|
||||
\c Goto loop
|
||||
\c loop2:
|
||||
\c IntOp $R2 $R2 + 1
|
||||
\c StrCpy $R0 $CMDLINE 1 $R2
|
||||
\c StrCmp $R0 " " loop2
|
||||
\c StrCpy $R0 $CMDLINE "" $R2
|
||||
\c Pop $R3
|
||||
\c Pop $R2
|
||||
\c Pop $R1
|
||||
\c Exch $R0
|
||||
\c FunctionEnd
|
||||
|
||||
\H{strstr} Search in a string
|
||||
|
||||
|
@ -568,7 +573,7 @@
|
|||
\c Pop $R0
|
||||
\c StrCmp $R0 "online" connected
|
||||
\c MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
|
||||
\c Quit ;Remove to make error not fatal
|
||||
\c Quit ;This will quit the installer. You might want to add your own error handling.
|
||||
\c
|
||||
\c noie3:
|
||||
\c
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue