public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] perf_counter : breaking parameter parsing when the command is  reached
@ 2009-07-06  5:44 Erdem Aktas
  2009-07-10  9:14 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Erdem Aktas @ 2009-07-06  5:44 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Peter Zijlstra, Mike Galbraith, Paul Mackerras,
	Arnaldo Carvalho de Melo, Frederic Weisbecker

    Once the perf parameter parser reaches a non-parameter word, that means
    the command is already found and the rest of the string is the parameter
    of this command so no need to parse more.

    As an example, when we want to run
    perf stat -- ls -al
    it is obvious that the -al is the parameter of the ls command, so we
    should able to run this like
    perf stat ls -al

    Signed-off-by: eaktas <eaktas1@gmail.com>

diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 1bf6719..4ad4962 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -284,6 +284,11 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
 			if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
 				break;
 			ctx->out[ctx->cpidx++] = ctx->argv[0];
+			while (--(ctx->argc)) {
+				ctx->argv++;
+				ctx->out[ctx->cpidx++] = ctx->argv[0];
+			}
+			ctx->argc++;
 			continue;
 		}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] perf_counter : breaking parameter parsing when the command is reached
  2009-07-06  5:44 [patch] perf_counter : breaking parameter parsing when the command is reached Erdem Aktas
@ 2009-07-10  9:14 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2009-07-10  9:14 UTC (permalink / raw)
  To: Erdem Aktas
  Cc: linux-kernel, Peter Zijlstra, Mike Galbraith, Paul Mackerras,
	Arnaldo Carvalho de Melo, Frederic Weisbecker


* Erdem Aktas <eaktas1@gmail.com> wrote:

>     Once the perf parameter parser reaches a non-parameter word, that means
>     the command is already found and the rest of the string is the parameter
>     of this command so no need to parse more.
> 
>     As an example, when we want to run
>     perf stat -- ls -al
>     it is obvious that the -al is the parameter of the ls command, so we
>     should able to run this like
>     perf stat ls -al
> 
>     Signed-off-by: eaktas <eaktas1@gmail.com>
> 
> diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
> index 1bf6719..4ad4962 100644
> --- a/tools/perf/util/parse-options.c
> +++ b/tools/perf/util/parse-options.c
> @@ -284,6 +284,11 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
>  			if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
>  				break;
>  			ctx->out[ctx->cpidx++] = ctx->argv[0];
> +			while (--(ctx->argc)) {
> +				ctx->argv++;
> +				ctx->out[ctx->cpidx++] = ctx->argv[0];
> +			}
> +			ctx->argc++;

I think there might be a simpler solution: pass in 
PARSE_OPT_STOP_AT_NON_OPTION.

Then we'll trigger this existing code in parse_options_end():

        memmove(ctx->out + ctx->cpidx, ctx->argv, ctx->argc * sizeof(*ctx->out));
        ctx->out[ctx->cpidx + ctx->argc] = NULL;
        return ctx->cpidx + ctx->argc;

which should solve the issue just as well, correct?

	Ingo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-10  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-06  5:44 [patch] perf_counter : breaking parameter parsing when the command is reached Erdem Aktas
2009-07-10  9:14 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox