Re: white space after star unexpected

david ingamells <[email protected]>
Newsgroups gmane.comp.gnu.indent.bugs
Message-ID <[email protected]>
John E Hein wrote:
> Moore, Robert wrote at 09:34 -0700 on Jun 19, 2008:
>  > I understand quite well.
>  > 
>  > Indent needs to be smarter.
>
> I don't think anyone would disagree (well, some would).  But it has
> never been a full c parser (let alone c++).  No one has ever put forth
> the patches to make that work.  indent-ng would be an interesting SoC.
>
>
> _______________________________________________
> bug-indent mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/bug-indent
>
>
>   
Well! This has become the liveliest debate on indent for quite some time!
As Robert has said, Indent needs to be smarter. However there are some 
obstacles to achieving that:
1) The parsing job for a smart indent is lots harder than for a C 
compiler as it has to

    * understand C and dialects thereof, as well as C++ (according to
      lots many respondents)
    * understand and manage white-space and various styles of
      commenting, all of which a C compiler can just throw away.
    * understand the preprocessor syntax and process it while still
      keeping the original source file content intact.
    * understand the mixes of all these items together. (eg what about
      indenting inside #ifdef ... #else .. #endif)

2) The current code of indent is not at all well structured for 
achieving this. The original developer said at the time that it was just 
a quick hack, and it has been hacked ever since by hanging more and more 
extra bits off it, most of which were done without fully understanding 
the existing code.

I would love to have the time to work on an indent-ng, but with having 
to earn a living in a very demanding job, maintain my home and give my 
family the time they deserve I have no time over.


On the subject of the original mail that triggered all this, * is used 
in C to declare a pointer, as in the prototype that was complained 
about. It is also used as a dereferencing unary operator (e.g. *pi = 10 
+ *pj;) and a multiplication binary operator (e.g. i = 10 * x;). Indent 
is not smart enough to know the context unless it knows that the word 
before the * is a type - which it has to be told as it doesn't 
pre-process the code.

Regarding the request to change the behaviour, many users don't see that 
space as "unexpected". I have see all of the following as preferred 
styles for prototypes:

void func(type * p);
void func(type* p);
void func (type *p);
void func (type*); /* etc */

I personally don't consider any of them worth a flame war and I don't 
think any of them worth my effort to extend indent to support them - but 
that;'s maybe because my favourite IS supported :^). Anyone who does 
care enough is welcome to submit an update and I will integrate it, but 
the update must satisfy the regression test, have a new test added to 
the regression test suite to prove the correctness of the update and the 
documentation must be extended.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.