Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1261449
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v9 4/9] perf config: Add comparing name treating '_' and '-' as being the same thing. |
| Date | 2015-11-03 13:20 +0100 |
| Message-ID | <qqIJb-2zy-1@gated-at.bofh.it> (permalink) |
| References | <qqz3c-4xe-9@gated-at.bofh.it> <qqz3e-4xe-57@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Nov 03, 2015 at 10:50:15AM +0900, Taeung Song wrote:
> The comparing name functionality is that
> two config name are compared treating '-' or '_' as
> being the same thing. For example, both 'print_percent'
> and 'print-percent' in 'call-graph' section
> are regarded as the same thing.
Hmm.. but this code only does it for 'perf config' command, right?
What we want is treating them in all other commands which use
perf_config() callbacks. I think it'd be better to convert the
character when parsing the config files..
Thanks,
Namhyung
>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
> tools/perf/builtin-config.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-config.c b/tools/perf/builtin-config.c
> index f99c39d..d4e2899 100644
> --- a/tools/perf/builtin-config.c
> +++ b/tools/perf/builtin-config.c
> @@ -32,6 +32,27 @@ static struct option config_options[] = {
> OPT_END()
> };
>
> +static int compare_name(const char *name1, const char *name2)
> +{
> + while (true) {
> + /*
> + * If two names have '-' or '_', them are treated
> + * as being the same thing.
> + */
> + if ((*name1 == '-' || *name1 == '_')
> + && (*name2 == '-' || *name2 == '_')) {
> + name1++, name2++;
> + continue;
> + }
> +
> + if (*name1 && (*name1 == *name2))
> + name1++, name2++;
> + else
> + break;
> + }
> + return *(const unsigned char *)name1-*(const unsigned char *)name2;
> +}
> +
> static struct config_section *find_section(struct list_head *sections,
> const char *section_name)
> {
> @@ -50,7 +71,7 @@ static struct config_element *find_element(const char *name,
> struct config_element *element;
>
> list_for_each_entry(element, §ion->element_head, list)
> - if (!strcmp(element->name, name))
> + if (!compare_name(element->name, name))
> return element;
>
> return NULL;
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v9 0/9] perf tools: Add 'perf-config' command Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
[PATCH v9 7/9] perf config: Add 'set' feature Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
[PATCH v9 3/9] perf config: Collect configs to handle config variables Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
Re: [PATCH v9 3/9] perf config: Collect configs to handle config variables Namhyung Kim <namhyung@kernel.org> - 2015-11-03 13:20 +0100
[PATCH v9 2/9] perf config: Add '--system' and '--user' options to select which config file is used Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
Re: [PATCH v9 2/9] perf config: Add '--system' and '--user' options to select which config file is used Namhyung Kim <namhyung@kernel.org> - 2015-11-03 12:50 +0100
[PATCH v9 5/9] perf config: Add a option 'list-all' to perf-config Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
Re: [PATCH v9 5/9] perf config: Add a option 'list-all' to perf-config Namhyung Kim <namhyung@kernel.org> - 2015-11-03 13:40 +0100
[PATCH v9 6/9] perf config: Add 'get' functionaliy Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
[PATCH v9 9/9] perf config: Add a option 'remove' to perf-config Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
[PATCH v9 4/9] perf config: Add comparing name treating '_' and '-' as being the same thing. Taeung Song <treeze.taeung@gmail.com> - 2015-11-03 03:00 +0100
Re: [PATCH v9 4/9] perf config: Add comparing name treating '_' and '-' as being the same thing. Namhyung Kim <namhyung@kernel.org> - 2015-11-03 13:20 +0100
csiph-web