CodingStyle
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Wed Mar 5 15:59:06 PST 2014
On Wed, 5 Mar 2014, Cristian Ionescu-Idbohrn wrote:
> On Wed, 5 Mar 2014, Dirk Hohndel wrote:
>
> > - Positioning of the /* fallthrough */ comment in switch statements
> >
> > I kinda like it where I had it (lined up with "case" so it stands out
> > more)
>
> Yes. I'll look around and try to find something in that big pile of
> elisp scripts.
I had a look around. Did not manage to find anything ready to use :(
We're limited to these knobs:
(case-label . 0) ; Guessed value
(statement-case-open . 0)
(statement-case-intro . +) ; Guessed value
which is exactly what is shown near bellow:
dive.c: switch (psi) {
dive.c: case 2300 ... 2500: /* 2400 psi: LP tank */
dive.c- fmt = "LP%d";
dive.c- break;
dive.c: case 2600 ... 2700: /* 2640 psi: LP+10% */
dive.c- fmt = "LP%d";
dive.c- break;
dive.c: case 2900 ... 3100: /* 3000 psi: ALx tank */
dive.c- fmt = "AL%d";
dive.c- break;
dive.c: case 3400 ... 3500: /* 3442 psi: HP tank */
dive.c- fmt = "HP%d";
dive.c- break;
dive.c: case 3700 ... 3850: /* HP+10% */
dive.c- fmt = "HP%d+";
dive.c- break;
'break' preceedes 'case'; 'break' is indented relative to 'case' and
you replace 'break' with a comment.
parse-xml.c: switch (*buf) {
parse-xml.c: case '-':
parse-xml.c- sign = -1;
parse-xml.c- /* fallthrough */
parse-xml.c: case '+':
parse-xml.c- buf++;
parse-xml.c- }
I would argue this:
parse-xml.c: switch (*buf) {
parse-xml.c: case '-':
parse-xml.c- sign = -1;
parse-xml.c- /* fallthrough */
^^^^^^^^
parse-xml.c: case '+':
parse-xml.c- buf++;
parse-xml.c- }
(indenting the comment in tha same way a 'break' would be) would still
be more "natural".
Cheers,
--
Cristian
More information about the subsurface
mailing list