Skip to content

Commit ac837e4

Browse files
author
Phil Shafer
committed
Merge branch 'develop'
2 parents a46bb35 + 33c649d commit ac837e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1844
-617
lines changed

doc/Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# using the SOFTWARE, you agree to be bound by the terms of that
99
# LICENSE.
1010

11-
doc docs: xolint.rst html
11+
doc docs: xolint-errors.rst html
1212

1313
#
1414
# The contents of xolint.rst is generated based on xolint.pl, since we
@@ -17,8 +17,8 @@ doc docs: xolint.rst html
1717
# the developer needs to commit any changes.
1818
#
1919

20-
xolint.rst: ${top_srcdir}/xolint/xolint.pl
21-
perl ${top_srcdir}/xolint/xolint.pl -D > ${top_srcdir}/doc/xolint.rst
20+
xolint-errors.rst: ${top_srcdir}/xolint/xolint.pl
21+
perl ${top_srcdir}/xolint/xolint.pl -D > ${top_srcdir}/doc/xolint-errors.rst
2222

2323
SPHINX = python3 -msphinx
2424

doc/api.rst

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,18 @@ xo_destroy
386386
Emitting Content (xo_emit)
387387
--------------------------
388388
389-
The functions in this section are used to emit output.
390-
391-
The "fmt" argument is a string containing field descriptors as
392-
specified in :ref:`format-strings`. The use of a handle is optional and
393-
`NULL` can be passed to access the internal "default" handle. See
389+
The functions in this section are used to emit output. They use a
390+
`format` string containing field descriptors as specified in
391+
:ref:`format-strings`. The use of a handle is optional and `NULL` can
392+
be passed to access the internal "default" handle. See
394393
:ref:`handles`.
395394
396395
The remaining arguments to `xo_emit` and `xo_emit_h` are a set of
397396
arguments corresponding to the fields in the format string. Care must
398397
be taken to ensure the argument types match the fields in the format
399-
string, since an inappropriate cast can ruin your day. The vap
400-
argument to `xo_emit_hv` points to a variable argument list that can
401-
be used to retrieve arguments via `va_arg`.
398+
string, since an inappropriate or missing argument can ruin your day.
399+
The `vap` argument to `xo_emit_hv` points to a variable argument list
400+
that can be used to retrieve arguments via `va_arg`.
402401
403402
.. c:function:: xo_ssize_t xo_emit (const char *fmt, ...)
404403
@@ -428,19 +427,40 @@ be used to retrieve arguments via `va_arg`.
428427
Single Field Emitting Functions (xo_emit_field)
429428
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430429
431-
The functions in this section can also make output, but only make a
432-
single field at a time. These functions are intended to avoid the
433-
scenario where one would otherwise need to compose a format
434-
descriptors using `snprintf`. The individual parts of the format
435-
descriptor are passed in distinctly.
436-
437-
.. c:function:: xo_ssize_t xo_emit_field (const char *rolmod, const char *contents, const char *fmt, const char *efmt, ...)
430+
The functions in this section emit formatted output similar to
431+
`xo_emit` but where `xo_emit` uses a single string argument containing
432+
the description for multiple fields, `xo_emit_field` emits a single
433+
field using multiple ar- guments to contain the field description.
434+
`xo_emit_field_h` adds an ex- plicit handle to use instead of the
435+
default handle, while `xo_emit_field_hv` accepts a va_list for
436+
additional flexibility.
437+
438+
The arguments `rolmod`, `content`, `fmt`, and `efmt` are detailed in
439+
:ref:`field-formatting`. Using distinct arguments allows callers to
440+
pass the field description in pieces, rather than having to use
441+
something like `snprintf` to build the format string required by
442+
`xo_emit`. The arguments are each NUL-terminated strings. The `rolmod`
443+
argument contains the `role` and `modifier` portions of the field
444+
description, the `content` argument contains the `content` portion, and
445+
the `fmt` and `efmt` contain the `field-format` and `encoding-format` por-
446+
tions, respectively.
447+
448+
As with `xo_emit`, the `fmt` and `efmt` values are both optional,
449+
since the `field-format` string defaults to "%s", and the
450+
`encoding-format`'s default value is derived from the `field-format`
451+
per :ref:`field-formatting`. However, care must be taken to avoid
452+
using a value directly as the format, since characters like '{', '%',
453+
and '}' will be interpreted as formatting directives, and may cause
454+
xo_emit_field to dereference arbitrary values off the stack, leading
455+
to bugs, core files, and gnashing of teeth.
456+
457+
.. c:function:: xo_ssize_t xo_emit_field (const char *rolmod, const char *content, const char *fmt, const char *efmt, ...)
438458
439459
:param rolmod: A comma-separated list of field roles and field modifiers
440460
:type rolmod: const char *
441-
:param contents: The "contents" portion of the field description string
442-
:type contents: const char *
443-
:param fmt: Content format string
461+
:param content: The "content" portion of the field description string
462+
:type content: const char *
463+
:param fmt: Contents format string
444464
:type fmt: const char *
445465
:param efmt: Encoding format string, followed by additional arguments
446466
:type efmt: const char *
@@ -450,8 +470,11 @@ descriptor are passed in distinctly.
450470
::
451471
452472
EXAMPLE::
473+
xo_emit_field("T", title, NULL, NULL, NULL);
453474
xo_emit_field("T", "Host name is ", NULL, NULL);
454475
xo_emit_field("V", "host-name", NULL, NULL, host-name);
476+
xo_emit_field(",leaf-list,quotes", "sku", "%s-%u", "%s-000-%u",
477+
"gum", 1412);
455478
456479
.. c:function:: xo_ssize_t xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents, const char *fmt, const char *efmt, ...)
457480

doc/faq.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,7 @@ a difference, change the names to make that difference more obvious.
205205
What does this message mean?
206206
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
207207

208-
.. include:: xolint.rst
208+
.. toctree::
209+
:maxdepth: 2
210+
211+
xolint-errors.rst

doc/field-formatting.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
.. index:: Field Formatting
3+
.. _field-formatting:
34

45
Field Formatting
56
----------------

0 commit comments

Comments
 (0)