Skip to content

Commit e5287e6

Browse files
captain5050acmel
authored andcommitted
perf expr: Allow exponents on floating point values
Pass the optional exponent component through to strtod that already supports it. We already have exponents in ScaleUnit and so this adds uniformity. Reported-by: Zhengjun Xing <[email protected]> Reviewed-By: Kajol Jain <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Richter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b236371 commit e5287e6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tools/perf/tests/expr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
9797
ret |= test(ctx, "2.2 > 2.2", 0);
9898
ret |= test(ctx, "2.2 < 1.1", 0);
9999
ret |= test(ctx, "1.1 > 2.2", 0);
100+
ret |= test(ctx, "1.1e10 < 1.1e100", 1);
101+
ret |= test(ctx, "1.1e2 > 1.1e-2", 1);
100102

101103
if (ret) {
102104
expr__ctx_free(ctx);

tools/perf/util/expr.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int literal(yyscan_t scanner)
9191
}
9292
%}
9393

94-
number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)
94+
number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)?
9595

9696
sch [-,=]
9797
spec \\{sch}

0 commit comments

Comments
 (0)