bug-indent
[Top][All Lists]
Advanced

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

[Bug-indent] defects during structure initialisation


From: Pavel Sakov
Subject: [Bug-indent] defects during structure initialisation
Date: Mon, 4 Aug 2003 11:00:33 +1000

Folks,

Following are a few examples of code formatting with indent-2.2.8a that
supposedly expose some defects during structure initialisation.

First, three files used in these examples: a.c, b.c and c.c:

a.c:

<BEGIN>
struct {
    int a;
    int b;
} AAA[] = {
    {
     1, 2}, {
             3, 4}
};
<END>

b.c:

<BEGIN>
struct {
    int a;
    int b;
} AAA[] = {
    {1, 2}, 
    {3, 4}
};
<END>

c.c:

<BEGIN>
mystruct AAA[] = {
    {1, 2}, 
    {3, 4}
};

typedef struct {
    int a;
    int b;
} BBB;

mystruct CCC[] = {
    {1, 2}, 
    {3, 4}
};
<END>

-------------------------

Example1:

indent --original -st -T AAA a.c

produces:
<BEGIN>
struct {
    int a;
    int b;
} AAA[] = {
    {
     1, 2}, {
             3, 4}
};
<END>

indent --original -st -T AAA b.c

produces:
<BEGIN>
struct {
    int a;
    int b;
} AAA[] = {
    {1, 2},
    {3, 4}
};
<END>

One has different output while a.c and b.c are equivalent from C syntax point of
view. Also, without "-T" indent produces yet more ugly output, I wonder why
(AAA is not a type here, rather a variable name).

----------------------------

Example2:

indent --original -st -T AAA c.c

produces:
<BEGIN>
mystruct AAA[] = {
    {1, 2}
    ,
    {3, 4}
};

typedef struct {
    int a;
    int b;
} BBB;

mystruct CCC[] = {
    {1, 2},
    {3, 4}
};
<END>

Here adding "-T AAA" to the command line "fixes" the output, yet one would not
expect indent to add an extra line before comma in the first case. (And once
again, AAA is not a type here.)

Cheers
Pavel





reply via email to

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