bug-indent
[Top][All Lists]
Advanced

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

Re: [Bug-indent] argument formatting


From: david ingamells
Subject: Re: [Bug-indent] argument formatting
Date: Mon, 23 Sep 2002 19:26:13 +0200

Stefan,
The problem you describe has nothing to do with function arguments since  
BIT_MASK is a macro. Indent has problems with macros since it does not 
contain a preprocessor. This is not a problem that has any easy solution.

You could try re-defining BIT_MASK to look like a function so that it is used 
thus: 
a = BIT_MASK(7,4);

e.g.
define BIT_MASK(x,y) ((0xFFFFFFFF>>(31-((x)&31)+((y)&31)))<<((y)&31))

personally I find such macro tricks as your sample demonstrates to be very 
dirty and my experience is that they can lead to very awkward to trace bugs.

Regards,
David

On Thursday 19 September 2002 9:02 am, you wrote:
> Hello Indent'ers,
>
> first of all:  Thanks for great and useful software.  I am using it to get
> obfuscated C source readable.
>
> I found the following (mis)behaviour in formatting function arguments:
> Original source:
>
> ===========================================================================
> #define BIT_MASK(x) ((0xFFFFFFFF>>(31-((1?x)&31)+((0?x)&31)))<<((0?x)&31))
> void main (void) {
>   unsigned int a,b,c;
>
>   a = BIT_MASK(7:4);
>   b = BIT_MASK ( 31 : 28);
>   c = BIT_MASK(0:0) | BIT_MASK ( 31 : 28) | BIT_MASK ( 7 : 4 );
>   printf("0x%08X, 0x%08X, 0x%08X\n", a, b, c);
> }
> ===========================================================================
>
> Using
>       $ indent -st bittest.c
>
> produces:
>
> ===========================================================================
> #define BIT_MASK(x) ((0xFFFFFFFF>>(31-((1?x)&31)+((0?x)&31)))<<((0?x)&31))
> void
> main (void)
> {
>   unsigned int a, b, c;
>
> a = BIT_MASK (7:4);
> b = BIT_MASK (31:28);
> c = BIT_MASK (0: 0) | BIT_MASK (31: 28) | BIT_MASK (7:4);
>   printf ("0x%08X, 0x%08X, 0x%08X\n", a, b, c);
> }
> ===========================================================================
>
> Watch the arguments of BIT_MASK() when assigned to 'c'.  In the last place
> it is as I like it, but the previous one have a space inserted.  Thus
> you get different formatting in the same line.  Is this correct behaviour
> or can you easily change it?
>
> Can you please also reply to me directly for I do not read the mailing
> list...
>
> Thanks in advance,
>       address@hidden
>
>
>
> _______________________________________________
> Bug-indent mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-indent

-- 
David Ingamells
address@hidden
+31 (013) 5093388     (home)
+31 615010947 (mobile)




reply via email to

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