bore

basic core utilities (PD)
git clone git://bvnf.space/bore.git
Log | Files | Refs | README

README (3010B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
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 <ben@bvnf.space> (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.