fix #1067
This commit is contained in:
parent
e7bac00673
commit
96e1454511
|
|
@ -431,7 +431,12 @@ namespace GPPGParserScanner
|
|||
while (match.Success)
|
||||
{
|
||||
string s = match.Value.Replace("{", "").Replace("}", "");
|
||||
int colon_pos = s.IndexOf(':');
|
||||
int colon_pos = s.LastIndexOf(':');
|
||||
int comma_pos = s.LastIndexOf(',');
|
||||
int bracket_pos = s.LastIndexOf(')');
|
||||
int sqbracked_pos = s.LastIndexOf(']');
|
||||
if (comma_pos != -1 && comma_pos > bracket_pos && comma_pos > sqbracked_pos)
|
||||
colon_pos = comma_pos;
|
||||
if (colon_pos != -1 && s.IndexOf('?') == -1)
|
||||
{
|
||||
var_formats.Add(ind, s.Substring(colon_pos));
|
||||
|
|
|
|||
28
TestSuite/formatstring6.pas
Normal file
28
TestSuite/formatstring6.pas
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
begin
|
||||
var a := 3.1;
|
||||
var s := $'{a,6:F2}';
|
||||
var s2 := string.Format('{0,6:F2}',a);
|
||||
assert(s = s2);
|
||||
s := $'{a,-10}';
|
||||
s2 := string.Format('{0,-10}', a);
|
||||
assert(s = s2);
|
||||
s := $'a is {a,6:N2}';
|
||||
s2 := string.Format('a is {0,6:N2}',a);
|
||||
assert(s = s2);
|
||||
s := $'{Min(2,3),-5:F2}';
|
||||
s2 := string.Format('{0,-5:F2}', Min(2,3));
|
||||
assert(s = s2);
|
||||
s := $'{Min(2,3):F2}';
|
||||
s2 := string.Format('{0:F2}', Min(2,3));
|
||||
assert(s = s2);
|
||||
var arr1 := Arr(1,2,3);
|
||||
s := $'{arr1[2],-5:F2}';
|
||||
s2 := string.Format('{0,-5:F2}', arr1[2]);
|
||||
var arr2 := new integer[2,2];
|
||||
s := $'{arr2[0,0],-5:F2}';
|
||||
s2 := string.Format('{0,-5:F2}', arr2[0,0]);
|
||||
assert(s = s2);
|
||||
s := $'{arr2[0,0]}';
|
||||
s2 := string.Format('{0}', arr2[0,0]);
|
||||
assert(s = s2);
|
||||
end.
|
||||
Loading…
Reference in a new issue