Hello again.

This is the last one from Josh for now.
Apologies to him for taking so long to process this.

---------- Forwarded message ----------
From: Josh Triplett <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Date: Sun, 29 Aug 2010 23:45:40 -0700
Subject: indent: Recognizes typedefs in declarations,
    but not parameters or casts; fails to consistently handle "type *"

Package: indent
Version: 2.2.11-1
Severity: normal

Consider the following file:

void *f1(u32 *p1, void *p2)
{
    u32 *v1;
    void *v2;
    return (void *)v1;
}

u32 *f2(u32 *p1, void *p2)
{
    return (u32 *)v2;
}


"indent -kr -ncas" will indent this as follows:

--- u32.c.orig  2010-08-29 23:38:16.000000000 -0700
+++ u32.c       2010-08-29 23:39:38.000000000 -0700
@@ -1,11 +1,11 @@
-void *f1(u32 *p1, void *p2)
+void *f1(u32 * p1, void *p2)
 {
     u32 *v1;
     void *v2;
     return (void *)v1;
 }

-u32 *f2(u32 *p1, void *p2)
+u32 *f2(u32 * p1, void *p2)
 {
-    return (u32 *)v2;
+    return (u32 *) v2;
 }

Notice how it handled "u32 *v1" and "u32 *f2(...)" correctly and
consistently, but it mis-indented the parameter "u32 * p1" and the cast
"(u32 *) v2".

Ideally, I'd like to see indent automatically handling these types
correctly; the parameters in particular seem like they should prove as
simple as declarations.  However, if it turns out indent can't handle
this without prior knowledge of the program's types, I can live with a
solution that involves explicitly telling indent a list of names which
it should treat as types, since in this case the list would prove quite
short.

- Josh Triplett

[...]

_______________________________________________
bug-indent mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-indent

Reply via email to