lkml.org 
[lkml]   [2022]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] perf expr: Allow exponents on floating point values
On Thu, May 26, 2022 at 7:06 PM Ian Rogers <irogers@google.com> wrote:
>
> 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 <zhengjun.xing@linux.intel.com>
> Signed-off-by: Ian Rogers <irogers@google.com>

Ping. Simple fix with tests, PTAL. Thanks,
Ian

> ---
> tools/perf/tests/expr.c | 2 ++
> tools/perf/util/expr.l | 2 +-
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
> index d54c5371c6a6..5c0032fe93ae 100644
> --- a/tools/perf/tests/expr.c
> +++ b/tools/perf/tests/expr.c
> @@ -97,6 +97,8 @@ static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_u
> ret |= test(ctx, "2.2 > 2.2", 0);
> ret |= test(ctx, "2.2 < 1.1", 0);
> ret |= test(ctx, "1.1 > 2.2", 0);
> + ret |= test(ctx, "1.1e10 < 1.1e100", 1);
> + ret |= test(ctx, "1.1e2 > 1.1e-2", 1);
>
> if (ret) {
> expr__ctx_free(ctx);
> diff --git a/tools/perf/util/expr.l b/tools/perf/util/expr.l
> index 0a13eb20c814..4dc8edbfd9ce 100644
> --- a/tools/perf/util/expr.l
> +++ b/tools/perf/util/expr.l
> @@ -91,7 +91,7 @@ static int literal(yyscan_t scanner)
> }
> %}
>
> -number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)
> +number ([0-9]+\.?[0-9]*|[0-9]*\.?[0-9]+)(e-?[0-9]+)?
>
> sch [-,=]
> spec \\{sch}
> --
> 2.36.1.124.g0e6072fb45-goog
>

\
 
 \ /
  Last update: 2022-06-09 07:30    [W:0.041 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site