/[cvs]/joko/ToolBox/Windows/VpnDial-installer/string_functions.nsi
ViewVC logotype

Annotation of /joko/ToolBox/Windows/VpnDial-installer/string_functions.nsi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue Nov 22 17:05:07 2005 UTC (18 years, 7 months ago) by janosch
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +98 -98 lines
dos2unix

1 janosch 1.2 !include "LogicLib.nsh"
2    
3     ; from: http://nsis.sourceforge.net/StrRep
4     !define StrRep "!insertmacro StrRep"
5    
6     !macro StrRep ResultVar String SubString RepString
7     Push "${String}"
8     Push "${SubString}"
9     Push "${RepString}"
10     Call StrRep
11     Pop "${ResultVar}"
12     !macroend
13    
14     Function StrRep
15     /*After this point:
16     ------------------------------------------
17     $R0 = RepString (input)
18     $R1 = SubString (input)
19     $R2 = String (input)
20     $R3 = RepStrLen (temp)
21     $R4 = SubStrLen (temp)
22     $R5 = StrLen (temp)
23     $R6 = StartCharPos (temp)
24     $R7 = TempStrL (temp)
25     $R8 = TempStrR (temp)*/
26    
27     ;Get input from user
28     Exch $R0
29     Exch
30     Exch $R1
31     Exch
32     Exch 2
33     Exch $R2
34     Push $R3
35     Push $R4
36     Push $R5
37     Push $R6
38     Push $R7
39     Push $R8
40    
41     ;Return "String" if "SubString" is ""
42     ${IfThen} $R1 == "" ${|} Goto Done ${|}
43    
44     ;Get "RepString", "String" and "SubString" length
45     StrLen $R3 $R0
46     StrLen $R4 $R1
47     StrLen $R5 $R2
48     ;Start "StartCharPos" counter
49     StrCpy $R6 0
50    
51     ;Loop until "SubString" is found or "String" reaches its end
52     ${Do}
53     ;Remove everything before and after the searched part ("TempStrL")
54     StrCpy $R7 $R2 $R4 $R6
55    
56     ;Compare "TempStrL" with "SubString"
57     ${If} $R7 == $R1
58     ;Split "String" to replace the string wanted
59     StrCpy $R7 $R2 $R6 ;TempStrL
60    
61     ;Calc: "StartCharPos" + "SubStrLen" = EndCharPos
62     IntOp $R8 $R6 + $R4
63    
64     StrCpy $R8 $R2 "" $R8 ;TempStrR
65    
66     ;Insert the new string between the two separated parts of "String"
67     StrCpy $R2 $R7$R0$R8
68     ;Now calculate the new "StrLen" and "StartCharPos"
69     StrLen $R5 $R2
70     IntOp $R6 $R6 + $R3
71     ${Continue}
72     ${EndIf}
73    
74     ;If not "SubString", this could be "String" end
75     ${IfThen} $R6 >= $R5 ${|} ${ExitDo} ${|}
76     ;If not, continue the loop
77     IntOp $R6 $R6 + 1
78     ${Loop}
79    
80     Done:
81    
82     ;Return output to user
83     StrCpy $R0 $R2
84    
85     /*After this point:
86     ------------------------------------------
87     $R0 = ResultVar (output)*/
88    
89     Pop $R8
90     Pop $R7
91     Pop $R6
92     Pop $R5
93     Pop $R4
94     Pop $R3
95     Pop $R2
96     Pop $R1
97     Exch $R0
98     FunctionEnd

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed