xref: /freebsd/contrib/libxo/doc/xolint.rst (revision 34b867ca30479cec104fd069178df294f8ea35f1)
1*34b867caSPhil Shafer======
2*34b867caSPhil Shaferxolint
3*34b867caSPhil Shafer======
4983afe33SPhil Shafer
5*34b867caSPhil Shafer`xolint` is a tool for reporting common mistakes in format strings
6*34b867caSPhil Shaferin source code that invokes `xo_emit`.  It allows these errors
7*34b867caSPhil Shaferto be diagnosed at build time, rather than waiting until runtime.
8983afe33SPhil Shafer
9*34b867caSPhil Shafer`xolint` takes the one or more C files as arguments, and reports
10*34b867caSPhil Shaferand errors, warning, or informational messages as needed:
11983afe33SPhil Shafer
12*34b867caSPhil Shafer  ============ ===================================================
13*34b867caSPhil Shafer   Option       Meaning
14*34b867caSPhil Shafer  ============ ===================================================
15*34b867caSPhil Shafer   -c           Invoke 'cpp' against the input file
16*34b867caSPhil Shafer   -C <flags>   Flags that are passed to 'cpp
17*34b867caSPhil Shafer   -d           Enable debug output
18*34b867caSPhil Shafer   -D           Generate documentation for all xolint messages
19*34b867caSPhil Shafer   -I           Generate info table code
20*34b867caSPhil Shafer   -p           Print the offending lines after the message
21*34b867caSPhil Shafer   -V           Print vocabulary of all field names
22*34b867caSPhil Shafer   -X           Extract samples from xolint, suitable for testing
23*34b867caSPhil Shafer  ============ ===================================================
24983afe33SPhil Shafer
25*34b867caSPhil ShaferThe output message will contain the source filename and line number, the
26*34b867caSPhil Shaferclass of the message, the message, and, if -p is given, the
27*34b867caSPhil Shaferline that contains the error::
28983afe33SPhil Shafer
29*34b867caSPhil Shafer    % xolint.pl -t xolint.c
30*34b867caSPhil Shafer    xolint.c: 16: error: anchor format should be "%d"
31*34b867caSPhil Shafer    16         xo_emit("{[:/%s}");
32983afe33SPhil Shafer
33*34b867caSPhil ShaferThe "-I" option will generate a table of `xo_info_t`_ structures,
34*34b867caSPhil Shafersuitable for inclusion in source code.
35983afe33SPhil Shafer
36*34b867caSPhil Shafer.. _xo_info_t: :ref:`field-information`
37983afe33SPhil Shafer
38*34b867caSPhil ShaferThe "-V" option does not report errors, but prints a complete list of
39*34b867caSPhil Shaferall field names, sorted alphabetically.  The output can help spot
40*34b867caSPhil Shaferinconsistencies and spelling errors.
41