qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qapi: generate space in c_type() to fix coding


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] qapi: generate space in c_type() to fix coding style
Date: Fri, 25 Apr 2014 08:06:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Amos Kong <address@hidden> writes:

> On Tue, Apr 22, 2014 at 09:20:41AM +0200, Markus Armbruster wrote:
>> Paolo Bonzini <address@hidden> writes:
>> 
>> > Il 18/04/2014 23:56, Amos Kong ha scritto:
>> >> Currently we always add a space after c_type in mcgen(), there is
>> >> some redundant space in generated code. The space isn't needed for
>> >> points by the coding style.
>> >>
>> >>   char * value;
>> >>         ^
>> >>   qapi_free_NameInfo(NameInfo * obj)
>> >>                                ^
>> >> It's fussy to add checking in each mcgen(), this patch just addes
>> >> the necessary space in c_type(), and remove original space in mcgen().
>> >
>> > It also makes the generator harder to read to though, and the
>> > improvement in the generated code is minor enough that I think the
>> > change is overall negative.  But I won't oppose the patch if the
>> > maintainers are fine with it.
>
> Hi Markus,
>  
>> The readability hit could be avoided: instead of moving the space from
>> mcgen()'s argument to c_type()'s result, add a "hungry character" to
>> c_type()'s result, then make it eat space to the right in mcgen().
>
> '\b' is used to eat char in left, but what's the "hungry character" to
> each char in right?
>
> When I added a '\b' to c_type()'s return, there is an arror:
>   error: stray '\10' in program

I'm afraid you misunderstood me.

Pick a character that cannot occur in valid C code.  Make c_type()'s
return value end in that character in the cases where you don't want
space.  Then make mcgen() strip it from its return value along with
immediately following space.

Questions?

[...]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]