From 52c0cd1ee199b9ee30adafaa7e034d9e02055278 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 2 Oct 2007 10:18:25 +0000 Subject: fixed bug in StringReplaceW... oops :) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@463 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UCommon.pas | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'Game/Code/Classes/UCommon.pas') 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; -- cgit v1.2.3