Skip to content

aabacchus/bore

Repository files navigation

bore: Ben's cORE
==========

My basic set of core utilities. Watch this space!
They shall implement commands and utilities from POSIX.1-2017, with
almost no extensions to the standard (check the PROGRESS file). They are written
using only the standard POSIX.1-2008 C library (_XOPEN_SOURCE=700).

Each utility is a single self-contained file, relying on no internal libraries.

The software found in this repository has been dedicated to the public domain.
See UNLICENSE for more details.

Building
--------

The requirements are:

* Any C99 compiler
* Any POSIX.1-2008 standard C library
* Any POSIX make implementation (optional; you can compile manually)

Just type `make`, and the binaries shall be compiled into the bin/ directory.

Contributing
------------

Contributions are welcome; please email patches to me at <[email protected]> (or
communicate by means of git-request-pull(1)), and make sure either the commit
message or the file contains a public domain dedication.

Programming style guide
-----------------------

This is how I tend to write C:

* 4 spaces of indentation.

* function type and name are separated by a linebreak:

DO:    int
       foo() {
           ...
       }
NOT:   int foo() {
           ...
       }

* C language keywords have a space between them and the bracket:

DO:    if (x)
NOT:   if(x)

* function definitions and calls have no space before the bracket:

DO:    foo(x);
NOT:   foo (x);

* curly braces come at the end of a line, and separated by a space:

DO:    while (x) {
           ...
       }
NOT:   while (x){
           ...
       }
NOR:   while (x){ ... }

DO:    int
       foo() {
           ...
       }
NOT:   int
       foo(){
           ...
       }

* one-line blocks do not require curly braces, but it's better practice to put
  them in:

OK:    if (x)
           foo();
BEST:  if (x) {
           foo();
       }

* assignment should not take place inside an if block or similar, unless it is
  particularly useful such as in an while block. Use a separate line.

DO:    fd = open("path", O_RDONLY);
       if (fd == -1) {
           ...
NOT:   if ((fd = open("path", O_RDONLY)) == -1) {
           ...
OK:    while ((n = read(fd, buf, BUFSIZ) > 0) {
           ...

* there should be spaces between elements in brackets, but not directly inside
  the brackets. if in doubt, try to use spaces as you would under english
  grammatical rules.
  Just keep it consistent and tidy.

DO:    for (int i; i < max; i *= 2)
NOT:   for ( int i;i <max;   i*=2 )

* the asterisk goes next to the pointer name, not the type.

DO:    char *s;
NOT:   int* x, y;

* variables should be named concisely; not too short to avoid confusion or
  obfuscation, but not too long so as to appear cluttered.

* don't typedef to avoid typing the word struct.

* use snake_case rather than camelCase where necessary.

* try to wrap lines at about 80 columns.

It shouldn't need noting that all code should be as portable as possible, using
only POSIX features and functions.

Releases

No releases published

Packages

No packages published