hedgewars/uLocale.pas
changeset 15960 79b1129b4d03
parent 14861 acb0526bf458
child 15961 4ad8dd66d9d5
equal deleted inserted replaced
15959:723be7e392e5 15960:79b1129b4d03
   162             6: curArg:= arg7;
   162             6: curArg:= arg7;
   163             7: curArg:= arg8;
   163             7: curArg:= arg8;
   164             8: curArg:= arg9;
   164             8: curArg:= arg9;
   165         end;
   165         end;
   166 
   166 
       
   167         // Replace % sign in argument with ASCII ESC
       
   168         // to prevent infinite loop below.
       
   169         curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]);
       
   170 
   167         repeat
   171         repeat
   168         p:= Pos('%'+IntToStr(i+1), tempstr);
   172         p:= Pos('%'+IntToStr(i+1), tempstr);
   169         if (p <> 0) then
   173         if (p <> 0) then
   170             begin
   174             begin
   171             delete(tempstr, p, 2);
   175             delete(tempstr, p, 2);
   172             insert(curArg, tempstr, p);
   176             insert(curArg, tempstr, p);
   173             end;
   177             end;
   174         until (p = 0);
   178         until (p = 0);
   175     end;
   179     end;
       
   180 
       
   181 tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]);
   176 Format:= tempstr;
   182 Format:= tempstr;
   177 end;
   183 end;
   178 
   184 
   179 // Same as Format, but for ansistring
   185 // Same as Format, but for ansistring
   180 function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring; argCount: Byte): ansistring;
   186 function FormatA(fmt: ansistring; arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9: ansistring; argCount: Byte): ansistring;
   194             6: curArg:= arg7;
   200             6: curArg:= arg7;
   195             7: curArg:= arg8;
   201             7: curArg:= arg8;
   196             8: curArg:= arg9;
   202             8: curArg:= arg9;
   197         end;
   203         end;
   198 
   204 
       
   205         // Replace % sign in argument with ASCII ESC
       
   206         // to prevent infinite loop below.
       
   207         curArg:= StringReplace(curArg, '%', Char($1B), [rfReplaceAll]);
       
   208 
   199         repeat
   209         repeat
   200         p:= Pos('%'+IntToStr(i+1), tempstr);
   210         p:= Pos('%'+IntToStr(i+1), tempstr);
   201         if (p <> 0) then
   211         if (p <> 0) then
   202             begin
   212             begin
   203             delete(tempstr, p, 2);
   213             delete(tempstr, p, 2);
   204             insert(curArg, tempstr, p);
   214             insert(curArg, tempstr, p);
   205             end;
   215             end;
   206         until (p = 0);
   216         until (p = 0);
   207     end;
   217     end;
       
   218 
       
   219 tempstr:= StringReplace(tempstr, Char($1B), '%', [rfReplaceAll]);
   208 FormatA:= tempstr;
   220 FormatA:= tempstr;
   209 end;
   221 end;
   210 
   222 
   211 // The following functions are just shortcuts of Format/FormatA, with fewer argument counts
   223 // The following functions are just shortcuts of Format/FormatA, with fewer argument counts
   212 function Format(fmt: shortstring; arg1: shortstring): shortstring;
   224 function Format(fmt: shortstring; arg1: shortstring): shortstring;