aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Shafer <phil@FreeBSD.org>2017-05-16 18:41:36 +0000
committerPhil Shafer <phil@FreeBSD.org>2017-05-16 18:41:36 +0000
commitf720a75aba553acfa285f6788564d4a6d7b43d34 (patch)
tree21887c4f5a4c7a29d9ce96b61c6f44c4e8ccde2f
parenta7390ff330936e2bf4e492d86a6f5e288ff8a008 (diff)
downloadsrc-vendor/Juniper/libxo/0.7.2.tar.gz
src-vendor/Juniper/libxo/0.7.2.zip
Import libxo 0.7.2vendor/Juniper/libxo/0.7.2
-rw-r--r--configure.ac25
-rw-r--r--doc/Makefile.am4
-rw-r--r--doc/libxo-manual.html391
-rw-r--r--doc/libxo.txt45
-rw-r--r--libxo/Makefile.am7
-rw-r--r--libxo/libxo.c543
-rw-r--r--libxo/xo.h109
-rw-r--r--libxo/xo_buf.h10
-rw-r--r--libxo/xo_encoder.c4
-rw-r--r--libxo/xo_format.52
-rw-r--r--libxo/xo_options.7147
-rw-r--r--libxo/xo_syslog.c17
-rw-r--r--tests/core/saved/test_01.E.out2
-rw-r--r--tests/core/saved/test_01.J.out2
-rw-r--r--tests/core/saved/test_01.JP.out2
-rw-r--r--tests/core/saved/test_01.X.out2
-rw-r--r--tests/core/saved/test_01.XP.out2
-rw-r--r--tests/core/saved/test_10.X.out2
-rw-r--r--tests/core/saved/test_10.XP.out2
-rw-r--r--tests/core/saved/test_11.X.out2
-rw-r--r--tests/core/saved/test_11.XP.out2
-rw-r--r--tests/core/test_01.c4
-rw-r--r--tests/gettext/po/pig_latin/strerror.po2
-rw-r--r--tests/gettext/saved/gt_01.J.out2
-rw-r--r--tests/gettext/saved/gt_01.JP.out2
-rw-r--r--tests/gettext/strerror.pot2
-rw-r--r--xo/xo.c4
27 files changed, 809 insertions, 529 deletions
diff --git a/configure.ac b/configure.ac
index b47dedb0758f..26d85b6283d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
-AC_INIT([libxo], [0.6.3], [phil@juniper.net])
+AC_INIT([libxo], [0.7.2], [phil@juniper.net])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
# Support silent build rules. Requires at least automake-1.11.
@@ -20,7 +20,6 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PROG_CC
-AM_PROG_AR
AC_PROG_INSTALL
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LN_S
@@ -135,6 +134,21 @@ if test "$GETTEXT_ENABLE" != "no"; then
AC_MSG_RESULT([$HAVE_GETTEXT])
fi
+
+ if test "$HAVE_GETTEXT" != "yes"; then
+ GETTEXT_PREFIX=/usr/local
+ AC_MSG_CHECKING([gettext in ${GETTEXT_PREFIX}])
+
+ _save_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <libintl.h>]
+ [int main() {char *cp = dgettext(NULL, "xx"); return 0; }]])],
+ [HAVE_GETTEXT=yes],
+ [HAVE_GETTEXT=no])
+ CFLAGS="$_save_cflags"
+
+ AC_MSG_RESULT([$HAVE_GETTEXT])
+ fi
fi
if test "$HAVE_GETTEXT" = "yes"; then
@@ -278,6 +292,13 @@ AC_ARG_ENABLE([debug],
AC_MSG_RESULT([$LIBXO_DEBUG])
AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"])
+AC_MSG_CHECKING([whether to use int return codes])
+AC_ARG_ENABLE([int-return-codes],
+ [ --enable-int-return-codes Use int return codes (instead of ssize_t)],
+ [USE_INT_RETURN_CODES=yes; AC_DEFINE([USE_INT_RETURN_CODES], [1], [Use int return codes])],
+ [USE_INT_RETURN_CODES=no])
+AC_MSG_RESULT([$USE_INT_RETURN_CODES])
+
AC_MSG_CHECKING([whether to build with text-only rendering])
AC_ARG_ENABLE([text-only],
[ --enable-text-only Turn on text-only rendering],
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 16d6ba5bffaf..a00994cacb6f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -61,9 +61,9 @@ xolint.txt: ${top_srcdir}/xolint/xolint.pl
CLEANFILES = \
xolint.txt \
${INPUT}.xml \
-${INPUT}.txt \
${INPUT}.fxml \
-${INPUT}.html
+${OUTPUT}.txt \
+${OUTPUT}.html
else
doc docs:
@${ECHO} "The 'oxtradoc' tool is not installed; see libslax.org"
diff --git a/doc/libxo-manual.html b/doc/libxo-manual.html
index 0c042a47a418..34053c98b1f9 100644
--- a/doc/libxo-manual.html
+++ b/doc/libxo-manual.html
@@ -515,7 +515,7 @@ li.indline1 {
}
@top-right {
- content: "May 2016";
+ content: "May 2017";
}
@top-center {
@@ -22009,7 +22009,7 @@ jQuery(function ($) {
</tr>
<tr>
<td class="header left"></td>
-<td class="header right">May 28, 2016</td>
+<td class="header right">May 15, 2017</td>
</tr>
</table></div>
<p id="title" class="title">libxo: The Easy Way to Generate text, XML, JSON, and HTML output<br><span class="filename">libxo-manual</span></p>
@@ -22271,36 +22271,40 @@ jQuery(function ($) {
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_1_4">3.1.4   </div>
-<a href="#xo_set_style">xo_set_style</a><ul class="toc">
+<a href="#xo_set_style">xo_set_style</a>
+</li>
+<li class="tocline1">
+<div class="section-number" id="toc_doc_section_3_1_5">3.1.5   </div>
+<a href="#xo_get_style">xo_get_style</a><ul class="toc">
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_4_1">3.1.4.1   </div>
+<div class="section-number" id="toc_doc_section_3_1_5_1">3.1.5.1   </div>
<a href="#styles">Output Styles (XO_STYLE_*)</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_4_2">3.1.4.2   </div>
+<div class="section-number" id="toc_doc_section_3_1_5_2">3.1.5.2   </div>
<a href="#xo_set_style_name">xo_set_style_name</a>
</li>
</ul>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5">3.1.5   </div>
+<div class="section-number" id="toc_doc_section_3_1_6">3.1.6   </div>
<a href="#xo_set_flags">xo_set_flags</a><ul class="toc">
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5_1">3.1.5.1   </div>
+<div class="section-number" id="toc_doc_section_3_1_6_1">3.1.6.1   </div>
<a href="#flags">Flags (XOF_*)</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5_2">3.1.5.2   </div>
+<div class="section-number" id="toc_doc_section_3_1_6_2">3.1.6.2   </div>
<a href="#xo_clear_flags">xo_clear_flags</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5_3">3.1.5.3   </div>
+<div class="section-number" id="toc_doc_section_3_1_6_3">3.1.6.3   </div>
<a href="#xo_set_options">xo_set_options</a>
</li>
</ul>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_6">3.1.6   </div>
+<div class="section-number" id="toc_doc_section_3_1_7">3.1.7   </div>
<a href="#xo_destroy">xo_destroy</a>
</li>
</ul>
@@ -23879,7 +23883,7 @@ jQuery(function ($) {
<p id="doc_section_2_2_4_p_1">For strings, the 'h' and 'l' modifiers affect the interpretation of the bytes pointed to argument. The default '%s' string is a 'char *' pointer to a string encoded as UTF-8. Since UTF-8 is compatible with ASCII data, a normal 7-bit ASCII string can be used. '%ls' expects a 'wchar_t *' pointer to a wide-character string, encoded as a 32-bit Unicode values. '%hs' expects a 'char *' pointer to a multi-byte string encoded with the current locale, as given by the LC_CTYPE, LANG, or LC_ALL environment varibles. The first of this list of variables is used and if none of the variables are set, the locale defaults to "UTF&#8209;8".</p>
<p id="doc_section_2_2_4_p_2">libxo will convert these arguments as needed to either UTF-8 (for XML, JSON, and HTML styles) or locale-based strings for display in text style.</p>
<div id="doc_figure_u.64"></div> <pre>
- xo_emit("Alll strings are utf-8 content {:tag/%ls}",
+ xo_emit("All strings are utf-8 content {:tag/%ls}",
L"except for wide strings");
</pre> <p id="doc_section_2_2_4_p_4">"%S" is equivalent to "%ls".</p>
<div id="doc_table_u.7"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
@@ -24316,6 +24320,14 @@ jQuery(function ($) {
<td>Enable "Do The Right Thing" mode</td>
</tr>
<tr>
+<td>flush</td>
+<td>Flush after every libxo function call</td>
+</tr>
+<tr>
+<td>flush-line</td>
+<td>Flush after every line (line-buffered)</td>
+</tr>
+<tr>
<td>html</td>
<td>Emit HTML output</td>
</tr>
@@ -24377,7 +24389,7 @@ jQuery(function ($) {
</tr>
<tr>
<td>underscores</td>
-<td>Replace XML-friendly "-"s with JSON friendly "_"s e</td>
+<td>Replace XML-friendly "-"s with JSON friendly "_"s</td>
</tr>
<tr>
<td>units</td>
@@ -24402,6 +24414,19 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_2_4_p_5">The brief options are detailed in <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a>.</p>
+<p id="doc_section_2_4_p_6">Most of these option are simple and direct, but some require additional details:</p>
+<p id="doc_section_2_4_p_7"> </p>
+<ul>
+<li>"flush&#8209;line" performs line buffering, even when the output is not directed to a TTY device.</li>
+<li>"info" generates additional data for HTML, encoded in attributes using names that state with "data&#8209;".</li>
+<li>"keys" adds a "key" attribute for XML output to indicate that a leaf is an identifier for the list member.</li>
+<li>"no&#8209;humanize"avoids "humanizing" numeric output (see humanize_number(3) for details).</li>
+<li>"no&#8209;locale" instructs libxo to avoid translating output to the current locale.</li>
+<li>"no&#8209;retain" disables the ability of libxo to internally retain "compiled" information about formatting strings.</li>
+<li>"underscores" can be used with JSON output to change XML-friendly names with dashes into JSON-friendly name with underscores.</li>
+<li>"warn" allows libxo to emit warnings on stderr when application code make incorrect calls.</li>
+<li>"warn&#8209;xml" causes those warnings to be placed in XML inside the output.</li>
+</ul>
</div>
</div>
<hr class="noprint">
@@ -24443,8 +24468,9 @@ jQuery(function ($) {
<li><a href="#xo_create_to_file" title="xo_create_to_file">Section 3.1.2</a></li>
<li><a href="#xo_set_writer" title="xo_set_writer">Section 3.1.3</a></li>
<li><a href="#xo_set_style" title="xo_set_style">Section 3.1.4</a></li>
-<li><a href="#xo_set_flags" title="xo_set_flags">Section 3.1.5</a></li>
-<li><a href="#xo_destroy" title="xo_destroy">Section 3.1.6</a></li>
+<li><a href="#xo_get_style" title="xo_get_style">Section 3.1.5</a></li>
+<li><a href="#xo_set_flags" title="xo_set_flags">Section 3.1.6</a></li>
+<li><a href="#xo_destroy" title="xo_destroy">Section 3.1.7</a></li>
</ul>
<div class="content">
<h3 id="doc_section_3_1_1">
@@ -24460,7 +24486,7 @@ jQuery(function ($) {
xo_handle_t *xop = xo_create(XO_STYLE_JSON, XOF_WARN);
....
xo_emit_h(xop, "testing\n");
- </pre> <p id="doc_section_3_1_1_p_3">See also <a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.4.1</a> and <a href="#flags" title="Flags (XOF_*)">Section 3.1.5.1</a>.</p>
+ </pre> <p id="doc_section_3_1_1_p_3">See also <a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.5.1</a> and <a href="#flags" title="Flags (XOF_*)">Section 3.1.6.1</a>.</p>
</div>
<div class="content">
<h3 id="doc_section_3_1_2">
@@ -24499,18 +24525,31 @@ jQuery(function ($) {
</pre> <p id="doc_section_3_1_4_p_3">To use the default handle, pass a NULL handle:</p>
<div id="doc_figure_u.89"></div> <pre>
xo_set_style(NULL, XO_STYLE_XML);
- </pre> <p id="doc_section_3_1_4_p_5">Section Contents: </p>
+ </pre> </div>
+<div class="content">
+<h3 id="doc_section_3_1_5">
+<div class="self-section-number">
+<a href="#doc_section_3_1_5">3.1.5</a> </div>
+<a id="xo_get_style" href="#xo_get_style">xo_get_style</a>
+</h3>
+<p id="doc_section_3_1_5_p_1">To find the current style, use the xo_get_style() function:</p>
+<div id="doc_figure_u.90"></div> <pre>
+ xo_style_t xo_get_style(xo_handle_t *xop);
+ </pre> <p id="doc_section_3_1_5_p_3">To use the default handle, pass a NULL handle:</p>
+<div id="doc_figure_u.91"></div> <pre>
+ style = xo_get_style(NULL);
+ </pre> <p id="doc_section_3_1_5_p_5">Section Contents: </p>
<ul>
-<li><a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.4.1</a></li>
-<li><a href="#xo_set_style_name" title="xo_set_style_name">Section 3.1.4.2</a></li>
+<li><a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.5.1</a></li>
+<li><a href="#xo_set_style_name" title="xo_set_style_name">Section 3.1.5.2</a></li>
</ul>
<div class="content">
-<h4 id="doc_section_3_1_4_1">
+<h4 id="doc_section_3_1_5_1">
<div class="self-section-number">
-<a href="#doc_section_3_1_4_1">3.1.4.1</a> </div>
+<a href="#doc_section_3_1_5_1">3.1.5.1</a> </div>
<a id="styles" href="#styles">Output Styles (XO_STYLE_*)</a>
</h4>
-<p id="doc_section_3_1_4_1_p_1">The libxo functions accept a set of output styles:</p>
+<p id="doc_section_3_1_5_1_p_1">The libxo functions accept a set of output styles:</p>
<div id="doc_table_u.11"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24537,45 +24576,45 @@ jQuery(function ($) {
</table></div>
</div>
<div class="content">
-<h4 id="doc_section_3_1_4_2">
+<h4 id="doc_section_3_1_5_2">
<div class="self-section-number">
-<a href="#doc_section_3_1_4_2">3.1.4.2</a> </div>
+<a href="#doc_section_3_1_5_2">3.1.5.2</a> </div>
<a id="xo_set_style_name" href="#xo_set_style_name">xo_set_style_name</a>
</h4>
-<p id="doc_section_3_1_4_2_p_1">The xo_set_style_name() can be used to set the style based on a name encoded as a string:</p>
-<div id="doc_figure_u.90"></div> <pre>
+<p id="doc_section_3_1_5_2_p_1">The xo_set_style_name() can be used to set the style based on a name encoded as a string:</p>
+<div id="doc_figure_u.92"></div> <pre>
int xo_set_style_name (xo_handle_t *xop, const char *style);
- </pre> <p id="doc_section_3_1_4_2_p_3">The name can be any of the styles: "text", "xml", "json", or "html".</p>
-<div id="doc_figure_u.91"></div> <pre>
+ </pre> <p id="doc_section_3_1_5_2_p_3">The name can be any of the styles: "text", "xml", "json", or "html".</p>
+<div id="doc_figure_u.93"></div> <pre>
EXAMPLE:
xo_set_style_name(NULL, "html");
</pre> </div>
</div>
<div class="content">
-<h3 id="doc_section_3_1_5">
+<h3 id="doc_section_3_1_6">
<div class="self-section-number">
-<a href="#doc_section_3_1_5">3.1.5</a> </div>
+<a href="#doc_section_3_1_6">3.1.6</a> </div>
<a id="xo_set_flags" href="#xo_set_flags">xo_set_flags</a>
</h3>
-<p id="doc_section_3_1_5_p_1">To set the flags, use the xo_set_flags() function:</p>
-<div id="doc_figure_u.92"></div> <pre>
+<p id="doc_section_3_1_6_p_1">To set the flags, use the xo_set_flags() function:</p>
+<div id="doc_figure_u.94"></div> <pre>
void xo_set_flags(xo_handle_t *xop, unsigned flags);
- </pre> <p id="doc_section_3_1_5_p_3">To use the default handle, pass a NULL handle:</p>
-<div id="doc_figure_u.93"></div> <pre>
+ </pre> <p id="doc_section_3_1_6_p_3">To use the default handle, pass a NULL handle:</p>
+<div id="doc_figure_u.95"></div> <pre>
xo_set_style(NULL, XO_STYLE_XML);
- </pre> <p id="doc_section_3_1_5_p_5">Section Contents: </p>
+ </pre> <p id="doc_section_3_1_6_p_5">Section Contents: </p>
<ul>
-<li><a href="#flags" title="Flags (XOF_*)">Section 3.1.5.1</a></li>
-<li><a href="#xo_clear_flags" title="xo_clear_flags">Section 3.1.5.2</a></li>
-<li><a href="#xo_set_options" title="xo_set_options">Section 3.1.5.3</a></li>
+<li><a href="#flags" title="Flags (XOF_*)">Section 3.1.6.1</a></li>
+<li><a href="#xo_clear_flags" title="xo_clear_flags">Section 3.1.6.2</a></li>
+<li><a href="#xo_set_options" title="xo_set_options">Section 3.1.6.3</a></li>
</ul>
<div class="content">
-<h4 id="doc_section_3_1_5_1">
+<h4 id="doc_section_3_1_6_1">
<div class="self-section-number">
-<a href="#doc_section_3_1_5_1">3.1.5.1</a> </div>
+<a href="#doc_section_3_1_6_1">3.1.6.1</a> </div>
<a id="flags" href="#flags">Flags (XOF_*)</a>
</h4>
-<p id="doc_section_3_1_5_1_p_1">The set of valid flags include:</p>
+<p id="doc_section_3_1_6_1_p_1">The set of valid flags include:</p>
<div id="doc_table_u.12"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24648,12 +24687,12 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<p id="doc_section_3_1_5_1_p_2">The XOF_CLOSE_FP flag will trigger the call of the close_func (provided via xo_set_writer()) when the handle is destroyed.</p>
-<p id="doc_section_3_1_5_1_p_3">The XOF_COLOR flag enables color and effects in output regardless of output device, while the XOF_COLOR_ALLOWED flag allows color and effects only if the output device is a terminal.</p>
-<p id="doc_section_3_1_5_1_p_4">The XOF_PRETTY flag requests 'pretty printing', which will trigger the addition of indentation and newlines to enhance the readability of XML, JSON, and HTML output. Text output is not affected.</p>
-<p id="doc_section_3_1_5_1_p_5">The XOF_WARN flag requests that warnings will trigger diagnostic output (on standard error) when the library notices errors during operations, or with arguments to functions. Without warnings enabled, such conditions are ignored.</p>
-<p id="doc_section_3_1_5_1_p_6">Warnings allow developers to debug their interaction with libxo. The function "xo_failure" can used as a breakpoint for a debugger, regardless of whether warnings are enabled.</p>
-<p id="doc_section_3_1_5_1_p_7">If the style is XO_STYLE_HTML, the following additional flags can be used:</p>
+<p id="doc_section_3_1_6_1_p_2">The XOF_CLOSE_FP flag will trigger the call of the close_func (provided via xo_set_writer()) when the handle is destroyed.</p>
+<p id="doc_section_3_1_6_1_p_3">The XOF_COLOR flag enables color and effects in output regardless of output device, while the XOF_COLOR_ALLOWED flag allows color and effects only if the output device is a terminal.</p>
+<p id="doc_section_3_1_6_1_p_4">The XOF_PRETTY flag requests 'pretty printing', which will trigger the addition of indentation and newlines to enhance the readability of XML, JSON, and HTML output. Text output is not affected.</p>
+<p id="doc_section_3_1_6_1_p_5">The XOF_WARN flag requests that warnings will trigger diagnostic output (on standard error) when the library notices errors during operations, or with arguments to functions. Without warnings enabled, such conditions are ignored.</p>
+<p id="doc_section_3_1_6_1_p_6">Warnings allow developers to debug their interaction with libxo. The function "xo_failure" can used as a breakpoint for a debugger, regardless of whether warnings are enabled.</p>
+<p id="doc_section_3_1_6_1_p_7">If the style is XO_STYLE_HTML, the following additional flags can be used:</p>
<div id="doc_table_u.13"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24670,9 +24709,9 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<p id="doc_section_3_1_5_1_p_8">The XOF_XPATH flag enables the emission of XPath expressions detailing the hierarchy of XML elements used to encode the data field, if the XPATH style of output were requested.</p>
-<p id="doc_section_3_1_5_1_p_9">The XOF_INFO flag encodes additional informational fields for HTML output. See <a href="#info" title="Field Information (xo_info_t)">Section 3.4.4</a> for details.</p>
-<p id="doc_section_3_1_5_1_p_10">If the style is XO_STYLE_XML, the following additional flags can be used:</p>
+<p id="doc_section_3_1_6_1_p_8">The XOF_XPATH flag enables the emission of XPath expressions detailing the hierarchy of XML elements used to encode the data field, if the XPATH style of output were requested.</p>
+<p id="doc_section_3_1_6_1_p_9">The XOF_INFO flag encodes additional informational fields for HTML output. See <a href="#info" title="Field Information (xo_info_t)">Section 3.4.4</a> for details.</p>
+<p id="doc_section_3_1_6_1_p_10">If the style is XO_STYLE_XML, the following additional flags can be used:</p>
<div id="doc_table_u.14"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24683,43 +24722,43 @@ jQuery(function ($) {
<td>Flag 'key' fields for xml</td>
</tr></tbody>
</table></div>
-<p id="doc_section_3_1_5_1_p_11">The XOF_KEYS flag adds 'key' attribute to the XML encoding for field definitions that use the 'k' modifier. The key attribute has the value "key":</p>
-<div id="doc_figure_u.94"></div> <pre>
+<p id="doc_section_3_1_6_1_p_11">The XOF_KEYS flag adds 'key' attribute to the XML encoding for field definitions that use the 'k' modifier. The key attribute has the value "key":</p>
+<div id="doc_figure_u.96"></div> <pre>
xo_emit("{k:name}", item);
XML:
&lt;name key="key"&gt;truck&lt;/name&gt;
</pre> </div>
<div class="content">
-<h4 id="doc_section_3_1_5_2">
+<h4 id="doc_section_3_1_6_2">
<div class="self-section-number">
-<a href="#doc_section_3_1_5_2">3.1.5.2</a> </div>
+<a href="#doc_section_3_1_6_2">3.1.6.2</a> </div>
<a id="xo_clear_flags" href="#xo_clear_flags">xo_clear_flags</a>
</h4>
-<p id="doc_section_3_1_5_2_p_1">The xo_clear_flags() function turns off the given flags in a specific handle.</p>
-<div id="doc_figure_u.95"></div> <pre>
+<p id="doc_section_3_1_6_2_p_1">The xo_clear_flags() function turns off the given flags in a specific handle.</p>
+<div id="doc_figure_u.97"></div> <pre>
void xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
</pre> </div>
<div class="content">
-<h4 id="doc_section_3_1_5_3">
+<h4 id="doc_section_3_1_6_3">
<div class="self-section-number">
-<a href="#doc_section_3_1_5_3">3.1.5.3</a> </div>
+<a href="#doc_section_3_1_6_3">3.1.6.3</a> </div>
<a id="xo_set_options" href="#xo_set_options">xo_set_options</a>
</h4>
-<p id="doc_section_3_1_5_3_p_1">The xo_set_options() function accepts a comma-separated list of styles and flags and enables them for a specific handle.</p>
-<div id="doc_figure_u.96"></div> <pre>
+<p id="doc_section_3_1_6_3_p_1">The xo_set_options() function accepts a comma-separated list of styles and flags and enables them for a specific handle.</p>
+<div id="doc_figure_u.98"></div> <pre>
int xo_set_options (xo_handle_t *xop, const char *input);
- </pre> <p id="doc_section_3_1_5_3_p_3">The options are identical to those listed in <a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a>.</p>
+ </pre> <p id="doc_section_3_1_6_3_p_3">The options are identical to those listed in <a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a>.</p>
</div>
</div>
<div class="content">
-<h3 id="doc_section_3_1_6">
+<h3 id="doc_section_3_1_7">
<div class="self-section-number">
-<a href="#doc_section_3_1_6">3.1.6</a> </div>
+<a href="#doc_section_3_1_7">3.1.7</a> </div>
<a id="xo_destroy" href="#xo_destroy">xo_destroy</a>
</h3>
-<p id="doc_section_3_1_6_p_1">The xo_destroy function releases a handle and any resources it is using. Calling xo_destroy with a NULL handle will release any resources associated with the default handle.</p>
-<div id="doc_figure_u.97"></div> <pre>
+<p id="doc_section_3_1_7_p_1">The xo_destroy function releases a handle and any resources it is using. Calling xo_destroy with a NULL handle will release any resources associated with the default handle.</p>
+<div id="doc_figure_u.99"></div> <pre>
void xo_destroy(xo_handle_t *xop);
</pre> </div>
</div>
@@ -24730,7 +24769,7 @@ jQuery(function ($) {
<a id="emitting-content-xo_emit" href="#emitting-content-xo_emit">Emitting Content (xo_emit)</a>
</h2>
<p id="doc_section_3_2_p_1">The following functions are used to emit output:</p>
-<div id="doc_figure_u.98"></div> <pre>
+<div id="doc_figure_u.100"></div> <pre>
int xo_emit (const char *fmt, ...);
int xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
int xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
@@ -24750,7 +24789,7 @@ jQuery(function ($) {
<a id="xo_emit_field" href="#xo_emit_field">Single Field Emitting Functions (xo_emit_field)</a>
</h3>
<p id="doc_section_3_2_1_p_1">The following functions can also make output, but only make a single field at a time:</p>
-<div id="doc_figure_u.99"></div> <pre>
+<div id="doc_figure_u.101"></div> <pre>
int xo_emit_field_hv (xo_handle_t *xop, const char *rolmod,
const char *contents, const char *fmt,
const char *efmt, va_list vap);
@@ -24762,7 +24801,7 @@ jQuery(function ($) {
int xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
</pre> <p id="doc_section_3_2_1_p_3">These functions are intended to avoid the scenario where one would otherwise need to compose a format descriptors using snprintf(). The individual parts of the format descriptor are passed in distinctly.</p>
-<div id="doc_figure_u.100"></div> <pre>
+<div id="doc_figure_u.102"></div> <pre>
xo_emit("T", "Host name is ", NULL, NULL);
xo_emit("V", "host-name", NULL, NULL, host-name);
</pre> </div>
@@ -24773,14 +24812,14 @@ jQuery(function ($) {
<a id="xo_attr" href="#xo_attr">Attributes (xo_attr)</a>
</h3>
<p id="doc_section_3_2_2_p_1">The xo_attr() function emits attributes for the XML output style.</p>
-<div id="doc_figure_u.101"></div> <pre>
+<div id="doc_figure_u.103"></div> <pre>
int xo_attr (const char *name, const char *fmt, ...);
int xo_attr_h (xo_handle_t *xop, const char *name,
const char *fmt, ...);
int xo_attr_hv (xo_handle_t *xop, const char *name,
const char *fmt, va_list vap);
</pre> <p id="doc_section_3_2_2_p_3">The name parameter give the name of the attribute to be encoded. The fmt parameter gives a printf-style format string used to format the value of the attribute using any remaining arguments, or the vap parameter passed to xo_attr_hv().</p>
-<div id="doc_figure_u.102"></div> <pre>
+<div id="doc_figure_u.104"></div> <pre>
EXAMPLE:
xo_attr("seconds", "%ld", (unsigned long) login_time);
struct tm *tmp = localtime(login_time);
@@ -24798,7 +24837,7 @@ jQuery(function ($) {
<a id="flushing-output-xo_flush" href="#flushing-output-xo_flush">Flushing Output (xo_flush)</a>
</h3>
<p id="doc_section_3_2_3_p_1">libxo buffers data, both for performance and consistency, but also to allow some advanced features to work properly. At various times, the caller may wish to flush any data buffered within the library. The xo_flush() call is used for this:</p>
-<div id="doc_figure_u.103"></div> <pre>
+<div id="doc_figure_u.105"></div> <pre>
void xo_flush (void);
void xo_flush_h (xo_handle_t *xop);
</pre> <p id="doc_section_3_2_3_p_3">Calling xo_flush also triggers the flush function associated with the handle. For the default handle, this is equivalent to "fflush(stdio);".</p>
@@ -24810,7 +24849,7 @@ jQuery(function ($) {
<a id="finishing-output-xo_finish" href="#finishing-output-xo_finish">Finishing Output (xo_finish)</a>
</h3>
<p id="doc_section_3_2_4_p_1">When the program is ready to exit or close a handle, a call to xo_finish() is required. This flushes any buffered data, closes open libxo constructs, and completes any pending operations.</p>
-<div id="doc_figure_u.104"></div> <pre>
+<div id="doc_figure_u.106"></div> <pre>
int xo_finish (void);
int xo_finish_h (xo_handle_t *xop);
void xo_finish_atexit (void);
@@ -24826,7 +24865,7 @@ jQuery(function ($) {
</h2>
<p id="doc_section_3_3_p_1">libxo represents to types of hierarchy: containers and lists. A container appears once under a given parent where a list contains instances that can appear multiple times. A container is used to hold related fields and to give the data organization and scope.</p>
<p id="doc_section_3_3_p_2">To create a container, use the xo_open_container and xo_close_container functions:</p>
-<div id="doc_figure_u.105"></div> <pre>
+<div id="doc_figure_u.107"></div> <pre>
int xo_open_container (const char *name);
int xo_open_container_h (xo_handle_t *xop, const char *name);
int xo_open_container_hd (xo_handle_t *xop, const char *name);
@@ -24840,7 +24879,7 @@ jQuery(function ($) {
<p id="doc_section_3_3_p_5">The close functions with the "_d" suffix are used in "Do The Right Thing" mode, where the name of the open containers, lists, and instances are maintained internally by libxo to allow the caller to avoid keeping track of the open container name.</p>
<p id="doc_section_3_3_p_6">Use the XOF_WARN flag to generate a warning if the name given on the close does not match the current open container.</p>
<p id="doc_section_3_3_p_7">For TEXT and HTML output, containers are not rendered into output text, though for HTML they are used when the XOF_XPATH flag is set.</p>
-<div id="doc_figure_u.106"></div> <pre>
+<div id="doc_figure_u.108"></div> <pre>
EXAMPLE:
xo_open_container("system");
xo_emit("The host name is {:host-name}\n", hn);
@@ -24857,7 +24896,7 @@ jQuery(function ($) {
</h3>
<p id="doc_section_3_3_1_p_1">Lists are sequences of instances of homogeneous data objects. Two distinct levels of calls are needed to represent them in our output styles. Calls must be made to open and close a list, and for each instance of data in that list, calls must be make to open and close that instance.</p>
<p id="doc_section_3_3_1_p_2">The name given to all calls must be identical, and it is strongly suggested that the name be singular, not plural, as a matter of style and usage expectations.</p>
-<div id="doc_figure_u.107"></div> <pre>
+<div id="doc_figure_u.109"></div> <pre>
EXAMPLE:
xo_open_list("user");
for (i = 0; i &lt; num_users; i++) {
@@ -24926,7 +24965,7 @@ jQuery(function ($) {
<a id="xo_parse_args" href="#xo_parse_args">Parsing Command-line Arguments (xo_parse_args)</a>
</h3>
<p id="doc_section_3_4_1_p_1">The xo_parse_args() function is used to process a program's arguments. libxo-specific options are processed and removed from the argument list so the calling application does not need to process them. If successful, a new value for argc is returned. On failure, a message it emitted and -1 is returned.</p>
-<div id="doc_figure_u.108"></div> <pre>
+<div id="doc_figure_u.110"></div> <pre>
argc = xo_parse_args(argc, argv);
if (argc &lt; 0)
exit(EXIT_FAILURE);
@@ -24939,7 +24978,7 @@ jQuery(function ($) {
<a id="xo_set_program" href="#xo_set_program">xo_set_program</a>
</h3>
<p id="doc_section_3_4_2_p_1">The xo_set_program function sets name of the program as reported by functions like xo_failure, xo_warn, xo_err, etc. The program name is initialized by xo_parse_args, but subsequent calls to xo_set_program can override this value.</p>
-<div id="doc_figure_u.109"></div> <pre>
+<div id="doc_figure_u.111"></div> <pre>
xo_set_program(argv[0]);
</pre> <p id="doc_section_3_4_2_p_3">Note that the value is not copied, so the memory passed to xo_set_program (and xo_parse_args) must be maintained by the caller.</p>
</div>
@@ -24950,7 +24989,7 @@ jQuery(function ($) {
<a id="xo_set_version" href="#xo_set_version">xo_set_version</a>
</h3>
<p id="doc_section_3_4_3_p_1">The xo_set_version function records a version number to be emitted as part of the data for encoding styles (XML and JSON). This version number is suitable for tracking changes in the content, allowing a user of the data to discern which version of the data model is in use.</p>
-<div id="doc_figure_u.110"></div> <pre>
+<div id="doc_figure_u.112"></div> <pre>
void xo_set_version (const char *version);
void xo_set_version_h (xo_handle_t *xop, const char *version);
</pre> </div>
@@ -24963,7 +25002,7 @@ jQuery(function ($) {
<p id="doc_section_3_4_4_p_1">HTML data can include additional information in attributes that begin with "data&#8209;". To enable this, three things must occur:</p>
<p id="doc_section_3_4_4_p_2">First the application must build an array of xo_info_t structures, one per tag. The array must be sorted by name, since libxo uses a binary search to find the entry that matches names from format instructions.</p>
<p id="doc_section_3_4_4_p_3">Second, the application must inform libxo about this information using the xo_set_info() call:</p>
-<div id="doc_figure_u.111"></div> <pre>
+<div id="doc_figure_u.113"></div> <pre>
typedef struct xo_info_s {
const char *xi_name; /* Name of the element */
const char *xi_type; /* Type of field */
@@ -24973,7 +25012,7 @@ jQuery(function ($) {
void xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count);
</pre> <p id="doc_section_3_4_4_p_5">Like other libxo calls, passing NULL for the handle tells libxo to use the default handle.</p>
<p id="doc_section_3_4_4_p_6">If the count is -1, libxo will count the elements of infop, but there must be an empty element at the end. More typically, the number is known to the application:</p>
-<div id="doc_figure_u.112"></div> <pre>
+<div id="doc_figure_u.114"></div> <pre>
xo_info_t info[] = {
{ "in-stock", "number", "Number of items in stock" },
{ "name", "string", "Name of the item" },
@@ -24986,7 +25025,7 @@ jQuery(function ($) {
xo_set_info(NULL, info, info_count);
</pre> <p id="doc_section_3_4_4_p_8">Third, the emission of info must be triggered with the XOF_INFO flag using either the xo_set_flags() function or the "&#8209;&#8209;libxo=info" command line argument.</p>
<p id="doc_section_3_4_4_p_9">The type and help values, if present, are emitted as the "data&#8209;type" and "data&#8209;help" attributes:</p>
-<div id="doc_figure_u.113"></div> <pre>
+<div id="doc_figure_u.115"></div> <pre>
&lt;div class="data" data-tag="sku" data-type="string"
data-help="Stock Keeping Unit"&gt;GRO-000-533&lt;/div&gt;
</pre> </div>
@@ -24997,7 +25036,7 @@ jQuery(function ($) {
<a id="memory-allocation" href="#memory-allocation">Memory Allocation</a>
</h3>
<p id="doc_section_3_4_5_p_1">The xo_set_allocator function allows libxo to be used in environments where the standard realloc() and free() functions are not available.</p>
-<div id="doc_figure_u.114"></div> <pre>
+<div id="doc_figure_u.116"></div> <pre>
void xo_set_allocator (xo_realloc_func_t realloc_func,
xo_free_func_t free_func);
</pre> <p id="doc_section_3_4_5_p_3">realloc_func should expect the same arguments as realloc(3) and return a pointer to memory following the same convention. free_func will receive the same argument as free(3) and should release it, as appropriate for the environment.</p>
@@ -25079,10 +25118,10 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_3_4_6_p_2">For example, warnings can be enabled by:</p>
-<div id="doc_figure_u.115"></div> <pre>
+<div id="doc_figure_u.117"></div> <pre>
% env LIBXO_OPTIONS=W my-app
</pre> <p id="doc_section_3_4_6_p_4">Complete HTML output can be generated with:</p>
-<div id="doc_figure_u.116"></div> <pre>
+<div id="doc_figure_u.118"></div> <pre>
% env LIBXO_OPTIONS=HXI my-app
</pre> <p id="doc_section_3_4_6_p_6">Since environment variables are inherited, child processes will have the same options, which may be undesirable, making the use of the "&#8209;&#8209;libxo" option is preferable in most situations.</p>
</div>
@@ -25093,7 +25132,7 @@ jQuery(function ($) {
<a id="errors-warnings-and-messages" href="#errors-warnings-and-messages">Errors, Warnings, and Messages</a>
</h3>
<p id="doc_section_3_4_7_p_1">Many programs make use of the standard library functions err() and warn() to generate errors and warnings for the user. libxo wants to pass that information via the current output style, and provides compatible functions to allow this:</p>
-<div id="doc_figure_u.117"></div> <pre>
+<div id="doc_figure_u.119"></div> <pre>
void xo_warn (const char *fmt, ...);
void xo_warnx (const char *fmt, ...);
void xo_warn_c (int code, const char *fmt, ...);
@@ -25109,7 +25148,7 @@ jQuery(function ($) {
void xo_message_hcv (xo_handle_t *xop, int code,
const char *fmt, va_list vap);
</pre> <p id="doc_section_3_4_7_p_3">These functions display the program name, a colon, a formatted message based on the arguments, and then optionally a colon and an error message associated with either "errno" or the "code" parameter.</p>
-<div id="doc_figure_u.118"></div> <pre>
+<div id="doc_figure_u.120"></div> <pre>
EXAMPLE:
if (open(filename, O_RDONLY) &lt; 0)
xo_err(1, "cannot open file '%s'", filename);
@@ -25121,7 +25160,7 @@ jQuery(function ($) {
<a id="xo_error" href="#xo_error">xo_error</a>
</h3>
<p id="doc_section_3_4_8_p_1">The xo_error function can be used for generic errors that should be reported over the handle, rather than to stderr. The xo_error function behaves like xo_err for TEXT and HTML output styles, but puts the error into XML or JSON elements:</p>
-<div id="doc_figure_u.119"></div> <pre>
+<div id="doc_figure_u.121"></div> <pre>
EXAMPLE::
xo_error("Does not %s", "compute");
XML::
@@ -25136,7 +25175,7 @@ jQuery(function ($) {
<a id="xo_no_setlocale" href="#xo_no_setlocale">xo_no_setlocale</a>
</h3>
<p id="doc_section_3_4_9_p_1">libxo automatically initializes the locale based on setting of the environment variables LC_CTYPE, LANG, and LC_ALL. The first of this list of variables is used and if none of the variables, the locale defaults to "UTF&#8209;8". The caller may wish to avoid this behavior, and can do so by calling the xo_no_setlocale() function.</p>
-<div id="doc_figure_u.120"></div> <pre>
+<div id="doc_figure_u.122"></div> <pre>
void xo_no_setlocale (void);
</pre> </div>
</div>
@@ -25152,7 +25191,7 @@ jQuery(function ($) {
<p id="doc_section_3_5_p_4">https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers</p>
<p id="doc_section_3_5_p_5">Use the <a href="#xo_set_syslog_enterprise_id" title="xo_set_syslog_enterprise_id">Section 3.5.3.5</a>() function to set the Enterprise ID, as needed.</p>
<p id="doc_section_3_5_p_6">The message name should follow the conventions in <a href="#good-field-names" title="What makes a good field name?">Section 8.1.3</a>, as should the fields within the message.</p>
-<div id="doc_figure_u.121"></div> <pre>
+<div id="doc_figure_u.123"></div> <pre>
/* Both of these calls are optional */
xo_set_syslog_enterprise_id(32473);
xo_open_log("my-program", 0, LOG_DAEMON);
@@ -25180,7 +25219,7 @@ jQuery(function ($) {
<a id="priority" href="#priority">Priority, Facility, and Flags</a>
</h3>
<p id="doc_section_3_5_1_p_1">The xo_syslog, xo_vsyslog, and xo_open_log functions accept a set of flags which provide the priority of the message, the source facility, and some additional features. These values are OR'd together to create a single integer argument:</p>
-<div id="doc_figure_u.122"></div> <pre>
+<div id="doc_figure_u.124"></div> <pre>
xo_syslog(LOG_ERR | LOG_AUTH, "login-failed",
"Login failed; user '{:user}' from host '{:address}'",
user, addr);
@@ -25325,7 +25364,7 @@ jQuery(function ($) {
</h3>
<p id="doc_section_3_5_2_p_1">Use the xo_syslog function to generate syslog messages by calling it with a log priority and facility, a message name, a format string, and a set of arguments. The priority/facility argument are discussed above, as is the message name.</p>
<p id="doc_section_3_5_2_p_2">The format string follows the same conventions as xo_emit's format string, with each field being rendered as an SD-PARAM pair.</p>
-<div id="doc_figure_u.123"></div> <pre>
+<div id="doc_figure_u.125"></div> <pre>
xo_syslog(LOG_ERR, "poofd-missing-file",
"'{:filename}' not found: {:error/%m}", filename);
@@ -25354,7 +25393,7 @@ jQuery(function ($) {
<a id="xo_vsyslog" href="#xo_vsyslog">xo_vsyslog</a>
</h4>
<p id="doc_section_3_5_3_1_p_1">xo_vsyslog is identical in function to xo_syslog, but takes the set of arguments using a va_list.</p>
-<div id="doc_figure_u.124"></div> <pre>
+<div id="doc_figure_u.126"></div> <pre>
void my_log (const char *name, const char *fmt, ...)
{
va_list vap;
@@ -25370,7 +25409,7 @@ jQuery(function ($) {
<a id="xo_open_log" href="#xo_open_log">xo_open_log</a>
</h4>
<p id="doc_section_3_5_3_2_p_1">xo_open_log functions similar to openlog(3), allowing customization of the program name, the log facility number, and the additional option flags described in <a href="#priority" title="Priority, Facility, and Flags">Section 3.5.1</a>.</p>
-<div id="doc_figure_u.125"></div> <pre>
+<div id="doc_figure_u.127"></div> <pre>
void
xo_open_log (const char *ident, int logopt, int facility);
</pre> </div>
@@ -25381,7 +25420,7 @@ jQuery(function ($) {
<a id="xo_close_log" href="#xo_close_log">xo_close_log</a>
</h4>
<p id="doc_section_3_5_3_3_p_1">xo_close_log functions similar to closelog(3), closing the log file and releasing any associated resources.</p>
-<div id="doc_figure_u.126"></div> <pre>
+<div id="doc_figure_u.128"></div> <pre>
void
xo_close_log (void);
</pre> </div>
@@ -25392,7 +25431,7 @@ jQuery(function ($) {
<a id="xo_set_logmask" href="#xo_set_logmask">xo_set_logmask</a>
</h4>
<p id="doc_section_3_5_3_4_p_1">xo_set_logmask function similar to setlogmask(3), restricting the set of generated log event to those whose associated bit is set in maskpri. Use LOG_MASK(pri) to find the appropriate bit, or LOG_UPTO(toppri) to create a mask for all priorities up to and including toppri.</p>
-<div id="doc_figure_u.127"></div> <pre>
+<div id="doc_figure_u.129"></div> <pre>
int
xo_set_logmask (int maskpri);
@@ -25407,7 +25446,7 @@ jQuery(function ($) {
</h4>
<p id="doc_section_3_5_3_5_p_1">Use the xo_set_syslog_enterprise_id to supply a platform- or application-specific enterprise id. This value is used in any future syslog messages.</p>
<p id="doc_section_3_5_3_5_p_2">Ideally, the operating system should supply a default value via the "kern.syslog.enterprise_id" sysctl value. Lacking that, the application should provide a suitable value.</p>
-<div id="doc_figure_u.128"></div> <pre>
+<div id="doc_figure_u.130"></div> <pre>
void
xo_set_syslog_enterprise_id (unsigned short eid);
</pre> <p id="doc_section_3_5_3_5_p_4">Enterprise IDs are administered by IANA, the Internet Assigned Number Authority. The complete list is EIDs on their web site:</p>
@@ -25449,7 +25488,7 @@ jQuery(function ($) {
<a id="loading-encoders" href="#loading-encoders">Loading Encoders</a>
</h3>
<p id="doc_section_3_6_1_p_1">Encoders can be registered statically or discovered dynamically. Applications can choose to call the xo_encoder_register() function to explicitly register encoders, but more typically they are built as shared libraries, placed in the libxo/extensions directory, and loaded based on name. libxo looks for a file with the name of the encoder and an extension of ".enc". This can be a file or a symlink to the shared library file that supports the encoder.</p>
-<div id="doc_figure_u.129"></div> <pre>
+<div id="doc_figure_u.131"></div> <pre>
% ls -1 lib/libxo/extensions/*.enc
lib/libxo/extensions/cbor.enc
lib/libxo/extensions/test.enc
@@ -25461,7 +25500,7 @@ jQuery(function ($) {
<a id="encoder-initialization" href="#encoder-initialization">Encoder Initialization</a>
</h3>
<p id="doc_section_3_6_2_p_1">Each encoder must export a symbol used to access the library, which must have the following signature:</p>
-<div id="doc_figure_u.130"></div> <pre>
+<div id="doc_figure_u.132"></div> <pre>
int xo_encoder_library_init (XO_ENCODER_INIT_ARGS);
</pre> <p id="doc_section_3_6_2_p_3">XO_ENCODER_INIT_ARGS is a macro defined in xo_encoder.h that defines an argument called "arg", a pointer of the type xo_encoder_init_args_t. This structure contains two fields:</p>
<p id="doc_section_3_6_2_p_4"> </p>
@@ -25566,7 +25605,7 @@ jQuery(function ($) {
<p id="doc_section_4_p_1">The "xo" utility allows command line access to the functionality of the libxo library. Using "xo", shell scripts can emit XML, JSON, and HTML using the same commands that emit text output.</p>
<p id="doc_section_4_p_2">The style of output can be selected using a specific option: "&#8209;X" for XML, "&#8209;J" for JSON, "&#8209;H" for HTML, or "&#8209;T" for TEXT, which is the default. The "--style &lt;style&gt;" option can also be used. The LIBXO_OPTIONS environment variable can also be used to set the style, as well as other flags.</p>
<p id="doc_section_4_p_3">The "xo" utility accepts a format string suitable for xo_emit() and a set of zero or more arguments used to supply data for that string.</p>
-<div id="doc_figure_u.131"></div> <pre>
+<div id="doc_figure_u.133"></div> <pre>
xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6
TEXT:
@@ -25586,7 +25625,7 @@ jQuery(function ($) {
&lt;div class="text"&gt; pounds.&lt;/div&gt;
&lt;/div&gt;
</pre> <p id="doc_section_4_p_5">The "--wrap &lt;path&gt;" option can be used to wrap emitted content in a specific hierarchy. The path is a set of hierarchical names separated by the '/' character.</p>
-<div id="doc_figure_u.132"></div> <pre>
+<div id="doc_figure_u.134"></div> <pre>
xo --wrap top/a/b/c '{:tag}' value
XML:
@@ -25610,7 +25649,7 @@ jQuery(function ($) {
}
}
</pre> <p id="doc_section_4_p_7">The "--open &lt;path&gt;" and "--close &lt;path&gt;" can be used to emit hierarchical information without the matching close and open tag. This allows a shell script to emit open tags, data, and then close tags. The "&#8209;&#8209;depth" option may be used to set the depth for indentation. The "&#8209;&#8209;leading&#8209;xpath" may be used to prepend data to the XPath values used for HTML output style.</p>
-<div id="doc_figure_u.133"></div> <pre>
+<div id="doc_figure_u.135"></div> <pre>
#!/bin/sh
xo --open top/data
xo --depth 2 '{tag}' value
@@ -25639,7 +25678,7 @@ jQuery(function ($) {
<a id="command-line-options" href="#command-line-options">Command Line Options</a>
</h2>
<p id="doc_section_4_1_p_1">Usage: xo [options] format [fields]</p>
-<div id="doc_figure_u.134"></div> <pre>
+<div id="doc_figure_u.136"></div> <pre>
--close &lt;path&gt; Close tags for the given path
--depth &lt;num&gt; Set the depth for pretty printing
--help Display this help text
@@ -25663,7 +25702,7 @@ jQuery(function ($) {
<a href="#doc_section_4_2">4.2</a> </div>
<a id="example-2" href="#example-2">Example</a>
</h2>
-<div id="doc_figure_u.135"></div> <pre>
+<div id="doc_figure_u.137"></div> <pre>
% xo 'The {:product} is {:status}\n' stereo "in route"
The stereo is in route
% ./xo/xo -p -X 'The {:product} is {:status}\n' stereo "in route"
@@ -25721,7 +25760,7 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_5_p_3">The output message will contain the source filename and line number, the class of the message, the message, and, if -p is given, the line that contains the error:</p>
-<div id="doc_figure_u.136"></div> <pre>
+<div id="doc_figure_u.138"></div> <pre>
% xolint.pl -t xolint.c
xolint.c: 16: error: anchor format should be "%d"
16 xo_emit("{[:/%s}");
@@ -25789,7 +25828,7 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<div id="doc_figure_u.137"></div> <pre>
+<div id="doc_figure_u.139"></div> <pre>
EXAMPLE:
% xopo -s "There are {:count/%u} {:event/%.6s} events\n"
There are {:count} {:event} events\n
@@ -25848,7 +25887,7 @@ jQuery(function ($) {
<a id="did-the-complex-semantics-of-format-strings-evolve-over-time" href="#did-the-complex-semantics-of-format-strings-evolve-over-time">Did the complex semantics of format strings evolve over time?</a>
</h3>
<p id="doc_section_8_1_2_p_1">The history is both long and short: libxo's functionality is based on what JUNOS does in a data modeling language called ODL (output definition language). In JUNOS, all subcomponents generate XML, which is feed to the CLI, where data from the ODL files tell is how to render that XML into text. ODL might had a set of tags like:</p>
-<div id="doc_figure_u.138"></div> <pre>
+<div id="doc_figure_u.140"></div> <pre>
tag docsis-state {
help "State of the DOCSIS interface";
type string;
@@ -25927,7 +25966,7 @@ jQuery(function ($) {
<dt>Reuse existing field names</dt>
<dd>Nothing's worse than writing expressions like:</dd>
</dl>
-<div id="doc_figure_u.139"></div> <pre>
+<div id="doc_figure_u.141"></div> <pre>
if ($src1/process[pid == $pid]/name ==
$src2/proc-table/proc-list
/proc-entry[process-id == $pid]/proc-name) {
@@ -25988,10 +26027,10 @@ jQuery(function ($) {
<a id="a-percent-sign-appearing-in-text-is-a-literal" href="#a-percent-sign-appearing-in-text-is-a-literal">'A percent sign appearing in text is a literal'</a>
</h3>
<p id="doc_section_8_2_1_p_1">The message "A percent sign appearing in text is a literal" can be caused by code like:</p>
-<div id="doc_figure_u.140"></div> <pre>
+<div id="doc_figure_u.142"></div> <pre>
xo_emit("cost: %d", cost);
</pre> <p id="doc_section_8_2_1_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.141"></div> <pre>
+<div id="doc_figure_u.143"></div> <pre>
xo_emit("{L:cost}: {:cost/%d}", cost);
</pre> <p id="doc_section_8_2_1_p_5">This can be a bit surprising and could be a field that was not properly converted to a libxo-style format string.</p>
</div>
@@ -26002,10 +26041,10 @@ jQuery(function ($) {
<a id="unknown-long-name-for-rolemodifier" href="#unknown-long-name-for-rolemodifier">'Unknown long name for role/modifier'</a>
</h3>
<p id="doc_section_8_2_2_p_1">The message "Unknown long name for role/modifier" can be caused by code like:</p>
-<div id="doc_figure_u.142"></div> <pre>
+<div id="doc_figure_u.144"></div> <pre>
xo_emit("{,humanization:value}", value);
</pre> <p id="doc_section_8_2_2_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.143"></div> <pre>
+<div id="doc_figure_u.145"></div> <pre>
xo_emit("{,humanize:value}", value);
</pre> <p id="doc_section_8_2_2_p_5">The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.</p>
</div>
@@ -26017,10 +26056,10 @@ jQuery(function ($) {
</h3>
<p id="doc_section_8_2_3_p_1">The message "Last character before field definition is a field type" can be caused by code like:</p>
<p id="doc_section_8_2_3_p_2">A common typo:</p>
-<div id="doc_figure_u.144"></div> <pre>
+<div id="doc_figure_u.146"></div> <pre>
xo_emit("{T:Min} T{:Max}");
</pre> <p id="doc_section_8_2_3_p_4">This code should be replaced with code like:</p>
-<div id="doc_figure_u.145"></div> <pre>
+<div id="doc_figure_u.147"></div> <pre>
xo_emit("{T:Min} {T:Max}");
</pre> <p id="doc_section_8_2_3_p_6">Twiddling the "{" and the field role is a common typo.</p>
</div>
@@ -26031,10 +26070,10 @@ jQuery(function ($) {
<a id="encoding-format-uses-different-number-of-arguments" href="#encoding-format-uses-different-number-of-arguments">'Encoding format uses different number of arguments'</a>
</h3>
<p id="doc_section_8_2_4_p_1">The message "Encoding format uses different number of arguments" can be caused by code like:</p>
-<div id="doc_figure_u.146"></div> <pre>
+<div id="doc_figure_u.148"></div> <pre>
xo_emit("{:name/%6.6s %%04d/%s}", name, number);
</pre> <p id="doc_section_8_2_4_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.147"></div> <pre>
+<div id="doc_figure_u.149"></div> <pre>
xo_emit("{:name/%6.6s %04d/%s-%d}", name, number);
</pre> <p id="doc_section_8_2_4_p_5">Both format should consume the same number of arguments off the stack</p>
</div>
@@ -26045,10 +26084,10 @@ jQuery(function ($) {
<a id="only-one-field-role-can-be-used" href="#only-one-field-role-can-be-used">'Only one field role can be used'</a>
</h3>
<p id="doc_section_8_2_5_p_1">The message "Only one field role can be used" can be caused by code like:</p>
-<div id="doc_figure_u.148"></div> <pre>
+<div id="doc_figure_u.150"></div> <pre>
xo_emit("{LT:Max}");
</pre> <p id="doc_section_8_2_5_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.149"></div> <pre>
+<div id="doc_figure_u.151"></div> <pre>
xo_emit("{T:Max}");
</pre> </div>
<div class="content">
@@ -26058,10 +26097,10 @@ jQuery(function ($) {
<a id="potential-missing-slash-after-c-d-n-l-or-t-with-format" href="#potential-missing-slash-after-c-d-n-l-or-t-with-format">'Potential missing slash after C, D, N, L, or T with format'</a>
</h3>
<p id="doc_section_8_2_6_p_1">The message "Potential missing slash after C, D, N, L, or T with format" can be caused by code like:</p>
-<div id="doc_figure_u.150"></div> <pre>
+<div id="doc_figure_u.152"></div> <pre>
xo_emit("{T:%6.6s}\n", "Max");
</pre> <p id="doc_section_8_2_6_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.151"></div> <pre>
+<div id="doc_figure_u.153"></div> <pre>
xo_emit("{T:/%6.6s}\n", "Max");
</pre> <p id="doc_section_8_2_6_p_5">The "%6.6s" will be a literal, not a field format. While it's possibly valid, it's likely a missing "/".</p>
</div>
@@ -26072,7 +26111,7 @@ jQuery(function ($) {
<a id="an-encoding-format-cannot-be-given-roles-dnlt" href="#an-encoding-format-cannot-be-given-roles-dnlt">'An encoding format cannot be given (roles: DNLT)'</a>
</h3>
<p id="doc_section_8_2_7_p_1">The message "An encoding format cannot be given (roles: DNLT)" can be caused by code like:</p>
-<div id="doc_figure_u.152"></div> <pre>
+<div id="doc_figure_u.154"></div> <pre>
xo_emit("{T:Max//%s}", "Max");
</pre> <p id="doc_section_8_2_7_p_3">Fields with the C, D, N, L, and T roles are not emitted in the 'encoding' style (JSON, XML), so an encoding format would make no sense.</p>
</div>
@@ -26083,7 +26122,7 @@ jQuery(function ($) {
<a id="format-cannot-be-given-when-content-is-present-roles-cdln" href="#format-cannot-be-given-when-content-is-present-roles-cdln">'Format cannot be given when content is present (roles: CDLN)'</a>
</h3>
<p id="doc_section_8_2_8_p_1">The message "Format cannot be given when content is present (roles: CDLN)" can be caused by code like:</p>
-<div id="doc_figure_u.153"></div> <pre>
+<div id="doc_figure_u.155"></div> <pre>
xo_emit("{N:Max/%6.6s}", "Max");
</pre> <p id="doc_section_8_2_8_p_3">Fields with the C, D, L, or N roles can't have both static literal content ("{L:Label}") and a format ("{L:/%s}"). This error will also occur when the content has a backslash in it, like "{N:Type of I/O}"; backslashes should be escaped, like "{N:Type of I\\/O}". Note the double backslash, one for handling 'C' strings, and one for libxo.</p>
</div>
@@ -26094,10 +26133,10 @@ jQuery(function ($) {
<a id="field-has-color-without-fg--or-bg--role-c" href="#field-has-color-without-fg--or-bg--role-c">'Field has color without fg- or bg- (role: C)'</a>
</h3>
<p id="doc_section_8_2_9_p_1">The message "Field has color without fg- or bg- (role: C)" can be caused by code like:</p>
-<div id="doc_figure_u.154"></div> <pre>
+<div id="doc_figure_u.156"></div> <pre>
xo_emit("{C:green}{:foo}{C:}", x);
</pre> <p id="doc_section_8_2_9_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.155"></div> <pre>
+<div id="doc_figure_u.157"></div> <pre>
xo_emit("{C:fg-green}{:foo}{C:}", x);
</pre> <p id="doc_section_8_2_9_p_5">Colors must be prefixed by either "fg&#8209;" or "bg&#8209;".</p>
</div>
@@ -26108,10 +26147,10 @@ jQuery(function ($) {
<a id="field-has-invalid-color-or-effect-role-c" href="#field-has-invalid-color-or-effect-role-c">'Field has invalid color or effect (role: C)'</a>
</h3>
<p id="doc_section_8_2_10_p_1">The message "Field has invalid color or effect (role: C)" can be caused by code like:</p>
-<div id="doc_figure_u.156"></div> <pre>
+<div id="doc_figure_u.158"></div> <pre>
xo_emit("{C:fg-purple,bold}{:foo}{C:gween}", x);
</pre> <p id="doc_section_8_2_10_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.157"></div> <pre>
+<div id="doc_figure_u.159"></div> <pre>
xo_emit("{C:fg-red,bold}{:foo}{C:fg-green}", x);
</pre> <p id="doc_section_8_2_10_p_5">The list of colors and effects are limited. The set of colors includes default, black, red, green, yellow, blue, magenta, cyan, and white, which must be prefixed by either "fg&#8209;" or "bg&#8209;". Effects are limited to bold, no-bold, underline, no-underline, inverse, no-inverse, normal, and reset. Values must be separated by commas.</p>
</div>
@@ -26122,10 +26161,10 @@ jQuery(function ($) {
<a id="field-has-humanize-modifier-but-no-format-string" href="#field-has-humanize-modifier-but-no-format-string">'Field has humanize modifier but no format string'</a>
</h3>
<p id="doc_section_8_2_11_p_1">The message "Field has humanize modifier but no format string" can be caused by code like:</p>
-<div id="doc_figure_u.158"></div> <pre>
+<div id="doc_figure_u.160"></div> <pre>
xo_emit("{h:value}", value);
</pre> <p id="doc_section_8_2_11_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.159"></div> <pre>
+<div id="doc_figure_u.161"></div> <pre>
xo_emit("{h:value/%d}", value);
</pre> <p id="doc_section_8_2_11_p_5">Humanization is only value for numbers, which are not likely to use the default format ("%s").</p>
</div>
@@ -26136,10 +26175,10 @@ jQuery(function ($) {
<a id="field-has-hn--modifier-but-not-h-modifier" href="#field-has-hn--modifier-but-not-h-modifier">'Field has hn-* modifier but not 'h' modifier'</a>
</h3>
<p id="doc_section_8_2_12_p_1">The message "Field has hn-* modifier but not 'h' modifier" can be caused by code like:</p>
-<div id="doc_figure_u.160"></div> <pre>
+<div id="doc_figure_u.162"></div> <pre>
xo_emit("{,hn-1000:value}", value);
</pre> <p id="doc_section_8_2_12_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.161"></div> <pre>
+<div id="doc_figure_u.163"></div> <pre>
xo_emit("{h,hn-1000:value}", value);
</pre> <p id="doc_section_8_2_12_p_5">The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.</p>
</div>
@@ -26150,10 +26189,10 @@ jQuery(function ($) {
<a id="value-field-must-have-a-name-as-content" href="#value-field-must-have-a-name-as-content">'Value field must have a name (as content)")'</a>
</h3>
<p id="doc_section_8_2_13_p_1">The message "Value field must have a name (as content)")" can be caused by code like:</p>
-<div id="doc_figure_u.162"></div> <pre>
+<div id="doc_figure_u.164"></div> <pre>
xo_emit("{:/%s}", "value");
</pre> <p id="doc_section_8_2_13_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.163"></div> <pre>
+<div id="doc_figure_u.165"></div> <pre>
xo_emit("{:tag-name/%s}", "value");
</pre> <p id="doc_section_8_2_13_p_5">The field name is used for XML and JSON encodings. These tags names are static and must appear directly in the field descriptor.</p>
</div>
@@ -26164,10 +26203,10 @@ jQuery(function ($) {
<a id="use-hyphens-not-underscores-for-value-field-name" href="#use-hyphens-not-underscores-for-value-field-name">'Use hyphens, not underscores, for value field name'</a>
</h3>
<p id="doc_section_8_2_14_p_1">The message "Use hyphens, not underscores, for value field name" can be caused by code like:</p>
-<div id="doc_figure_u.164"></div> <pre>
+<div id="doc_figure_u.166"></div> <pre>
xo_emit("{:no_under_scores}", "bad");
</pre> <p id="doc_section_8_2_14_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.165"></div> <pre>
+<div id="doc_figure_u.167"></div> <pre>
xo_emit("{:no-under-scores}", "bad");
</pre> <p id="doc_section_8_2_14_p_5">Use of hyphens is traditional in XML, and the XOF_UNDERSCORES flag can be used to generate underscores in JSON, if desired. But the raw field name should use hyphens.</p>
</div>
@@ -26178,10 +26217,10 @@ jQuery(function ($) {
<a id="value-field-name-cannot-start-with-digit" href="#value-field-name-cannot-start-with-digit">'Value field name cannot start with digit'</a>
</h3>
<p id="doc_section_8_2_15_p_1">The message "Value field name cannot start with digit" can be caused by code like:</p>
-<div id="doc_figure_u.166"></div> <pre>
+<div id="doc_figure_u.168"></div> <pre>
xo_emit("{:10-gig/}");
</pre> <p id="doc_section_8_2_15_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.167"></div> <pre>
+<div id="doc_figure_u.169"></div> <pre>
xo_emit("{:ten-gig/}");
</pre> <p id="doc_section_8_2_15_p_5">XML element names cannot start with a digit.</p>
</div>
@@ -26192,10 +26231,10 @@ jQuery(function ($) {
<a id="value-field-name-should-be-lower-case" href="#value-field-name-should-be-lower-case">'Value field name should be lower case'</a>
</h3>
<p id="doc_section_8_2_16_p_1">The message "Value field name should be lower case" can be caused by code like:</p>
-<div id="doc_figure_u.168"></div> <pre>
+<div id="doc_figure_u.170"></div> <pre>
xo_emit("{:WHY-ARE-YOU-SHOUTING}", "NO REASON");
</pre> <p id="doc_section_8_2_16_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.169"></div> <pre>
+<div id="doc_figure_u.171"></div> <pre>
xo_emit("{:why-are-you-shouting}", "no reason");
</pre> <p id="doc_section_8_2_16_p_5">Lower case is more civilized. Even TLAs should be lower case to avoid scenarios where the differences between "XPath" and "Xpath" drive your users crazy. Lower case rules the seas.</p>
</div>
@@ -26206,10 +26245,10 @@ jQuery(function ($) {
<a id="value-field-name-should-be-longer-than-two-characters" href="#value-field-name-should-be-longer-than-two-characters">'Value field name should be longer than two characters'</a>
</h3>
<p id="doc_section_8_2_17_p_1">The message "Value field name should be longer than two characters" can be caused by code like:</p>
-<div id="doc_figure_u.170"></div> <pre>
+<div id="doc_figure_u.172"></div> <pre>
xo_emit("{:x}", "mumble");
</pre> <p id="doc_section_8_2_17_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.171"></div> <pre>
+<div id="doc_figure_u.173"></div> <pre>
xo_emit("{:something-meaningful}", "mumble");
</pre> <p id="doc_section_8_2_17_p_5">Field names should be descriptive, and it's hard to be descriptive in less than two characters. Consider your users and try to make something more useful. Note that this error often occurs when the field type is placed after the colon ("{:T/%20s}"), instead of before it ("{T:/20s}").</p>
</div>
@@ -26220,10 +26259,10 @@ jQuery(function ($) {
<a id="value-field-name-contains-invalid-character" href="#value-field-name-contains-invalid-character">'Value field name contains invalid character'</a>
</h3>
<p id="doc_section_8_2_18_p_1">The message "Value field name contains invalid character" can be caused by code like:</p>
-<div id="doc_figure_u.172"></div> <pre>
+<div id="doc_figure_u.174"></div> <pre>
xo_emit("{:cost-in-$$/%u}", 15);
</pre> <p id="doc_section_8_2_18_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.173"></div> <pre>
+<div id="doc_figure_u.175"></div> <pre>
xo_emit("{:cost-in-dollars/%u}", 15);
</pre> <p id="doc_section_8_2_18_p_5">An invalid character is often a sign of a typo, like "{:]}" instead of "{]:}". Field names are restricted to lower-case characters, digits, and hyphens.</p>
</div>
@@ -26234,10 +26273,10 @@ jQuery(function ($) {
<a id="decoration-field-contains-invalid-character" href="#decoration-field-contains-invalid-character">'decoration field contains invalid character'</a>
</h3>
<p id="doc_section_8_2_19_p_1">The message "decoration field contains invalid character" can be caused by code like:</p>
-<div id="doc_figure_u.174"></div> <pre>
+<div id="doc_figure_u.176"></div> <pre>
xo_emit("{D:not good}");
</pre> <p id="doc_section_8_2_19_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.175"></div> <pre>
+<div id="doc_figure_u.177"></div> <pre>
xo_emit("{D:((}{:good}{D:))}", "yes");
</pre> <p id="doc_section_8_2_19_p_5">This is minor, but fields should use proper roles. Decoration fields are meant to hold punctuation and other characters used to decorate the content, typically to make it more readable to human readers.</p>
</div>
@@ -26248,10 +26287,10 @@ jQuery(function ($) {
<a id="anchor-content-should-be-decimal-width" href="#anchor-content-should-be-decimal-width">'Anchor content should be decimal width'</a>
</h3>
<p id="doc_section_8_2_20_p_1">The message "Anchor content should be decimal width" can be caused by code like:</p>
-<div id="doc_figure_u.176"></div> <pre>
+<div id="doc_figure_u.178"></div> <pre>
xo_emit("{[:mumble}");
</pre> <p id="doc_section_8_2_20_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.177"></div> <pre>
+<div id="doc_figure_u.179"></div> <pre>
xo_emit("{[:32}");
</pre> <p id="doc_section_8_2_20_p_5">Anchors need an integer value to specify the width of the set of anchored fields. The value can be positive (for left padding/right justification) or negative (for right padding/left justification) and can appear in either the start or stop anchor field descriptor.</p>
</div>
@@ -26262,10 +26301,10 @@ jQuery(function ($) {
<a id="anchor-format-should-be-d" href="#anchor-format-should-be-d">'Anchor format should be "%d"'</a>
</h3>
<p id="doc_section_8_2_21_p_1">The message "Anchor format should be "%d"" can be caused by code like:</p>
-<div id="doc_figure_u.178"></div> <pre>
+<div id="doc_figure_u.180"></div> <pre>
xo_emit("{[:/%s}");
</pre> <p id="doc_section_8_2_21_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.179"></div> <pre>
+<div id="doc_figure_u.181"></div> <pre>
xo_emit("{[:/%d}");
</pre> <p id="doc_section_8_2_21_p_5">Anchors only grok integer values, and if the value is not static, if must be in an 'int' argument, represented by the "%d" format. Anything else is an error.</p>
</div>
@@ -26276,10 +26315,10 @@ jQuery(function ($) {
<a id="anchor-cannot-have-both-format-and-encoding-format" href="#anchor-cannot-have-both-format-and-encoding-format">'Anchor cannot have both format and encoding format")'</a>
</h3>
<p id="doc_section_8_2_22_p_1">The message "Anchor cannot have both format and encoding format")" can be caused by code like:</p>
-<div id="doc_figure_u.180"></div> <pre>
+<div id="doc_figure_u.182"></div> <pre>
xo_emit("{[:32/%d}");
</pre> <p id="doc_section_8_2_22_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.181"></div> <pre>
+<div id="doc_figure_u.183"></div> <pre>
xo_emit("{[:32}");
</pre> <p id="doc_section_8_2_22_p_5">Anchors can have a static value or argument for the width, but cannot have both.</p>
</div>
@@ -26290,10 +26329,10 @@ jQuery(function ($) {
<a id="max-width-only-valid-for-strings" href="#max-width-only-valid-for-strings">'Max width only valid for strings'</a>
</h3>
<p id="doc_section_8_2_23_p_1">The message "Max width only valid for strings" can be caused by code like:</p>
-<div id="doc_figure_u.182"></div> <pre>
+<div id="doc_figure_u.184"></div> <pre>
xo_emit("{:tag/%2.4.6d}", 55);
</pre> <p id="doc_section_8_2_23_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.183"></div> <pre>
+<div id="doc_figure_u.185"></div> <pre>
xo_emit("{:tag/%2.6d}", 55);
</pre> <p id="doc_section_8_2_23_p_5">libxo allows a true 'max width' in addition to the traditional printf-style 'max number of bytes to use for input'. But this is supported only for string values, since it makes no sense for non-strings. This error may occur from a typo, like "{:tag/%6..6d}" where only one period should be used.</p>
</div>
@@ -26333,7 +26372,7 @@ jQuery(function ($) {
<p id="doc_section_9_2_p_1">libxo is open source, under a new BSD license. Source code is available on github, as are recent releases. To get the most current release, please visit:</p>
<p id="doc_section_9_2_p_2"> <a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a></p>
<p id="doc_section_9_2_p_3">After downloading and untarring the source code, building involves the following steps:</p>
-<div id="doc_figure_u.184"></div> <pre>
+<div id="doc_figure_u.186"></div> <pre>
sh bin/setup.sh
cd build
../configure
@@ -26342,7 +26381,7 @@ jQuery(function ($) {
sudo make install
</pre> <p id="doc_section_9_2_p_5">libxo uses a distinct "build" directory to keep generated files separated from source files.</p>
<p id="doc_section_9_2_p_6">Use "../configure --help" to display available configuration options, which include the following:</p>
-<div id="doc_figure_u.185"></div> <pre>
+<div id="doc_figure_u.187"></div> <pre>
--enable-warnings Turn on compiler warnings
--enable-debug Turn on debugging
--enable-text-only Turn on text-only rendering
@@ -26362,7 +26401,7 @@ jQuery(function ($) {
<a href="#doc_section_9_3">9.3</a> </div>
<a id="howto-convert-command-line-applications" href="#howto-convert-command-line-applications">Howto: Convert command line applications</a>
</h2>
-<div id="doc_figure_u.186"></div> <pre>
+<div id="doc_figure_u.188"></div> <pre>
How do I convert an existing command line application?
</pre> <p id="doc_section_9_3_p_2">There are three basic steps for converting command line application to use libxo.</p>
<p id="doc_section_9_3_p_3"> </p>
@@ -26386,10 +26425,10 @@ jQuery(function ($) {
<a id="setting-up-the-context" href="#setting-up-the-context">Setting up the context</a>
</h3>
<p id="doc_section_9_3_1_p_1">To use libxo, you'll need to include the "xo.h" header file in your source code files:</p>
-<div id="doc_figure_u.187"></div> <pre>
+<div id="doc_figure_u.189"></div> <pre>
#include &lt;libxo/xo.h&gt;
</pre> <p id="doc_section_9_3_1_p_3">In your main() function, you'll need to call xo_parse_args to handling argument parsing (<a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 3.4.1</a>). This function removes libxo-specific arguments the program's argv and returns either the number of remaining arguments or -1 to indicate an error.</p>
-<div id="doc_figure_u.188"></div> <pre>
+<div id="doc_figure_u.190"></div> <pre>
int main (int argc, char **argv)
{
argc = xo_parse_args(argc, argv);
@@ -26398,7 +26437,7 @@ jQuery(function ($) {
....
}
</pre> <p id="doc_section_9_3_1_p_5">At the bottom of your main(), you'll need to call xo_finish() to complete output processing for the default handle (<a href="#handles" title="Handles">Section 3.1</a>). libxo provides the xo_finish_atexit function that is suitable for use with the atexit(3) function.</p>
-<div id="doc_figure_u.189"></div> <pre>
+<div id="doc_figure_u.191"></div> <pre>
atexit(xo_finish_atexit);
</pre> </div>
<div class="content">
@@ -26408,20 +26447,20 @@ jQuery(function ($) {
<a id="converting-printf-calls" href="#converting-printf-calls">Converting printf Calls</a>
</h3>
<p id="doc_section_9_3_2_p_1">The second task is inspecting code for printf(3) calls and replacing them with xo_emit() calls. The format strings are similar in task, but libxo format strings wrap output fields in braces. The following two calls produce identical text output:</p>
-<div id="doc_figure_u.190"></div> <pre>
+<div id="doc_figure_u.192"></div> <pre>
printf("There are %d %s events\n", count, etype);
xo_emit("There are {:count/%d} {:event} events\n", count, etype);
</pre> <p id="doc_section_9_3_2_p_3">"count" and "event" are used as names for JSON and XML output. The "count" field uses the format "%d" and "event" uses the default "%s" format. Both are "value" roles, which is the default role.</p>
<p id="doc_section_9_3_2_p_4">Since text outside of output fields is passed verbatim, other roles are less important, but their proper use can help make output more useful. The "note" and "label" roles allow HTML output to recognize the relationship between text and the associated values, allowing appropriate "hover" and "onclick" behavior. Using the "units" role allows the presentation layer to perform conversions when needed. The "warning" and "error" roles allows use of color and font to draw attention to warnings. The "padding" role makes the use of vital whitespace more clear (<a href="#padding-role" title="The Padding Role ({P:})">Section 2.2.1.6</a>).</p>
<p id="doc_section_9_3_2_p_5">The "title" role indicates the headings of table and sections. This allows HTML output to use CSS to make this relationship more obvious.</p>
-<div id="doc_figure_u.191"></div> <pre>
+<div id="doc_figure_u.193"></div> <pre>
printf("Statistics:\n");
xo_emit("{T:Statistics}:\n");
</pre> <p id="doc_section_9_3_2_p_7">The "color" roles controls foreground and background colors, as well as effects like bold and underline (see <a href="#color-role" title="The Color Role ({C:})">Section 2.2.1.1</a>).</p>
-<div id="doc_figure_u.192"></div> <pre>
+<div id="doc_figure_u.194"></div> <pre>
xo_emit("{C:bold}required{C:}\n");
</pre> <p id="doc_section_9_3_2_p_9">Finally, the start- and stop-anchor roles allow justification and padding over multiple fields (see <a href="#anchor-role" title="The Anchor Roles ({[:} and {]:})">Section 2.2.1.10</a>).</p>
-<div id="doc_figure_u.193"></div> <pre>
+<div id="doc_figure_u.195"></div> <pre>
snprintf(buf, sizeof(buf), "(%u/%u/%u)", min, ave, max);
printf("%30s", buf);
@@ -26435,7 +26474,7 @@ jQuery(function ($) {
<a id="creating-hierarchy" href="#creating-hierarchy">Creating Hierarchy</a>
</h3>
<p id="doc_section_9_3_3_p_1">Text output doesn't have any sort of hierarchy, but XML and JSON require this. Typically applications use indentation to represent these relationship:</p>
-<div id="doc_figure_u.194"></div> <pre>
+<div id="doc_figure_u.196"></div> <pre>
printf("table %d\n", tnum);
for (i = 0; i &lt; tmax; i++) {
printf(" %s %d\n", table[i].name, table[i].size);
@@ -26453,7 +26492,7 @@ jQuery(function ($) {
</pre> <p id="doc_section_9_3_3_p_3">The open and close list functions are used before and after the list, and the open and close instance functions are used before and after each instance with in the list.</p>
<p id="doc_section_9_3_3_p_4">Typically these developer looks for a "for" loop as an indication of where to put these calls.</p>
<p id="doc_section_9_3_3_p_5">In addition, the open and close container functions allow for organization levels of hierarchy.</p>
-<div id="doc_figure_u.195"></div> <pre>
+<div id="doc_figure_u.197"></div> <pre>
printf("Paging information:\n");
printf(" Free: %lu\n", free);
printf(" Active: %lu\n", active);
@@ -26472,7 +26511,7 @@ jQuery(function ($) {
<a id="converting-error-functions" href="#converting-error-functions">Converting Error Functions</a>
</h3>
<p id="doc_section_9_3_4_p_1">libxo provides variants of the standard error and warning functions, err(3) and warn(3). There are two variants, one for putting the errors on standard error, and the other writes the errors and warnings to the handle using the appropriate encoding style:</p>
-<div id="doc_figure_u.196"></div> <pre>
+<div id="doc_figure_u.198"></div> <pre>
err(1, "cannot open output file: %s", file);
xo_err(1, "cannot open output file: %s", file);
@@ -26490,12 +26529,12 @@ jQuery(function ($) {
<a href="#doc_section_9_5">9.5</a> </div>
<a id="howto-i18n" href="#howto-i18n">Howto: Internationalization (i18n)</a>
</h2>
-<div id="doc_figure_u.197"></div> <pre>
+<div id="doc_figure_u.199"></div> <pre>
How do I use libxo to support internationalization?
</pre> <p id="doc_section_9_5_p_2">libxo allows format and field strings to be used a keys into message catalogs to enable translation into a user's native language by invoking the standard gettext(3) functions.</p>
<p id="doc_section_9_5_p_3">gettext setup is a bit complicated: text strings are extracted from source files into "portable object template" (.pot) files using the "xgettext" command. For each language, this template file is used as the source for a message catalog in the "portable object" (.po) format, which are translated by hand and compiled into "machine object" (.mo) files using the "msgfmt" command. The .mo files are then typically installed in the /usr/share/locale or /opt/local/share/locale directories. At run time, the user's language settings are used to select a .mo file which is searched for matching messages. Text strings in the source code are used as keys to look up the native language strings in the .mo file.</p>
<p id="doc_section_9_5_p_4">Since the xo_emit format string is used as the key into the message catalog, libxo removes unimportant field formatting and modifiers from the format string before use so that minor formatting changes will not impact the expensive translation process. We don't want a developer change such as changing "/%06d" to "/%08d" to force hand inspection of all .po files. The simplified version can be generated for a single message using the "xopo -s &lt;text&gt;" command, or an entire .pot can be translated using the "xopo -f &lt;input&gt; -o &lt;output&gt;" command.</p>
-<div id="doc_figure_u.198"></div> <pre>
+<div id="doc_figure_u.200"></div> <pre>
EXAMPLE:
% xopo -s "There are {:count/%u} {:event/%.6s} events\n"
There are {:count} {:event} events\n
@@ -26528,7 +26567,7 @@ jQuery(function ($) {
sudo cp po/my_lang/LC_MESSAGES/foo.mo \
/opt/local/share/locale/my_lang/LC_MESSAGE/
</pre> <p id="doc_section_9_5_p_6">Once these steps are complete, you can use the "gettext" command to test the message catalog:</p>
-<div id="doc_figure_u.199"></div> <pre>
+<div id="doc_figure_u.201"></div> <pre>
gettext -d foo -e "some text"
</pre> <p id="doc_section_9_5_p_8">Section Contents: </p>
<ul><li><a href="#i18n-and-xo_emit" title="i18n and xo_emit">Section 9.5.1</a></li></ul>
@@ -26546,7 +26585,7 @@ jQuery(function ($) {
<li>The "{p:}" modifier looks for a pluralized version of the field.</li>
</ul>
<p id="doc_section_9_5_1_p_3">Together these three flags allows a single function call to give native language support, as well as libxo's normal XML, JSON, and HTML support.</p>
-<div id="doc_figure_u.200"></div> <pre>
+<div id="doc_figure_u.202"></div> <pre>
printf(gettext("Received %zu %s from {g:server} server\n"),
counter, ngettext("byte", "bytes", counter),
gettext("web"));
@@ -26554,17 +26593,17 @@ jQuery(function ($) {
xo_emit("{G:}Received {:received/%zu} {Ngp:byte,bytes} "
"from {g:server} server\n", counter, "web");
</pre> <p id="doc_section_9_5_1_p_5">libxo will see the "{G:}" role and will first simplify the format string, removing field formats and modifiers.</p>
-<div id="doc_figure_u.201"></div> <pre>
+<div id="doc_figure_u.203"></div> <pre>
"Received {:received} {N:byte,bytes} from {:server} server\n"
</pre> <p id="doc_section_9_5_1_p_7">libxo calls gettext(3) with that string to get a localized version. If your language were Pig Latin, the result might look like:</p>
-<div id="doc_figure_u.202"></div> <pre>
+<div id="doc_figure_u.204"></div> <pre>
"Eceivedray {:received} {N:byte,bytes} omfray "
"{:server} erversay\n"
</pre> <p id="doc_section_9_5_1_p_9">Note the field names do not change and they should not be translated. The contents of the note ("byte,bytes") should also not be translated, since the "g" modifier will need the untranslated value as the key for the message catalog.</p>
<p id="doc_section_9_5_1_p_10">The field "{g:server}" requests the rendered value of the field be translated using gettext(3). In this example, "web" would be used.</p>
<p id="doc_section_9_5_1_p_11">The field "{Ngp:byte,bytes}" shows an example of plural form using the "p" modifier with the "g" modifier. The base singular and plural forms appear inside the field, separated by a comma. At run time, libxo uses the previous field's numeric value to decide which form to use by calling ngettext(3).</p>
<p id="doc_section_9_5_1_p_12">If a domain name is needed, it can be supplied as the content of the {G:} role. Domain names remain in use throughout the format string until cleared with another domain name.</p>
-<div id="doc_figure_u.203"></div> <pre>
+<div id="doc_figure_u.205"></div> <pre>
printf(dgettext("dns", "Host %s not found: %d(%s)\n"),
name, errno, dgettext("strerror", strerror(errno)));
@@ -26589,7 +26628,7 @@ jQuery(function ($) {
<a id="unit-test" href="#unit-test">Unit Test</a>
</h2>
<p id="doc_section_10_1_p_1">Here is the unit test example:</p>
-<div id="doc_figure_u.204"></div> <pre>
+<div id="doc_figure_u.206"></div> <pre>
int
main (int argc, char **argv)
{
@@ -26682,7 +26721,7 @@ jQuery(function ($) {
return 0;
}
</pre> <p id="doc_section_10_1_p_3">Text output:</p>
-<div id="doc_figure_u.205"></div> <pre>
+<div id="doc_figure_u.207"></div> <pre>
% ./testxo --libxo text
Item 'gum':
Total sold: 1412.0
@@ -26715,7 +26754,7 @@ jQuery(function ($) {
On order: 1
SKU: GRO-000-533
</pre> <p id="doc_section_10_1_p_5">JSON output:</p>
-<div id="doc_figure_u.206"></div> <pre>
+<div id="doc_figure_u.208"></div> <pre>
% ./testxo --libxo json,pretty
"top": {
"data": {
@@ -26770,7 +26809,7 @@ jQuery(function ($) {
}
}
</pre> <p id="doc_section_10_1_p_7">XML output:</p>
-<div id="doc_figure_u.207"></div> <pre>
+<div id="doc_figure_u.209"></div> <pre>
% ./testxo --libxo pretty,xml
&lt;top&gt;
&lt;data&gt;
@@ -26821,7 +26860,7 @@ jQuery(function ($) {
&lt;/data&gt;
&lt;/top&gt;
</pre> <p id="doc_section_10_1_p_9">HMTL output:</p>
-<div id="doc_figure_u.208"></div> <pre>
+<div id="doc_figure_u.210"></div> <pre>
% ./testxo --libxo pretty,html
&lt;div class="line"&gt;
&lt;div class="label"&gt;Item&lt;/div&gt;
@@ -27016,7 +27055,7 @@ jQuery(function ($) {
&lt;div class="data" data-tag="sku"&gt;GRO-000-533&lt;/div&gt;
&lt;/div&gt;
</pre> <p id="doc_section_10_1_p_11">HTML output with xpath and info flags:</p>
-<div id="doc_figure_u.209"></div> <pre>
+<div id="doc_figure_u.211"></div> <pre>
% ./testxo --libxo pretty,html,xpath,info
&lt;div class="line"&gt;
&lt;div class="label"&gt;Item&lt;/div&gt;
diff --git a/doc/libxo.txt b/doc/libxo.txt
index 4cd51cca5d57..f4b0eff5ebc0 100644
--- a/doc/libxo.txt
+++ b/doc/libxo.txt
@@ -1070,7 +1070,7 @@ libxo will convert these arguments as needed to either UTF-8 (for XML,
JSON, and HTML styles) or locale-based strings for display in text
style.
- xo_emit("Alll strings are utf-8 content {:tag/%ls}",
+ xo_emit("All strings are utf-8 content {:tag/%ls}",
L"except for wide strings");
"%S" is equivalent to "%ls".
@@ -1464,6 +1464,8 @@ styles, flags, or features:
|-------------+-------------------------------------------------------|
| color | Enable colors/effects for display styles (TEXT, HTML) |
| dtrt | Enable "Do The Right Thing" mode |
+| flush | Flush after every libxo function call |
+| flush-line | Flush after every line (line-buffered) |
| html | Emit HTML output |
| indent=xx | Set the indentation level |
| info | Add info attributes (HTML) |
@@ -1479,7 +1481,7 @@ styles, flags, or features:
| pretty | Emit pretty-printed output |
| retain | Force retaining formatting information |
| text | Emit TEXT output |
-| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
+| underscores | Replace XML-friendly "-"s with JSON friendly "_"s |
| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
| warn | Emit warnings when libxo detects bad calls |
| warn-xml | Emit warnings in XML |
@@ -1489,6 +1491,29 @@ styles, flags, or features:
The brief options are detailed in ^LIBXO_OPTIONS^.
+Most of these option are simple and direct, but some require
+additional details:
+
+- "flush-line" performs line buffering, even when the output is not
+directed to a TTY device.
+- "info" generates additional data for HTML, encoded in attributes
+using names that state with "data-".
+- "keys" adds a "key" attribute for XML output to indicate that a leaf
+is an identifier for the list member.
+- "no-humanize"avoids "humanizing" numeric output (see
+humanize_number(3) for details).
+- "no-locale" instructs libxo to avoid translating output to the
+current locale.
+- "no-retain" disables the ability of libxo to internally retain
+"compiled" information about formatting strings.
+- "underscores" can be used with JSON output to change XML-friendly
+names with dashes into JSON-friendly name with underscores.
+- "warn" allows libxo to emit warnings on stderr when application code
+make incorrect calls.
+- "warn-xml" causes those warnings to be placed in XML inside the
+output.
+
+
* The libxo API
This section gives details about the functions in libxo, how to call
@@ -1577,6 +1602,16 @@ To use the default handle, pass a NULL handle:
xo_set_style(NULL, XO_STYLE_XML);
+*** xo_get_style
+
+To find the current style, use the xo_get_style() function:
+
+ xo_style_t xo_get_style(xo_handle_t *xop);
+
+To use the default handle, pass a NULL handle:
+
+ style = xo_get_style(NULL);
+
**** Output Styles (XO_STYLE_*) @styles@
The libxo functions accept a set of output styles:
@@ -2883,9 +2918,9 @@ which include the following:
Compiler warnings are a very good thing, but recent compiler version
have added some very pedantic checks. While every attempt is made to
keep libxo code warning-free, warnings are now optional. If you are
-doing development work on libxo, it is required that you use
---enable-warnings to keep the code warning free, but most users need
-not use this option.
+doing development work on libxo, it is required that you
+use --enable-warnings to keep the code warning free, but most users
+need not use this option.
libxo provides the --enable-text-only option to reduce the footprint
of the library for smaller installations. XML, JSON, and HTML
diff --git a/libxo/Makefile.am b/libxo/Makefile.am
index b11c311e70b2..a484a9b71dd9 100644
--- a/libxo/Makefile.am
+++ b/libxo/Makefile.am
@@ -72,7 +72,10 @@ man3_files = \
man5_files = \
xo_format.5
-man_MANS = ${man3_files} ${man5_files}
+man7_files = \
+ xo_options.7
+
+man_MANS = ${man3_files} ${man5_files} ${man7_files}
EXTRA_DIST = \
${man_MANS}
@@ -87,3 +90,5 @@ install-data-hook:
cat ../libxo/add.man >> ${DESTDIR}${man3dir}/$$file ; done
for file in ${man5_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man5dir}/$$file ; done
+ for file in ${man7_files}; do \
+ cat ../libxo/add.man >> ${DESTDIR}${man7dir}/$$file ; done
diff --git a/libxo/libxo.c b/libxo/libxo.c
index 7a714b1573d1..973675a7b115 100644
--- a/libxo/libxo.c
+++ b/libxo/libxo.c
@@ -274,11 +274,11 @@ struct xo_handle_s {
va_list xo_vap; /* Variable arguments (stdargs) */
char *xo_leading_xpath; /* A leading XPath expression */
mbstate_t xo_mbstate; /* Multi-byte character conversion state */
- unsigned xo_anchor_offset; /* Start of anchored text */
- unsigned xo_anchor_columns; /* Number of columns since the start anchor */
- int xo_anchor_min_width; /* Desired width of anchored text */
- unsigned xo_units_offset; /* Start of units insertion point */
- unsigned xo_columns; /* Columns emitted during this xo_emit call */
+ ssize_t xo_anchor_offset; /* Start of anchored text */
+ ssize_t xo_anchor_columns; /* Number of columns since the start anchor */
+ ssize_t xo_anchor_min_width; /* Desired width of anchored text */
+ ssize_t xo_units_offset; /* Start of units insertion point */
+ ssize_t xo_columns; /* Columns emitted during this xo_emit call */
uint8_t xo_color_map_fg[XO_NUM_COLORS]; /* Foreground color mappings */
uint8_t xo_color_map_bg[XO_NUM_COLORS]; /* Background color mappings */
xo_colors_t xo_colors; /* Current color and effect values */
@@ -426,10 +426,10 @@ typedef struct xo_field_info_s {
const char *xfi_format; /* Field's Format */
const char *xfi_encoding; /* Field's encoding format */
const char *xfi_next; /* Next character in format string */
- unsigned xfi_len; /* Length of field */
- unsigned xfi_clen; /* Content length */
- unsigned xfi_flen; /* Format length */
- unsigned xfi_elen; /* Encoding length */
+ ssize_t xfi_len; /* Length of field */
+ ssize_t xfi_clen; /* Content length */
+ ssize_t xfi_flen; /* Format length */
+ ssize_t xfi_elen; /* Encoding length */
unsigned xfi_fnum; /* Field number (if used; 0 otherwise) */
unsigned xfi_renum; /* Reordered number (0 == no renumbering) */
} xo_field_info_t;
@@ -457,15 +457,15 @@ xo_free_func_t xo_free = free;
static void
xo_failure (xo_handle_t *xop, const char *fmt, ...);
-static int
+static ssize_t
xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
xo_state_t new_state);
static void
xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
- const char *name, int nlen,
- const char *value, int vlen,
- const char *encoding, int elen);
+ const char *name, ssize_t nlen,
+ const char *value, ssize_t vlen,
+ const char *encoding, ssize_t elen);
static void
xo_anchor_clear (xo_handle_t *xop);
@@ -491,7 +491,7 @@ xo_style (xo_handle_t *xop UNUSED)
/*
* Callback to write data to a FILE pointer
*/
-static int
+static xo_ssize_t
xo_write_to_file (void *opaque, const char *data)
{
FILE *fp = (FILE *) opaque;
@@ -750,14 +750,14 @@ static char xo_xml_lt[] = "&lt;";
static char xo_xml_gt[] = "&gt;";
static char xo_xml_quot[] = "&quot;";
-static int
-xo_escape_xml (xo_buffer_t *xbp, int len, xo_xff_flags_t flags)
+static ssize_t
+xo_escape_xml (xo_buffer_t *xbp, ssize_t len, xo_xff_flags_t flags)
{
- int slen;
- unsigned delta = 0;
+ ssize_t slen;
+ ssize_t delta = 0;
char *cp, *ep, *ip;
const char *sp;
- int attr = (flags & XFF_ATTR);
+ int attr = XOF_BIT_ISSET(flags, XFF_ATTR);
for (cp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
/* We're subtracting 2: 1 for the NUL, 1 for the char we replace */
@@ -806,10 +806,10 @@ xo_escape_xml (xo_buffer_t *xbp, int len, xo_xff_flags_t flags)
return len + delta;
}
-static int
-xo_escape_json (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
+static ssize_t
+xo_escape_json (xo_buffer_t *xbp, ssize_t len, xo_xff_flags_t flags UNUSED)
{
- unsigned delta = 0;
+ ssize_t delta = 0;
char *cp, *ep, *ip;
for (cp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
@@ -854,10 +854,10 @@ xo_escape_json (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
* PARAM-VALUE = UTF-8-STRING ; characters '"', '\' and
* ; ']' MUST be escaped.
*/
-static int
-xo_escape_sdparams (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
+static ssize_t
+xo_escape_sdparams (xo_buffer_t *xbp, ssize_t len, xo_xff_flags_t flags UNUSED)
{
- unsigned delta = 0;
+ ssize_t delta = 0;
char *cp, *ep, *ip;
for (cp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
@@ -892,7 +892,7 @@ xo_escape_sdparams (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
static void
xo_buf_escape (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *str, int len, xo_xff_flags_t flags)
+ const char *str, ssize_t len, xo_xff_flags_t flags)
{
if (!xo_buf_has_room(xbp, len))
return;
@@ -921,10 +921,10 @@ xo_buf_escape (xo_handle_t *xop, xo_buffer_t *xbp,
* Write the current contents of the data buffer using the handle's
* xo_write function.
*/
-static int
+static ssize_t
xo_write (xo_handle_t *xop)
{
- int rc = 0;
+ ssize_t rc = 0;
xo_buffer_t *xbp = &xop->xo_data;
if (xbp->xb_curp != xbp->xb_bufp) {
@@ -945,12 +945,12 @@ xo_write (xo_handle_t *xop)
* Format arguments into our buffer. If a custom formatter has been set,
* we use that to do the work; otherwise we vsnprintf().
*/
-static int
+static ssize_t
xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
{
va_list va_local;
- int rc;
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t rc;
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
va_copy(va_local, vap);
@@ -990,12 +990,12 @@ xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
/*
* Print some data through the handle.
*/
-static int
+static ssize_t
xo_printf_v (xo_handle_t *xop, const char *fmt, va_list vap)
{
xo_buffer_t *xbp = &xop->xo_data;
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
- int rc;
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t rc;
va_list va_local;
va_copy(va_local, vap);
@@ -1023,10 +1023,10 @@ xo_printf_v (xo_handle_t *xop, const char *fmt, va_list vap)
return rc;
}
-static int
+static ssize_t
xo_printf (xo_handle_t *xop, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, fmt);
@@ -1041,7 +1041,7 @@ xo_printf (xo_handle_t *xop, const char *fmt, ...)
* These next few function are make The Essential UTF-8 Ginsu Knife.
* Identify an input and output character, and convert it.
*/
-static int xo_utf8_bits[7] = { 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
+static uint8_t xo_utf8_bits[7] = { 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
static int
xo_is_utf8 (char ch)
@@ -1049,11 +1049,11 @@ xo_is_utf8 (char ch)
return (ch & 0x80);
}
-static inline int
+static inline ssize_t
xo_utf8_to_wc_len (const char *buf)
{
unsigned b = (unsigned char) *buf;
- int len;
+ ssize_t len;
if ((b & 0x80) == 0x0)
len = 1;
@@ -1073,12 +1073,12 @@ xo_utf8_to_wc_len (const char *buf)
return len;
}
-static int
-xo_buf_utf8_len (xo_handle_t *xop, const char *buf, int bufsiz)
+static ssize_t
+xo_buf_utf8_len (xo_handle_t *xop, const char *buf, ssize_t bufsiz)
{
unsigned b = (unsigned char) *buf;
- int len, i;
+ ssize_t len, i;
len = xo_utf8_to_wc_len(buf);
if (len == -1) {
@@ -1109,13 +1109,13 @@ xo_buf_utf8_len (xo_handle_t *xop, const char *buf, int bufsiz)
* but we put 6 bits off all other bytes.
*/
static inline wchar_t
-xo_utf8_char (const char *buf, int len)
+xo_utf8_char (const char *buf, ssize_t len)
{
/* Most common case: singleton byte */
if (len == 1)
return (unsigned char) buf[0];
- int i;
+ ssize_t i;
wchar_t wc;
const unsigned char *cp = (const unsigned char *) buf;
@@ -1133,10 +1133,10 @@ xo_utf8_char (const char *buf, int len)
/*
* Determine the number of bytes needed to encode a wide character.
*/
-static int
+static ssize_t
xo_utf8_emit_len (wchar_t wc)
{
- int len;
+ ssize_t len;
if ((wc & ((1<<7) - 1)) == wc) /* Simple case */
len = 1;
@@ -1155,9 +1155,9 @@ xo_utf8_emit_len (wchar_t wc)
}
static void
-xo_utf8_emit_char (char *buf, int len, wchar_t wc)
+xo_utf8_emit_char (char *buf, ssize_t len, wchar_t wc)
{
- int i;
+ ssize_t i;
if (len == 1) { /* Simple case */
buf[0] = wc & 0x7f;
@@ -1173,12 +1173,12 @@ xo_utf8_emit_char (char *buf, int len, wchar_t wc)
buf[0] |= ~xo_utf8_bits[len] << 1;
}
-static int
+static ssize_t
xo_buf_append_locale_from_utf8 (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *ibuf, int ilen)
+ const char *ibuf, ssize_t ilen)
{
wchar_t wc;
- int len;
+ ssize_t len;
/*
* Build our wide character from the input buffer; the number of
@@ -1218,11 +1218,11 @@ xo_buf_append_locale_from_utf8 (xo_handle_t *xop, xo_buffer_t *xbp,
static void
xo_buf_append_locale (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *cp, int len)
+ const char *cp, ssize_t len)
{
const char *sp = cp, *ep = cp + len;
- unsigned save_off = xbp->xb_bufp - xbp->xb_curp;
- int slen;
+ ssize_t save_off = xbp->xb_bufp - xbp->xb_curp;
+ ssize_t slen;
int cols = 0;
for ( ; cp < ep; cp++) {
@@ -1274,7 +1274,7 @@ xo_buf_append_locale (xo_handle_t *xop, xo_buffer_t *xbp,
* buffer with no fanciness.
*/
static void
-xo_data_append (xo_handle_t *xop, const char *str, int len)
+xo_data_append (xo_handle_t *xop, const char *str, ssize_t len)
{
xo_buf_append(&xop->xo_data, str, len);
}
@@ -1283,7 +1283,7 @@ xo_data_append (xo_handle_t *xop, const char *str, int len)
* Append the given string to the given buffer
*/
static void
-xo_data_escape (xo_handle_t *xop, const char *str, int len)
+xo_data_escape (xo_handle_t *xop, const char *str, ssize_t len)
{
xo_buf_escape(xop, &xop->xo_data, str, len, 0);
}
@@ -1453,7 +1453,7 @@ xo_retain_add (const char *fmt, xo_field_info_t *fields, unsigned num_fields)
{
unsigned hash = xo_retain_hash(fmt);
xo_retain_entry_t *xrep;
- unsigned sz = sizeof(*xrep) + (num_fields + 1) * sizeof(*fields);
+ ssize_t sz = sizeof(*xrep) + (num_fields + 1) * sizeof(*fields);
xo_field_info_t *xfip;
xrep = xo_realloc(NULL, sz);
@@ -1493,8 +1493,8 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
if (fmt == NULL)
return;
- int len = strlen(fmt);
- int plen = xo_program ? strlen(xo_program) : 0;
+ ssize_t len = strlen(fmt);
+ ssize_t plen = xo_program ? strlen(xo_program) : 0;
char *newfmt = alloca(len + 1 + plen + 2); /* NUL, and ": " */
if (plen) {
@@ -1519,8 +1519,8 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
va_list va_local;
va_copy(va_local, vap);
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
- int rc = vsnprintf(xbp->xb_curp, left, newfmt, vap);
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t rc = vsnprintf(xbp->xb_curp, left, newfmt, vap);
if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
va_end(va_local);
@@ -1652,7 +1652,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
static char msg_open[] = "<message>";
static char msg_close[] = "</message>";
xo_buffer_t *xbp;
- int rc;
+ ssize_t rc;
va_list va_local;
xop = xo_default(xop);
@@ -1671,7 +1671,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
va_copy(va_local, vap);
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
rc = vsnprintf(xbp->xb_curp, left, fmt, vap);
if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
@@ -1712,8 +1712,8 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
case XO_STYLE_HTML:
{
char buf[BUFSIZ], *bp = buf, *cp;
- int bufsiz = sizeof(buf);
- int rc2;
+ ssize_t bufsiz = sizeof(buf);
+ ssize_t rc2;
va_copy(va_local, vap);
@@ -2013,7 +2013,7 @@ typedef struct xo_mapping_s {
} xo_mapping_t;
static xo_xff_flags_t
-xo_name_lookup (xo_mapping_t *map, const char *value, int len)
+xo_name_lookup (xo_mapping_t *map, const char *value, ssize_t len)
{
if (len == 0)
return 0;
@@ -2059,6 +2059,7 @@ static xo_mapping_t xo_xof_names[] = {
{ XOF_COLUMNS, "columns" },
{ XOF_DTRT, "dtrt" },
{ XOF_FLUSH, "flush" },
+ { XOF_FLUSH_LINE, "flush-line" },
{ XOF_IGNORE_CLOSE, "ignore-close" },
{ XOF_INFO, "info" },
{ XOF_KEYS, "keys" },
@@ -2112,7 +2113,8 @@ int
xo_set_options (xo_handle_t *xop, const char *input)
{
char *cp, *ep, *vp, *np, *bp;
- int style = -1, new_style, len, rc = 0;
+ int style = -1, new_style, rc = 0;
+ ssize_t len;
xo_xof_flags_t new_flag;
if (input == NULL)
@@ -2131,7 +2133,7 @@ xo_set_options (xo_handle_t *xop, const char *input)
* ideal for lazy people, such as myself.
*/
if (*input == ':') {
- int sz;
+ ssize_t sz;
for (input++ ; *input; input++) {
switch (*input) {
@@ -2302,7 +2304,7 @@ xo_get_flags (xo_handle_t *xop)
* strndup with a twist: len < 0 means strlen
*/
static char *
-xo_strndup (const char *str, int len)
+xo_strndup (const char *str, ssize_t len)
{
if (len < 0)
len = strlen(str);
@@ -2476,7 +2478,7 @@ xo_info_compare (const void *key, const void *data)
static xo_info_t *
-xo_info_find (xo_handle_t *xop, const char *name, int nlen)
+xo_info_find (xo_handle_t *xop, const char *name, ssize_t nlen)
{
xo_info_t *xip;
char *cp = alloca(nlen + 1); /* Need local copy for NUL termination */
@@ -2515,13 +2517,15 @@ xo_check_conversion (xo_handle_t *xop, int have_enc, int need_enc)
static int
xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp,
xo_xff_flags_t flags,
- const wchar_t *wcp, const char *cp, int len, int max,
+ const wchar_t *wcp, const char *cp,
+ ssize_t len, int max,
int need_enc, int have_enc)
{
int cols = 0;
wchar_t wc = 0;
- int ilen, olen, width;
- int attr = (flags & XFF_ATTR);
+ ssize_t ilen, olen;
+ ssize_t width;
+ int attr = XOF_BIT_ISSET(flags, XFF_ATTR);
const char *sp;
if (len > 0 && !xo_buf_has_room(xbp, len))
@@ -2629,7 +2633,7 @@ xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp,
else
break;
- int slen = strlen(sp);
+ ssize_t slen = strlen(sp);
if (!xo_buf_has_room(xbp, slen - 1))
return -1;
@@ -2714,7 +2718,7 @@ xo_needed_encoding (xo_handle_t *xop)
return XF_ENC_UTF8; /* Otherwise, we love UTF-8 */
}
-static int
+static ssize_t
xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
xo_format_t *xfp)
{
@@ -2723,8 +2727,9 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
char *cp = NULL;
wchar_t *wcp = NULL;
- int len, cols = 0, rc = 0;
- int off = xbp->xb_curp - xbp->xb_bufp, off2;
+ ssize_t len;
+ ssize_t cols = 0, rc = 0;
+ ssize_t off = xbp->xb_curp - xbp->xb_bufp, off2;
int need_enc = xo_needed_encoding(xop);
if (xo_check_conversion(xop, xfp->xf_enc, need_enc))
@@ -2852,7 +2857,7 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
* Look backwards in a buffer to find a numeric value
*/
static int
-xo_buf_find_last_number (xo_buffer_t *xbp, int start_offset)
+xo_buf_find_last_number (xo_buffer_t *xbp, ssize_t start_offset)
{
int rc = 0; /* Fail with zero */
int digit = 1;
@@ -2873,12 +2878,12 @@ xo_buf_find_last_number (xo_buffer_t *xbp, int start_offset)
return rc;
}
-static int
-xo_count_utf8_cols (const char *str, int len)
+static ssize_t
+xo_count_utf8_cols (const char *str, ssize_t len)
{
- int tlen;
+ ssize_t tlen;
wchar_t wc;
- int cols = 0;
+ ssize_t cols = 0;
const char *ep = str + len;
while (str < ep) {
@@ -2896,7 +2901,7 @@ xo_count_utf8_cols (const char *str, int len)
* Find the width-in-columns of this character, which must be done
* in wide characters, since we lack a mbswidth() function.
*/
- int width = xo_wcwidth(wc);
+ ssize_t width = xo_wcwidth(wc);
if (width < 0)
width = iswcntrl(wc) ? 0 : 1;
@@ -2967,9 +2972,9 @@ xo_dngettext (xo_handle_t *xop UNUSED, const char *singular,
* call to d[n]gettext() to get the locale-based version. Note that
* both input and output of gettext() this should be UTF-8.
*/
-static int
+static ssize_t
xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
- int start_offset, int cols, int need_enc)
+ ssize_t start_offset, ssize_t cols, int need_enc)
{
xo_buffer_t *xbp = &xop->xo_data;
@@ -2979,7 +2984,7 @@ xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
xbp->xb_curp[0] = '\0'; /* NUL-terminate the input string */
char *cp = xbp->xb_bufp + start_offset;
- int len = xbp->xb_curp - cp;
+ ssize_t len = xbp->xb_curp - cp;
const char *newstr = NULL;
/*
@@ -3043,7 +3048,7 @@ xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
* Since the new string string might be in gettext's buffer or
* in the buffer (as the plural form), we make a copy.
*/
- int nlen = strlen(newstr);
+ ssize_t nlen = strlen(newstr);
char *newcopy = alloca(nlen + 1);
memcpy(newcopy, newstr, nlen + 1);
@@ -3053,12 +3058,12 @@ xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
}
static void
-xo_data_append_content (xo_handle_t *xop, const char *str, int len,
+xo_data_append_content (xo_handle_t *xop, const char *str, ssize_t len,
xo_xff_flags_t flags)
{
int cols;
int need_enc = xo_needed_encoding(xop);
- int start_offset = xo_buf_offset(&xop->xo_data);
+ ssize_t start_offset = xo_buf_offset(&xop->xo_data);
cols = xo_format_string_direct(xop, &xop->xo_data, XFF_UNESCAPE | flags,
NULL, str, len, -1,
@@ -3080,11 +3085,11 @@ xo_bump_width (xo_format_t *xfp, int digit)
*ip = ((*ip > 0) ? *ip : 0) * 10 + digit;
}
-static int
-xo_trim_ws (xo_buffer_t *xbp, int len)
+static ssize_t
+xo_trim_ws (xo_buffer_t *xbp, ssize_t len)
{
char *cp, *sp, *ep;
- int delta;
+ ssize_t delta;
/* First trim leading space */
for (cp = sp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
@@ -3118,18 +3123,18 @@ xo_trim_ws (xo_buffer_t *xbp, int len)
* and the format is in 'fmt'. If 'xbp' is null, we use xop->xo_data;
* this is the most common case.
*/
-static int
+static ssize_t
xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *fmt, int flen, xo_xff_flags_t flags)
+ const char *fmt, ssize_t flen, xo_xff_flags_t flags)
{
xo_format_t xf;
const char *cp, *ep, *sp, *xp = NULL;
- int rc, cols;
+ ssize_t rc, cols;
int style = (flags & XFF_XML) ? XO_STYLE_XML : xo_style(xop);
- unsigned make_output = !(flags & XFF_NO_OUTPUT);
+ unsigned make_output = !(flags & XFF_NO_OUTPUT) ? 1 : 0;
int need_enc = xo_needed_encoding(xop);
int real_need_enc = need_enc;
- int old_cols = xop->xo_columns;
+ ssize_t old_cols = xop->xo_columns;
/* The gettext interface is UTF-8, so we'll need that for now */
if (flags & XFF_GT_FIELD)
@@ -3138,7 +3143,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
if (xbp == NULL)
xbp = &xop->xo_data;
- unsigned start_offset = xo_buf_offset(xbp);
+ ssize_t start_offset = xo_buf_offset(xbp);
for (cp = fmt, ep = fmt + flen; cp < ep; cp++) {
/*
@@ -3290,7 +3295,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
if (!xf.xf_skip) {
xo_buffer_t *fbp = &xop->xo_fmt;
- int len = cp - sp + 1;
+ ssize_t len = cp - sp + 1;
if (!xo_buf_has_room(fbp, len + 1))
return -1;
@@ -3318,7 +3323,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
rc = xo_trim_ws(xbp, rc);
} else {
- int columns = rc = xo_vsnprintf(xop, xbp, newfmt, xop->xo_vap);
+ ssize_t columns = rc = xo_vsnprintf(xop, xbp, newfmt, xop->xo_vap);
/*
* For XML and HTML, we need "&<>" processing; for JSON,
@@ -3459,7 +3464,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
* and then copying it in, while converting to locale, if
* needed.
*/
- int new_cols = xo_format_gettext(xop, flags, start_offset,
+ ssize_t new_cols = xo_format_gettext(xop, flags, start_offset,
old_cols, real_need_enc);
if (XOF_ISSET(xop, XOF_COLUMNS))
@@ -3512,8 +3517,8 @@ xo_color_append_html (xo_handle_t *xop)
* test. But the boat only goes where we want when we hold
* the rudder, so xo_humanize fixes part of the problem.
*/
-static int
-xo_humanize (char *buf, int len, uint64_t value, int flags)
+static ssize_t
+xo_humanize (char *buf, ssize_t len, uint64_t value, int flags)
{
int scale = 0;
@@ -3539,9 +3544,9 @@ xo_humanize (char *buf, int len, uint64_t value, int flags)
* what needs cleaned up.
*/
typedef struct xo_humanize_save_s {
- unsigned xhs_offset; /* Saved xo_offset */
- unsigned xhs_columns; /* Saved xo_columns */
- unsigned xhs_anchor_columns; /* Saved xo_anchor_columns */
+ ssize_t xhs_offset; /* Saved xo_offset */
+ ssize_t xhs_columns; /* Saved xo_columns */
+ ssize_t xhs_anchor_columns; /* Saved xo_anchor_columns */
} xo_humanize_save_t;
/*
@@ -3556,7 +3561,7 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
if (XOF_ISSET(xop, XOF_NO_HUMANIZE))
return;
- unsigned end_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t end_offset = xbp->xb_curp - xbp->xb_bufp;
if (end_offset == savep->xhs_offset) /* Huh? Nothing to render */
return;
@@ -3581,8 +3586,8 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
if (xo_buf_has_room(xbp, 10)) {
xbp->xb_curp = xbp->xb_bufp + savep->xhs_offset;
- int rc;
- int left = (xbp->xb_bufp + xbp->xb_size) - xbp->xb_curp;
+ ssize_t rc;
+ ssize_t left = (xbp->xb_bufp + xbp->xb_size) - xbp->xb_curp;
int hn_flags = HN_NOSPACE; /* On by default */
if (flags & XFF_HN_SPACE)
@@ -3594,8 +3599,7 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
if (flags & XFF_HN_1000)
hn_flags |= HN_DIVISOR_1000;
- rc = xo_humanize(xbp->xb_curp,
- left, value, hn_flags);
+ rc = xo_humanize(xbp->xb_curp, left, value, hn_flags);
if (rc > 0) {
xbp->xb_curp += rc;
xop->xo_columns = savep->xhs_columns + rc;
@@ -3607,9 +3611,9 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
static void
xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
- const char *name, int nlen,
- const char *value, int vlen,
- const char *encoding, int elen)
+ const char *name, ssize_t nlen,
+ const char *value, ssize_t vlen,
+ const char *encoding, ssize_t elen)
{
static char div_start[] = "<div class=\"";
static char div_tag[] = "\" data-tag=\"";
@@ -3636,7 +3640,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
*/
int need_predidate =
(name && (flags & XFF_KEY) && !(flags & XFF_DISPLAY_ONLY)
- && XOF_ISSET(xop, XOF_XPATH));
+ && XOF_ISSET(xop, XOF_XPATH)) ? 1 : 0;
if (need_predidate) {
va_list va_local;
@@ -3667,8 +3671,8 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
/* Now we record this predicate expression in the stack */
xo_stack_t *xsp = &xop->xo_stack[xop->xo_depth];
- int olen = xsp->xs_keys ? strlen(xsp->xs_keys) : 0;
- int dlen = pbp->xb_curp - pbp->xb_bufp;
+ ssize_t olen = xsp->xs_keys ? strlen(xsp->xs_keys) : 0;
+ ssize_t dlen = pbp->xb_curp - pbp->xb_bufp;
char *cp = xo_realloc(xsp->xs_keys, olen + dlen + 1);
if (cp) {
@@ -3790,7 +3794,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
}
xo_buffer_t *xbp = &xop->xo_data;
- unsigned base_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t base_offset = xbp->xb_curp - xbp->xb_bufp;
xo_data_append(xop, div_end, sizeof(div_end) - 1);
@@ -3808,10 +3812,10 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
* stuff it into the "data-number" attribute.
*/
static const char div_number[] = "\" data-number=\"";
- int div_len = sizeof(div_number) - 1;
+ ssize_t div_len = sizeof(div_number) - 1;
- unsigned end_offset = xbp->xb_curp - xbp->xb_bufp;
- int olen = end_offset - save.xhs_offset;
+ ssize_t end_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t olen = end_offset - save.xhs_offset;
char *cp = alloca(olen + 1);
memcpy(cp, xbp->xb_bufp + save.xhs_offset, olen);
@@ -3820,7 +3824,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
xo_format_humanize(xop, xbp, &save, flags);
if (xo_buf_has_room(xbp, div_len + olen)) {
- unsigned new_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t new_offset = xbp->xb_curp - xbp->xb_bufp;
/* Move the humanized string off to the left */
@@ -3843,7 +3847,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
}
static void
-xo_format_text (xo_handle_t *xop, const char *str, int len)
+xo_format_text (xo_handle_t *xop, const char *str, ssize_t len)
{
switch (xo_style(xop)) {
case XO_STYLE_TEXT:
@@ -3858,10 +3862,10 @@ xo_format_text (xo_handle_t *xop, const char *str, int len)
static void
xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
xo_xff_flags_t flags = xfip->xfi_flags;
static char div_open[] = "<div class=\"title";
@@ -3888,9 +3892,9 @@ xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip,
}
xo_buffer_t *xbp = &xop->xo_data;
- int start = xbp->xb_curp - xbp->xb_bufp;
- int left = xbp->xb_size - start;
- int rc;
+ ssize_t start = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t left = xbp->xb_size - start;
+ ssize_t rc;
if (xo_style(xop) == XO_STYLE_HTML) {
xo_line_ensure_open(xop, 0);
@@ -3993,9 +3997,9 @@ xo_arg (xo_handle_t *xop)
#endif /* 0 */
static void
-xo_format_value (xo_handle_t *xop, const char *name, int nlen,
- const char *format, int flen,
- const char *encoding, int elen, xo_xff_flags_t flags)
+xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen,
+ const char *format, ssize_t flen,
+ const char *encoding, ssize_t elen, xo_xff_flags_t flags)
{
int pretty = XOF_ISSET(xop, XOF_PRETTY);
int quote;
@@ -4016,7 +4020,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
memcpy(nbuf, name, nlen);
nbuf[nlen] = '\0';
- int rc = xo_transition(xop, 0, nbuf, XSS_EMIT_LEAF_LIST);
+ ssize_t rc = xo_transition(xop, 0, nbuf, XSS_EMIT_LEAF_LIST);
if (rc < 0)
flags |= XFF_DISPLAY_ONLY | XFF_ENCODE_ONLY;
else
@@ -4040,7 +4044,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
memcpy(nbuf, name, nlen);
nbuf[nlen] = '\0';
- int rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
+ ssize_t rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
if (rc < 0)
flags |= XFF_DISPLAY_ONLY | XFF_ENCODE_ONLY;
else
@@ -4058,7 +4062,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
memcpy(nbuf, name, nlen);
nbuf[nlen] = '\0';
- int rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
+ ssize_t rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
if (rc < 0)
flags |= XFF_DISPLAY_ONLY | XFF_ENCODE_ONLY;
else
@@ -4181,7 +4185,8 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
flen = strlen(format);
}
- int first = !(xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST);
+ int first = (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
+ ? 0 : 1;
xo_format_prep(xop, flags);
@@ -4193,7 +4198,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
quote = 0;
format = "true"; /* JSON encodes empty tags as a boolean true */
flen = 4;
- } else if (strchr("diouxXDOUeEfFgGaAcCp", format[flen - 1]) == NULL)
+ } else if (strchr("diouDOUeEfFgG", format[flen - 1]) == NULL)
quote = 1;
else
quote = 0;
@@ -4216,13 +4221,13 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
xo_data_append(xop, "\"", 1);
xbp = &xop->xo_data;
- int off = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t off = xbp->xb_curp - xbp->xb_bufp;
xo_data_escape(xop, name, nlen);
if (XOF_ISSET(xop, XOF_UNDERSCORES)) {
- int now = xbp->xb_curp - xbp->xb_bufp;
- for ( ; off < now; off++)
+ ssize_t coff = xbp->xb_curp - xbp->xb_bufp;
+ for ( ; off < coff; off++)
if (xbp->xb_bufp[off] == '-')
xbp->xb_bufp[off] = '_';
}
@@ -4309,11 +4314,11 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
nlen = sizeof(missing) - 1;
}
- unsigned name_offset = xo_buf_offset(&xop->xo_data);
+ ssize_t name_offset = xo_buf_offset(&xop->xo_data);
xo_data_append(xop, name, nlen);
xo_data_append(xop, "", 1);
- unsigned value_offset = xo_buf_offset(&xop->xo_data);
+ ssize_t value_offset = xo_buf_offset(&xop->xo_data);
xo_do_format_field(xop, NULL, format, flen, flags);
xo_data_append(xop, "", 1);
@@ -4327,10 +4332,10 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
static void
xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
/* Start by discarding previous domain */
if (xop->xo_gt_domain) {
@@ -4342,13 +4347,13 @@ xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
if (len == 0 && flen == 0)
return;
- int start_offset = -1;
+ ssize_t start_offset = -1;
if (len == 0 && flen != 0) {
/* Need to do format the data to get the domainname from args */
start_offset = xop->xo_data.xb_curp - xop->xo_data.xb_bufp;
xo_do_format_field(xop, NULL, fmt, flen, 0);
- int end_offset = xop->xo_data.xb_curp - xop->xo_data.xb_bufp;
+ ssize_t end_offset = xop->xo_data.xb_curp - xop->xo_data.xb_bufp;
len = end_offset - start_offset;
str = xop->xo_data.xb_bufp + start_offset;
}
@@ -4363,7 +4368,7 @@ xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
static void
xo_format_content (xo_handle_t *xop, const char *class_name,
const char *tag_name,
- const char *str, int len, const char *fmt, int flen,
+ const char *str, ssize_t len, const char *fmt, ssize_t flen,
xo_xff_flags_t flags)
{
switch (xo_style(xop)) {
@@ -4500,7 +4505,7 @@ xo_colors_parse (xo_handle_t *xop, xo_colors_t *xocp, char *str)
#endif /* LIBXO_TEXT_ONLY */
char *cp, *ep, *np, *xp;
- int len = strlen(str);
+ ssize_t len = strlen(str);
int rc;
/*
@@ -4703,10 +4708,10 @@ xo_colors_handle_html (xo_handle_t *xop, xo_colors_t *newp)
static void
xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
xo_buffer_t xb;
@@ -4776,10 +4781,10 @@ xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip,
static void
xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
xo_xff_flags_t flags = xfip->xfi_flags;
static char units_start_xml[] = " units=\"";
@@ -4791,8 +4796,8 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
}
xo_buffer_t *xbp = &xop->xo_data;
- int start = xop->xo_units_offset;
- int stop = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t start = xop->xo_units_offset;
+ ssize_t stop = xbp->xb_curp - xbp->xb_bufp;
if (xo_style(xop) == XO_STYLE_XML)
xo_buf_append(xbp, units_start_xml, sizeof(units_start_xml) - 1);
@@ -4808,8 +4813,8 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
xo_buf_append(xbp, "\"", 1);
- int now = xbp->xb_curp - xbp->xb_bufp;
- int delta = now - stop;
+ ssize_t now = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t delta = now - stop;
if (delta <= 0) { /* Strange; no output to move */
xbp->xb_curp = xbp->xb_bufp + stop; /* Reset buffer to prior state */
return;
@@ -4828,12 +4833,12 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
memmove(xbp->xb_bufp + start, buf, delta);
}
-static int
+static ssize_t
xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
long width = 0;
char *bp;
@@ -4879,7 +4884,7 @@ xo_anchor_clear (xo_handle_t *xop)
*/
static void
xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -4901,7 +4906,7 @@ xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
static void
xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -4913,7 +4918,7 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
XOIF_CLEAR(xop, XOIF_UNITS_PENDING);
- int width = xo_find_width(xop, xfip, str, len);
+ ssize_t width = xo_find_width(xop, xfip, str, len);
if (width == 0)
width = xop->xo_anchor_min_width;
@@ -4921,10 +4926,10 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
goto done;
xo_buffer_t *xbp = &xop->xo_data;
- int start = xop->xo_anchor_offset;
- int stop = xbp->xb_curp - xbp->xb_bufp;
- int abswidth = (width > 0) ? width : -width;
- int blen = abswidth - xop->xo_anchor_columns;
+ ssize_t start = xop->xo_anchor_offset;
+ ssize_t stop = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t abswidth = (width > 0) ? width : -width;
+ ssize_t blen = abswidth - xop->xo_anchor_columns;
if (blen <= 0) /* Already over width */
goto done;
@@ -4943,8 +4948,8 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
if (width < 0) /* Already left justified */
goto done;
- int now = xbp->xb_curp - xbp->xb_bufp;
- int delta = now - stop;
+ ssize_t now = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t delta = now - stop;
if (delta <= 0) /* Strange; no output to move */
goto done;
@@ -5148,7 +5153,7 @@ xo_parse_roles (xo_handle_t *xop, const char *fmt,
if (*np == ':' || *np == '/' || *np == '}' || *np == ',')
break;
- int slen = np - sp;
+ ssize_t slen = np - sp;
if (slen > 0) {
xo_xff_flags_t value;
@@ -5440,7 +5445,7 @@ xo_parse_fields (xo_handle_t *xop, xo_field_info_t *fields,
xfip->xfi_start = basep = cp + 1;
const char *format = NULL;
- int flen = 0;
+ ssize_t flen = 0;
/* Looking at roles and modifiers */
sp = xo_parse_roles(xop, fmt, basep, xfip);
@@ -5623,9 +5628,9 @@ xo_dump_fields (xo_field_info_t *fields)
(unsigned long) xfip->xfi_flags,
isprint((int) xfip->xfi_ftype) ? xfip->xfi_ftype : ' ',
xfip->xfi_ftype,
- xfip->xfi_clen, xfip->xfi_content ?: "",
- xfip->xfi_flen, xfip->xfi_format ?: "",
- xfip->xfi_elen, xfip->xfi_encoding ?: "");
+ (int) xfip->xfi_clen, xfip->xfi_content ?: "",
+ (int) xfip->xfi_flen, xfip->xfi_format ?: "",
+ (int) xfip->xfi_elen, xfip->xfi_encoding ?: "");
}
}
@@ -5850,13 +5855,13 @@ xo_gettext_build_format (xo_handle_t *xop,
static void
xo_gettext_rebuild_content (xo_handle_t *xop, xo_field_info_t *fields,
- unsigned *fstart, unsigned min_fstart,
- unsigned *fend, unsigned max_fend)
+ ssize_t *fstart, unsigned min_fstart,
+ ssize_t *fend, unsigned max_fend)
{
xo_field_info_t *xfip;
char *buf;
- unsigned base = fstart[min_fstart];
- unsigned blen = fend[max_fend] - base;
+ ssize_t base = fstart[min_fstart];
+ ssize_t blen = fend[max_fend] - base;
xo_buffer_t *xbp = &xop->xo_data;
if (blen == 0)
@@ -5868,7 +5873,8 @@ xo_gettext_rebuild_content (xo_handle_t *xop, xo_field_info_t *fields,
memcpy(buf, xbp->xb_bufp + fstart[min_fstart], blen); /* Copy our data */
- unsigned field = min_fstart, soff, doff = base, len, fnum;
+ unsigned field = min_fstart, len, fnum;
+ ssize_t soff, doff = base;
xo_field_info_t *zp;
/*
@@ -5923,8 +5929,8 @@ xo_gettext_combine_formats (xo_handle_t *xop UNUSED, const char *fmt UNUSED,
static void
xo_gettext_rebuild_content (xo_handle_t *xop UNUSED,
xo_field_info_t *fields UNUSED,
- unsigned *fstart UNUSED, unsigned min_fstart UNUSED,
- unsigned *fend UNUSED, unsigned max_fend UNUSED)
+ ssize_t *fstart UNUSED, unsigned min_fstart UNUSED,
+ ssize_t *fend UNUSED, unsigned max_fend UNUSED)
{
return;
}
@@ -5933,7 +5939,7 @@ xo_gettext_rebuild_content (xo_handle_t *xop UNUSED,
/*
* Emit a set of fields. This is really the core of libxo.
*/
-static int
+static ssize_t
xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
unsigned max_fields, const char *fmt)
{
@@ -5945,7 +5951,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
xo_field_info_t *new_fields = NULL;
xo_field_info_t *xfip;
unsigned field;
- int rc = 0;
+ ssize_t rc = 0;
int flush = XOF_ISSET(xop, XOF_FLUSH);
int flush_line = XOF_ISSET(xop, XOF_FLUSH_LINE);
@@ -5964,9 +5970,9 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
unsigned flimit = max_fields * 2; /* Pessimistic limit */
unsigned min_fstart = flimit - 1;
unsigned max_fend = 0; /* Highest recorded fend[] entry */
- unsigned fstart[flimit];
+ ssize_t fstart[flimit];
bzero(fstart, flimit * sizeof(fstart[0]));
- unsigned fend[flimit];
+ ssize_t fend[flimit];
bzero(fend, flimit * sizeof(fend[0]));
for (xfip = fields, field = 0; xfip->xfi_ftype && field < max_fields;
@@ -5982,7 +5988,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
}
const char *content = xfip->xfi_content;
- int clen = xfip->xfi_clen;
+ ssize_t clen = xfip->xfi_clen;
if (flags & XFF_ARGUMENT) {
/*
@@ -6060,7 +6066,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
new_max_fields = max_fields;
/* Leave a blank slot at the beginning */
- int sz = (new_max_fields + 1) * sizeof(xo_field_info_t);
+ ssize_t sz = (new_max_fields + 1) * sizeof(xo_field_info_t);
new_fields = alloca(sz);
bzero(new_fields, sz);
@@ -6155,7 +6161,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
xop->xo_gt_domain = NULL;
}
- return (rc < 0) ? rc : (int) xop->xo_columns;
+ return (rc < 0) ? rc : xop->xo_columns;
}
/*
@@ -6238,10 +6244,10 @@ xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
return xb.xb_bufp;
}
-int
+xo_ssize_t
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_copy(xop->xo_vap, vap);
@@ -6252,10 +6258,10 @@ xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap)
return rc;
}
-int
+xo_ssize_t
xo_emit_h (xo_handle_t *xop, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_start(xop->xo_vap, fmt);
@@ -6266,11 +6272,11 @@ xo_emit_h (xo_handle_t *xop, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_emit (const char *fmt, ...)
{
xo_handle_t *xop = xo_default(NULL);
- int rc;
+ ssize_t rc;
va_start(xop->xo_vap, fmt);
rc = xo_do_emit(xop, 0, fmt);
@@ -6280,11 +6286,11 @@ xo_emit (const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
const char *fmt, va_list vap)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_copy(xop->xo_vap, vap);
@@ -6295,10 +6301,10 @@ xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
return rc;
}
-int
+xo_ssize_t
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_start(xop->xo_vap, fmt);
@@ -6309,11 +6315,11 @@ xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...)
{
xo_handle_t *xop = xo_default(NULL);
- int rc;
+ ssize_t rc;
va_start(xop->xo_vap, fmt);
rc = xo_do_emit(xop, flags, fmt);
@@ -6329,12 +6335,12 @@ xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...)
* a convenience function to avoid callers using snprintf to build field
* descriptions.
*/
-int
+xo_ssize_t
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt,
va_list vap)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
@@ -6365,8 +6371,6 @@ xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
xfi.xfi_flen = 2;
}
-
-
va_copy(xop->xo_vap, vap);
rc = xo_do_emit_fields(xop, &xfi, 1, fmt ?: contents ?: "field");
@@ -6376,11 +6380,11 @@ xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
return rc;
}
-int
+xo_ssize_t
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, efmt);
@@ -6390,11 +6394,11 @@ xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
return rc;
}
-int
+xo_ssize_t
xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, efmt);
@@ -6404,16 +6408,16 @@ xo_emit_field (const char *rolmod, const char *contents,
return rc;
}
-int
+xo_ssize_t
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap)
{
- const int extra = 5; /* space, equals, quote, quote, and nul */
+ const ssize_t extra = 5; /* space, equals, quote, quote, and nul */
xop = xo_default(xop);
- int rc = 0;
- int nlen = strlen(name);
+ ssize_t rc = 0;
+ ssize_t nlen = strlen(name);
xo_buffer_t *xbp = &xop->xo_attrs;
- unsigned name_offset, value_offset;
+ ssize_t name_offset, value_offset;
switch (xo_style(xop)) {
case XO_STYLE_XML:
@@ -6461,10 +6465,10 @@ xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap)
return rc;
}
-int
+xo_ssize_t
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, fmt);
@@ -6474,10 +6478,10 @@ xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_attr (const char *name, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, fmt);
@@ -6576,7 +6580,7 @@ xo_set_depth (xo_handle_t *xop, int depth)
}
static xo_xsf_flags_t
-xo_stack_flags (unsigned xflags)
+xo_stack_flags (xo_xof_flags_t xflags)
{
if (xflags & XOF_DTRT)
return XSF_DTRT;
@@ -6597,10 +6601,10 @@ xo_emit_top (xo_handle_t *xop, const char *ppn)
}
}
-static int
+static ssize_t
xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -6660,25 +6664,25 @@ xo_open_container_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
return xo_transition(xop, flags, name, XSS_OPEN_CONTAINER);
}
-int
+xo_ssize_t
xo_open_container_h (xo_handle_t *xop, const char *name)
{
return xo_open_container_hf(xop, 0, name);
}
-int
+xo_ssize_t
xo_open_container (const char *name)
{
return xo_open_container_hf(NULL, 0, name);
}
-int
+xo_ssize_t
xo_open_container_hd (xo_handle_t *xop, const char *name)
{
return xo_open_container_hf(xop, XOF_DTRT, name);
}
-int
+xo_ssize_t
xo_open_container_d (const char *name)
{
return xo_open_container_hf(NULL, XOF_DTRT, name);
@@ -6689,7 +6693,7 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -6698,7 +6702,7 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -6741,25 +6745,25 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
return rc;
}
-int
+xo_ssize_t
xo_close_container_h (xo_handle_t *xop, const char *name)
{
return xo_transition(xop, 0, name, XSS_CLOSE_CONTAINER);
}
-int
+xo_ssize_t
xo_close_container (const char *name)
{
return xo_close_container_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_container_hd (xo_handle_t *xop)
{
return xo_close_container_h(xop, NULL);
}
-int
+xo_ssize_t
xo_close_container_d (void)
{
return xo_close_container_h(NULL, NULL);
@@ -6768,7 +6772,7 @@ xo_close_container_d (void)
static int
xo_do_open_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
int indent = 0;
xop = xo_default(xop);
@@ -6816,25 +6820,25 @@ xo_open_list_hf (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
return xo_transition(xop, flags, name, XSS_OPEN_LIST);
}
-int
+xo_ssize_t
xo_open_list_h (xo_handle_t *xop, const char *name)
{
return xo_open_list_hf(xop, 0, name);
}
-int
+xo_ssize_t
xo_open_list (const char *name)
{
return xo_open_list_hf(NULL, 0, name);
}
-int
+xo_ssize_t
xo_open_list_hd (xo_handle_t *xop, const char *name)
{
return xo_open_list_hf(xop, XOF_DTRT, name);
}
-int
+xo_ssize_t
xo_open_list_d (const char *name)
{
return xo_open_list_hf(NULL, XOF_DTRT, name);
@@ -6843,7 +6847,7 @@ xo_open_list_d (const char *name)
static int
xo_do_close_list (xo_handle_t *xop, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
const char *pre_nl = "";
if (name == NULL) {
@@ -6851,7 +6855,7 @@ xo_do_close_list (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -6887,25 +6891,25 @@ xo_do_close_list (xo_handle_t *xop, const char *name)
return rc;
}
-int
+xo_ssize_t
xo_close_list_h (xo_handle_t *xop, const char *name)
{
return xo_transition(xop, 0, name, XSS_CLOSE_LIST);
}
-int
+xo_ssize_t
xo_close_list (const char *name)
{
return xo_close_list_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_list_hd (xo_handle_t *xop)
{
return xo_close_list_h(xop, NULL);
}
-int
+xo_ssize_t
xo_close_list_d (void)
{
return xo_close_list_h(NULL, NULL);
@@ -6914,7 +6918,7 @@ xo_close_list_d (void)
static int
xo_do_open_leaf_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
int indent = 0;
xop = xo_default(xop);
@@ -6962,7 +6966,7 @@ xo_do_open_leaf_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
static int
xo_do_close_leaf_list (xo_handle_t *xop, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
const char *pre_nl = "";
if (name == NULL) {
@@ -6970,7 +6974,7 @@ xo_do_close_leaf_list (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -7010,7 +7014,7 @@ xo_do_open_instance (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
{
xop = xo_default(xop);
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -7065,25 +7069,25 @@ xo_open_instance_hf (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
return xo_transition(xop, flags, name, XSS_OPEN_INSTANCE);
}
-int
+xo_ssize_t
xo_open_instance_h (xo_handle_t *xop, const char *name)
{
return xo_open_instance_hf(xop, 0, name);
}
-int
+xo_ssize_t
xo_open_instance (const char *name)
{
return xo_open_instance_hf(NULL, 0, name);
}
-int
+xo_ssize_t
xo_open_instance_hd (xo_handle_t *xop, const char *name)
{
return xo_open_instance_hf(xop, XOF_DTRT, name);
}
-int
+xo_ssize_t
xo_open_instance_d (const char *name)
{
return xo_open_instance_hf(NULL, XOF_DTRT, name);
@@ -7094,7 +7098,7 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -7103,7 +7107,7 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -7145,25 +7149,25 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
return rc;
}
-int
+xo_ssize_t
xo_close_instance_h (xo_handle_t *xop, const char *name)
{
return xo_transition(xop, 0, name, XSS_CLOSE_INSTANCE);
}
-int
+xo_ssize_t
xo_close_instance (const char *name)
{
return xo_close_instance_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_instance_hd (xo_handle_t *xop)
{
return xo_close_instance_h(xop, NULL);
}
-int
+xo_ssize_t
xo_close_instance_d (void)
{
return xo_close_instance_h(NULL, NULL);
@@ -7173,7 +7177,7 @@ static int
xo_do_close_all (xo_handle_t *xop, xo_stack_t *limit)
{
xo_stack_t *xsp;
- int rc = 0;
+ ssize_t rc = 0;
xo_xsf_flags_t flags;
for (xsp = &xop->xo_stack[xop->xo_depth]; xsp >= limit; xsp--) {
@@ -7222,7 +7226,7 @@ static int
xo_do_close (xo_handle_t *xop, const char *name, xo_state_t new_state)
{
xo_stack_t *xsp, *limit = NULL;
- int rc;
+ ssize_t rc;
xo_state_t need_state = new_state;
if (new_state == XSS_CLOSE_CONTAINER)
@@ -7282,17 +7286,16 @@ xo_do_close (xo_handle_t *xop, const char *name, xo_state_t new_state)
/*
* We are in a given state and need to transition to the new state.
*/
-static int
+static ssize_t
xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
xo_state_t new_state)
{
xo_stack_t *xsp;
- int rc;
+ ssize_t rc = 0;
int old_state, on_marker;
xop = xo_default(xop);
- rc = 0;
xsp = &xop->xo_stack[xop->xo_depth];
old_state = xsp->xs_state;
on_marker = (old_state == XSS_MARKER);
@@ -7552,7 +7555,7 @@ xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
return -1;
}
-int
+xo_ssize_t
xo_open_marker_h (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
@@ -7563,13 +7566,13 @@ xo_open_marker_h (xo_handle_t *xop, const char *name)
return 0;
}
-int
+xo_ssize_t
xo_open_marker (const char *name)
{
return xo_open_marker_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_marker_h (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
@@ -7577,7 +7580,7 @@ xo_close_marker_h (xo_handle_t *xop, const char *name)
return xo_do_close(xop, name, XSS_MARKER);
}
-int
+xo_ssize_t
xo_close_marker (const char *name)
{
return xo_close_marker_h(NULL, name);
@@ -7606,10 +7609,10 @@ xo_set_allocator (xo_realloc_func_t realloc_func, xo_free_func_t free_func)
xo_free = free_func;
}
-int
+xo_ssize_t
xo_flush_h (xo_handle_t *xop)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
@@ -7626,13 +7629,13 @@ xo_flush_h (xo_handle_t *xop)
return rc;
}
-int
+xo_ssize_t
xo_flush (void)
{
return xo_flush_h(NULL);
}
-int
+xo_ssize_t
xo_finish_h (xo_handle_t *xop)
{
const char *cp = "";
@@ -7660,7 +7663,7 @@ xo_finish_h (xo_handle_t *xop)
return xo_flush_h(xop);
}
-int
+xo_ssize_t
xo_finish (void)
{
return xo_finish_h(NULL);
@@ -7688,7 +7691,7 @@ xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap)
* If the format string doesn't end with a newline, we pop
* one on ourselves.
*/
- int len = strlen(fmt);
+ ssize_t len = strlen(fmt);
if (len > 0 && fmt[len - 1] != '\n') {
char *newfmt = alloca(len + 2);
memcpy(newfmt, fmt, len);
@@ -7867,7 +7870,7 @@ xo_set_version_h (xo_handle_t *xop, const char *version)
switch (xo_style(xop)) {
case XO_STYLE_XML:
/* For XML, we record this as an attribute for the first tag */
- xo_attr_h(xop, "__version", "%s", version);
+ xo_attr_h(xop, "version", "%s", version);
break;
case XO_STYLE_JSON:
@@ -7937,7 +7940,7 @@ xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code,
(void) xo_emit_hv(xop, fmt, vap);
- int len = strlen(fmt);
+ ssize_t len = strlen(fmt);
if (len > 0 && fmt[len - 1] != '\n') {
if (code > 0) {
const char *msg = strerror(code);
diff --git a/libxo/xo.h b/libxo/xo.h
index 310b21cae366..13023d3839b5 100644
--- a/libxo/xo.h
+++ b/libxo/xo.h
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <stdarg.h>
+#include <limits.h>
#include <stdlib.h>
#include <errno.h>
@@ -39,7 +40,10 @@
* coward's path, we'll turn it on inside a #if that allows
* others to turn it off where needed. Not ideal, but functional.
*/
-#if !defined(NO_PRINTFLIKE) && !defined(__linux__)
+#if !defined(NO_PRINTFLIKE)
+#if defined(__linux) && !defined(__printflike)
+#define __printflike(_x, _y) __attribute__((__format__ (__printf__, _x, _y)))
+#endif
#define PRINTFLIKE(_x, _y) __printflike(_x, _y)
#else
#define PRINTFLIKE(_x, _y)
@@ -115,7 +119,18 @@ typedef struct xo_info_s {
struct xo_handle_s; /* Opaque structure forward */
typedef struct xo_handle_s xo_handle_t; /* Handle for XO output */
-typedef int (*xo_write_func_t)(void *, const char *);
+/*
+ * Early versions of the API used "int" instead of "size_t" for buffer
+ * sizes. We want to fix this but allow for backwards compatibility
+ * where needed.
+ */
+#ifdef USE_INT_RETURN_CODES
+typedef int xo_ssize_t; /* Buffer size */
+#else /* USE_INT_RETURN_CODES */
+typedef ssize_t xo_ssize_t; /* Buffer size */
+#endif /* USE_INT_RETURN_CODES */
+
+typedef xo_ssize_t (*xo_write_func_t)(void *, const char *);
typedef void (*xo_close_func_t)(void *);
typedef int (*xo_flush_func_t)(void *);
typedef void *(*xo_realloc_func_t)(void *, size_t);
@@ -126,7 +141,7 @@ typedef void (*xo_free_func_t)(void *);
* of the xo handle. The caller should return the number of bytes _needed_
* to fit the data, even if this exceeds 'len'.
*/
-typedef int (*xo_formatter_t)(xo_handle_t *, char *, int,
+typedef xo_ssize_t (*xo_formatter_t)(xo_handle_t *, char *, xo_ssize_t,
const char *, va_list);
typedef void (*xo_checkpointer_t)(xo_handle_t *, va_list, int);
@@ -182,23 +197,23 @@ xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, xo_checkpointer_t);
void
xo_set_depth (xo_handle_t *xop, int depth);
-int
+xo_ssize_t
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
-int
+xo_ssize_t
xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
-int
+xo_ssize_t
xo_emit (const char *fmt, ...);
-int
+xo_ssize_t
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
const char *fmt, va_list vap);
-int
+xo_ssize_t
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
-int
+xo_ssize_t
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
PRINTFLIKE(2, 0)
@@ -260,97 +275,97 @@ xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_open_container_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_container (const char *name);
-int
+xo_ssize_t
xo_open_container_hd (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_container_d (const char *name);
-int
+xo_ssize_t
xo_close_container_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_container (const char *name);
-int
+xo_ssize_t
xo_close_container_hd (xo_handle_t *xop);
-int
+xo_ssize_t
xo_close_container_d (void);
-int
+xo_ssize_t
xo_open_list_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_list (const char *name);
-int
+xo_ssize_t
xo_open_list_hd (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_list_d (const char *name);
-int
+xo_ssize_t
xo_close_list_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_list (const char *name);
-int
+xo_ssize_t
xo_close_list_hd (xo_handle_t *xop);
-int
+xo_ssize_t
xo_close_list_d (void);
-int
+xo_ssize_t
xo_open_instance_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_instance (const char *name);
-int
+xo_ssize_t
xo_open_instance_hd (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_instance_d (const char *name);
-int
+xo_ssize_t
xo_close_instance_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_instance (const char *name);
-int
+xo_ssize_t
xo_close_instance_hd (xo_handle_t *xop);
-int
+xo_ssize_t
xo_close_instance_d (void);
-int
+xo_ssize_t
xo_open_marker_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_marker (const char *name);
-int
+xo_ssize_t
xo_close_marker_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_marker (const char *name);
-int
+xo_ssize_t
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...);
-int
+xo_ssize_t
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap);
-int
+xo_ssize_t
xo_attr (const char *name, const char *fmt, ...);
void
@@ -362,16 +377,16 @@ xo_error_h (xo_handle_t *xop, const char *fmt, ...);
void
xo_error (const char *fmt, ...);
-int
+xo_ssize_t
xo_flush_h (xo_handle_t *xop);
-int
+xo_ssize_t
xo_flush (void);
-int
+xo_ssize_t
xo_finish_h (xo_handle_t *xop);
-int
+xo_ssize_t
xo_finish (void);
void
@@ -644,16 +659,16 @@ char *
xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
xo_simplify_field_func_t field_cb);
-int
+xo_ssize_t
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt,
va_list vap);
-int
+xo_ssize_t
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
-int
+xo_ssize_t
xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
diff --git a/libxo/xo_buf.h b/libxo/xo_buf.h
index 01eb397d37c4..3bb5628a6ea0 100644
--- a/libxo/xo_buf.h
+++ b/libxo/xo_buf.h
@@ -28,7 +28,7 @@
typedef struct xo_buffer_s {
char *xb_bufp; /* Buffer memory */
char *xb_curp; /* Current insertion point */
- unsigned xb_size; /* Size of buffer */
+ ssize_t xb_size; /* Size of buffer */
} xo_buffer_t;
/*
@@ -111,10 +111,10 @@ xo_buf_cleanup (xo_buffer_t *xbp)
* return 0 to tell the caller they are in trouble.
*/
static inline int
-xo_buf_has_room (xo_buffer_t *xbp, int len)
+xo_buf_has_room (xo_buffer_t *xbp, ssize_t len)
{
if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
- int sz = xbp->xb_size + XO_BUFSIZ;
+ ssize_t sz = xbp->xb_size + XO_BUFSIZ;
char *bp = xo_realloc(xbp->xb_bufp, sz);
if (bp == NULL)
return 0;
@@ -131,7 +131,7 @@ xo_buf_has_room (xo_buffer_t *xbp, int len)
* Append the given string to the given buffer
*/
static inline void
-xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
+xo_buf_append (xo_buffer_t *xbp, const char *str, ssize_t len)
{
if (!xo_buf_has_room(xbp, len))
return;
@@ -146,7 +146,7 @@ xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
static inline void
xo_buf_append_str (xo_buffer_t *xbp, const char *str)
{
- int len = strlen(str);
+ ssize_t len = strlen(str);
if (!xo_buf_has_room(xbp, len))
return;
diff --git a/libxo/xo_encoder.c b/libxo/xo_encoder.c
index eb2960bf7d9f..ef9403b909aa 100644
--- a/libxo/xo_encoder.c
+++ b/libxo/xo_encoder.c
@@ -139,7 +139,7 @@ xo_encoder_list_add (const char *name)
xo_encoder_node_t *xep = xo_realloc(NULL, sizeof(*xep));
if (xep) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
xep->xe_name = xo_realloc(NULL, len);
if (xep->xe_name == NULL) {
xo_free(xep);
@@ -241,7 +241,7 @@ xo_encoder_discover (const char *name)
bzero(&xei, sizeof(xei));
xei.xei_version = XO_ENCODER_VERSION;
- int rc = func(&xei);
+ ssize_t rc = func(&xei);
if (rc == 0 && xei.xei_handler) {
xep = xo_encoder_list_add(name);
if (xep) {
diff --git a/libxo/xo_format.5 b/libxo/xo_format.5
index abd1b6f65c5f..b1829c8941dc 100644
--- a/libxo/xo_format.5
+++ b/libxo/xo_format.5
@@ -630,7 +630,7 @@ The format string has the form:
\(aq%\(aq format\-modifier * format\-character
.Ed
.Pp
-The format\- modifier can be:
+The format\-modifier can be:
.Bl -bullet
.It
a \(aq#\(aq character, indicating the output value should be prefixed with
diff --git a/libxo/xo_options.7 b/libxo/xo_options.7
new file mode 100644
index 000000000000..5e86668d009f
--- /dev/null
+++ b/libxo/xo_options.7
@@ -0,0 +1,147 @@
+.\" #
+.\" # Copyright (c) 2014-2017, Juniper Networks, Inc.
+.\" # All rights reserved.
+.\" # This SOFTWARE is licensed under the LICENSE provided in the
+.\" # ../Copyright file. By downloading, installing, copying, or
+.\" # using the SOFTWARE, you agree to be bound by the terms of that
+.\" # LICENSE.
+.\" # Phil Shafer, July 2014
+.\"
+.Dd May 11, 2017
+.Dt LIBXO 3
+.Os
+.Sh NAME
+.Nm xo_options
+.Nd common options for libxo\-based commands
+.Sh DESCRIPTION
+.Pp
+.Nm libxo
+allows the rendering of data into
+various output styles, including
+.Em text ,
+.Em XML ,
+.Em JSON ,
+and
+.Em HTML .
+.Nm libxo
+uses command line options to trigger rendering behavior.
+Options are recognised in three forms:
+.Bl -bullet
+.It
+\-\-libxo <options>
+.It
+\-\-libxo=<options>
+.It
+\-\-libxo:<brief\-options>
+.El
+.Pp
+The first two forms accept a comma\-separated set of words, detailed
+below, while the third form accepts a set of letters, also below.
+The triggered functionality is identical.
+.Bl -column "Token2341234"
+.It Sy "Option " "Action"
+.It "color " "Enable colors/effects for display styles (TEXT, HTML)"
+.It "flush " "Flush after each emit call"
+.It "flush\-line " "Flush each line of output"
+.It "html " "Emit HTML output"
+.It "indent=xx " "Set the indentation level"
+.It "info " "Add info attributes (HTML)"
+.It "json " "Emit JSON output"
+.It "keys " "Emit the key attribute for keys (XML)"
+.It "log\-gettext" "Log (via stderr) each gettext(3) string lookup"
+.It "log\-syslog " "Log (via stderr) each syslog message (via xo_syslog)"
+.It "no\-humanize" "Ignore the {h:} modifier (TEXT, HTML)"
+.It "no\-locale " "Do not initialize the locale setting"
+.It "no\-retain " "Prevent retaining formatting information"
+.It "pretty " "Emit pretty\-printed output"
+.It "retain " "Force retaining formatting information"
+.It "text " "Emit TEXT output"
+.It "underscores" "Replace XML\-friendly \"\-\"s with JSON friendly \"_\"s"
+.It "units " "Add the 'units' (XML) or 'data\-units (HTML) attribute"
+.It "warn " "Emit warnings when libxo detects bad calls"
+.It "warn\-xml " "Emit warnings in XML"
+.It "xml " "Emit XML output"
+.It "xpath " "Add XPath expressions (HTML)"
+.El
+.Pp
+The brief options are a set of single\-letter aliases for the longer
+terms, used as a single string:
+.Bl -column "Value" "Equivalent Token"
+.It Sy "Value" "Equivalent Token"
+.It "c
+.It "f " "flush"
+.It "F " "flush\-line"
+.It "H " "html"
+.It "I " "info"
+.It "i<num>" "indent=<num>"
+.It "J " "json"
+.It "k " "keys"
+.It "n " "no\-humanize"
+.It "P " "pretty"
+.It "T " "text"
+.It "U " "units"
+.It "u " "underscore
+.It "W " "warn"
+.It "X " "xml"
+.It "x " "xpath"
+.El
+.Pp
+Most of these option are simple and direct, but some require
+additional details:
+.Pp
+.Fa "flush\-line"
+performs line buffering, even when the output is not directed to
+a TTY device.
+.Pp
+.Fa info
+generates additional data for HTML, encoded in attributes using
+names that state with "data\-".
+.Pp
+.Fa keys
+adds a "key" attribute for XML output to indicate that a leaf is
+an identifier for the list member.
+.Pp
+.Fa no\-humanize
+avoids "humanizing" numeric output (see
+.Xr humanize_number 3
+for details).
+.Pp
+.Fa no\-locale
+instructs
+.Nm libxo
+to avoid translating output to the current locale.
+.Pp
+.Fa no\-retain
+disables the ability of
+.Nm libxo
+to internally retain "compiled" information about formatting strings.
+.Pp
+.Fa underscores
+can be used with
+.Em JSON
+output to change
+.Em XML \-friendly
+names with dashes into
+.Em JSON \-friendly
+name with underscores.
+.Pp
+.Fa warn
+allows
+.Nm libxo
+to emit warnings on stderr when application code make incorrect calls.
+.Fa warn\-xml causes those warnings to be placed in
+.Em XML
+inside the output.
+.Sh EXAMPLES
+The following are three example invocations of
+.Xr ps 1 :
+.Bd -literal
+ ps \-\-libxo json,pretty,warn \-ux
+
+ ps \-\-libxo=xml \-lg
+
+ ps \-\-libxo:Hxc 1
+.Ed
+.Sh SEE ALSO
+.Xr libxo 3 ,
+.Xr xo_format 5
diff --git a/libxo/xo_syslog.c b/libxo/xo_syslog.c
index c7d67f3cfcd3..c1e19e5d77c2 100644
--- a/libxo/xo_syslog.c
+++ b/libxo/xo_syslog.c
@@ -21,7 +21,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -53,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <limits.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/time.h>
@@ -94,11 +95,13 @@
#define XO_DEFAULT_EID 32473 /* Fallback to the "example" number */
#endif
+#ifndef HOST_NAME_MAX
#ifdef _SC_HOST_NAME_MAX
#define HOST_NAME_MAX _SC_HOST_NAME_MAX
#else
#define HOST_NAME_MAX 255
#endif /* _SC_HOST_NAME_MAX */
+#endif /* HOST_NAME_MAX */
#ifndef UNUSED
#define UNUSED __attribute__ ((__unused__))
@@ -425,12 +428,13 @@ xo_set_syslog_handler (xo_syslog_open_t open_func,
xo_syslog_close = close_func;
}
-static size_t
-xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
+static ssize_t
+xo_snprintf (char *out, ssize_t outsize, const char *fmt, ...)
{
- int status;
- size_t retval = 0;
+ ssize_t status;
+ ssize_t retval = 0;
va_list ap;
+
if (out && outsize) {
va_start(ap, fmt);
status = vsnprintf(out, outsize, fmt, ap);
@@ -443,10 +447,11 @@ xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
}
va_end(ap);
}
+
return retval;
}
-static int
+static xo_ssize_t
xo_syslog_handle_write (void *opaque, const char *data)
{
xo_buffer_t *xbp = opaque;
diff --git a/tests/core/saved/test_01.E.out b/tests/core/saved/test_01.E.out
index de23baad0b16..75f5d0a1d3da 100644
--- a/tests/core/saved/test_01.E.out
+++ b/tests/core/saved/test_01.E.out
@@ -1,5 +1,7 @@
op create: [] []
op open_container: [top] []
+op content: [kve_start] [0xdeadbeef]
+op content: [kve_end] [0xcabb1e]
op string: [host] [my-box]
op string: [domain] [example.com]
op string: [host] [my-box]
diff --git a/tests/core/saved/test_01.J.out b/tests/core/saved/test_01.J.out
index 3fc12a173148..1577ce0c0410 100644
--- a/tests/core/saved/test_01.J.out
+++ b/tests/core/saved/test_01.J.out
@@ -1,2 +1,2 @@
-{"top": {"host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
+{"top": {"kve_start":"0xdeadbeef","kve_end":"0xcabb1e","host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
}
diff --git a/tests/core/saved/test_01.JP.out b/tests/core/saved/test_01.JP.out
index 2c7397f5e20a..d24abbc0254f 100644
--- a/tests/core/saved/test_01.JP.out
+++ b/tests/core/saved/test_01.JP.out
@@ -1,5 +1,7 @@
{
"top": {
+ "kve_start": "0xdeadbeef",
+ "kve_end": "0xcabb1e",
"host": "my-box",
"domain": "example.com",
"host": "my-box",
diff --git a/tests/core/saved/test_01.X.out b/tests/core/saved/test_01.X.out
index da80e681b27b..a243ce7c79f1 100644
--- a/tests/core/saved/test_01.X.out
+++ b/tests/core/saved/test_01.X.out
@@ -1 +1 @@
-<top><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top> \ No newline at end of file
+<top><kve_start>0xdeadbeef</kve_start><kve_end>0xcabb1e</kve_end><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top> \ No newline at end of file
diff --git a/tests/core/saved/test_01.XP.out b/tests/core/saved/test_01.XP.out
index c331dceafe62..98dc13b68f29 100644
--- a/tests/core/saved/test_01.XP.out
+++ b/tests/core/saved/test_01.XP.out
@@ -1,4 +1,6 @@
<top>
+ <kve_start>0xdeadbeef</kve_start>
+ <kve_end>0xcabb1e</kve_end>
<host>my-box</host>
<domain>example.com</domain>
<host>my-box</host>
diff --git a/tests/core/saved/test_10.X.out b/tests/core/saved/test_10.X.out
index 49c6dd88c4fd..c9321566d907 100644
--- a/tests/core/saved/test_10.X.out
+++ b/tests/core/saved/test_10.X.out
@@ -1 +1 @@
-<top __version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top> \ No newline at end of file
+<top version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top> \ No newline at end of file
diff --git a/tests/core/saved/test_10.XP.out b/tests/core/saved/test_10.XP.out
index 33c88d96214f..ec1aa93c7512 100644
--- a/tests/core/saved/test_10.XP.out
+++ b/tests/core/saved/test_10.XP.out
@@ -1,4 +1,4 @@
-<top __version="3.1.4">
+<top version="3.1.4">
<data test="value">
<data test2="value2">bold</data>
<data>bold-ul</data>
diff --git a/tests/core/saved/test_11.X.out b/tests/core/saved/test_11.X.out
index bb73a4293c9a..5c279b73b151 100644
--- a/tests/core/saved/test_11.X.out
+++ b/tests/core/saved/test_11.X.out
@@ -14,4 +14,4 @@
{{test-program: }}
{{An application 1011 log entry}}
-<top __version="3.1.4"></top> \ No newline at end of file
+<top version="3.1.4"></top> \ No newline at end of file
diff --git a/tests/core/saved/test_11.XP.out b/tests/core/saved/test_11.XP.out
index 46b5dd079ee5..02765614e9ab 100644
--- a/tests/core/saved/test_11.XP.out
+++ b/tests/core/saved/test_11.XP.out
@@ -14,5 +14,5 @@
{{test-program: }}
{{An application 1011 log entry}}
-<top __version="3.1.4">
+<top version="3.1.4">
</top>
diff --git a/tests/core/test_01.c b/tests/core/test_01.c
index 05d778a0bca4..a3a6a4be3e29 100644
--- a/tests/core/test_01.c
+++ b/tests/core/test_01.c
@@ -9,6 +9,7 @@
*/
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <unistd.h>
@@ -79,6 +80,9 @@ main (int argc, char **argv)
xo_open_container_h(NULL, "top");
+ xo_emit("{e:kve_start/%#jx}", (uintmax_t) 0xdeadbeef);
+ xo_emit("{e:kve_end/%#jx}", (uintmax_t) 0xcabb1e);
+
xo_emit("testing argument modifier {a:}.{a:}...\n",
"host", "my-box", "domain", "example.com");
diff --git a/tests/gettext/po/pig_latin/strerror.po b/tests/gettext/po/pig_latin/strerror.po
index 8b41c0a85db7..9b62dd71245d 100644
--- a/tests/gettext/po/pig_latin/strerror.po
+++ b/tests/gettext/po/pig_latin/strerror.po
@@ -10,7 +10,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
-# 4. Neither the name of the University nor the names of its contributors
+# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
diff --git a/tests/gettext/saved/gt_01.J.out b/tests/gettext/saved/gt_01.J.out
index 86527d149a6d..e6c2dd0e0798 100644
--- a/tests/gettext/saved/gt_01.J.out
+++ b/tests/gettext/saved/gt_01.J.out
@@ -1,2 +1,2 @@
-{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":automaticyay,"type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
+{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":"automaticyay","type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
}
diff --git a/tests/gettext/saved/gt_01.JP.out b/tests/gettext/saved/gt_01.JP.out
index 537ab213cb7c..6fcfcd6189f1 100644
--- a/tests/gettext/saved/gt_01.JP.out
+++ b/tests/gettext/saved/gt_01.JP.out
@@ -42,7 +42,7 @@
"__warning": {
"program": "gt_01.test",
"message": "automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay",
- "style": automaticyay,
+ "style": "automaticyay",
"type": "ardinalyay",
"target": "ammetersgray",
"error": "Ermissionpay eniedday"
diff --git a/tests/gettext/strerror.pot b/tests/gettext/strerror.pot
index c63e6bdb9e87..475162d5413d 100644
--- a/tests/gettext/strerror.pot
+++ b/tests/gettext/strerror.pot
@@ -10,7 +10,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
-# 4. Neither the name of the University nor the names of its contributors
+# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
diff --git a/xo/xo.c b/xo/xo.c
index ce758afb7cab..e48d2f8110c0 100644
--- a/xo/xo.c
+++ b/xo/xo.c
@@ -90,8 +90,8 @@ checkpoint (xo_handle_t *xop UNUSED, va_list vap UNUSED, int restore)
* with our command line arguments to build strings. This involves faking
* some printf-style logic.
*/
-static int
-formatter (xo_handle_t *xop, char *buf, int bufsiz,
+static xo_ssize_t
+formatter (xo_handle_t *xop, char *buf, xo_ssize_t bufsiz,
const char *fmt, va_list vap UNUSED)
{
int lflag UNUSED = 0; /* Parse long flag, though currently ignored */