There is a lindent script in linux kernel source. It breaks long lines, but uses space instead of tab as indentation. However, the codingstyle document also from the kernel source indicates no space is allowed for indentation. Is there a fix for this problem? Or the result from lindent(space indentation) is actually allowed in kernel source? Thanks.
--
Leo Li
Freescale Semiconductor
[email protected]
On Llu, 2006-03-20 at 19:32 +0800, Li Yang-r58472 wrote:
> There is a lindent script in linux kernel source. It breaks long
> lines, but uses space instead of tab as indentation. However, the
> codingstyle document also from the kernel source indicates no space is
> allowed for indentation. Is there a fix for this problem? Or the
> result from lindent(space indentation) is actually allowed in kernel
> source? Thanks.
>
It should produce suitable output. Do you have examples of where it
produces space indentation and you expect tabs ?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alan Cox napsal(a):
> On Llu, 2006-03-20 at 19:32 +0800, Li Yang-r58472 wrote:
>> There is a lindent script in linux kernel source. It breaks long
>> lines, but uses space instead of tab as indentation. However, the
>> codingstyle document also from the kernel source indicates no space is
>> allowed for indentation. Is there a fix for this problem? Or the
>> result from lindent(space indentation) is actually allowed in kernel
>> source? Thanks.
>>
>
> It should produce suitable output. Do you have examples of where it
> produces space indentation and you expect tabs ?
As far as I know, it produces:
<tab> if (very long condition &&
<tab> ssss2nd condition)...
where ssss are four spaces. Maybe this is considered as well formed at all, but
I indent 3 tabs in this case.
regards,
- --
Jiri Slaby http://www.fi.muni.cz/~xslaby
\_.-^-._ [email protected] _.-^-._/
B67499670407CE62ACC8 22A032CC55C339D47A7E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFEHsFXMsxVwznUen4RAsGBAJ9wP+y7teZrFQNeNnBDIx0lSfBP+QCguLwx
IAvBdGnkp8Y/Ft9yOH7m3js=
=4zgg
-----END PGP SIGNATURE-----
On Mon, 2006-03-20 at 15:51, Jiri Slaby wrote:
> > It should produce suitable output. Do you have examples of where it
> > produces space indentation and you expect tabs ?
> As far as I know, it produces:
> <tab> if (very long condition &&
> <tab> ssss2nd condition)...
> where ssss are four spaces. Maybe this is considered as well formed at all, but
> I indent 3 tabs in this case.
Does that mean your tabs are 2-chars wide ? I think Linus stated that
tabs should be 8-chars wide, that should be somewhere in the
CodingStyle.
Xav
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Xavier Bestel napsal(a):
> On Mon, 2006-03-20 at 15:51, Jiri Slaby wrote:
>>> It should produce suitable output. Do you have examples of where it
>>> produces space indentation and you expect tabs ?
>> As far as I know, it produces:
>> <tab> if (very long condition &&
>> <tab> ssss2nd condition)...
>> where ssss are four spaces. Maybe this is considered as well formed at all, but
>> I indent 3 tabs in this case.
>
> Does that mean your tabs are 2-chars wide ? I think Linus stated that
> tabs should be 8-chars wide, that should be somewhere in the
> CodingStyle.
Nope, you maybe misunderstood me. Tab is 8 chars wide, but lindent do 4 spaces
on line after `if' if the condition continues on the next line. Then, I wrote I
do 2 tabs (16 chars) instead of 4-lindent spaces.
regards,
- --
Jiri Slaby http://www.fi.muni.cz/~xslaby
\_.-^-._ [email protected] _.-^-._/
B67499670407CE62ACC8 22A032CC55C339D47A7E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFEHtZWMsxVwznUen4RAv5gAJ9Q14Us1CCO3k+FoNWWgfDNYRzY4gCgt7jg
HKphoxhtCeUYU/l2mNg4TIY=
=P1Gq
-----END PGP SIGNATURE-----
On Mon, 2006-03-20 at 17:21, Jiri Slaby wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Xavier Bestel napsal(a):
> > On Mon, 2006-03-20 at 15:51, Jiri Slaby wrote:
> >>> It should produce suitable output. Do you have examples of where it
> >>> produces space indentation and you expect tabs ?
> >> As far as I know, it produces:
> >> <tab> if (very long condition &&
> >> <tab> ssss2nd condition)...
> >> where ssss are four spaces. Maybe this is considered as well formed at all, but
> >> I indent 3 tabs in this case.
> >
> > Does that mean your tabs are 2-chars wide ? I think Linus stated that
> > tabs should be 8-chars wide, that should be somewhere in the
> > CodingStyle.
> Nope, you maybe misunderstood me. Tab is 8 chars wide, but lindent do 4 spaces
> on line after `if' if the condition continues on the next line. Then, I wrote I
> do 2 tabs (16 chars) instead of 4-lindent spaces.
My bad. I thought your 3 tabs were equivalent to 1 tab + 4 spaces.
> From: Alan Cox [mailto:[email protected]]
> Sent: Monday, March 20, 2006 10:37 PM
> To: Li Yang-r58472
> Cc: [email protected]
> Subject: Re: Lindent and coding style
>
> On Llu, 2006-03-20 at 19:32 +0800, Li Yang-r58472 wrote:
> > There is a lindent script in linux kernel source. It breaks long
> > lines, but uses space instead of tab as indentation. However, the
> > codingstyle document also from the kernel source indicates no space is
> > allowed for indentation. Is there a fix for this problem? Or the
> > result from lindent(space indentation) is actually allowed in kernel
> > source? Thanks.
> >
>
> It should produce suitable output. Do you have examples of where it
> produces space indentation and you expect tabs ?
As Jiri has said, it produces code like
<tab> if (very long condition &&
<tab> ssss2nd condition)...
The indent command will align the second line at the next character of the left parentheses it belongs to. In my opinion, this approach makes code more readable. However, it does not comply with the coding style of kernel.
> From: Alan Cox [mailto:[email protected]]
> Sent: Monday, March 20, 2006 10:37 PM
> To: Li Yang-r58472
> Cc: [email protected]
> Subject: Re: Lindent and coding style
>
> On Llu, 2006-03-20 at 19:32 +0800, Li Yang-r58472 wrote:
> > There is a lindent script in linux kernel source. It breaks long
> > lines, but uses space instead of tab as indentation. However, the
> > codingstyle document also from the kernel source indicates no space is
> > allowed for indentation. Is there a fix for this problem? Or the
> > result from lindent(space indentation) is actually allowed in kernel
> > source? Thanks.
> >
>
> It should produce suitable output. Do you have examples of where it
> produces space indentation and you expect tabs ?
One more thing to add, my indent is GNU indent 2.2.9 coming with Redhat 9.0. Does it matter?
On Maw, 2006-03-21 at 10:55 +0800, Li Yang-r58472 wrote:
> > It should produce suitable output. Do you have examples of where it
> > produces space indentation and you expect tabs ?
> As Jiri has said, it produces code like
> <tab> if (very long condition &&
> <tab> ssss2nd condition)...
> The indent command will align the second line at the next character of the left parentheses it belongs to. In my opinion, this approach makes code more readable. However, it does not comply with the coding style of kernel.
Lots of the kernel uses exactly that format (probably because of indent)
so I wouldn't worry personally. The CodingStyle document is a guide not
a formal specification.