On Thu, 27 Nov 2008, [utf-8] Dag-Erling Sm??rgrav wrote:
"M. Warner Losh" <[EMAIL PROTECTED]> writes:
I personally really dislike the style (and yes, I know all the
arguments for it). If you really want something that complex inside a
block to need block scoped variables, then that really argues for a
function oft times...
There is one particular situation where it is very convenient:
int
foo(struct sockaddr *sa)
{
switch (s->sa_family) {
case AF_INET: {
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
/* ... */
break;
}
Switch statements are 1 case (the only case?) where the braces needed for
non-C99 declarations don't require extra indentation. However, indent(1)
doesn't understand this and mangles the above to:
int
foo(struct sockaddr *sa)
{
switch (s->sa_family) {
case AF_INET:{
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
/* ... */
break;
}
indent(1) has fixed a style bug in the above (the missing blank line after
the declarations) but it has introduced 2 (the missing space before "{"
and the unwanted indentation). Fixing the other style bug in the above
(the initialization in the declaration) is beyond the scope of indent(1).
gindent-2.2.9 -npro gives the same style bugs and 1 more (it misformats
the comment to a block one, but that may be due to a bad default).
Bruce
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"