public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Lindent and coding style
@ 2006-03-20 11:32 Li Yang-r58472
  2006-03-20 14:36 ` Alan Cox
  0 siblings, 1 reply; 9+ messages in thread
From: Li Yang-r58472 @ 2006-03-20 11:32 UTC (permalink / raw)
  To: linux-kernel

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
 
LeoLi@freescale.com 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Lindent and coding style
  2006-03-20 11:32 Lindent and coding style Li Yang-r58472
@ 2006-03-20 14:36 ` Alan Cox
  2006-03-20 14:51   ` Jiri Slaby
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Cox @ 2006-03-20 14:36 UTC (permalink / raw)
  To: Li Yang-r58472; +Cc: linux-kernel

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 ?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Lindent and coding style
  2006-03-20 14:36 ` Alan Cox
@ 2006-03-20 14:51   ` Jiri Slaby
  2006-03-20 16:12     ` Xavier Bestel
  0 siblings, 1 reply; 9+ messages in thread
From: Jiri Slaby @ 2006-03-20 14:51 UTC (permalink / raw)
  To: Alan Cox; +Cc: Li Yang-r58472, linux-kernel

-----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         www.fi.muni.cz/~xslaby
\_.-^-._   jirislaby@gmail.com   _.-^-._/
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-----

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Lindent and coding style
  2006-03-20 14:51   ` Jiri Slaby
@ 2006-03-20 16:12     ` Xavier Bestel
  2006-03-20 16:21       ` Jiri Slaby
  0 siblings, 1 reply; 9+ messages in thread
From: Xavier Bestel @ 2006-03-20 16:12 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Alan Cox, Li Yang-r58472, linux-kernel

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Lindent and coding style
  2006-03-20 16:12     ` Xavier Bestel
@ 2006-03-20 16:21       ` Jiri Slaby
  2006-03-20 16:28         ` Xavier Bestel
  0 siblings, 1 reply; 9+ messages in thread
From: Jiri Slaby @ 2006-03-20 16:21 UTC (permalink / raw)
  To: Xavier Bestel; +Cc: Alan Cox, Li Yang-r58472, linux-kernel

-----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         www.fi.muni.cz/~xslaby
\_.-^-._   jirislaby@gmail.com   _.-^-._/
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-----

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Lindent and coding style
  2006-03-20 16:21       ` Jiri Slaby
@ 2006-03-20 16:28         ` Xavier Bestel
  0 siblings, 0 replies; 9+ messages in thread
From: Xavier Bestel @ 2006-03-20 16:28 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Alan Cox, Li Yang-r58472, linux-kernel

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.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Lindent and coding style
@ 2006-03-21  2:55 Li Yang-r58472
  2006-03-21 10:22 ` Alan Cox
  0 siblings, 1 reply; 9+ messages in thread
From: Li Yang-r58472 @ 2006-03-21  2:55 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

> From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
> Sent: Monday, March 20, 2006 10:37 PM
> To: Li Yang-r58472
> Cc: linux-kernel@vger.kernel.org
> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Lindent and coding style
@ 2006-03-21  2:58 Li Yang-r58472
  0 siblings, 0 replies; 9+ messages in thread
From: Li Yang-r58472 @ 2006-03-21  2:58 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

> From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
> Sent: Monday, March 20, 2006 10:37 PM
> To: Li Yang-r58472
> Cc: linux-kernel@vger.kernel.org
> 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?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Lindent and coding style
  2006-03-21  2:55 Li Yang-r58472
@ 2006-03-21 10:22 ` Alan Cox
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Cox @ 2006-03-21 10:22 UTC (permalink / raw)
  To: Li Yang-r58472; +Cc: linux-kernel

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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-03-21 10:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-20 11:32 Lindent and coding style Li Yang-r58472
2006-03-20 14:36 ` Alan Cox
2006-03-20 14:51   ` Jiri Slaby
2006-03-20 16:12     ` Xavier Bestel
2006-03-20 16:21       ` Jiri Slaby
2006-03-20 16:28         ` Xavier Bestel
  -- strict thread matches above, loose matches on Subject: below --
2006-03-21  2:55 Li Yang-r58472
2006-03-21 10:22 ` Alan Cox
2006-03-21  2:58 Li Yang-r58472

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox