Skip to content

Commit fec3124

Browse files
committed
printf() WARN fix for %argnum$ > 9
1 parent 4980fd9 commit fec3124

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Peachpie.CodeAnalysis/FlowAnalysis/Passes/DiagnosticWalker.Functions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal partial class DiagnosticWalker<T>
2222
/// Matches <c>printf()</c> format specifier.
2323
/// </summary>
2424
static readonly Lazy<Regex> s_printfSpecsRegex = new Lazy<Regex>(
25-
() => new Regex(@"%(?:(\d)+\$)?[+-]?(?:[ 0]|'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]", RegexOptions.Compiled | RegexOptions.CultureInvariant)
25+
() => new Regex(@"%(?:(\d+)\$)?[+-]?(?:[ 0]|'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]", RegexOptions.Compiled | RegexOptions.CultureInvariant)
2626
);
2727

2828
void printfCheck(string name, ImmutableArray<BoundArgument> arguments)
@@ -44,7 +44,7 @@ void printfCheck(string name, ImmutableArray<BoundArgument> arguments)
4444
else
4545
{
4646
// %2$d
47-
int numSpec = int.Parse(numSpecStr);
47+
int numSpec = int.Parse(numSpecStr); // > 0, starts from 1
4848
numSpecMax = Math.Max(numSpec, numSpecMax);
4949
}
5050
}

0 commit comments

Comments
 (0)