Received: from eggs.gnu.org ([2001:4830:134:3::10]:40829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpAn4-0000UU-D8 for qemu-devel@nongnu.org; Mon, 04 May 2015 03:27:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YpAn0-0005e9-7w for qemu-devel@nongnu.org; Mon, 04 May 2015 03:27:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpAmz-0005e1-VI for qemu-devel@nongnu.org; Mon, 04 May 2015 03:27:42 -0400 From: Markus Armbruster References: <1430312814-19706-1-git-send-email-eblake@redhat.com> <1430312814-19706-26-git-send-email-eblake@redhat.com> <554538D0.1050406@redhat.com> Date: Mon, 04 May 2015 09:26:57 +0200 In-Reply-To: <554538D0.1050406@redhat.com> (Eric Blake's message of "Sat, 02 May 2015 14:51:28 -0600") Message-ID: <878ud4iz0e.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v7 25/39] qapi: Require valid names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, berto@igalia.com, qemu-devel@nongnu.org Eric Blake writes: > On 04/29/2015 07:06 AM, Eric Blake wrote: >> Previous commits demonstrated that the generator overlooked various >> bad naming situations: >> - types, commands, and events need a valid name >> - enum members must be valid names, when combined with prefix >> - union and alternate branches cannot be marked optional >> > >> regex, this patch just uses a broader combination that allows both >> upstream and downstream names, as well as a small hack that >> realizes that any enum name is merely a suffix to an already valid >> name prefix (that is, any enum name is valid if prepending _ fits >> the normal rules). >> > >> + # Enum members can start with a digit, because the generated C >> + # code always prefixes it with the enum name >> + if enum_member: >> + membername = "_%s" %membername >> + if not valid_name.match(membername): >> + raise QAPIExprError(expr_info, > > Python question: Would it be any simpler to write: > > membername = '_' + membername > > and if so, do I need to squash anything in? I find + easier to read here, even when compare to a correctly spaced "_%s" % membername. I think we have enough squash candidates to justify a quick v8. I'd prefer that, as I I haven't checked v7 anyway :)