Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 1996 09:26:40 +0200 (MET DST)
From:      grog@lemis.de (Greg Lehey)
To:        rnordier@iafrica.com (Robert Nordier)
Cc:        chat@FreeBSD.ORG (FreeBSD Chat)
Subject:   Re: Indentation styles
Message-ID:  <199605290726.JAA19555@allegro.lemis.de>
In-Reply-To: <199605281940.VAA00188@eac.iafrica.com> from "Robert Nordier" at May 28, 96 09:39:59 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Robert Nordier writes:
>
> Terry Lambert wrote:
>>> I think Greg's concern in valid, but this is one of Nature's
>>> Insoluble Problems.  Let's have some sanity, please!
>>
>> At one time I suggested running a "beautifier" on code as part of the
>> CVS commit process.  I still like the idea.
>>
>> I also like the idea of running a local style template on checkout
>> from a CVS tree.  8-).
>
> A local style template on checkout isn't a bad idea.  If only 'indent'
> were just a little smarter.  But (just when things seem to be going
> well) it comes up with:
>
>    static char    *f_args[F_ARGS] = {
>            "160", "180", "320", "360",     /* K_ARGS */
>            "720", "1200", "1440", "2880",
>            "1.2", "1.44", "2.88"   /* M_ARGS */
>} ;
>
>    static struct BPB stdbpb[BPBCNT] = {
>            {512, 1, 1, 2, 64, 320, 0xfe, 1, 8, 1, 0, 0},   /* 160K */
>            {512, 1, 1, 2, 64, 360, 0xfc, 2, 9, 1, 0, 0},   /* 180K */
>            {512, 2, 1, 2, 112, 640, 0xff, 1, 8, 2, 0, 0},  /* 320K */
>            {512, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2, 0, 0},  /* 360K */
>            {512, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2, 0, 0}, /* 720K */
>            {512, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2, 0, 0},        /* 1.2M */
>            {512, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2, 0, 0},        /* 1.44M */
>            {512, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2, 0, 0} /* 2.88M */
>} ;

You don't say how you want it to look.  This looks OK to me, except
for the hanging braces (personal taste).  Just for giggles, I ran this
fragment through indent and got:

static char *f_args [F_ARGS] =
{
  "160", "180", "320", "360",				    /* K_ARGS */
  "720", "1200", "1440", "2880",
  "1.2", "1.44", "2.88"					    /* M_ARGS */
};

static struct BPB stdbpb [BPBCNT] =
{
  {512, 1, 1, 2, 64, 320, 0xfe, 1, 8, 1, 0, 0},		    /* 160K */
  {512, 1, 1, 2, 64, 360, 0xfc, 2, 9, 1, 0, 0},		    /* 180K */
  {512, 2, 1, 2, 112, 640, 0xff, 1, 8, 2, 0, 0},	    /* 320K */
  {512, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2, 0, 0},	    /* 360K */
  {512, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2, 0, 0},	    /* 720K */
  {512, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2, 0, 0},	    /* 1.2M */
  {512, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2, 0, 0},	    /* 1.44M */
  {512, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2, 0, 0}	    /* 2.88M */
};

This is pretty much what I want to see.  

> I think my main point is that a "What is not forbidden should be made
> compulsory" attitude is likely to make a few (maybe eccentric) souls
> unhappy.  And maybe the issue is just too contentious for common-sense
> to prevail.

I think this is dodging the point.  The point is that one limitation
on what you can do in working on somebody else's code is the degree to
which you can understand it.  If you can do something to improve that
situation, this will help you achieve more objectives.  One way to
work towards this goal is to have style guides.  Of course, as Terry
point out, a lot of them are based on convention and the tools you
use.  The FreeBSD style doesn't work well with my tools, which is why
I sent out the original message.

Greg




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605290726.JAA19555>