bug-indent
[Top][All Lists]
Advanced

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

Re: Expected behavior for -cs and -ncs


From: david ingamells
Subject: Re: Expected behavior for -cs and -ncs
Date: Thu, 24 Jul 2008 17:15:35 +0200
User-agent: Thunderbird 2.0.0.14 (X11/20080421)

Ian Carvalho wrote:
david ingamells wrote:
John E Hein wrote:
david ingamells wrote at 19:42 +0200 on Jul 23, 2008:
 > This works in 2.2.10:
 >  > $ indent -npro -ncs
 >  > unsigned char *cp = (unsigned char *)ptr;
 > int
 > foo ()
 > {
 >   return (int)n;
 > }
 >  > $ indent -npro -cs
 >  > unsigned char *cp = (unsigned char *) ptr;
 > int
 > foo ()
 > {
 >   return (int) n;
 > }
> > > I know of no update that fixed this in 2.2.10, so I am surprised that it > doesn't work in 2.2.9. > I have added this to the regression test now, so it will be checked in > the future.

Seems okay in my local test here on 2.2.9, too...


echo '(unsigned char *)ptr;' | gindent -npro -cs
(unsigned char *) ptr;

echo '(unsigned char *)ptr;' | gindent -npro -ncs
(unsigned char *)ptr;

However, --no-space-after-cast fails:


echo '(unsigned char *)ptr;' | gindent -npro --space-after-cast
(unsigned char *) ptr;

echo '(unsigned char *)ptr;' | gindent -npro --no-space-after-cast
indent: unknown option "no-space-after-cast"


A quick check in the code explains why:

{"no-space-after-casts",                        "ncs"},

And the manual says the same. I think what is best is that I update the manual to remove the trailing "s" and recognise both forms in the code. That way users will move over to the right one and existing users won't get a nasty surprise.

On seeing your responses, went through the code I am trying to indent. Looks like the example I have given is flawed.

When the cast happens with a typedef'd variable then it does not seem to work.

Using this:
--- start ---
typedef unsigned char   uchar;

unsigned char *cp = (unsigned char *)ptr;
uchar *ucp = (uchar *)ptr;
--- end --
as the source

$ indent -npro -ncs
I get
--- start ---
typedef unsigned char   uchar;

unsigned char *cp = (unsigned char *)ptr;
uchar *ucp = (uchar *) ptr;
--- end ---

and for

$ indent -npro -cs
I get
--- start ---
typedef unsigned char   uchar;

unsigned char *cp = (unsigned char *) ptr;
uchar *ucp = (uchar *) ptr;
--- end ---

Thus, the space is present in both cases if the cast is to a typedef'd type.

Is this the expected behavior?

Thanks



Yes that is expected. You need  -Tuchar




reply via email to

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