[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 18/22] target-i386: parse cpu_model string into
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 18/22] target-i386: parse cpu_model string into set of stringified properties |
Date: |
Tue, 02 Oct 2012 13:36:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 |
Il 02/10/2012 13:28, Eric Blake ha scritto:
>>> >> + *cpu_name = strtok_r(s, ",", &sptr);
>> >
>> > This would break build since strtok_r() isn't available on Mingw, it's
> Correct. Microsoft is stuck in the past when it comes to standard
> conformance.
Luckily, in the common case of a non-varying delimiter g_strsplit is just
as simple:
gchar **
g_strsplit (const gchar *string,
const gchar *delimiter,
gint max_tokens);
Splits a string into a maximum of max_tokens pieces, using the given delimiter.
If max_tokens is reached, the remainder of string is appended to the last token.
As a special case, the result of splitting the empty string "" is an empty
vector,
not a vector containing a single string. The reason for this special case is
that
being able to represent a empty vector is typically more useful than consistent
handling of empty elements. If you do need to represent empty elements, you'll
need to check for the empty string before calling g_strsplit().
string :
a string to split.
delimiter :
a string which specifies the places at which to split the string. The
delimiter
is not included in any of the resulting strings, unless max_tokens is
reached.
max_tokens :
the maximum number of pieces to split string into. If this is less than
1, the
string is split completely.
Returns :
a newly-allocated NULL-terminated array of strings. Use g_strfreev() to
free it.