Correct (English language) style. No change in (C language) style.
This commit is contained in:
parent
e9b73edf31
commit
3f5e413d6b
@ -58,12 +58,12 @@ After any copyright header, there is a blank line, and the
|
|||||||
for source files.
|
for source files.
|
||||||
Version control system ID tags should only exist once in a file
|
Version control system ID tags should only exist once in a file
|
||||||
(unlike this one).
|
(unlike this one).
|
||||||
Non-C/C++ source files follow the above example, while C/C++ source files
|
Non-C/C++ source files follow the example above, while C/C++ source files
|
||||||
follow the below one.
|
follow the one below.
|
||||||
All VCS (version control system) revision identification from files obtained
|
All VCS (version control system) revision identification from files obtained
|
||||||
from elsewhere should be maintained, including if there are multiple IDs
|
from elsewhere should be maintained, including, where applicable, multiple IDs
|
||||||
showing a file's history.
|
showing a file's history.
|
||||||
In general, keep the IDs in tact, including any `$'s.
|
In general, keep the IDs intact, including any `$'s.
|
||||||
Most
|
Most
|
||||||
.No non- Ns Fx
|
.No non- Ns Fx
|
||||||
VCS IDs should be indented by a tab if in a comment.
|
VCS IDs should be indented by a tab if in a comment.
|
||||||
@ -77,17 +77,17 @@ static const char rcsid[] =
|
|||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Followed by another blank line.
|
Leave another blank line before the header files.
|
||||||
.Pp
|
.Pp
|
||||||
Kernel include files (i.e. sys/*.h) come first; normally, you'll need
|
Kernel include files (i.e. sys/*.h) come first; normally, include
|
||||||
<sys/types.h>
|
<sys/types.h>
|
||||||
OR <sys/param.h>, but not both! <sys/types.h> includes <sys/cdefs.h>,
|
OR <sys/param.h>, but not both. <sys/types.h> includes <sys/cdefs.h>,
|
||||||
and it's okay to depend on that.
|
and it's okay to depend on that.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
#include <sys/types.h> /* Non-local includes in angle brackets. */
|
#include <sys/types.h> /* Non-local includes in angle brackets. */
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
If it's a network program, put the network include files next.
|
For a network program, put the network include files next.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/if_dl.h>
|
#include <net/if_dl.h>
|
||||||
@ -96,8 +96,8 @@ If it's a network program, put the network include files next.
|
|||||||
#include <protocols/rwhod.h>
|
#include <protocols/rwhod.h>
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Then there's a blank line, followed by the /usr include files.
|
Leave a blank line before the next group, the /usr include files,
|
||||||
The /usr include files should be sorted!
|
which should be sorted alphabetically by name.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
.Ed
|
.Ed
|
||||||
@ -108,7 +108,7 @@ to the program go in pathnames.h in the local directory.
|
|||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
Then, there's a blank line, and the user include files.
|
Leave another blank line before the user include files.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
#include "pathnames.h" /* Local includes in double quotes. */
|
#include "pathnames.h" /* Local includes in double quotes. */
|
||||||
.Ed
|
.Ed
|
||||||
@ -416,7 +416,7 @@ If a line overflows reuse the type keyword.
|
|||||||
.Pp
|
.Pp
|
||||||
Be careful to not obfuscate the code by initializing variables in
|
Be careful to not obfuscate the code by initializing variables in
|
||||||
the declarations. Use this feature only thoughtfully.
|
the declarations. Use this feature only thoughtfully.
|
||||||
DO NOT use function calls in initializers!
|
DO NOT use function calls in initializers.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
struct foo one, *two;
|
struct foo one, *two;
|
||||||
double three;
|
double three;
|
||||||
@ -469,7 +469,7 @@ Use
|
|||||||
.Xr err 3
|
.Xr err 3
|
||||||
or
|
or
|
||||||
.Xr warn 3 ,
|
.Xr warn 3 ,
|
||||||
don't roll your own!
|
don't roll your own.
|
||||||
.Bd -literal
|
.Bd -literal
|
||||||
if ((four = malloc(sizeof(struct foo))) == NULL)
|
if ((four = malloc(sizeof(struct foo))) == NULL)
|
||||||
err(1, (char *)NULL);
|
err(1, (char *)NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user