[tz] coding style for tzcode?

Christos Zoulas christos at zoulas.com
Sat Oct 4 20:14:51 UTC 2014


On Oct 4, 12:41pm, eggert at cs.ucla.edu (Paul Eggert) wrote:
-- Subject: Re: [tz] coding style for tzcode?

| The code has always been somewhat eclectic in style.  As it gets more 
| complicated the 8-character indenting has had problems scaling, and I've been 
| using 2-character indenting in new changes when that doesn't involve reindenting 
| much existing code, and sometimes 4-character to insert an intermediate level of 
| indentation without reindenting much else.  Reformatting the code to a 
| particular style or indentation level would make it harder to compare versions.

Well, 

It is not necessary to change:
	if (foo)
		return -1

to:
	if (foo)
	  return false;

I don't any discussion about changing the coding style anywhere.

Also:

This indentation is clearly wrong, and this is why it runs out of
horizontal space:

        if (doextend && nread > 2 &&
                up->buf[0] == '\n' && up->buf[nread - 1] == '\n' &&
                sp->typecnt + 2 <= TZ_MAX_TYPES) {
                        struct state    *ts = &lsp->u.st;
                
                        up->buf[nread - 1] = '\0';
                        if (tzparse(&up->buf[1], ts, false)
                            && ts->typecnt == 2
                            && sp->charcnt + ts->charcnt <= TZ_MAX_CHARS) {
                                        for (i = 0; i < 2; ++i)
                                                ts->ttis[i].tt_abbrind +=
                                                        sp->charcnt;
                                        for (i = 0; i < ts->charcnt; ++i)
                                                sp->chars[sp->charcnt++] =
                                                        ts->chars[i];
                                        i = 0;  



At least can we have a statement as to what the official indentation of
the code is? 

As far as losing the ability to run diff because of whitespace changes:
	1. you can always run diff -bw
	2. you do all the whitespace formatting changes in one shot without
	   any other coding changes.

christos


More information about the tz mailing list