knfmt
The knfmt(1) utility formats source code files according to style(9) from OpenBSD in a best effort fashion. By default, source code is read from standard input and the formatted source code is written to standard output:
$ knfmt <knfmt.c
It can perform an in place edit by writing back the formatted source code:
$ knfmt -i knfmt.c
It can produce a diff between the original and formatted source code:
$ knfmt -d knfmt.c
In addition, it can given a diff only format the changed lines. This option is compatible with the options mentioned above:
$ git diff | knfmt -Dd
It can subjectively try to simplify the source code:
$ knfmt -s knfmt.c
The implementation is further described in DESIGN.
Installation
OpenBSD
# pkg_add knfmt
From source
The installation prefix defaults to /usr/local and can be altered using the
PREFIX environment variable when invoking configure:
$ ./configure
$ make install
License
Copyright (c) 2021-2022 Anton Lindqvist. Distributed under the ISC license.