# HG changeset patch # User Wuzzy # Date 1687418030 -7200 # Node ID 4ad8dd66d9d5a43a964525661c4e3c6678a4192b # Parent 79b1129b4d03777583c237ca36f350e0365eec3d Fix pas2C build fail in uLocale diff -r 79b1129b4d03 -r 4ad8dd66d9d5 hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Mon Jun 19 14:09:37 2023 +0200 +++ b/hedgewars/uLocale.pas Thu Jun 22 09:13:50 2023 +0200 @@ -166,7 +166,7 @@ // Replace % sign in argument with ASCII ESC // to prevent infinite loop below. - curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]); + ReplaceChars(curArg, '%', Char($1B)); repeat p:= Pos('%'+IntToStr(i+1), tempstr); @@ -178,7 +178,7 @@ until (p = 0); end; -tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]); +ReplaceChars(tempstr, Char($1B), '%'); Format:= tempstr; end; @@ -204,7 +204,7 @@ // Replace % sign in argument with ASCII ESC // to prevent infinite loop below. - curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]); + ReplaceCharsA(curArg, '%', Char($1B)); repeat p:= Pos('%'+IntToStr(i+1), tempstr); @@ -216,7 +216,7 @@ until (p = 0); end; -tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]); +ReplaceCharsA(tempstr, Char($1B), '%'); FormatA:= tempstr; end; diff -r 79b1129b4d03 -r 4ad8dd66d9d5 hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Mon Jun 19 14:09:37 2023 +0200 +++ b/hedgewars/uUtils.pas Thu Jun 22 09:13:50 2023 +0200 @@ -34,6 +34,9 @@ procedure EscapeCharA(var a: ansistring; e: char); procedure UnEscapeCharA(var a: ansistring; e: char); +procedure ReplaceChars(var a: shortstring; c1, c2: char); +procedure ReplaceCharsA(var a: ansistring; c1, c2: char); + function ExtractFileDir(s: shortstring) : shortstring; function ExtractFileName(s: shortstring) : shortstring; @@ -304,6 +307,28 @@ until (i <= 0); end; { UnEscapeCharA } +// Replace all characters c1 with c2 in shortstring a +procedure ReplaceChars(var a: shortstring; c1, c2: char); +var i: LongInt; +begin +repeat + i:= Pos(c1, a); + if (i > 0) then + a[i]:= c2; +until (i <= 0); +end; { ReplaceChars } + +// Replace all characters c1 with c2 in antistring a +procedure ReplaceCharsA(var a: ansistring; c1, c2: char); +var i: LongInt; +begin +repeat + i:= Pos(c1, a); + if (i > 0) then + a[i]:= c2; +until (i <= 0); +end; { ReplaceCharsA } + function EnumToStr(const en : TGearType) : shortstring; overload; begin EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en))