From 624f7225f49cdf3ac2e92bde7be3df21bbd496ea Mon Sep 17 00:00:00 2001 From: joostverburg Date: Mon, 15 Sep 2003 19:18:18 +0000 Subject: [PATCH] improved GetParant, GetParameters git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2918 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/usefulfunc.but | 89 ++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/Docs/src/usefulfunc.but b/Docs/src/usefulfunc.but index 411029b0..694ef664 100644 --- a/Docs/src/usefulfunc.but +++ b/Docs/src/usefulfunc.but @@ -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