Thanks! I just hadn't ever seen (or knew it was legal to use)
curly braces by themselves.


On Wednesday 29 January 2003 18:53, Kurt Bigler wrote:
> on 1/29/03 10:16 AM, Jesse Guardiani <[EMAIL PROTECTED]> wrote:
> > Actually, this appears to be part of the if statement before it.
> >
> > A complete listing would be this (again, from main2() in sqwebmail.c):
> >
> > if (!ip_addr)   ip_addr="127.0.0.1";
>
> The above is a one-line if statement.  With no braces immediately after the
> if closing parenthesis, only  the single statment ip_addr="127.0.0.1" is
> conditionally executed.
>
> Many people prefer to use indentation clarify it:
>
>     if (!ip_addr)
>         ip_addr="127.0.0.1";
>
> Other people would like to see the braces even if they are not required:
>
>     if (!ip_addr)
>     {
>         ip_addr="127.0.0.1";
>     }
>
> and using the braces there would certainly reduce the visual ambiguity (for
> some of us).
>
> > umask(0077);
>
> The umask is executed unconditionally, as is the block below.
>
> > {
> >   const char *p=getenv("SQWEBMAIL_TIMEOUTHARD");
> >
> >   if (p && *p)
> >       timeouthard=atoi(p);
> > }
>
> The block (probably should be called a "compound statement"?) restricts the
> scope of the variable p, which can be useful in making code more readable,
> and potentially to help the optimizer.
>
> Whever a block like this follows something above it that looks like it
> might have a block following it, it can be confusing.  I have been confused
> by code like this, some of which I had written.
>
> But this is all pretty much a matter of opinion.  We all see code
> differently, and have different processes for interacting with it.
> Basically I think we each try to develop ways of coding that reduces the
> number of mistakes we make when we are maintaining our own code.  For those
> who can not type fast, shortcuts will also be desirable.
>
> > I understand the curly braces now, I think, but when are the lines
> > before the curly braces (and after the 'if') executed?
> >
> > Always?
> >
> > Very confused. Thanks.
> >
> > Jesse
> >
> > On Wednesday 29 January 2003 12:47, Jesse Guardiani wrote:
> >> Mr. Sam,
> >>
> >> I noticed that you use "floating" curly braces throughout Sqwebmail,
> >> like this (taken from main2() ):
> >>
> >> umask(0077);
> >>
> >> {
> >> const char *p=getenv("SQWEBMAIL_TIMEOUTHARD");
> >>
> >> if (p && *p)
> >> timeouthard=atoi(p);
> >> }
> >>
> >>
> >> I've never seen that done before.
> >>
> >> Why do you do that?
> >>
> >>
> >> Thanks,

-- 
Jesse Guardiani, Systems Administrator
WingNET Internet Services,
P.O. Box 2605 // Cleveland, TN 37320-2605
423-559-LINK (v)  423-559-5145 (f)
http://www.wingnet.net

We are actively looking for companies that do a lot of long
distance faxing and want to cut their long distance bill by
up to 50%.  Contact [EMAIL PROTECTED] for more info.



Reply via email to