D
dt
Greetings,
I'm having some trouble understanding the plethora of options
available for GNU indent for my C code.
Except for the function's opening {, I want all code to line
up under the opening { of the block it resides in.
Let me explain with an example. I'm using this command,
gindent -npro -kr -bl -bli4 -nce < ncmp.c > ncmp2.c
and ncmp2.c is neatly formatted like this,
int32_t dcrp_oidncmp(dcroid_t * a, dcroid_t * b, size_t n)
{
size_t i;
size_t szA = OID_LEN(a);
size_t szB = OID_LEN(b);
if (n == 0)
{
return 0;
}
else if (szB == 0)
{
return 1;
}
else
{
for (i = 0; i < n && i < szA && i < szB; i++)
{
if (OID_AT(a, i) > OID_AT(b, i))
return 1;
else if (OID_AT(a, i) < OID_AT(b, i))
return -1;
}
return 0;
}
}
However, notice the extra indention of code for inner blocks;
I want output to omit that extra indention, like this output,
int32_t dcrp_oidncmp(dcroid_t * a, dcroid_t * b, size_t n)
{
size_t i;
size_t szA = OID_LEN(a);
size_t szB = OID_LEN(b);
if (n == 0)
{
return 0;
}
else if (szB == 0)
{
return 1;
}
else
{
for (i = 0; i < n && i < szA && i < szB; i++)
{
if (OID_AT(a, i) > OID_AT(b, i))
return 1;
else if (OID_AT(a, i) < OID_AT(b, i))
return -1;
}
return 0;
}
}
Except for the function's opening {, all code is lined up
under the opening { of the block it resides in.
I don't seem to see any options that turn off this extra
indent. How do I do this? Any ideas?
Regards,
David
I'm having some trouble understanding the plethora of options
available for GNU indent for my C code.
Except for the function's opening {, I want all code to line
up under the opening { of the block it resides in.
Let me explain with an example. I'm using this command,
gindent -npro -kr -bl -bli4 -nce < ncmp.c > ncmp2.c
and ncmp2.c is neatly formatted like this,
int32_t dcrp_oidncmp(dcroid_t * a, dcroid_t * b, size_t n)
{
size_t i;
size_t szA = OID_LEN(a);
size_t szB = OID_LEN(b);
if (n == 0)
{
return 0;
}
else if (szB == 0)
{
return 1;
}
else
{
for (i = 0; i < n && i < szA && i < szB; i++)
{
if (OID_AT(a, i) > OID_AT(b, i))
return 1;
else if (OID_AT(a, i) < OID_AT(b, i))
return -1;
}
return 0;
}
}
However, notice the extra indention of code for inner blocks;
I want output to omit that extra indention, like this output,
int32_t dcrp_oidncmp(dcroid_t * a, dcroid_t * b, size_t n)
{
size_t i;
size_t szA = OID_LEN(a);
size_t szB = OID_LEN(b);
if (n == 0)
{
return 0;
}
else if (szB == 0)
{
return 1;
}
else
{
for (i = 0; i < n && i < szA && i < szB; i++)
{
if (OID_AT(a, i) > OID_AT(b, i))
return 1;
else if (OID_AT(a, i) < OID_AT(b, i))
return -1;
}
return 0;
}
}
Except for the function's opening {, all code is lined up
under the opening { of the block it resides in.
I don't seem to see any options that turn off this extra
indent. How do I do this? Any ideas?
Regards,
David