From: Frederic Weisbecker <fweisbec@gmail.com>
To: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] perf tools: New function to parse string representing size in bytes
Date: Sun, 15 Nov 2009 06:11:57 +0100 [thread overview]
Message-ID: <20091115051155.GB5427@nowhere> (raw)
In-Reply-To: <1258257045-1363-1-git-send-email-mitake@dcl.info.waseda.ac.jp>
On Sun, Nov 15, 2009 at 12:50:45PM +0900, Hitoshi Mitake wrote:
> This patch modifies util/string.[ch] to add new function: bytesexp2int()
> to parse string representing size in bytes.
>
> Below is the description of bytesexp2int().
>
> Parse (\d+)(b|B|kb|KB|mb|MB|gb|GB) (e.g. "256MB")
> and return its numeric value. (e.g. 268435456)
>
> The parameter str is not changed before and after calling,
> but it changed temporally and internally for atoi().
> So type of str is char *, not const char *.
>
> Signed-off-by: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> tools/perf/util/string.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++
> tools/perf/util/string.h | 1 +
> 2 files changed, 90 insertions(+), 0 deletions(-)
>
> diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
> index 04743d3..bbedb06 100644
> --- a/tools/perf/util/string.c
> +++ b/tools/perf/util/string.c
> @@ -1,4 +1,5 @@
> #include <string.h>
> +#include <stdlib.h>
> #include "string.h"
>
> static int hex(char ch)
> @@ -43,3 +44,91 @@ char *strxfrchar(char *s, char from, char to)
>
> return s;
> }
> +
> +static int digit(char ch)
> +{
> + if ('0' <= ch && ch <= '9')
> + return 1;
> + return 0;
> +}
We have a "isdigit" macro in util.h already, despite the even already
existing isdigit from the libc. I don't know why we have that. I guess
it comes from git sources but I'm not sure why it has been reimplemented.
next prev parent reply other threads:[~2009-11-15 5:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-15 3:50 Hitoshi Mitake
2009-11-15 5:11 ` Frederic Weisbecker [this message]
2009-11-15 8:08 ` Ingo Molnar
2009-11-15 8:15 ` Hitoshi Mitake
2009-11-15 8:17 ` [PATCH v2] " Hitoshi Mitake
2009-11-15 8:57 ` Ingo Molnar
2009-11-15 9:52 ` Hitoshi Mitake
2009-11-15 10:19 ` [PATCH v3] " Hitoshi Mitake
2009-11-15 10:28 ` Ingo Molnar
2009-11-15 10:57 ` Hitoshi Mitake
2009-11-15 11:04 ` Ingo Molnar
2009-11-15 11:32 ` Hitoshi Mitake
2009-11-15 11:36 ` [PATCH v4] " Hitoshi Mitake
2009-11-15 14:18 ` [tip:perf/core] perf tools: Add new perf_atoll() " tip-bot for Hitoshi Mitake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091115051155.GB5427@nowhere \
--to=fweisbec@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mitake@dcl.info.waseda.ac.jp \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome