From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: David Scott <dave.scott@citrix.com>
Cc: xen-devel@lists.xenproject.org, stefano.stabellini@eu.citrix.com,
ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
ian.campbell@citrix.com
Subject: Re: [PATCH v6 for-4.5 4/5] xl: add 'trim' and 'split_string_into_pair' functions
Date: Thu, 25 Sep 2014 15:06:13 -0400 [thread overview]
Message-ID: <20140925190613.GB29663@laptop.dumpdata.com> (raw)
In-Reply-To: <1411591685-25308-5-git-send-email-dave.scott@citrix.com>
On Wed, Sep 24, 2014 at 09:48:04PM +0100, David Scott wrote:
> Signed-off-by: David Scott <dave.scott@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> tools/libxl/xl_cmdimpl.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 1fc2171..d6f311f 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -300,7 +300,6 @@ static void *xrealloc(void *ptr, size_t sz) {
> return r;
> }
>
> -static char *xstrdup(const char *x) __attribute__ ((unused));
> static char *xstrdup(const char *x)
> {
> char *r;
> @@ -564,6 +563,71 @@ static void split_string_into_string_list(const char *str,
> free(s);
> }
>
> +/* NB: this follows the interface used by <ctype.h>. See 'man 3 ctype'
> + and look for CTYPE in libxl_internal.h */
> +typedef int (*char_predicate_t)(const int c);
> +
> +static void trim(char_predicate_t predicate, const char *input, char **output) __attribute__ ((unused));
> +static void trim(char_predicate_t predicate, const char *input, char **output)
> +{
> + char *p, *q, *tmp;
> + if (*input == '\000')
> + return;
> + /* Input has length >= 1 */
> +
> + p = tmp = xstrdup(input);
> + /* Skip past the first whitespace */
> + while ((*p != '\000') && (predicate((unsigned char)*p)))
> + p ++;
> + q = p + strlen(p) - 1;
> + /* q points to the last non-NULL character */
> + while ((q > p) && (predicate((unsigned char)*q)))
> + q --;
> + /* q points to the last character we want */
> + q ++;
> + *q = '\000';
> + *output = xstrdup(p);
> + free(tmp);
> +}
> +
> +static int split_string_into_pair(const char *str,
> + const char *delim,
> + char **a,
> + char **b) __attribute__ ((unused));
> +static int split_string_into_pair(const char *str,
> + const char *delim,
> + char **a,
> + char **b)
> +{
> + char *s, *p, *saveptr, *aa = NULL, *bb = NULL;
> + int rc = 0;
> +
> + s = xstrdup(str);
> +
> + p = strtok_r(s, delim, &saveptr);
> + if (p == NULL) {
> + rc = ERROR_INVAL;
> + goto out;
> + }
> + aa = xstrdup(p);
> + p = strtok_r(NULL, delim, &saveptr);
> + if (p == NULL) {
> + rc = ERROR_INVAL;
> + goto out;
> + }
> + bb = xstrdup(p);
> +
> + *a = aa;
> + aa = NULL;
> + *b = bb;
> + bb = NULL;
> +out:
> + free(s);
> + free(aa);
> + free(bb);
> + return rc;
> +}
> +
> static int parse_range(const char *str, unsigned long *a, unsigned long *b)
> {
> const char *nstr;
> --
> 1.7.10.4
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-09-25 19:06 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-24 20:48 xl, libxl: add support for 'channels' David Scott
2014-09-24 20:48 ` [PATCH v6 for-4.5 1/5] " David Scott
2014-09-25 18:56 ` Konrad Rzeszutek Wilk
2014-09-26 9:12 ` Wei Liu
2014-09-24 20:48 ` [PATCH v6 for-4.5 2/5] xl: move 'replace_string' further up the file David Scott
2014-09-25 19:06 ` Konrad Rzeszutek Wilk
2014-09-26 9:15 ` Wei Liu
2014-09-24 20:48 ` [PATCH v6 for-4.5 3/5] xl: add 'xstrdup' next to 'xrealloc' David Scott
2014-09-25 19:06 ` Konrad Rzeszutek Wilk
2014-09-26 9:22 ` Wei Liu
2014-09-24 20:48 ` [PATCH v6 for-4.5 4/5] xl: add 'trim' and 'split_string_into_pair' functions David Scott
2014-09-25 19:06 ` Konrad Rzeszutek Wilk [this message]
2014-09-26 10:09 ` Wei Liu
2014-09-26 15:45 ` Ian Jackson
2014-09-26 15:51 ` Wei Liu
2014-09-26 15:53 ` Ian Jackson
2014-09-24 20:48 ` [PATCH v6 for-4.5 5/5] xl: add support for 'channels' David Scott
2014-09-25 19:11 ` Konrad Rzeszutek Wilk
2014-09-26 10:22 ` Wei Liu
2014-09-25 19:13 ` xl, libxl: " Konrad Rzeszutek Wilk
2014-09-25 19:37 ` Dave Scott
2014-09-26 15:14 ` Ian Jackson
2014-09-26 19:20 ` Konrad Rzeszutek Wilk
2014-10-07 16:52 ` Dave Scott
2014-10-07 16:59 ` Konrad Rzeszutek Wilk
2014-10-08 11:06 ` Stefano Stabellini
2014-10-08 13:26 ` Ian Campbell
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=20140925190613.GB29663@laptop.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=dave.scott@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).