[PATCH 1 of 6] C modules: don't mix tabs and spaces

Maxim Dounin mdounin at mdounin.ru
Thu Aug 27 08:46:29 CDT 2009


Hello!

On Thu, Aug 27, 2009 at 01:09:10PM -0000, Nicolas Dumazet wrote:

> # HG changeset patch
> # User Nicolas Dumazet <nicdumz.commits at gmail.com>
> # Date 1251369425 -7200
> # Node ID fdd0c8cdca78d000e76e895519abde0eeb0bbad1
> # Parent  7345fa5e572e029362bc6f2f96af452607ebb1ff
> C modules: don't mix tabs and spaces
> 
> Use tabs seems it is apparently the standard.

I believe it's linux kernel style which is used for C code.  Matt 
wrote about it some time ago.

[...]

> @@ -253,7 +253,7 @@
>  	pos = (struct pos *)calloc(bn ? bn : 1, sizeof(struct pos));
>  	/* we can't have more matches than lines in the shorter file */
>  	l.head = l.base = (struct hunk *)malloc(sizeof(struct hunk) *
> -	                                        ((an<bn ? an:bn) + 1));
> +											((an<bn ? an:bn) + 1));

Here is a good illustration why tabs shouldn't be used to pad 
continuation lines (are you using tabwidth=4 in your editor? try 
default - 8).  Even if tabs used for indenting.

[...]

> diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c
> --- a/mercurial/diffhelpers.c
> +++ b/mercurial/diffhelpers.c
> @@ -74,7 +74,7 @@
>  		todob = lenb - PyList_Size(b);
>  		num = todoa > todob ? todoa : todob;
>  		if (num == 0)
> -		    break;
> +			break;

This one looks like real style fix.

[...]

Maxim Dounin


More information about the Mercurial-devel mailing list