From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUHRS-0004Q7-0M for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:51:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUHRO-0004k5-Jx for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:51:21 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:54986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUHRO-0004jd-Gb for qemu-devel@nongnu.org; Tue, 25 Aug 2015 12:51:18 -0400 Received: from /spool/local by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Aug 2015 12:51:17 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id B93A3C9003E for ; Tue, 25 Aug 2015 12:42:18 -0400 (EDT) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7PGpEZN64487642 for ; Tue, 25 Aug 2015 16:51:14 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7PGpDwP009259 for ; Tue, 25 Aug 2015 12:51:13 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1435751267-26378-4-git-send-email-marcandre.lureau@gmail.com> References: <1435751267-26378-1-git-send-email-marcandre.lureau@gmail.com> <1435751267-26378-4-git-send-email-marcandre.lureau@gmail.com> Message-ID: <20150825155052.11069.68446@loki> Date: Tue, 25 Aug 2015 10:50:52 -0500 Subject: Re: [Qemu-devel] [PATCH 03/12] qga: move string split in seperate function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Quoting Marc-Andr=C3=A9 Lureau (2015-07-01 06:47:38) > The function is going to be reused in a later patch. > = > Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michael Roth > --- > qga/main.c | 33 ++++++++++++++++++++++----------- > 1 file changed, 22 insertions(+), 11 deletions(-) > = > diff --git a/qga/main.c b/qga/main.c > index af93992..0c455f8 100644 > --- a/qga/main.c > +++ b/qga/main.c > @@ -921,6 +921,26 @@ static void ga_print_cmd(QmpCommand *cmd, void *opaq= ue) > printf("%s\n", qmp_command_name(cmd)); > } > = > +static GList *split_list(gchar *str, const gchar separator) > +{ > + GList *list =3D NULL; > + int i, j, len; > + > + for (j =3D 0, i =3D 0, len =3D strlen(str); i < len; i++) { > + if (str[i] =3D=3D separator) { > + str[i] =3D 0; > + list =3D g_list_append(list, &str[j]); > + j =3D i + 1; > + } > + } > + > + if (j < i) { > + list =3D g_list_append(list, &str[j]); > + } > + > + return list; > +} > + > int main(int argc, char **argv) > { > const char *sopt =3D "hVvdm:p:l:f:F::b:s:t:"; > @@ -953,7 +973,7 @@ int main(int argc, char **argv) > { "statedir", 1, NULL, 't' }, > { NULL, 0, NULL, 0 } > }; > - int opt_ind =3D 0, ch, daemonize =3D 0, i, j, len; > + int opt_ind =3D 0, ch, daemonize =3D 0; > GLogLevelFlags log_level =3D G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICA= L; > GList *blacklist =3D NULL; > GAState *s; > @@ -1001,16 +1021,7 @@ int main(int argc, char **argv) > qmp_for_each_command(ga_print_cmd, NULL); > exit(EXIT_SUCCESS); > } > - for (j =3D 0, i =3D 0, len =3D strlen(optarg); i < len; i++)= { > - if (optarg[i] =3D=3D ',') { > - optarg[i] =3D 0; > - blacklist =3D g_list_append(blacklist, &optarg[j]); > - j =3D i + 1; > - } > - } > - if (j < i) { > - blacklist =3D g_list_append(blacklist, &optarg[j]); > - } > + blacklist =3D g_list_concat(blacklist, split_list(optarg, ',= ')); > break; > } > #ifdef _WIN32 > -- = > 2.4.3 >=20