Fix pas2C build fail in uLocale
authorWuzzy <Wuzzy@disroot.org>
Thu, 22 Jun 2023 09:13:50 +0200
changeset 15991 4ad8dd66d9d5
parent 15990 79b1129b4d03
child 15992 4013354585be
Fix pas2C build fail in uLocale
hedgewars/uLocale.pas
hedgewars/uUtils.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;
 
--- 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))