From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJ0mg-0003ft-8H for qemu-devel@nongnu.org; Tue, 02 Oct 2012 07:37:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJ0ma-0000mp-0F for qemu-devel@nongnu.org; Tue, 02 Oct 2012 07:37:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJ0mZ-0000ml-Mo for qemu-devel@nongnu.org; Tue, 02 Oct 2012 07:36:59 -0400 Message-ID: <506AD1AB.4040605@redhat.com> Date: Tue, 02 Oct 2012 13:36:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1348691578-17231-1-git-send-email-imammedo@redhat.com> <1348691578-17231-19-git-send-email-imammedo@redhat.com> <506ACFDB.3040302@redhat.com> In-Reply-To: <506ACFDB.3040302@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 18/22] target-i386: parse cpu_model string into set of stringified properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, Don@cloudswitch.com, mtosatti@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, Blue Swirl , Igor Mammedov , lersek@redhat.com, afaerber@suse.de, stefanha@linux.vnet.ibm.com 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.