diff options
author | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-10-02 10:18:25 +0000 |
---|---|---|
committer | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-10-02 10:18:25 +0000 |
commit | 52c0cd1ee199b9ee30adafaa7e034d9e02055278 (patch) | |
tree | cb6d3e37e912bd44961739fea578524081802dd9 | |
parent | b50f5d910e081bc1dd6925e84874d97b7de46d9c (diff) | |
download | usdx-52c0cd1ee199b9ee30adafaa7e034d9e02055278.tar.gz usdx-52c0cd1ee199b9ee30adafaa7e034d9e02055278.tar.xz usdx-52c0cd1ee199b9ee30adafaa7e034d9e02055278.zip |
fixed bug in StringReplaceW...
oops :)
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@463 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r-- | Game/Code/Classes/UCommon.pas | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Game/Code/Classes/UCommon.pas b/Game/Code/Classes/UCommon.pas index 5b911da0..af9ae82d 100644 --- a/Game/Code/Classes/UCommon.pas +++ b/Game/Code/Classes/UCommon.pas @@ -46,7 +46,7 @@ procedure DeallocateHWnd(Wnd: HWND); {$ENDIF} // FPC Only -function StringReplaceW(text, search, rep: WideString):WideString; +function StringReplaceW(text : WideString; search, rep: WideChar):WideString; function AdaptFilePaths( const aPath : widestring ): widestring; @@ -60,18 +60,30 @@ function AdaptFilePaths( const aPath : widestring ): widestring; implementation -function StringReplaceW(text, search, rep: WideString):WideString; +function StringReplaceW(text : WideString; search, rep: WideChar):WideString; var iPos : integer; - sTemp : WideString; +// sTemp : WideString; begin +(* result := text; iPos := Pos(search, result); while (iPos > 0) do begin - sTEmp := copy(result, iPos + length(search), length(result)); + sTemp := copy(result, iPos + length(search), length(result)); result := copy(result, 1, iPos - 1) + rep + sTEmp; - iPos := Pos(search, result); + iPos := Pos(search, result); + end; +*) + result := text; + + if search = rep then + exit; + + for iPos := 0 to length( result ) - 1 do + begin + if result[ iPos ] = search then + result[ iPos ] := rep; end; end; |