You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Martin Kraemer <Ma...@mch.sni.de> on 1997/09/17 17:34:10 UTC
[Silence on the list?] Coding Style Questions
[Wow! Not a single message today? What's going on? Hyperreal down? Or my
company?]
As the code is revamped and unified, I'd like to know which style is
preferred for "new style" code. Is there a consensus, or a paper about it,
or do developers do it either way?
Which alternative is the preferred style, in your opinion?
Either: Or:
======= =====
port = 80; port = DEFAULT_PORT;
return DOCUMENT_FOLLOWS; return HTTP_OK;
return REDIRECT; return HTTP_MOVED_TEMPORARILY;
etc. etc.
#define HTTP_PROTO(major,minor) (1000*(major)+(minor))
if (r->proto_num >= 1001) ... if (r->proto_num >= HTTP_PROTO(1,1)) ...
With the exception of the last example, it appears to me that newer code
prefers the second column, but I might be mistaken.
Anyone?
Martin
--
| S I E M E N S | <Ma...@mch.sni.de> | Siemens Nixdorf
| ------------- | Voice: +49-89-636-46021 | Informationssysteme AG
| N I X D O R F | FAX: +49-89-636-44994 | 81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request
Re: [Silence on the list?] Coding Style Questions
Posted by Ben Laurie <be...@algroup.co.uk>.
Martin Kraemer wrote:
>
> [Wow! Not a single message today? What's going on? Hyperreal down? Or my
> company?]
>
> As the code is revamped and unified, I'd like to know which style is
> preferred for "new style" code. Is there a consensus, or a paper about it,
> or do developers do it either way?
>
> Which alternative is the preferred style, in your opinion?
>
> Either: Or:
> ======= =====
>
> port = 80; port = DEFAULT_PORT;
>
> return DOCUMENT_FOLLOWS; return HTTP_OK;
> return REDIRECT; return HTTP_MOVED_TEMPORARILY;
> etc. etc.
>
> #define HTTP_PROTO(major,minor) (1000*(major)+(minor))
> if (r->proto_num >= 1001) ... if (r->proto_num >= HTTP_PROTO(1,1)) ...
>
> With the exception of the last example, it appears to me that newer code
> prefers the second column, but I might be mistaken.
Yep, column 2. But DEFAULT_PORT should depend on the connection, as in
default_port(r) (in an ideal world).
Cheers,
Ben.
--
Ben Laurie |Phone: +44 (181) 994 6435|Apache Group member
Freelance Consultant |Fax: +44 (181) 994 6472|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd, |http://www.algroup.co.uk/Apache-SSL
London, England. |"Apache: TDG" http://www.ora.com/catalog/apache
Re: [Silence on the list?] Coding Style Questions
Posted by Dean Gaudet <dg...@arctic.org>.
On Wed, 17 Sep 1997, Martin Kraemer wrote:
> [Wow! Not a single message today? What's going on? Hyperreal down? Or my
> company?]
Yeah I know, I was wondering myself :)
> Either: Or:
> ======= =====
>
> port = 80; port = DEFAULT_PORT;
>
> return DOCUMENT_FOLLOWS; return HTTP_OK;
> return REDIRECT; return HTTP_MOVED_TEMPORARILY;
> etc. etc.
>
New code should be in the style of the second column.
> #define HTTP_PROTO(major,minor) (1000*(major)+(minor))
> if (r->proto_num >= 1001) ... if (r->proto_num >= HTTP_PROTO(1,1)) ...
This wouldn't be a bad change at all...
Dean