diff options
author | phil <phil@FreeBSD.org> | 2017-08-07 17:23:44 +0000 |
---|---|---|
committer | phil <phil@FreeBSD.org> | 2017-08-07 17:23:44 +0000 |
commit | 24dec0b179f6eba6d055b33faf478d202bfb11ba (patch) | |
tree | 85d6194bf51077fe9f92a2d137b166076c2030f3 /contrib/libxo | |
parent | f7b18a778494a28eccbb80840c7966374bb9e821 (diff) | |
download | FreeBSD-src-24dec0b179f6eba6d055b33faf478d202bfb11ba.zip FreeBSD-src-24dec0b179f6eba6d055b33faf478d202bfb11ba.tar.gz |
Import libxo-0.8.4 from HEAD into stable/11
Submitted by: phil
Diffstat (limited to 'contrib/libxo')
102 files changed, 4456 insertions, 3104 deletions
diff --git a/contrib/libxo/Makefile.am b/contrib/libxo/Makefile.am index cb71d52..286bef9 100644 --- a/contrib/libxo/Makefile.am +++ b/contrib/libxo/Makefile.am @@ -38,7 +38,14 @@ GH_PAGES_DIR = gh-pages/ GH_PAGES_DIR_VER = gh-pages/${PACKAGE_VERSION} PACKAGE_FILE = ${PACKAGE_TARNAME}-${PACKAGE_VERSION}.tar.gz -upload: dist upload-docs +XOHTML_FILES = \ + ${top_srcdir}/xohtml/xohtml.css \ + ${top_srcdir}/xohtml/xohtml.js \ + ${top_srcdir}/xohtml/external/jquery.js \ + ${top_srcdir}/xohtml/external/jquery.qtip.css \ + ${top_srcdir}/xohtml/external/jquery.qtip.js + +upload: dist upload-docs upload-xohtml-files @echo "Remember to run:" @echo " gt tag ${PACKAGE_VERSION}" @@ -56,6 +63,18 @@ upload-docs: docs libxo-manual.html ${PACKAGE_VERSION} \ && git push origin gh-pages ) ; true +upload-xohtml-files: + @echo "Uploading xohtml files ... " + @-[ -d ${GH_PAGES_DIR} ] \ + && echo "Updating xohtml files on gh-pages ..." \ + && mkdir -p ${GH_PAGES_DIR_VER}/xohtml \ + && cp ${XOHTML_FILES} ${GH_PAGES_DIR_VER}/xohtml \ + && (cd ${GH_PAGES_DIR} \ + && git add ${PACKAGE_VERSION}/xohtml \ + && git commit -m 'new xohtml files' \ + ${PACKAGE_VERSION}/xohtml \ + && git push origin gh-pages ) ; true + pkgconfigdir=$(libdir)/pkgconfig pkgconfig_DATA = packaging/${PACKAGE_NAME}.pc @@ -100,4 +119,25 @@ ANALYZE_DIR = ~/trash/libxo ANALYZE_CMD = scan-build-mp-3.6 analyze: + ${MAKE} clean ${ANALYZE_CMD} -o ${ANALYZE_DIR} ${MAKE} + +SANIFLAGS=-fno-omit-frame-pointer -g -O2 + +sanitize-address: + ${MAKE} clean + ${MAKE} CFLAGS="-fsanitize=address ${SANIFLAGS}" + ${MAKE} install + ${MAKE} test + +sanitize-undefined: + ${MAKE} clean + ${MAKE} CFLAGS="-fsanitize=undefined ${SANIFLAGS}" + ${MAKE} install + ${MAKE} test + +sanitize-memory: + ${MAKE} clean + ${MAKE} CFLAGS="-fsanitize=memory ${SANIFLAGS}" + ${MAKE} install + ${MAKE} test diff --git a/contrib/libxo/configure.ac b/contrib/libxo/configure.ac index b47dedb..fab8c88 100644 --- a/contrib/libxo/configure.ac +++ b/contrib/libxo/configure.ac @@ -12,7 +12,7 @@ # AC_PREREQ(2.2) -AC_INIT([libxo], [0.6.3], [phil@juniper.net]) +AC_INIT([libxo], [0.8.4], [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/contrib/libxo/doc/Makefile.am b/contrib/libxo/doc/Makefile.am index 16d6ba5..a00994c 100644 --- a/contrib/libxo/doc/Makefile.am +++ b/contrib/libxo/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/contrib/libxo/doc/libxo-manual.html b/contrib/libxo/doc/libxo-manual.html index 0c042a4..b56ddab 100644 --- a/contrib/libxo/doc/libxo-manual.html +++ b/contrib/libxo/doc/libxo-manual.html @@ -515,7 +515,7 @@ li.indline1 { } @top-right { - content: "May 2016"; + content: "August 2017"; } @top-center { @@ -21983,15 +21983,17 @@ jQuery(function ($) { </script><link rel="Contents" href="#doc.toc"> <link rel="Author" href="#doc.authors"> <link rel="Chapter" title="1 Overview" href="#doc_section_1"> -<link rel="Chapter" title="2 Formatting with libxo" href="#doc_section_2"> -<link rel="Chapter" title="3 The libxo API" href="#doc_section_3"> -<link rel="Chapter" title='4 The "xo" Utility' href="#doc_section_4"> -<link rel="Chapter" title="5 xolint" href="#doc_section_5"> -<link rel="Chapter" title="6 xohtml" href="#doc_section_6"> -<link rel="Chapter" title="7 xopo" href="#doc_section_7"> -<link rel="Chapter" title="8 FAQs" href="#doc_section_8"> -<link rel="Chapter" title="9 Howtos: Focused Directions" href="#doc_section_9"> -<link rel="Chapter" title="10 Examples" href="#doc_section_10"> +<link rel="Chapter" title="2 Getting libxo" href="#doc_section_2"> +<link rel="Chapter" title="3 Formatting with libxo" href="#doc_section_3"> +<link rel="Chapter" title="4 Command-line Arguments" href="#doc_section_4"> +<link rel="Chapter" title="5 The libxo API" href="#doc_section_5"> +<link rel="Chapter" title='6 The "xo" Utility' href="#doc_section_6"> +<link rel="Chapter" title="7 xolint" href="#doc_section_7"> +<link rel="Chapter" title="8 xohtml" href="#doc_section_8"> +<link rel="Chapter" title="9 xopo" href="#doc_section_9"> +<link rel="Chapter" title="10 FAQs" href="#doc_section_10"> +<link rel="Chapter" title="11 Howtos: Focused Directions" href="#doc_section_11"> +<link rel="Chapter" title="12 Examples" href="#doc_section_12"> <meta name="generator" content="http://greenbytes.de/tech/webdav/rfc2629.xslt, Revision 1.389, 2008-08-20 14:21:35, XSLT vendor: libxslt http://xmlsoft.org/XSLT/"> <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"> <meta name="DC.Creator" content="Shafer, P."> @@ -22009,7 +22011,7 @@ jQuery(function ($) { </tr> <tr> <td class="header left"></td> -<td class="header right">May 28, 2016</td> +<td class="header right">August 3, 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> @@ -22018,394 +22020,413 @@ jQuery(function ($) { <ul class="toc"> <li class="tocline0"> <div class="section-number" id="toc_doc_section_1">1 </div> -<a href="#overview">Overview</a><ul class="toc top-toc"><li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1">1.1 </div> -<a href="#getting-libxo">Getting libxo</a><ul class="toc"> +<a href="#overview">Overview</a> +</li> +<li class="tocline0"> +<div class="section-number" id="toc_doc_section_2">2 </div> +<a href="#getting-libxo">Getting libxo</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_1">1.1.1 </div> +<div class="section-number" id="toc_doc_section_2_1">2.1 </div> <a href="#downloading-libxo-source-code">Downloading libxo Source Code</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_2">1.1.2 </div> +<div class="section-number" id="toc_doc_section_2_2">2.2 </div> <a href="#building-libxo">Building libxo</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_2_1">1.1.2.1 </div> +<div class="section-number" id="toc_doc_section_2_2_1">2.2.1 </div> <a href="#setting-up-the-build">Setting up the build</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_2_2">1.1.2.2 </div> -<a href="#running-the-configure-script">Running the "configure" Script</a> -</li> +<div class="section-number" id="toc_doc_section_2_2_2">2.2.2 </div> +<a href="#running-the-configure-script">Running the "configure" Script</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_2_3">1.1.2.3 </div> +<div class="section-number" id="toc_doc_section_2_2_2_1">2.2.2.1 </div> <a href="#running-the-make-command">Running the "make" command</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_2_4">1.1.2.4 </div> +<div class="section-number" id="toc_doc_section_2_2_2_2">2.2.2.2 </div> <a href="#running-the-regression-tests">Running the Regression Tests</a> </li> +</ul> +</li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_1_1_2_5">1.1.2.5 </div> +<div class="section-number" id="toc_doc_section_2_2_3">2.2.3 </div> <a href="#installing-libxo">Installing libxo</a> </li> </ul> </li> </ul> -</li></ul> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_2">2 </div> +<div class="section-number" id="toc_doc_section_3">3 </div> <a href="#formatting-with-libxo">Formatting with libxo</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_1">2.1 </div> +<div class="section-number" id="toc_doc_section_3_1">3.1 </div> <a href="#encoding-styles">Encoding Styles</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_1_1">2.1.1 </div> +<div class="section-number" id="toc_doc_section_3_1_1">3.1.1 </div> <a href="#text-output">Text Output</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_1_2">2.1.2 </div> +<div class="section-number" id="toc_doc_section_3_1_2">3.1.2 </div> <a href="#xml-output">XML Output</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_1_3">2.1.3 </div> +<div class="section-number" id="toc_doc_section_3_1_3">3.1.3 </div> <a href="#json-output">JSON Output</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_1_4">2.1.4 </div> +<div class="section-number" id="toc_doc_section_3_1_4">3.1.4 </div> <a href="#html-output">HTML Output</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2">2.2 </div> +<div class="section-number" id="toc_doc_section_3_2">3.2 </div> <a href="#format-strings">Format Strings</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1">2.2.1 </div> +<div class="section-number" id="toc_doc_section_3_2_1">3.2.1 </div> <a href="#field-roles">Field Roles</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_1">2.2.1.1 </div> +<div class="section-number" id="toc_doc_section_3_2_1_1">3.2.1.1 </div> <a href="#color-role">The Color Role ({C:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_2">2.2.1.2 </div> +<div class="section-number" id="toc_doc_section_3_2_1_2">3.2.1.2 </div> <a href="#the-decoration-role-d">The Decoration Role ({D:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_3">2.2.1.3 </div> +<div class="section-number" id="toc_doc_section_3_2_1_3">3.2.1.3 </div> <a href="#gettext-role">The Gettext Role ({G:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_4">2.2.1.4 </div> +<div class="section-number" id="toc_doc_section_3_2_1_4">3.2.1.4 </div> <a href="#the-label-role-l">The Label Role ({L:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_5">2.2.1.5 </div> +<div class="section-number" id="toc_doc_section_3_2_1_5">3.2.1.5 </div> <a href="#the-note-role-n">The Note Role ({N:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_6">2.2.1.6 </div> +<div class="section-number" id="toc_doc_section_3_2_1_6">3.2.1.6 </div> <a href="#padding-role">The Padding Role ({P:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_7">2.2.1.7 </div> +<div class="section-number" id="toc_doc_section_3_2_1_7">3.2.1.7 </div> <a href="#the-title-role-t">The Title Role ({T:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_8">2.2.1.8 </div> +<div class="section-number" id="toc_doc_section_3_2_1_8">3.2.1.8 </div> <a href="#the-units-role-u">The Units Role ({U:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_9">2.2.1.9 </div> +<div class="section-number" id="toc_doc_section_3_2_1_9">3.2.1.9 </div> <a href="#the-value-role-v-and-">The Value Role ({V:} and {:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_1_10">2.2.1.10 </div> +<div class="section-number" id="toc_doc_section_3_2_1_10">3.2.1.10 </div> <a href="#anchor-role">The Anchor Roles ({[:} and {]:})</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2">2.2.2 </div> +<div class="section-number" id="toc_doc_section_3_2_2">3.2.2 </div> <a href="#field-modifiers">Field Modifiers</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_1">2.2.2.1 </div> +<div class="section-number" id="toc_doc_section_3_2_2_1">3.2.2.1 </div> <a href="#the-argument-modifier-a">The Argument Modifier ({a:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_2">2.2.2.2 </div> +<div class="section-number" id="toc_doc_section_3_2_2_2">3.2.2.2 </div> <a href="#the-colon-modifier-c">The Colon Modifier ({c:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_3">2.2.2.3 </div> +<div class="section-number" id="toc_doc_section_3_2_2_3">3.2.2.3 </div> <a href="#the-display-modifier-d">The Display Modifier ({d:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_4">2.2.2.4 </div> +<div class="section-number" id="toc_doc_section_3_2_2_4">3.2.2.4 </div> <a href="#e-modifier">The Encoding Modifier ({e:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_5">2.2.2.5 </div> +<div class="section-number" id="toc_doc_section_3_2_2_5">3.2.2.5 </div> <a href="#gettext-modifier">The Gettext Modifier ({g:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_6">2.2.2.6 </div> +<div class="section-number" id="toc_doc_section_3_2_2_6">3.2.2.6 </div> <a href="#the-humanize-modifier-h">The Humanize Modifier ({h:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_7">2.2.2.7 </div> +<div class="section-number" id="toc_doc_section_3_2_2_7">3.2.2.7 </div> <a href="#the-key-modifier-k">The Key Modifier ({k:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_8">2.2.2.8 </div> +<div class="section-number" id="toc_doc_section_3_2_2_8">3.2.2.8 </div> <a href="#the-leaf-list-modifier-l">The Leaf-List Modifier ({l:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_9">2.2.2.9 </div> +<div class="section-number" id="toc_doc_section_3_2_2_9">3.2.2.9 </div> <a href="#the-no-quotes-modifier-n">The No-Quotes Modifier ({n:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_10">2.2.2.10 </div> +<div class="section-number" id="toc_doc_section_3_2_2_10">3.2.2.10 </div> <a href="#plural-modifier">The Plural Modifier ({p:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_11">2.2.2.11 </div> +<div class="section-number" id="toc_doc_section_3_2_2_11">3.2.2.11 </div> <a href="#the-quotes-modifier-q">The Quotes Modifier ({q:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_12">2.2.2.12 </div> +<div class="section-number" id="toc_doc_section_3_2_2_12">3.2.2.12 </div> <a href="#the-trim-modifier-t">The Trim Modifier ({t:})</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_2_13">2.2.2.13 </div> +<div class="section-number" id="toc_doc_section_3_2_2_13">3.2.2.13 </div> <a href="#the-white-space-modifier-w">The White Space Modifier ({w:})</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_3">2.2.3 </div> +<div class="section-number" id="toc_doc_section_3_2_3">3.2.3 </div> <a href="#field-formatting">Field Formatting</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_4">2.2.4 </div> +<div class="section-number" id="toc_doc_section_3_2_4">3.2.4 </div> <a href="#utf-8-and-locale-strings">UTF-8 and Locale Strings</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_5">2.2.5 </div> +<div class="section-number" id="toc_doc_section_3_2_5">3.2.5 </div> <a href="#characters-outside-of-field-definitions">Characters Outside of Field Definitions</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_6">2.2.6 </div> +<div class="section-number" id="toc_doc_section_3_2_6">3.2.6 </div> <a href="#m-is-supported">"%m" Is Supported</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_7">2.2.7 </div> +<div class="section-number" id="toc_doc_section_3_2_7">3.2.7 </div> <a href="#n-is-not-supported">"%n" Is Not Supported</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_8">2.2.8 </div> +<div class="section-number" id="toc_doc_section_3_2_8">3.2.8 </div> <a href="#the-encoding-format-eformat">The Encoding Format (eformat)</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_9">2.2.9 </div> +<div class="section-number" id="toc_doc_section_3_2_9">3.2.9 </div> <a href="#content-strings">Content Strings</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_10">2.2.10 </div> +<div class="section-number" id="toc_doc_section_3_2_10">3.2.10 </div> <a href="#printf-like">Argument Validation</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_11">2.2.11 </div> +<div class="section-number" id="toc_doc_section_3_2_11">3.2.11 </div> <a href="#retain">Retaining Parsed Format Information</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_2_12">2.2.12 </div> +<div class="section-number" id="toc_doc_section_3_2_12">3.2.12 </div> <a href="#example">Example</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_3">2.3 </div> +<div class="section-number" id="toc_doc_section_3_3">3.3 </div> <a href="#representing-hierarchy">Representing Hierarchy</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_3_1">2.3.1 </div> +<div class="section-number" id="toc_doc_section_3_3_1">3.3.1 </div> <a href="#containers">Containers</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_3_2">2.3.2 </div> +<div class="section-number" id="toc_doc_section_3_3_2">3.3.2 </div> <a href="#lists-and-instances">Lists and Instances</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_3_3">2.3.3 </div> +<div class="section-number" id="toc_doc_section_3_3_3">3.3.3 </div> <a href="#dtrt-mode">DTRT Mode</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_3_4">2.3.4 </div> +<div class="section-number" id="toc_doc_section_3_3_4">3.3.4 </div> <a href="#markers">Markers</a> </li> </ul> </li> +</ul> +</li> +<li class="tocline0"> +<div class="section-number" id="toc_doc_section_4">4 </div> +<a href="#options">Command-line Arguments</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_2_4">2.4 </div> -<a href="#command-line-arguments">Command-line Arguments</a> +<div class="section-number" id="toc_doc_section_4_1">4.1 </div> +<a href="#option-keywords">Option keywords</a> +</li> +<li class="tocline1"> +<div class="section-number" id="toc_doc_section_4_2">4.2 </div> +<a href="#brief-options">Brief Options</a> +</li> +<li class="tocline1"> +<div class="section-number" id="toc_doc_section_4_3">4.3 </div> +<a href="#color-mapping">Color Mapping</a> </li> </ul> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_3">3 </div> +<div class="section-number" id="toc_doc_section_5">5 </div> <a href="#the-libxo-api">The libxo API</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_1">3.1 </div> +<div class="section-number" id="toc_doc_section_5_1">5.1 </div> <a href="#handles">Handles</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_1_1">3.1.1 </div> +<div class="section-number" id="toc_doc_section_5_1_1">5.1.1 </div> <a href="#xo_create">xo_create</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_1_2">3.1.2 </div> +<div class="section-number" id="toc_doc_section_5_1_2">5.1.2 </div> <a href="#xo_create_to_file">xo_create_to_file</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_1_3">3.1.3 </div> +<div class="section-number" id="toc_doc_section_5_1_3">5.1.3 </div> <a href="#xo_set_writer">xo_set_writer</a> </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"> +<div class="section-number" id="toc_doc_section_5_1_4">5.1.4 </div> +<a href="#xo_set_style">xo_set_style</a> +</li> <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_5_1_5">5.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_5_1_5_1">5.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_5_1_5_2">5.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_5_1_6">5.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_5_1_6_1">5.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_5_1_6_2">5.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_5_1_6_3">5.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_5_1_7">5.1.7 </div> <a href="#xo_destroy">xo_destroy</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_2">3.2 </div> +<div class="section-number" id="toc_doc_section_5_2">5.2 </div> <a href="#emitting-content-xo_emit">Emitting Content (xo_emit)</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_2_1">3.2.1 </div> +<div class="section-number" id="toc_doc_section_5_2_1">5.2.1 </div> <a href="#xo_emit_field">Single Field Emitting Functions (xo_emit_field)</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_2_2">3.2.2 </div> +<div class="section-number" id="toc_doc_section_5_2_2">5.2.2 </div> <a href="#xo_attr">Attributes (xo_attr)</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_2_3">3.2.3 </div> +<div class="section-number" id="toc_doc_section_5_2_3">5.2.3 </div> <a href="#flushing-output-xo_flush">Flushing Output (xo_flush)</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_2_4">3.2.4 </div> +<div class="section-number" id="toc_doc_section_5_2_4">5.2.4 </div> <a href="#finishing-output-xo_finish">Finishing Output (xo_finish)</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_3">3.3 </div> +<div class="section-number" id="toc_doc_section_5_3">5.3 </div> <a href="#emitting-hierarchy">Emitting Hierarchy</a><ul class="toc"><li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_3_1">3.3.1 </div> +<div class="section-number" id="toc_doc_section_5_3_1">5.3.1 </div> <a href="#lists-and-instances-2">Lists and Instances</a> </li></ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4">3.4 </div> +<div class="section-number" id="toc_doc_section_5_4">5.4 </div> <a href="#support-functions">Support Functions</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_1">3.4.1 </div> +<div class="section-number" id="toc_doc_section_5_4_1">5.4.1 </div> <a href="#xo_parse_args">Parsing Command-line Arguments (xo_parse_args)</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_2">3.4.2 </div> +<div class="section-number" id="toc_doc_section_5_4_2">5.4.2 </div> <a href="#xo_set_program">xo_set_program</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_3">3.4.3 </div> +<div class="section-number" id="toc_doc_section_5_4_3">5.4.3 </div> <a href="#xo_set_version">xo_set_version</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_4">3.4.4 </div> +<div class="section-number" id="toc_doc_section_5_4_4">5.4.4 </div> <a href="#info">Field Information (xo_info_t)</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_5">3.4.5 </div> +<div class="section-number" id="toc_doc_section_5_4_5">5.4.5 </div> <a href="#memory-allocation">Memory Allocation</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_6">3.4.6 </div> +<div class="section-number" id="toc_doc_section_5_4_6">5.4.6 </div> <a href="#LIBXO_OPTIONS">LIBXO_OPTIONS</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_7">3.4.7 </div> +<div class="section-number" id="toc_doc_section_5_4_7">5.4.7 </div> <a href="#errors-warnings-and-messages">Errors, Warnings, and Messages</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_8">3.4.8 </div> +<div class="section-number" id="toc_doc_section_5_4_8">5.4.8 </div> <a href="#xo_error">xo_error</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_4_9">3.4.9 </div> +<div class="section-number" id="toc_doc_section_5_4_9">5.4.9 </div> <a href="#xo_no_setlocale">xo_no_setlocale</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5">3.5 </div> +<div class="section-number" id="toc_doc_section_5_5">5.5 </div> <a href="#emitting-syslog-messages">Emitting syslog Messages</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_1">3.5.1 </div> +<div class="section-number" id="toc_doc_section_5_5_1">5.5.1 </div> <a href="#priority">Priority, Facility, and Flags</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_2">3.5.2 </div> +<div class="section-number" id="toc_doc_section_5_5_2">5.5.2 </div> <a href="#xo_syslog">xo_syslog</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_3">3.5.3 </div> +<div class="section-number" id="toc_doc_section_5_5_3">5.5.3 </div> <a href="#support-functions-2">Support functions</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_3_1">3.5.3.1 </div> +<div class="section-number" id="toc_doc_section_5_5_3_1">5.5.3.1 </div> <a href="#xo_vsyslog">xo_vsyslog</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_3_2">3.5.3.2 </div> +<div class="section-number" id="toc_doc_section_5_5_3_2">5.5.3.2 </div> <a href="#xo_open_log">xo_open_log</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_3_3">3.5.3.3 </div> +<div class="section-number" id="toc_doc_section_5_5_3_3">5.5.3.3 </div> <a href="#xo_close_log">xo_close_log</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_3_4">3.5.3.4 </div> +<div class="section-number" id="toc_doc_section_5_5_3_4">5.5.3.4 </div> <a href="#xo_set_logmask">xo_set_logmask</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_5_3_5">3.5.3.5 </div> +<div class="section-number" id="toc_doc_section_5_5_3_5">5.5.3.5 </div> <a href="#xo_set_syslog_enterprise_id">xo_set_syslog_enterprise_id</a> </li> </ul> @@ -22413,18 +22434,18 @@ jQuery(function ($) { </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_6">3.6 </div> +<div class="section-number" id="toc_doc_section_5_6">5.6 </div> <a href="#creating-custom-encoders">Creating Custom Encoders</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_6_1">3.6.1 </div> +<div class="section-number" id="toc_doc_section_5_6_1">5.6.1 </div> <a href="#loading-encoders">Loading Encoders</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_6_2">3.6.2 </div> +<div class="section-number" id="toc_doc_section_5_6_2">5.6.2 </div> <a href="#encoder-initialization">Encoder Initialization</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_3_6_3">3.6.3 </div> +<div class="section-number" id="toc_doc_section_5_6_3">5.6.3 </div> <a href="#operations">Operations</a> </li> </ul> @@ -22432,143 +22453,143 @@ jQuery(function ($) { </ul> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_4">4 </div> +<div class="section-number" id="toc_doc_section_6">6 </div> <a href="#the-xo-utility">The "xo" Utility</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_4_1">4.1 </div> +<div class="section-number" id="toc_doc_section_6_1">6.1 </div> <a href="#command-line-options">Command Line Options</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_4_2">4.2 </div> +<div class="section-number" id="toc_doc_section_6_2">6.2 </div> <a href="#example-2">Example</a> </li> </ul> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_5">5 </div> +<div class="section-number" id="toc_doc_section_7">7 </div> <a href="#xolint">xolint</a> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_6">6 </div> +<div class="section-number" id="toc_doc_section_8">8 </div> <a href="#xohtml">xohtml</a> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_7">7 </div> +<div class="section-number" id="toc_doc_section_9">9 </div> <a href="#xopo">xopo</a> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_8">8 </div> +<div class="section-number" id="toc_doc_section_10">10 </div> <a href="#faqs">FAQs</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_1">8.1 </div> +<div class="section-number" id="toc_doc_section_10_1">10.1 </div> <a href="#general">General</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_1_1">8.1.1 </div> +<div class="section-number" id="toc_doc_section_10_1_1">10.1.1 </div> <a href="#can-you-share-the-history-of-libxo">Can you share the history of libxo?</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_1_2">8.1.2 </div> +<div class="section-number" id="toc_doc_section_10_1_2">10.1.2 </div> <a href="#did-the-complex-semantics-of-format-strings-evolve-over-time">Did the complex semantics of format strings evolve over time?</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_1_3">8.1.3 </div> +<div class="section-number" id="toc_doc_section_10_1_3">10.1.3 </div> <a href="#good-field-names">What makes a good field name?</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2">8.2 </div> +<div class="section-number" id="toc_doc_section_10_2">10.2 </div> <a href="#what-does-this-message-mean">What does this message mean?</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_1">8.2.1 </div> +<div class="section-number" id="toc_doc_section_10_2_1">10.2.1 </div> <a href="#a-percent-sign-appearing-in-text-is-a-literal">'A percent sign appearing in text is a literal'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_2">8.2.2 </div> +<div class="section-number" id="toc_doc_section_10_2_2">10.2.2 </div> <a href="#unknown-long-name-for-rolemodifier">'Unknown long name for role/modifier'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_3">8.2.3 </div> +<div class="section-number" id="toc_doc_section_10_2_3">10.2.3 </div> <a href="#last-character-before-field-definition-is-a-field-type">'Last character before field definition is a field type'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_4">8.2.4 </div> +<div class="section-number" id="toc_doc_section_10_2_4">10.2.4 </div> <a href="#encoding-format-uses-different-number-of-arguments">'Encoding format uses different number of arguments'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_5">8.2.5 </div> +<div class="section-number" id="toc_doc_section_10_2_5">10.2.5 </div> <a href="#only-one-field-role-can-be-used">'Only one field role can be used'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_6">8.2.6 </div> +<div class="section-number" id="toc_doc_section_10_2_6">10.2.6 </div> <a 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> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_7">8.2.7 </div> +<div class="section-number" id="toc_doc_section_10_2_7">10.2.7 </div> <a href="#an-encoding-format-cannot-be-given-roles-dnlt">'An encoding format cannot be given (roles: DNLT)'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_8">8.2.8 </div> +<div class="section-number" id="toc_doc_section_10_2_8">10.2.8 </div> <a href="#format-cannot-be-given-when-content-is-present-roles-cdln">'Format cannot be given when content is present (roles: CDLN)'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_9">8.2.9 </div> +<div class="section-number" id="toc_doc_section_10_2_9">10.2.9 </div> <a href="#field-has-color-without-fg--or-bg--role-c">'Field has color without fg- or bg- (role: C)'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_10">8.2.10 </div> +<div class="section-number" id="toc_doc_section_10_2_10">10.2.10 </div> <a href="#field-has-invalid-color-or-effect-role-c">'Field has invalid color or effect (role: C)'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_11">8.2.11 </div> +<div class="section-number" id="toc_doc_section_10_2_11">10.2.11 </div> <a href="#field-has-humanize-modifier-but-no-format-string">'Field has humanize modifier but no format string'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_12">8.2.12 </div> +<div class="section-number" id="toc_doc_section_10_2_12">10.2.12 </div> <a href="#field-has-hn--modifier-but-not-h-modifier">'Field has hn-* modifier but not 'h' modifier'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_13">8.2.13 </div> +<div class="section-number" id="toc_doc_section_10_2_13">10.2.13 </div> <a href="#value-field-must-have-a-name-as-content">'Value field must have a name (as content)")'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_14">8.2.14 </div> +<div class="section-number" id="toc_doc_section_10_2_14">10.2.14 </div> <a href="#use-hyphens-not-underscores-for-value-field-name">'Use hyphens, not underscores, for value field name'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_15">8.2.15 </div> +<div class="section-number" id="toc_doc_section_10_2_15">10.2.15 </div> <a href="#value-field-name-cannot-start-with-digit">'Value field name cannot start with digit'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_16">8.2.16 </div> +<div class="section-number" id="toc_doc_section_10_2_16">10.2.16 </div> <a href="#value-field-name-should-be-lower-case">'Value field name should be lower case'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_17">8.2.17 </div> +<div class="section-number" id="toc_doc_section_10_2_17">10.2.17 </div> <a href="#value-field-name-should-be-longer-than-two-characters">'Value field name should be longer than two characters'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_18">8.2.18 </div> +<div class="section-number" id="toc_doc_section_10_2_18">10.2.18 </div> <a href="#value-field-name-contains-invalid-character">'Value field name contains invalid character'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_19">8.2.19 </div> +<div class="section-number" id="toc_doc_section_10_2_19">10.2.19 </div> <a href="#decoration-field-contains-invalid-character">'decoration field contains invalid character'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_20">8.2.20 </div> +<div class="section-number" id="toc_doc_section_10_2_20">10.2.20 </div> <a href="#anchor-content-should-be-decimal-width">'Anchor content should be decimal width'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_21">8.2.21 </div> +<div class="section-number" id="toc_doc_section_10_2_21">10.2.21 </div> <a href="#anchor-format-should-be-d">'Anchor format should be "%d"'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_22">8.2.22 </div> +<div class="section-number" id="toc_doc_section_10_2_22">10.2.22 </div> <a href="#anchor-cannot-have-both-format-and-encoding-format">'Anchor cannot have both format and encoding format")'</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_8_2_23">8.2.23 </div> +<div class="section-number" id="toc_doc_section_10_2_23">10.2.23 </div> <a href="#max-width-only-valid-for-strings">'Max width only valid for strings'</a> </li> </ul> @@ -22576,54 +22597,54 @@ jQuery(function ($) { </ul> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_9">9 </div> +<div class="section-number" id="toc_doc_section_11">11 </div> <a href="#howtos-focused-directions">Howtos: Focused Directions</a><ul class="toc top-toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_1">9.1 </div> +<div class="section-number" id="toc_doc_section_11_1">11.1 </div> <a href="#howto-report-bugs">Howto: Report bugs</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_2">9.2 </div> +<div class="section-number" id="toc_doc_section_11_2">11.2 </div> <a href="#howto-install-libxo">Howto: Install libxo</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_3">9.3 </div> +<div class="section-number" id="toc_doc_section_11_3">11.3 </div> <a href="#howto-convert-command-line-applications">Howto: Convert command line applications</a><ul class="toc"> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_3_1">9.3.1 </div> +<div class="section-number" id="toc_doc_section_11_3_1">11.3.1 </div> <a href="#setting-up-the-context">Setting up the context</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_3_2">9.3.2 </div> +<div class="section-number" id="toc_doc_section_11_3_2">11.3.2 </div> <a href="#converting-printf-calls">Converting printf Calls</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_3_3">9.3.3 </div> +<div class="section-number" id="toc_doc_section_11_3_3">11.3.3 </div> <a href="#creating-hierarchy">Creating Hierarchy</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_3_4">9.3.4 </div> +<div class="section-number" id="toc_doc_section_11_3_4">11.3.4 </div> <a href="#converting-error-functions">Converting Error Functions</a> </li> </ul> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_4">9.4 </div> +<div class="section-number" id="toc_doc_section_11_4">11.4 </div> <a href="#howto-use-xo-in-shell-scripts">Howto: Use "xo" in Shell Scripts</a> </li> <li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_5">9.5 </div> +<div class="section-number" id="toc_doc_section_11_5">11.5 </div> <a href="#howto-i18n">Howto: Internationalization (i18n)</a><ul class="toc"><li class="tocline1"> -<div class="section-number" id="toc_doc_section_9_5_1">9.5.1 </div> +<div class="section-number" id="toc_doc_section_11_5_1">11.5.1 </div> <a href="#i18n-and-xo_emit">i18n and xo_emit</a> </li></ul> </li> </ul> </li> <li class="tocline0"> -<div class="section-number" id="toc_doc_section_10">10 </div> +<div class="section-number" id="toc_doc_section_12">12 </div> <a href="#examples">Examples</a><ul class="toc top-toc"><li class="tocline1"> -<div class="section-number" id="toc_doc_section_10_1">10.1 </div> +<div class="section-number" id="toc_doc_section_12_1">12.1 </div> <a href="#unit-test">Unit Test</a> </li></ul> </li> @@ -22638,14 +22659,31 @@ jQuery(function ($) { <a id="overview" href="#overview">Overview</a> </h1> <p id="doc_section_1_p_1">libxo - A Library for Generating Text, XML, JSON, and HTML Output</p> -<p id="doc_section_1_p_2">You want to prepare for the future, but you need to live in the present. You'd love a flying car, but need to get to work today. You want to support features like XML, JSON, and HTML rendering to allow integration with NETCONF, REST, and web browsers, but you need to make text output for command line users. And you don't want multiple code paths that can't help but get out of sync. None of this "if (xml) {... } else {...}" logic. And ifdefs are right out. But you'd really, really like all the fancy features that modern encoding formats can provide. libxo can help.</p> -<p id="doc_section_1_p_3">The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced. The application calls a function "xo_emit" to product output that is described in a format string. A "field descriptor" tells libxo what the field is and what it means. Each field descriptor is placed in braces with a printf-like format string (<a href="#format-strings" title="Format Strings">Section 2.2</a>):</p> +<p id="doc_section_1_p_2">You want to prepare for the future, but you need to live in the present. You'd love a flying car, but need to get to work today. You want to support features like XML, JSON, and HTML rendering to allow integration with NETCONF, REST, and web browsers, but you need to make text output for command line users.</p> +<p id="doc_section_1_p_3">And you don't want multiple code paths that can't help but get out of sync:</p> <div id="doc_figure_u.1"></div> <pre> + /* None of this "if (xml) {... } else {...}" logic */ + if (xml) { + /* some code to make xml*/ + } else { + /* other code to make text */ + /* oops forgot to add something on both clauses! */ + } + + /* And ifdefs are right out. */ + #ifdef MAKE_XML + /* icky */ + #else + /* pooh */ + #endif + </pre> <p id="doc_section_1_p_5">But you'd really, really like all the fancy features that modern encoding formats can provide. libxo can help.</p> +<p id="doc_section_1_p_6">The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced. The application calls a function "xo_emit" to product output that is described in a format string. A "field descriptor" tells libxo what the field is and what it means. Each field descriptor is placed in braces with a printf-like format string (<a href="#format-strings" title="Format Strings">Section 3.2</a>):</p> +<div id="doc_figure_u.2"></div> <pre> xo_emit(" {:lines/%7ju} {:words/%7ju} " "{:characters/%7ju} {d:filename/%s}\n", linect, wordct, charct, file); - </pre> <p id="doc_section_1_p_5">Each field can have a role, with the 'value' role being the default, and the role tells libxo how and when to render that field. Output can then be generated in various style, using the "‑‑libxo" option:</p> -<div id="doc_figure_u.2"></div> <pre> + </pre> <p id="doc_section_1_p_8">Each field can have a role, with the 'value' role being the default, and the role tells libxo how and when to render that field (see <a href="#field-roles" title="Field Roles">Section 3.2.1</a> for details). Modifiers change how the field is rendered in different output styles (see <a href="#field-modifiers" title="Field Modifiers">Section 3.2.2</a> for details. Output can then be generated in various style, using the "‑‑libxo" option:</p> +<div id="doc_figure_u.3"></div> <pre> % wc /etc/motd 25 165 1140 /etc/motd % wc --libxo xml,pretty,warn /etc/motd @@ -22681,160 +22719,164 @@ jQuery(function ($) { <div class="text"> </div> <div class="data" data-tag="filename">/etc/motd</div> </div> - </pre> <p id="doc_section_1_p_7">Section Contents: </p> -<ul><li><a href="#getting-libxo" title="Getting libxo">Section 1.1</a></li></ul> + </pre> <p id="doc_section_1_p_10">Same code path, same format strings, same information, but it's rendered in distinct styles based on run-time flags.</p> +</div> +<hr class="noprint"> <div class="content"> -<h2 id="doc_section_1_1"> +<h1 id="doc_section_2" class="np"> <div class="self-section-number"> -<a href="#doc_section_1_1">1.1</a> </div> +<a href="#doc_section_2">2_</a> </div> <a id="getting-libxo" href="#getting-libxo">Getting libxo</a> -</h2> -<p id="doc_section_1_1_p_1">libxo lives on github as:</p> -<p id="doc_section_1_1_p_2"> <a href="https://github.com/Juniper/libxo">https://github.com/Juniper/libxo</a></p> -<p id="doc_section_1_1_p_3">The latest release of libxo is available at:</p> -<p id="doc_section_1_1_p_4"> <a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a></p> -<p id="doc_section_1_1_p_5">We are following the branching scheme from <a href="http://nvie.com/posts/a-successful-git-branching-model/">http://nvie.com/posts/a-successful-git-branching-model/</a> which means we will do development under the "develop" branch, and release from the "master" branch. To clone a developer tree, run the following command:</p> -<div id="doc_figure_u.3"></div> <pre> +</h1> +<p id="doc_section_2_p_1">libxo now ships as part of the FreeBSD Operating System (as of -11).</p> +<p id="doc_section_2_p_2">libxo lives on github as:</p> +<p id="doc_section_2_p_3"> <a href="https://github.com/Juniper/libxo">https://github.com/Juniper/libxo</a></p> +<p id="doc_section_2_p_4">The latest release of libxo is available at:</p> +<p id="doc_section_2_p_5"> <a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a></p> +<p id="doc_section_2_p_6">We are following the branching scheme from <a href="http://nvie.com/posts/a-successful-git-branching-model/">http://nvie.com/posts/a-successful-git-branching-model/</a> which means we will do development under the "develop" branch, and release from the "master" branch. To clone a developer tree, run the following command:</p> +<div id="doc_figure_u.4"></div> <pre> git clone https://github.com/Juniper/libxo.git -b develop - </pre> <p id="doc_section_1_1_p_7">We're using semantic release numbering, as defined in <a href="http://semver.org/spec/v2.0.0.html">http://semver.org/spec/v2.0.0.html</a>.</p> -<p id="doc_section_1_1_p_8">libxo is open source, distributed under the BSD license. It shipped as part of the FreeBSD operating system starting with release 11.0.</p> -<p id="doc_section_1_1_p_9">Issues, problems, and bugs should be directly to the issues page on our github site.</p> -<p id="doc_section_1_1_p_10">Section Contents: </p> + </pre> <p id="doc_section_2_p_8">We're using semantic release numbering, as defined in <a href="http://semver.org/spec/v2.0.0.html">http://semver.org/spec/v2.0.0.html</a>.</p> +<p id="doc_section_2_p_9">libxo is open source, distributed under the BSD license. It shipped as part of the FreeBSD operating system starting with release 11.0.</p> +<p id="doc_section_2_p_10">Issues, problems, and bugs should be directly to the issues page on our github site.</p> +<p id="doc_section_2_p_11">Section Contents: </p> <ul> -<li><a href="#downloading-libxo-source-code" title="Downloading libxo Source Code">Section 1.1.1</a></li> -<li><a href="#building-libxo" title="Building libxo">Section 1.1.2</a></li> +<li><a href="#downloading-libxo-source-code" title="Downloading libxo Source Code">Section 2.1</a></li> +<li><a href="#building-libxo" title="Building libxo">Section 2.2</a></li> </ul> <div class="content"> -<h3 id="doc_section_1_1_1"> +<h2 id="doc_section_2_1"> <div class="self-section-number"> -<a href="#doc_section_1_1_1">1.1.1</a> </div> +<a href="#doc_section_2_1">2.1</a> </div> <a id="downloading-libxo-source-code" href="#downloading-libxo-source-code">Downloading libxo Source Code</a> -</h3> -<p id="doc_section_1_1_1_p_1">You can retrieve the source for libxo in two ways:</p> -<p id="doc_section_1_1_1_p_2">A) Use a "distfile" for a specific release. We use github to maintain our releases. Visit github release page (<a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a>) to see the list of releases. To download the latest, look for the release with the green "Latest release" button and the green "libxo‑RELEASE.tar.gz" button under that section.</p> -<p id="doc_section_1_1_1_p_3">After downloading that release's distfile, untar it as follows:</p> -<div id="doc_figure_u.4"></div> <pre> +</h2> +<p id="doc_section_2_1_p_1">You can retrieve the source for libxo in two ways:</p> +<p id="doc_section_2_1_p_2">A) Use a "distfile" for a specific release. We use github to maintain our releases. Visit github release page (<a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a>) to see the list of releases. To download the latest, look for the release with the green "Latest release" button and the green "libxo‑RELEASE.tar.gz" button under that section.</p> +<p id="doc_section_2_1_p_3">After downloading that release's distfile, untar it as follows:</p> +<div id="doc_figure_u.5"></div> <pre> tar -zxf libxo-RELEASE.tar.gz cd libxo-RELEASE - </pre> <p id="doc_section_1_1_1_p_5">[Note: for Solaris users, your "tar" command lacks the "‑z" flag, so you'll need to substitute "gzip -dc "file" | tar xf -" instead of "tar -zxf "file"".]</p> -<p id="doc_section_1_1_1_p_6">B) Use the current build from github. This gives you the most recent source code, which might be less stable than a specific release. To build libxo from the git repo:</p> -<div id="doc_figure_u.5"></div> <pre> + </pre> <p id="doc_section_2_1_p_5">[Note: for Solaris users, your "tar" command lacks the "‑z" flag, so you'll need to substitute "gzip -dc "file" | tar xf -" instead of "tar -zxf "file"".]</p> +<p id="doc_section_2_1_p_6">B) Use the current build from github. This gives you the most recent source code, which might be less stable than a specific release. To build libxo from the git repo:</p> +<div id="doc_figure_u.6"></div> <pre> git clone https://github.com/Juniper/libxo.git cd libxo - </pre> <p id="doc_section_1_1_1_p_8">_BE AWARE_: The github repository does _not_ contain the files generated by "autoreconf", with the notable exception of the "m4" directory. Since these files (depcomp, configure, missing, install-sh, etc) are generated files, we keep them out of the source code repository.</p> -<p id="doc_section_1_1_1_p_9">This means that if you download the a release distfile, these files will be ready and you'll just need to run "configure", but if you download the source code from svn, then you'll need to run "autoreconf" by hand. This step is done for you by the "setup.sh" script, described in the next section.</p> + </pre> <p id="doc_section_2_1_p_8">_BE AWARE_: The github repository does _not_ contain the files generated by "autoreconf", with the notable exception of the "m4" directory. Since these files (depcomp, configure, missing, install-sh, etc) are generated files, we keep them out of the source code repository.</p> +<p id="doc_section_2_1_p_9">This means that if you download the a release distfile, these files will be ready and you'll just need to run "configure", but if you download the source code from svn, then you'll need to run "autoreconf" by hand. This step is done for you by the "setup.sh" script, described in the next section.</p> </div> <div class="content"> -<h3 id="doc_section_1_1_2"> +<h2 id="doc_section_2_2"> <div class="self-section-number"> -<a href="#doc_section_1_1_2">1.1.2</a> </div> +<a href="#doc_section_2_2">2.2</a> </div> <a id="building-libxo" href="#building-libxo">Building libxo</a> -</h3> -<p id="doc_section_1_1_2_p_1">To build libxo, you'll need to set up the build, run the "configure" script, run the "make" command, and run the regression tests.</p> -<p id="doc_section_1_1_2_p_2">The following is a summary of the commands needed. These commands are explained in detail in the rest of this section.</p> -<div id="doc_figure_u.6"></div> <pre> +</h2> +<p id="doc_section_2_2_p_1">To build libxo, you'll need to set up the build, run the "configure" script, run the "make" command, and run the regression tests.</p> +<p id="doc_section_2_2_p_2">The following is a summary of the commands needed. These commands are explained in detail in the rest of this section.</p> +<div id="doc_figure_u.7"></div> <pre> sh bin/setup.sh cd build ../configure make make test sudo make install - </pre> <p id="doc_section_1_1_2_p_4">The following sections will walk through each of these steps with additional details and options, but the above directions should be all that's needed.</p> -<p id="doc_section_1_1_2_p_5">Section Contents: </p> + </pre> <p id="doc_section_2_2_p_4">The following sections will walk through each of these steps with additional details and options, but the above directions should be all that's needed.</p> +<p id="doc_section_2_2_p_5">Section Contents: </p> <ul> -<li><a href="#setting-up-the-build" title="Setting up the build">Section 1.1.2.1</a></li> -<li><a href="#running-the-configure-script" title='Running the "configure" Script'>Section 1.1.2.2</a></li> -<li><a href="#running-the-make-command" title='Running the "make" command'>Section 1.1.2.3</a></li> -<li><a href="#running-the-regression-tests" title="Running the Regression Tests">Section 1.1.2.4</a></li> -<li><a href="#installing-libxo" title="Installing libxo">Section 1.1.2.5</a></li> +<li><a href="#setting-up-the-build" title="Setting up the build">Section 2.2.1</a></li> +<li><a href="#running-the-configure-script" title='Running the "configure" Script'>Section 2.2.2</a></li> +<li><a href="#installing-libxo" title="Installing libxo">Section 2.2.3</a></li> </ul> <div class="content"> -<h4 id="doc_section_1_1_2_1"> +<h3 id="doc_section_2_2_1"> <div class="self-section-number"> -<a href="#doc_section_1_1_2_1">1.1.2.1</a> </div> +<a href="#doc_section_2_2_1">2.2.1</a> </div> <a id="setting-up-the-build" href="#setting-up-the-build">Setting up the build</a> -</h4> -<p id="doc_section_1_1_2_1_p_1">[If you downloaded a distfile, you can skip this step.]</p> -<p id="doc_section_1_1_2_1_p_2">Run the "setup.sh" script to set up the build. This script runs the "autoreconf" command to generate the "configure" script and other generated files.</p> -<div id="doc_figure_u.7"></div> <pre> +</h3> +<p id="doc_section_2_2_1_p_1">[If you downloaded a distfile, you can skip this step.]</p> +<p id="doc_section_2_2_1_p_2">Run the "setup.sh" script to set up the build. This script runs the "autoreconf" command to generate the "configure" script and other generated files.</p> +<div id="doc_figure_u.8"></div> <pre> sh bin/setup.sh - </pre> <p id="doc_section_1_1_2_1_p_4">Note: We're are currently using autoreconf version 2.69.</p> + </pre> <p id="doc_section_2_2_1_p_4">Note: We're are currently using autoreconf version 2.69.</p> </div> <div class="content"> -<h4 id="doc_section_1_1_2_2"> +<h3 id="doc_section_2_2_2"> <div class="self-section-number"> -<a href="#doc_section_1_1_2_2">1.1.2.2</a> </div> +<a href="#doc_section_2_2_2">2.2.2</a> </div> <a id="running-the-configure-script" href="#running-the-configure-script">Running the "configure" Script</a> -</h4> -<p id="doc_section_1_1_2_2_p_1">Configure (and autoconf in general) provides a means of building software in diverse environments. Our configure script supports a set of options that can be used to adjust to your operating environment. Use "configure --help" to view these options.</p> -<p id="doc_section_1_1_2_2_p_2">We use the "build" directory to keep object files and generated files away from the source tree.</p> -<p id="doc_section_1_1_2_2_p_3">To run the configure script, change into the "build" directory, and run the "configure" script. Add any required options to the "../configure" command line.</p> -<div id="doc_figure_u.8"></div> <pre> +</h3> +<p id="doc_section_2_2_2_p_1">Configure (and autoconf in general) provides a means of building software in diverse environments. Our configure script supports a set of options that can be used to adjust to your operating environment. Use "configure --help" to view these options.</p> +<p id="doc_section_2_2_2_p_2">We use the "build" directory to keep object files and generated files away from the source tree.</p> +<p id="doc_section_2_2_2_p_3">To run the configure script, change into the "build" directory, and run the "configure" script. Add any required options to the "../configure" command line.</p> +<div id="doc_figure_u.9"></div> <pre> cd build ../configure - </pre> <p id="doc_section_1_1_2_2_p_5">Expect to see the "configure" script generate the following error:</p> -<div id="doc_figure_u.9"></div> <pre> - /usr/bin/rm: cannot remove `libtoolT': No such file or directory - </pre> <p id="doc_section_1_1_2_2_p_7">This error is harmless and can be safely ignored.</p> -<p id="doc_section_1_1_2_2_p_8">By default, libxo installs architecture-independent files, including extension library files, in the /usr/local directories. To specify an installation prefix other than /usr/local for all installation files, include the --prefix=prefix option and specify an alternate location. To install just the extension library files in a different, user-defined location, include the --with-extensions-dir=dir option and specify the location where the extension libraries will live.</p> + </pre> <p id="doc_section_2_2_2_p_5">Expect to see the "configure" script generate the following error:</p> <div id="doc_figure_u.10"></div> <pre> + /usr/bin/rm: cannot remove `libtoolT': No such file or directory + </pre> <p id="doc_section_2_2_2_p_7">This error is harmless and can be safely ignored.</p> +<p id="doc_section_2_2_2_p_8">By default, libxo installs architecture-independent files, including extension library files, in the /usr/local directories. To specify an installation prefix other than /usr/local for all installation files, include the --prefix=prefix option and specify an alternate location. To install just the extension library files in a different, user-defined location, include the --with-extensions-dir=dir option and specify the location where the extension libraries will live.</p> +<div id="doc_figure_u.11"></div> <pre> cd build ../configure [OPTION]... [VAR=VALUE]... - </pre> </div> + </pre> <p id="doc_section_2_2_2_p_10">Section Contents: </p> +<ul> +<li><a href="#running-the-make-command" title='Running the "make" command'>Section 2.2.2.1</a></li> +<li><a href="#running-the-regression-tests" title="Running the Regression Tests">Section 2.2.2.2</a></li> +</ul> <div class="content"> -<h4 id="doc_section_1_1_2_3"> +<h4 id="doc_section_2_2_2_1"> <div class="self-section-number"> -<a href="#doc_section_1_1_2_3">1.1.2.3</a> </div> +<a href="#doc_section_2_2_2_1">2.2.2.1</a> </div> <a id="running-the-make-command" href="#running-the-make-command">Running the "make" command</a> </h4> -<p id="doc_section_1_1_2_3_p_1">Once the "configure" script is run, build the images using the "make" command:</p> -<div id="doc_figure_u.11"></div> <pre> +<p id="doc_section_2_2_2_1_p_1">Once the "configure" script is run, build the images using the "make" command:</p> +<div id="doc_figure_u.12"></div> <pre> make </pre> </div> <div class="content"> -<h4 id="doc_section_1_1_2_4"> +<h4 id="doc_section_2_2_2_2"> <div class="self-section-number"> -<a href="#doc_section_1_1_2_4">1.1.2.4</a> </div> +<a href="#doc_section_2_2_2_2">2.2.2.2</a> </div> <a id="running-the-regression-tests" href="#running-the-regression-tests">Running the Regression Tests</a> </h4> -<p id="doc_section_1_1_2_4_p_1">libxo includes a set of regression tests that can be run to ensure the software is working properly. These test are optional, but will help determine if there are any issues running libxo on your machine. To run the regression tests:</p> -<div id="doc_figure_u.12"></div> <pre> +<p id="doc_section_2_2_2_2_p_1">libxo includes a set of regression tests that can be run to ensure the software is working properly. These test are optional, but will help determine if there are any issues running libxo on your machine. To run the regression tests:</p> +<div id="doc_figure_u.13"></div> <pre> make test </pre> </div> +</div> <div class="content"> -<h4 id="doc_section_1_1_2_5"> +<h3 id="doc_section_2_2_3"> <div class="self-section-number"> -<a href="#doc_section_1_1_2_5">1.1.2.5</a> </div> +<a href="#doc_section_2_2_3">2.2.3</a> </div> <a id="installing-libxo" href="#installing-libxo">Installing libxo</a> -</h4> -<p id="doc_section_1_1_2_5_p_1">Once the software is built, you'll need to install libxo using the "make install" command. If you are the root user, or the owner of the installation directory, simply issue the command:</p> -<div id="doc_figure_u.13"></div> <pre> - make install - </pre> <p id="doc_section_1_1_2_5_p_3">If you are not the "root" user and are using the "sudo" package, use:</p> +</h3> +<p id="doc_section_2_2_3_p_1">Once the software is built, you'll need to install libxo using the "make install" command. If you are the root user, or the owner of the installation directory, simply issue the command:</p> <div id="doc_figure_u.14"></div> <pre> - sudo make install - </pre> <p id="doc_section_1_1_2_5_p_5">Verify the installation by viewing the output of "xo --version":</p> + make install + </pre> <p id="doc_section_2_2_3_p_3">If you are not the "root" user and are using the "sudo" package, use:</p> <div id="doc_figure_u.15"></div> <pre> + sudo make install + </pre> <p id="doc_section_2_2_3_p_5">Verify the installation by viewing the output of "xo --version":</p> +<div id="doc_figure_u.16"></div> <pre> % xo --version libxo version 0.3.5-git-develop xo version 0.3.5-git-develop </pre> </div> </div> </div> -</div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_2" class="np"> +<h1 id="doc_section_3" class="np"> <div class="self-section-number"> -<a href="#doc_section_2">2_</a> </div> +<a href="#doc_section_3">3_</a> </div> <a id="formatting-with-libxo" href="#formatting-with-libxo">Formatting with libxo</a> </h1> -<p id="doc_section_2_p_1">Most unix commands emit text output aimed at humans. It is designed to be parsed and understood by a user. Humans are gifted at extracting details and pattern matching in such output. Often programmers need to extract information from this human-oriented output. Programmers use tools like grep, awk, and regular expressions to ferret out the pieces of information they need. Such solutions are fragile and require maintenance when output contents change or evolve, along with testing and validation.</p> -<p id="doc_section_2_p_2">Modern tool developers favor encoding schemes like XML and JSON, which allow trivial parsing and extraction of data. Such formats are simple, well understood, hierarchical, easily parsed, and often integrate easier with common tools and environments. Changes to content can be done in ways that do not break existing users of the data, which can reduce maintenance costs and increase feature velocity.</p> -<p id="doc_section_2_p_3">In addition, modern reality means that more output ends up in web browsers than in terminals, making HTML output valuable.</p> -<p id="doc_section_2_p_4">libxo allows a single set of function calls in source code to generate traditional text output, as well as XML and JSON formatted data. HTML can also be generated; "<div>" elements surround the traditional text output, with attributes that detail how to render the data.</p> -<p id="doc_section_2_p_5">A single libxo function call in source code is all that's required:</p> -<div id="doc_figure_u.16"></div> <pre> +<p id="doc_section_3_p_1">Most unix commands emit text output aimed at humans. It is designed to be parsed and understood by a user. Humans are gifted at extracting details and pattern matching in such output. Often programmers need to extract information from this human-oriented output. Programmers use tools like grep, awk, and regular expressions to ferret out the pieces of information they need. Such solutions are fragile and require maintenance when output contents change or evolve, along with testing and validation.</p> +<p id="doc_section_3_p_2">Modern tool developers favor encoding schemes like XML and JSON, which allow trivial parsing and extraction of data. Such formats are simple, well understood, hierarchical, easily parsed, and often integrate easier with common tools and environments. Changes to content can be done in ways that do not break existing users of the data, which can reduce maintenance costs and increase feature velocity.</p> +<p id="doc_section_3_p_3">In addition, modern reality means that more output ends up in web browsers than in terminals, making HTML output valuable.</p> +<p id="doc_section_3_p_4">libxo allows a single set of function calls in source code to generate traditional text output, as well as XML and JSON formatted data. HTML can also be generated; "<div>" elements surround the traditional text output, with attributes that detail how to render the data.</p> +<p id="doc_section_3_p_5">A single libxo function call in source code is all that's required:</p> +<div id="doc_figure_u.17"></div> <pre> xo_emit("Connecting to {:host}.{:domain}...\n", host, domain); TEXT: @@ -22855,64 +22897,63 @@ jQuery(function ($) { data-xpath="/top/domain">example.com</div> <div class="text">...</div> </div> - </pre> <p id="doc_section_2_p_7">Section Contents: </p> + </pre> <p id="doc_section_3_p_7">Section Contents: </p> <ul> -<li><a href="#encoding-styles" title="Encoding Styles">Section 2.1</a></li> -<li><a href="#format-strings" title="Format Strings">Section 2.2</a></li> -<li><a href="#representing-hierarchy" title="Representing Hierarchy">Section 2.3</a></li> -<li><a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a></li> +<li><a href="#encoding-styles" title="Encoding Styles">Section 3.1</a></li> +<li><a href="#format-strings" title="Format Strings">Section 3.2</a></li> +<li><a href="#representing-hierarchy" title="Representing Hierarchy">Section 3.3</a></li> </ul> <div class="content"> -<h2 id="doc_section_2_1"> +<h2 id="doc_section_3_1"> <div class="self-section-number"> -<a href="#doc_section_2_1">2.1</a> </div> +<a href="#doc_section_3_1">3.1</a> </div> <a id="encoding-styles" href="#encoding-styles">Encoding Styles</a> </h2> -<p id="doc_section_2_1_p_1">There are four encoding styles supported by libxo:</p> -<p id="doc_section_2_1_p_2"> </p> +<p id="doc_section_3_1_p_1">There are four encoding styles supported by libxo:</p> +<p id="doc_section_3_1_p_2"> </p> <ul> <li>TEXT output can be display on a terminal session, allowing compatibility with traditional command line usage.</li> <li>XML output is suitable for tools like XPath and protocols like NETCONF.</li> <li>JSON output can be used for RESTful APIs and integration with languages like Javascript and Python.</li> <li>HTML can be matched with a small CSS file to permit rendering in any HTML5 browser.</li> </ul> -<p id="doc_section_2_1_p_3">In general, XML and JSON are suitable for encoding data, while TEXT is suited for terminal output and HTML is suited for display in a web browser (see <a href="#xohtml" title="xohtml">Section 6</a>).</p> -<p id="doc_section_2_1_p_4">Section Contents: </p> +<p id="doc_section_3_1_p_3">In general, XML and JSON are suitable for encoding data, while TEXT is suited for terminal output and HTML is suited for display in a web browser (see <a href="#xohtml" title="xohtml">Section 8</a>).</p> +<p id="doc_section_3_1_p_4">Section Contents: </p> <ul> -<li><a href="#text-output" title="Text Output">Section 2.1.1</a></li> -<li><a href="#xml-output" title="XML Output">Section 2.1.2</a></li> -<li><a href="#json-output" title="JSON Output">Section 2.1.3</a></li> -<li><a href="#html-output" title="HTML Output">Section 2.1.4</a></li> +<li><a href="#text-output" title="Text Output">Section 3.1.1</a></li> +<li><a href="#xml-output" title="XML Output">Section 3.1.2</a></li> +<li><a href="#json-output" title="JSON Output">Section 3.1.3</a></li> +<li><a href="#html-output" title="HTML Output">Section 3.1.4</a></li> </ul> <div class="content"> -<h3 id="doc_section_2_1_1"> +<h3 id="doc_section_3_1_1"> <div class="self-section-number"> -<a href="#doc_section_2_1_1">2.1.1</a> </div> +<a href="#doc_section_3_1_1">3.1.1</a> </div> <a id="text-output" href="#text-output">Text Output</a> </h3> -<p id="doc_section_2_1_1_p_1">Most traditional programs generate text output on standard output, with contents like:</p> -<div id="doc_figure_u.17"></div> <pre> +<p id="doc_section_3_1_1_p_1">Most traditional programs generate text output on standard output, with contents like:</p> +<div id="doc_figure_u.18"></div> <pre> 36 ./src 40 ./bin 90 . - </pre> <p id="doc_section_2_1_1_p_3">In this example (taken from du source code), the code to generate this data might look like:</p> -<div id="doc_figure_u.18"></div> <pre> - printf("%d\t%s\n", num_blocks, path); - </pre> <p id="doc_section_2_1_1_p_5">Simple, direct, obvious. But it's only making text output. Imagine using a single code path to make TEXT, XML, JSON or HTML, deciding at run time which to generate.</p> -<p id="doc_section_2_1_1_p_6">libxo expands on the idea of printf format strings to make a single format containing instructions for creating multiple output styles:</p> + </pre> <p id="doc_section_3_1_1_p_3">In this example (taken from du source code), the code to generate this data might look like:</p> <div id="doc_figure_u.19"></div> <pre> + printf("%d\t%s\n", num_blocks, path); + </pre> <p id="doc_section_3_1_1_p_5">Simple, direct, obvious. But it's only making text output. Imagine using a single code path to make TEXT, XML, JSON or HTML, deciding at run time which to generate.</p> +<p id="doc_section_3_1_1_p_6">libxo expands on the idea of printf format strings to make a single format containing instructions for creating multiple output styles:</p> +<div id="doc_figure_u.20"></div> <pre> xo_emit("{:blocks/%d}\t{:path/%s}\n", num_blocks, path); - </pre> <p id="doc_section_2_1_1_p_8">This line will generate the same text output as the earlier printf call, but also has enough information to generate XML, JSON, and HTML.</p> -<p id="doc_section_2_1_1_p_9">The following sections introduce the other formats.</p> + </pre> <p id="doc_section_3_1_1_p_8">This line will generate the same text output as the earlier printf call, but also has enough information to generate XML, JSON, and HTML.</p> +<p id="doc_section_3_1_1_p_9">The following sections introduce the other formats.</p> </div> <div class="content"> -<h3 id="doc_section_2_1_2"> +<h3 id="doc_section_3_1_2"> <div class="self-section-number"> -<a href="#doc_section_2_1_2">2.1.2</a> </div> +<a href="#doc_section_3_1_2">3.1.2</a> </div> <a id="xml-output" href="#xml-output">XML Output</a> </h3> -<p id="doc_section_2_1_2_p_1">XML output consists of a hierarchical set of elements, each encoded with a start tag and an end tag. The element should be named for data value that it is encoding:</p> -<div id="doc_figure_u.20"></div> <pre> +<p id="doc_section_3_1_2_p_1">XML output consists of a hierarchical set of elements, each encoded with a start tag and an end tag. The element should be named for data value that it is encoding:</p> +<div id="doc_figure_u.21"></div> <pre> <item> <blocks>36</blocks> <path>./src</path> @@ -22925,16 +22966,16 @@ jQuery(function ($) { <blocks>90</blocks> <path>.</path> </item> - </pre> <p id="doc_section_2_1_2_p_3">XML is a W3C standard for encoding data. See w3c.org/TR/xml for additional information.</p> + </pre> <p id="doc_section_3_1_2_p_3">XML is a W3C standard for encoding data. See w3c.org/TR/xml for additional information.</p> </div> <div class="content"> -<h3 id="doc_section_2_1_3"> +<h3 id="doc_section_3_1_3"> <div class="self-section-number"> -<a href="#doc_section_2_1_3">2.1.3</a> </div> +<a href="#doc_section_3_1_3">3.1.3</a> </div> <a id="json-output" href="#json-output">JSON Output</a> </h3> -<p id="doc_section_2_1_3_p_1">JSON output consists of a hierarchical set of objects and lists, each encoded with a quoted name, a colon, and a value. If the value is a string, it must be quoted, but numbers are not quoted. Objects are encoded using braces; lists are encoded using square brackets. Data inside objects and lists is separated using commas:</p> -<div id="doc_figure_u.21"></div> <pre> +<p id="doc_section_3_1_3_p_1">JSON output consists of a hierarchical set of objects and lists, each encoded with a quoted name, a colon, and a value. If the value is a string, it must be quoted, but numbers are not quoted. Objects are encoded using braces; lists are encoded using square brackets. Data inside objects and lists is separated using commas:</p> +<div id="doc_figure_u.22"></div> <pre> items: [ { "blocks": 36, "path" : "./src" }, { "blocks": 40, "path" : "./bin" }, @@ -22942,14 +22983,14 @@ jQuery(function ($) { ] </pre> </div> <div class="content"> -<h3 id="doc_section_2_1_4"> +<h3 id="doc_section_3_1_4"> <div class="self-section-number"> -<a href="#doc_section_2_1_4">2.1.4</a> </div> +<a href="#doc_section_3_1_4">3.1.4</a> </div> <a id="html-output" href="#html-output">HTML Output</a> </h3> -<p id="doc_section_2_1_4_p_1">HTML output is designed to allow the output to be rendered in a web browser with minimal effort. Each piece of output data is rendered inside a <div> element, with a class name related to the role of the data. By using a small set of class attribute values, a CSS stylesheet can render the HTML into rich text that mirrors the traditional text content.</p> -<p id="doc_section_2_1_4_p_2">Additional attributes can be enabled to provide more details about the data, including data type, description, and an XPath location.</p> -<div id="doc_figure_u.22"></div> <pre> +<p id="doc_section_3_1_4_p_1">HTML output is designed to allow the output to be rendered in a web browser with minimal effort. Each piece of output data is rendered inside a <div> element, with a class name related to the role of the data. By using a small set of class attribute values, a CSS stylesheet can render the HTML into rich text that mirrors the traditional text content.</p> +<p id="doc_section_3_1_4_p_2">Additional attributes can be enabled to provide more details about the data, including data type, description, and an XPath location.</p> +<div id="doc_figure_u.23"></div> <pre> <div class="line"> <div class="data" data-tag="blocks">36</div> <div class="padding"> </div> @@ -22968,46 +23009,46 @@ jQuery(function ($) { </pre> </div> </div> <div class="content"> -<h2 id="doc_section_2_2"> +<h2 id="doc_section_3_2"> <div class="self-section-number"> -<a href="#doc_section_2_2">2.2</a> </div> +<a href="#doc_section_3_2">3.2</a> </div> <a id="format-strings" href="#format-strings">Format Strings</a> </h2> -<p id="doc_section_2_2_p_1">libxo uses format strings to control the rendering of data into the various output styles. Each format string contains a set of zero or more field descriptions, which describe independent data fields. Each field description contains a set of modifiers, a content string, and zero, one, or two format descriptors. The modifiers tell libxo what the field is and how to treat it, while the format descriptors are formatting instructions using printf-style format strings, telling libxo how to format the field. The field description is placed inside a set of braces, with a colon (":") after the modifiers and a slash ("/") before each format descriptors. Text may be intermixed with field descriptions within the format string.</p> -<p id="doc_section_2_2_p_2">The field description is given as follows:</p> -<div id="doc_figure_u.23"></div> <pre> +<p id="doc_section_3_2_p_1">libxo uses format strings to control the rendering of data into the various output styles. Each format string contains a set of zero or more field descriptions, which describe independent data fields. Each field description contains a set of modifiers, a content string, and zero, one, or two format descriptors. The modifiers tell libxo what the field is and how to treat it, while the format descriptors are formatting instructions using printf-style format strings, telling libxo how to format the field. The field description is placed inside a set of braces, with a colon (":") after the modifiers and a slash ("/") before each format descriptors. Text may be intermixed with field descriptions within the format string.</p> +<p id="doc_section_3_2_p_2">The field description is given as follows:</p> +<div id="doc_figure_u.24"></div> <pre> '{' [ role | modifier ]* [',' long-names ]* ':' [ content ] [ '/' field-format [ '/' encoding-format ]] '}' - </pre> <p id="doc_section_2_2_p_4">The role describes the function of the field, while the modifiers enable optional behaviors. The contents, field-format, and encoding-format are used in varying ways, based on the role. These are described in the following sections.</p> -<p id="doc_section_2_2_p_5">In the following example, three field descriptors appear. The first is a padding field containing three spaces of padding, the second is a label ("In stock"), and the third is a value field ("in‑stock"). The in-stock field has a "%u" format that will parse the next argument passed to the xo_emit function as an unsigned integer.</p> -<div id="doc_figure_u.24"></div> <pre> - xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\n", 65); - </pre> <p id="doc_section_2_2_p_7">This single line of code can generate text (" In stock: 65\n"), XML ("<in‑stock>65</in‑stock>"), JSON ('"in‑stock": 6'), or HTML (too lengthy to be listed here).</p> -<p id="doc_section_2_2_p_8">While roles and modifiers typically use single character for brevity, there are alternative names for each which allow more verbose formatting strings. These names must be preceded by a comma, and may follow any single-character values:</p> + </pre> <p id="doc_section_3_2_p_4">The role describes the function of the field, while the modifiers enable optional behaviors. The contents, field-format, and encoding-format are used in varying ways, based on the role. These are described in the following sections.</p> +<p id="doc_section_3_2_p_5">In the following example, three field descriptors appear. The first is a padding field containing three spaces of padding, the second is a label ("In stock"), and the third is a value field ("in‑stock"). The in-stock field has a "%u" format that will parse the next argument passed to the xo_emit function as an unsigned integer.</p> <div id="doc_figure_u.25"></div> <pre> + xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\n", 65); + </pre> <p id="doc_section_3_2_p_7">This single line of code can generate text (" In stock: 65\n"), XML ("<in‑stock>65</in‑stock>"), JSON ('"in‑stock": 6'), or HTML (too lengthy to be listed here).</p> +<p id="doc_section_3_2_p_8">While roles and modifiers typically use single character for brevity, there are alternative names for each which allow more verbose formatting strings. These names must be preceded by a comma, and may follow any single-character values:</p> +<div id="doc_figure_u.26"></div> <pre> xo_emit("{L,white,colon:In stock}{,key:in-stock/%u}\n", 65); - </pre> <p id="doc_section_2_2_p_10">Section Contents: </p> + </pre> <p id="doc_section_3_2_p_10">Section Contents: </p> <ul> -<li><a href="#field-roles" title="Field Roles">Section 2.2.1</a></li> -<li><a href="#field-modifiers" title="Field Modifiers">Section 2.2.2</a></li> -<li><a href="#field-formatting" title="Field Formatting">Section 2.2.3</a></li> -<li><a href="#utf-8-and-locale-strings" title="UTF-8 and Locale Strings">Section 2.2.4</a></li> -<li><a href="#characters-outside-of-field-definitions" title="Characters Outside of Field Definitions">Section 2.2.5</a></li> -<li><a href="#m-is-supported" title='"%m" Is Supported'>Section 2.2.6</a></li> -<li><a href="#n-is-not-supported" title='"%n" Is Not Supported'>Section 2.2.7</a></li> -<li><a href="#the-encoding-format-eformat" title="The Encoding Format (eformat)">Section 2.2.8</a></li> -<li><a href="#content-strings" title="Content Strings">Section 2.2.9</a></li> -<li><a href="#printf-like" title="Argument Validation">Section 2.2.10</a></li> -<li><a href="#retain" title="Retaining Parsed Format Information">Section 2.2.11</a></li> -<li><a href="#example" title="Example">Section 2.2.12</a></li> +<li><a href="#field-roles" title="Field Roles">Section 3.2.1</a></li> +<li><a href="#field-modifiers" title="Field Modifiers">Section 3.2.2</a></li> +<li><a href="#field-formatting" title="Field Formatting">Section 3.2.3</a></li> +<li><a href="#utf-8-and-locale-strings" title="UTF-8 and Locale Strings">Section 3.2.4</a></li> +<li><a href="#characters-outside-of-field-definitions" title="Characters Outside of Field Definitions">Section 3.2.5</a></li> +<li><a href="#m-is-supported" title='"%m" Is Supported'>Section 3.2.6</a></li> +<li><a href="#n-is-not-supported" title='"%n" Is Not Supported'>Section 3.2.7</a></li> +<li><a href="#the-encoding-format-eformat" title="The Encoding Format (eformat)">Section 3.2.8</a></li> +<li><a href="#content-strings" title="Content Strings">Section 3.2.9</a></li> +<li><a href="#printf-like" title="Argument Validation">Section 3.2.10</a></li> +<li><a href="#retain" title="Retaining Parsed Format Information">Section 3.2.11</a></li> +<li><a href="#example" title="Example">Section 3.2.12</a></li> </ul> <div class="content"> -<h3 id="doc_section_2_2_1"> +<h3 id="doc_section_3_2_1"> <div class="self-section-number"> -<a href="#doc_section_2_2_1">2.2.1</a> </div> +<a href="#doc_section_3_2_1">3.2.1</a> </div> <a id="field-roles" href="#field-roles">Field Roles</a> </h3> -<p id="doc_section_2_2_1_p_1">Field roles are optional, and indicate the role and formatting of the content. The roles are listed below; only one role is permitted:</p> +<p id="doc_section_3_2_1_p_1">Field roles are optional, and indicate the role and formatting of the content. The roles are listed below; only one role is permitted:</p> <div id="doc_table_u.1"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">R</th> @@ -23082,57 +23123,57 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<div id="doc_figure_u.26"></div> <pre> +<div id="doc_figure_u.27"></div> <pre> EXAMPLE: xo_emit("{L:Free}{D::}{P: }{:free/%u} {U:Blocks}\n", free_blocks); - </pre> <p id="doc_section_2_2_1_p_3">When a role is not provided, the "value" role is used as the default.</p> -<p id="doc_section_2_2_1_p_4">Roles and modifiers can also use more verbose names, when preceded by a comma:</p> -<div id="doc_figure_u.27"></div> <pre> + </pre> <p id="doc_section_3_2_1_p_3">When a role is not provided, the "value" role is used as the default.</p> +<p id="doc_section_3_2_1_p_4">Roles and modifiers can also use more verbose names, when preceded by a comma:</p> +<div id="doc_figure_u.28"></div> <pre> EXAMPLE: xo_emit("{,label:Free}{,decoration::}{,padding: }" "{,value:free/%u} {,units:Blocks}\n", free_blocks); - </pre> <p id="doc_section_2_2_1_p_6">Section Contents: </p> + </pre> <p id="doc_section_3_2_1_p_6">Section Contents: </p> <ul> -<li><a href="#color-role" title="The Color Role ({C:})">Section 2.2.1.1</a></li> -<li><a href="#the-decoration-role-d" title="The Decoration Role ({D:})">Section 2.2.1.2</a></li> -<li><a href="#gettext-role" title="The Gettext Role ({G:})">Section 2.2.1.3</a></li> -<li><a href="#the-label-role-l" title="The Label Role ({L:})">Section 2.2.1.4</a></li> -<li><a href="#the-note-role-n" title="The Note Role ({N:})">Section 2.2.1.5</a></li> -<li><a href="#padding-role" title="The Padding Role ({P:})">Section 2.2.1.6</a></li> -<li><a href="#the-title-role-t" title="The Title Role ({T:})">Section 2.2.1.7</a></li> -<li><a href="#the-units-role-u" title="The Units Role ({U:})">Section 2.2.1.8</a></li> -<li><a href="#the-value-role-v-and-" title="The Value Role ({V:} and {:})">Section 2.2.1.9</a></li> -<li><a href="#anchor-role" title="The Anchor Roles ({[:} and {]:})">Section 2.2.1.10</a></li> +<li><a href="#color-role" title="The Color Role ({C:})">Section 3.2.1.1</a></li> +<li><a href="#the-decoration-role-d" title="The Decoration Role ({D:})">Section 3.2.1.2</a></li> +<li><a href="#gettext-role" title="The Gettext Role ({G:})">Section 3.2.1.3</a></li> +<li><a href="#the-label-role-l" title="The Label Role ({L:})">Section 3.2.1.4</a></li> +<li><a href="#the-note-role-n" title="The Note Role ({N:})">Section 3.2.1.5</a></li> +<li><a href="#padding-role" title="The Padding Role ({P:})">Section 3.2.1.6</a></li> +<li><a href="#the-title-role-t" title="The Title Role ({T:})">Section 3.2.1.7</a></li> +<li><a href="#the-units-role-u" title="The Units Role ({U:})">Section 3.2.1.8</a></li> +<li><a href="#the-value-role-v-and-" title="The Value Role ({V:} and {:})">Section 3.2.1.9</a></li> +<li><a href="#anchor-role" title="The Anchor Roles ({[:} and {]:})">Section 3.2.1.10</a></li> </ul> <div class="content"> -<h4 id="doc_section_2_2_1_1"> +<h4 id="doc_section_3_2_1_1"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_1">2.2.1.1</a> </div> +<a href="#doc_section_3_2_1_1">3.2.1.1</a> </div> <a id="color-role" href="#color-role">The Color Role ({C:})</a> </h4> -<p id="doc_section_2_2_1_1_p_1">Colors and effects control how text values are displayed; they are used for display styles (TEXT and HTML).</p> -<div id="doc_figure_u.28"></div> <pre> - xo_emit("{C:bold}{:value}{C:no-bold}\n", value); - </pre> <p id="doc_section_2_2_1_1_p_3">Colors and effects remain in effect until modified by other "C"-role fields.</p> +<p id="doc_section_3_2_1_1_p_1">Colors and effects control how text values are displayed; they are used for display styles (TEXT and HTML).</p> <div id="doc_figure_u.29"></div> <pre> - xo_emit("{C:bold}{C:inverse}both{C:no-bold}only inverse\n"); - </pre> <p id="doc_section_2_2_1_1_p_5">If the content is empty, the "reset" action is performed.</p> + xo_emit("{C:bold}{:value}{C:no-bold}\n", value); + </pre> <p id="doc_section_3_2_1_1_p_3">Colors and effects remain in effect until modified by other "C"-role fields.</p> <div id="doc_figure_u.30"></div> <pre> - xo_emit("{C:both,underline}{:value}{C:}\n", value); - </pre> <p id="doc_section_2_2_1_1_p_7">The content should be a comma-separated list of zero or more colors or display effects.</p> + xo_emit("{C:bold}{C:inverse}both{C:no-bold}only inverse\n"); + </pre> <p id="doc_section_3_2_1_1_p_5">If the content is empty, the "reset" action is performed.</p> <div id="doc_figure_u.31"></div> <pre> - xo_emit("{C:bold,inverse}Ugly{C:no-bold,no-inverse}\n"); - </pre> <p id="doc_section_2_2_1_1_p_9">The color content can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"):</p> + xo_emit("{C:both,underline}{:value}{C:}\n", value); + </pre> <p id="doc_section_3_2_1_1_p_7">The content should be a comma-separated list of zero or more colors or display effects.</p> <div id="doc_figure_u.32"></div> <pre> + xo_emit("{C:bold,inverse}Ugly{C:no-bold,no-inverse}\n"); + </pre> <p id="doc_section_3_2_1_1_p_9">The color content can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"):</p> +<div id="doc_figure_u.33"></div> <pre> xo_emit("{C:/%s%s}{:value}{C:}", need_bold ? "bold" : "", need_underline ? "underline" : "", value); - </pre> <p id="doc_section_2_2_1_1_p_11">Color names are prefixed with either "fg‑" or "bg‑" to change the foreground and background colors, respectively.</p> -<div id="doc_figure_u.33"></div> <pre> + </pre> <p id="doc_section_3_2_1_1_p_11">Color names are prefixed with either "fg‑" or "bg‑" to change the foreground and background colors, respectively.</p> +<div id="doc_figure_u.34"></div> <pre> xo_emit("{C:/fg-%s,bg-%s}{Lwc:Cost}{:cost/%u}{C:reset}\n", fg_color, bg_color, cost); - </pre> <p id="doc_section_2_2_1_1_p_13">The following table lists the supported effects:</p> + </pre> <p id="doc_section_3_2_1_1_p_13">The following table lists the supported effects:</p> <div id="doc_table_u.2"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Name</th> @@ -23181,7 +23222,7 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_2_2_1_1_p_14">The following color names are supported:</p> +<p id="doc_section_3_2_1_1_p_14">The following color names are supported:</p> <div id="doc_table_u.3"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Name</th> @@ -23226,135 +23267,136 @@ jQuery(function ($) { </tr> </tbody> </table></div> +<p id="doc_section_3_2_1_1_p_15">When using colors, the developer should remember that users will change the foreground and background colors of terminal session according to their own tastes, so assuming that "blue" looks nice is never safe, and is a constant annoyance to your dear author. In addition, a significant percentage of users (1 in 12) will be color blind. Depending on color to convey critical information is not a good idea. Color should enhance output, but should not be used as the sole means of encoding information.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_1_2"> +<h4 id="doc_section_3_2_1_2"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_2">2.2.1.2</a> </div> +<a href="#doc_section_3_2_1_2">3.2.1.2</a> </div> <a id="the-decoration-role-d" href="#the-decoration-role-d">The Decoration Role ({D:})</a> </h4> -<p id="doc_section_2_2_1_2_p_1">Decorations are typically punctuation marks such as colons, semi-colons, and commas used to decorate the text and make it simpler for human readers. By marking these distinctly, HTML usage scenarios can use CSS to direct their display parameters.</p> -<div id="doc_figure_u.34"></div> <pre> +<p id="doc_section_3_2_1_2_p_1">Decorations are typically punctuation marks such as colons, semi-colons, and commas used to decorate the text and make it simpler for human readers. By marking these distinctly, HTML usage scenarios can use CSS to direct their display parameters.</p> +<div id="doc_figure_u.35"></div> <pre> xo_emit("{D:((}{:name}{D:))}\n", name); </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_1_3"> +<h4 id="doc_section_3_2_1_3"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_3">2.2.1.3</a> </div> +<a href="#doc_section_3_2_1_3">3.2.1.3</a> </div> <a id="gettext-role" href="#gettext-role">The Gettext Role ({G:})</a> </h4> -<p id="doc_section_2_2_1_3_p_1">libxo supports internationalization (i18n) through its use of gettext(3). Use the "{G:}" role to request that the remaining part of the format string, following the "{G:}" field, be handled using gettext().</p> -<p id="doc_section_2_2_1_3_p_2">Since gettext() uses the string as the key into the message catalog, libxo uses a simplified version of the format string that removes unimportant field formatting and modifiers, stopping minor formatting changes from impacting the expensive translation process. A developer change such as changing "/%06d" to "/%08d" should not force hand inspection of all .po files.</p> -<p id="doc_section_2_2_1_3_p_3">The simplified version can be generated for a single message using the "xopo -s <text>" command, or an entire .pot can be translated using the "xopo -f <input> -o <output>" command.</p> -<div id="doc_figure_u.35"></div> <pre> - xo_emit("{G:}Invalid token\n"); - </pre> <p id="doc_section_2_2_1_3_p_5">The {G:} role allows a domain name to be set. gettext calls will continue to use that domain name until the current format string processing is complete, enabling a library function to emit strings using it's own catalog. The domain name can be either static as the content of the field, or a format can be used to get the domain name from the arguments.</p> +<p id="doc_section_3_2_1_3_p_1">libxo supports internationalization (i18n) through its use of gettext(3). Use the "{G:}" role to request that the remaining part of the format string, following the "{G:}" field, be handled using gettext().</p> +<p id="doc_section_3_2_1_3_p_2">Since gettext() uses the string as the key into the message catalog, libxo uses a simplified version of the format string that removes unimportant field formatting and modifiers, stopping minor formatting changes from impacting the expensive translation process. A developer change such as changing "/%06d" to "/%08d" should not force hand inspection of all .po files.</p> +<p id="doc_section_3_2_1_3_p_3">The simplified version can be generated for a single message using the "xopo -s <text>" command, or an entire .pot can be translated using the "xopo -f <input> -o <output>" command.</p> <div id="doc_figure_u.36"></div> <pre> + xo_emit("{G:}Invalid token\n"); + </pre> <p id="doc_section_3_2_1_3_p_5">The {G:} role allows a domain name to be set. gettext calls will continue to use that domain name until the current format string processing is complete, enabling a library function to emit strings using it's own catalog. The domain name can be either static as the content of the field, or a format can be used to get the domain name from the arguments.</p> +<div id="doc_figure_u.37"></div> <pre> xo_emit("{G:libc}Service unavailable in restricted mode\n"); - </pre> <p id="doc_section_2_2_1_3_p_7">See <a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 9.5</a> for additional details.</p> + </pre> <p id="doc_section_3_2_1_3_p_7">See <a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 11.5</a> for additional details.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_1_4"> +<h4 id="doc_section_3_2_1_4"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_4">2.2.1.4</a> </div> +<a href="#doc_section_3_2_1_4">3.2.1.4</a> </div> <a id="the-label-role-l" href="#the-label-role-l">The Label Role ({L:})</a> </h4> -<p id="doc_section_2_2_1_4_p_1">Labels are text that appears before a value.</p> -<div id="doc_figure_u.37"></div> <pre> +<p id="doc_section_3_2_1_4_p_1">Labels are text that appears before a value.</p> +<div id="doc_figure_u.38"></div> <pre> xo_emit("{Lwc:Cost}{:cost/%u}\n", cost); </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_1_5"> +<h4 id="doc_section_3_2_1_5"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_5">2.2.1.5</a> </div> +<a href="#doc_section_3_2_1_5">3.2.1.5</a> </div> <a id="the-note-role-n" href="#the-note-role-n">The Note Role ({N:})</a> </h4> -<p id="doc_section_2_2_1_5_p_1">Notes are text that appears after a value.</p> -<div id="doc_figure_u.38"></div> <pre> +<p id="doc_section_3_2_1_5_p_1">Notes are text that appears after a value.</p> +<div id="doc_figure_u.39"></div> <pre> xo_emit("{:cost/%u} {N:per year}\n", cost); </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_1_6"> +<h4 id="doc_section_3_2_1_6"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_6">2.2.1.6</a> </div> +<a href="#doc_section_3_2_1_6">3.2.1.6</a> </div> <a id="padding-role" href="#padding-role">The Padding Role ({P:})</a> </h4> -<p id="doc_section_2_2_1_6_p_1">Padding represents whitespace used before and between fields.</p> -<p id="doc_section_2_2_1_6_p_2">The padding content can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"):</p> -<div id="doc_figure_u.39"></div> <pre> +<p id="doc_section_3_2_1_6_p_1">Padding represents whitespace used before and between fields.</p> +<p id="doc_section_3_2_1_6_p_2">The padding content can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"):</p> +<div id="doc_figure_u.40"></div> <pre> xo_emit("{P: }{Lwc:Cost}{:cost/%u}\n", cost); xo_emit("{P:/%30s}{Lwc:Cost}{:cost/%u}\n", "", cost); </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_1_7"> +<h4 id="doc_section_3_2_1_7"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_7">2.2.1.7</a> </div> +<a href="#doc_section_3_2_1_7">3.2.1.7</a> </div> <a id="the-title-role-t" href="#the-title-role-t">The Title Role ({T:})</a> </h4> -<p id="doc_section_2_2_1_7_p_1">Title are heading or column headers that are meant to be displayed to the user. The title can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"):</p> -<div id="doc_figure_u.40"></div> <pre> +<p id="doc_section_3_2_1_7_p_1">Title are heading or column headers that are meant to be displayed to the user. The title can be either static, when placed directly within the field descriptor, or a printf-style format descriptor can be used, if preceded by a slash ("/"):</p> +<div id="doc_figure_u.41"></div> <pre> xo_emit("{T:Interface Statistics}\n"); xo_emit("{T:/%20.20s}{T:/%6.6s}\n", "Item Name", "Cost"); - </pre> <p id="doc_section_2_2_1_7_p_3">Title fields have an extra convenience feature; if both content and format are specified, instead of looking to the argument list for a value, the content is used, allowing a mixture of format and content within the field descriptor:</p> -<div id="doc_figure_u.41"></div> <pre> + </pre> <p id="doc_section_3_2_1_7_p_3">Title fields have an extra convenience feature; if both content and format are specified, instead of looking to the argument list for a value, the content is used, allowing a mixture of format and content within the field descriptor:</p> +<div id="doc_figure_u.42"></div> <pre> xo_emit("{T:Name/%20s}{T:Count/%6s}\n"); - </pre> <p id="doc_section_2_2_1_7_p_5">Since the incoming argument is a string, the format must be "%s" or something suitable.</p> + </pre> <p id="doc_section_3_2_1_7_p_5">Since the incoming argument is a string, the format must be "%s" or something suitable.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_1_8"> +<h4 id="doc_section_3_2_1_8"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_8">2.2.1.8</a> </div> +<a href="#doc_section_3_2_1_8">3.2.1.8</a> </div> <a id="the-units-role-u" href="#the-units-role-u">The Units Role ({U:})</a> </h4> -<p id="doc_section_2_2_1_8_p_1">Units are the dimension by which values are measured, such as degrees, miles, bytes, and decibels. The units field carries this information for the previous value field.</p> -<div id="doc_figure_u.42"></div> <pre> - xo_emit("{Lwc:Distance}{:distance/%u}{Uw:miles}\n", miles); - </pre> <p id="doc_section_2_2_1_8_p_3">Note that the sense of the 'w' modifier is reversed for units; a blank is added before the contents, rather than after it.</p> -<p id="doc_section_2_2_1_8_p_4">When the XOF_UNITS flag is set, units are rendered in XML as the "units" attribute:</p> +<p id="doc_section_3_2_1_8_p_1">Units are the dimension by which values are measured, such as degrees, miles, bytes, and decibels. The units field carries this information for the previous value field.</p> <div id="doc_figure_u.43"></div> <pre> - <distance units="miles">50</distance> - </pre> <p id="doc_section_2_2_1_8_p_6">Units can also be rendered in HTML as the "data‑units" attribute:</p> + xo_emit("{Lwc:Distance}{:distance/%u}{Uw:miles}\n", miles); + </pre> <p id="doc_section_3_2_1_8_p_3">Note that the sense of the 'w' modifier is reversed for units; a blank is added before the contents, rather than after it.</p> +<p id="doc_section_3_2_1_8_p_4">When the XOF_UNITS flag is set, units are rendered in XML as the "units" attribute:</p> <div id="doc_figure_u.44"></div> <pre> + <distance units="miles">50</distance> + </pre> <p id="doc_section_3_2_1_8_p_6">Units can also be rendered in HTML as the "data‑units" attribute:</p> +<div id="doc_figure_u.45"></div> <pre> <div class="data" data-tag="distance" data-units="miles" data-xpath="/top/data/distance">50</div> </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_1_9"> +<h4 id="doc_section_3_2_1_9"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_9">2.2.1.9</a> </div> +<a href="#doc_section_3_2_1_9">3.2.1.9</a> </div> <a id="the-value-role-v-and-" href="#the-value-role-v-and-">The Value Role ({V:} and {:})</a> </h4> -<p id="doc_section_2_2_1_9_p_1">The value role is used to represent the a data value that is interesting for the non-display output styles (XML and JSON). Value is the default role; if no other role designation is given, the field is a value. The field name must appear within the field descriptor, followed by one or two format descriptors. The first format descriptor is used for display styles (TEXT and HTML), while the second one is used for encoding styles (XML and JSON). If no second format is given, the encoding format defaults to the first format, with any minimum width removed. If no first format is given, both format descriptors default to "%s".</p> -<div id="doc_figure_u.45"></div> <pre> +<p id="doc_section_3_2_1_9_p_1">The value role is used to represent the a data value that is interesting for the non-display output styles (XML and JSON). Value is the default role; if no other role designation is given, the field is a value. The field name must appear within the field descriptor, followed by one or two format descriptors. The first format descriptor is used for display styles (TEXT and HTML), while the second one is used for encoding styles (XML and JSON). If no second format is given, the encoding format defaults to the first format, with any minimum width removed. If no first format is given, both format descriptors default to "%s".</p> +<div id="doc_figure_u.46"></div> <pre> xo_emit("{:length/%02u}x{:width/%02u}x{:height/%02u}\n", length, width, height); xo_emit("{:author} wrote \"{:poem}\" in {:year/%4d}\n, author, poem, year); </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_1_10"> +<h4 id="doc_section_3_2_1_10"> <div class="self-section-number"> -<a href="#doc_section_2_2_1_10">2.2.1.10</a> </div> +<a href="#doc_section_3_2_1_10">3.2.1.10</a> </div> <a id="anchor-role" href="#anchor-role">The Anchor Roles ({[:} and {]:})</a> </h4> -<p id="doc_section_2_2_1_10_p_1">The anchor roles allow a set of strings by be padded as a group, but still be visible to xo_emit as distinct fields. Either the start or stop anchor can give a field width and it can be either directly in the descriptor or passed as an argument. Any fields between the start and stop anchor are padded to meet the minimum width given.</p> -<p id="doc_section_2_2_1_10_p_2">To give a width directly, encode it as the content of the anchor tag:</p> -<div id="doc_figure_u.46"></div> <pre> - xo_emit("({[:10}{:min/%d}/{:max/%d}{]:})\n", min, max); - </pre> <p id="doc_section_2_2_1_10_p_4">To pass a width as an argument, use "%d" as the format, which must appear after the "/". Note that only "%d" is supported for widths. Using any other value could ruin your day.</p> +<p id="doc_section_3_2_1_10_p_1">The anchor roles allow a set of strings by be padded as a group, but still be visible to xo_emit as distinct fields. Either the start or stop anchor can give a field width and it can be either directly in the descriptor or passed as an argument. Any fields between the start and stop anchor are padded to meet the minimum width given.</p> +<p id="doc_section_3_2_1_10_p_2">To give a width directly, encode it as the content of the anchor tag:</p> <div id="doc_figure_u.47"></div> <pre> + xo_emit("({[:10}{:min/%d}/{:max/%d}{]:})\n", min, max); + </pre> <p id="doc_section_3_2_1_10_p_4">To pass a width as an argument, use "%d" as the format, which must appear after the "/". Note that only "%d" is supported for widths. Using any other value could ruin your day.</p> +<div id="doc_figure_u.48"></div> <pre> xo_emit("({[:/%d}{:min/%d}/{:max/%d}{]:})\n", width, min, max); - </pre> <p id="doc_section_2_2_1_10_p_6">If the width is negative, padding will be added on the right, suitable for left justification. Otherwise the padding will be added to the left of the fields between the start and stop anchors, suitable for right justification. If the width is zero, nothing happens. If the number of columns of output between the start and stop anchors is less than the absolute value of the given width, nothing happens.</p> -<p id="doc_section_2_2_1_10_p_7">Widths over 8k are considered probable errors and not supported. If XOF_WARN is set, a warning will be generated.</p> + </pre> <p id="doc_section_3_2_1_10_p_6">If the width is negative, padding will be added on the right, suitable for left justification. Otherwise the padding will be added to the left of the fields between the start and stop anchors, suitable for right justification. If the width is zero, nothing happens. If the number of columns of output between the start and stop anchors is less than the absolute value of the given width, nothing happens.</p> +<p id="doc_section_3_2_1_10_p_7">Widths over 8k are considered probable errors and not supported. If XOF_WARN is set, a warning will be generated.</p> </div> </div> <div class="content"> -<h3 id="doc_section_2_2_2"> +<h3 id="doc_section_3_2_2"> <div class="self-section-number"> -<a href="#doc_section_2_2_2">2.2.2</a> </div> +<a href="#doc_section_3_2_2">3.2.2</a> </div> <a id="field-modifiers" href="#field-modifiers">Field Modifiers</a> </h3> -<p id="doc_section_2_2_2_p_1">Field modifiers are flags which modify the way content emitted for particular output styles:</p> +<p id="doc_section_3_2_2_p_1">Field modifiers are flags which modify the way content emitted for particular output styles:</p> <div id="doc_table_u.4"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">M</th> @@ -23444,31 +23486,31 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_2_2_2_p_2">Roles and modifiers can also use more verbose names, when preceded by a comma. For example, the modifier string "Lwc" (or "L,white,colon") means the field has a label role (text that describes the next field) and should be followed by a colon ('c') and a space ('w'). The modifier string "Vkq" (or ":key,quote") means the field has a value role (the default role), that it is a key for the current instance, and that the value should be quoted when encoded for JSON.</p> -<p id="doc_section_2_2_2_p_3">Section Contents: </p> +<p id="doc_section_3_2_2_p_2">Roles and modifiers can also use more verbose names, when preceded by a comma. For example, the modifier string "Lwc" (or "L,white,colon") means the field has a label role (text that describes the next field) and should be followed by a colon ('c') and a space ('w'). The modifier string "Vkq" (or ":key,quote") means the field has a value role (the default role), that it is a key for the current instance, and that the value should be quoted when encoded for JSON.</p> +<p id="doc_section_3_2_2_p_3">Section Contents: </p> <ul> -<li><a href="#the-argument-modifier-a" title="The Argument Modifier ({a:})">Section 2.2.2.1</a></li> -<li><a href="#the-colon-modifier-c" title="The Colon Modifier ({c:})">Section 2.2.2.2</a></li> -<li><a href="#the-display-modifier-d" title="The Display Modifier ({d:})">Section 2.2.2.3</a></li> -<li><a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 2.2.2.4</a></li> -<li><a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 2.2.2.5</a></li> -<li><a href="#the-humanize-modifier-h" title="The Humanize Modifier ({h:})">Section 2.2.2.6</a></li> -<li><a href="#the-key-modifier-k" title="The Key Modifier ({k:})">Section 2.2.2.7</a></li> -<li><a href="#the-leaf-list-modifier-l" title="The Leaf-List Modifier ({l:})">Section 2.2.2.8</a></li> -<li><a href="#the-no-quotes-modifier-n" title="The No-Quotes Modifier ({n:})">Section 2.2.2.9</a></li> -<li><a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 2.2.2.10</a></li> -<li><a href="#the-quotes-modifier-q" title="The Quotes Modifier ({q:})">Section 2.2.2.11</a></li> -<li><a href="#the-trim-modifier-t" title="The Trim Modifier ({t:})">Section 2.2.2.12</a></li> -<li><a href="#the-white-space-modifier-w" title="The White Space Modifier ({w:})">Section 2.2.2.13</a></li> +<li><a href="#the-argument-modifier-a" title="The Argument Modifier ({a:})">Section 3.2.2.1</a></li> +<li><a href="#the-colon-modifier-c" title="The Colon Modifier ({c:})">Section 3.2.2.2</a></li> +<li><a href="#the-display-modifier-d" title="The Display Modifier ({d:})">Section 3.2.2.3</a></li> +<li><a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 3.2.2.4</a></li> +<li><a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 3.2.2.5</a></li> +<li><a href="#the-humanize-modifier-h" title="The Humanize Modifier ({h:})">Section 3.2.2.6</a></li> +<li><a href="#the-key-modifier-k" title="The Key Modifier ({k:})">Section 3.2.2.7</a></li> +<li><a href="#the-leaf-list-modifier-l" title="The Leaf-List Modifier ({l:})">Section 3.2.2.8</a></li> +<li><a href="#the-no-quotes-modifier-n" title="The No-Quotes Modifier ({n:})">Section 3.2.2.9</a></li> +<li><a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 3.2.2.10</a></li> +<li><a href="#the-quotes-modifier-q" title="The Quotes Modifier ({q:})">Section 3.2.2.11</a></li> +<li><a href="#the-trim-modifier-t" title="The Trim Modifier ({t:})">Section 3.2.2.12</a></li> +<li><a href="#the-white-space-modifier-w" title="The White Space Modifier ({w:})">Section 3.2.2.13</a></li> </ul> <div class="content"> -<h4 id="doc_section_2_2_2_1"> +<h4 id="doc_section_3_2_2_1"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_1">2.2.2.1</a> </div> +<a href="#doc_section_3_2_2_1">3.2.2.1</a> </div> <a id="the-argument-modifier-a" href="#the-argument-modifier-a">The Argument Modifier ({a:})</a> </h4> -<p id="doc_section_2_2_2_1_p_1">The argument modifier indicates that the content of the field descriptor will be placed as a UTF-8 string (const char *) argument within the xo_emit parameters.</p> -<div id="doc_figure_u.48"></div> <pre> +<p id="doc_section_3_2_2_1_p_1">The argument modifier indicates that the content of the field descriptor will be placed as a UTF-8 string (const char *) argument within the xo_emit parameters.</p> +<div id="doc_figure_u.49"></div> <pre> EXAMPLE: xo_emit("{La:} {a:}\n", "Label text", "label", "value"); TEXT: @@ -23477,77 +23519,77 @@ jQuery(function ($) { "label": "value" XML: <label>value</label> - </pre> <p id="doc_section_2_2_2_1_p_3">The argument modifier allows field names for value fields to be passed on the stack, avoiding the need to build a field descriptor using snprintf. For many field roles, the argument modifier is not needed, since those roles have specific mechanisms for arguments, such as "{C:fg‑%s}".</p> + </pre> <p id="doc_section_3_2_2_1_p_3">The argument modifier allows field names for value fields to be passed on the stack, avoiding the need to build a field descriptor using snprintf. For many field roles, the argument modifier is not needed, since those roles have specific mechanisms for arguments, such as "{C:fg‑%s}".</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_2"> +<h4 id="doc_section_3_2_2_2"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_2">2.2.2.2</a> </div> +<a href="#doc_section_3_2_2_2">3.2.2.2</a> </div> <a id="the-colon-modifier-c" href="#the-colon-modifier-c">The Colon Modifier ({c:})</a> </h4> -<p id="doc_section_2_2_2_2_p_1">The colon modifier appends a single colon to the data value:</p> -<div id="doc_figure_u.49"></div> <pre> +<p id="doc_section_3_2_2_2_p_1">The colon modifier appends a single colon to the data value:</p> +<div id="doc_figure_u.50"></div> <pre> EXAMPLE: xo_emit("{Lc:Name}{:name}\n", "phil"); TEXT: Name:phil - </pre> <p id="doc_section_2_2_2_2_p_3">The colon modifier is only used for the TEXT and HTML output styles. It is commonly combined with the space modifier ('{w:}'). It is purely a convenience feature.</p> + </pre> <p id="doc_section_3_2_2_2_p_3">The colon modifier is only used for the TEXT and HTML output styles. It is commonly combined with the space modifier ('{w:}'). It is purely a convenience feature.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_3"> +<h4 id="doc_section_3_2_2_3"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_3">2.2.2.3</a> </div> +<a href="#doc_section_3_2_2_3">3.2.2.3</a> </div> <a id="the-display-modifier-d" href="#the-display-modifier-d">The Display Modifier ({d:})</a> </h4> -<p id="doc_section_2_2_2_3_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p> -<div id="doc_figure_u.50"></div> <pre> +<p id="doc_section_3_2_2_3_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p> +<div id="doc_figure_u.51"></div> <pre> EXAMPLE: xo_emit("{Lcw:Name}{d:name} {:id/%d}\n", "phil", 1); TEXT: Name: phil 1 XML: <id>1</id> - </pre> <p id="doc_section_2_2_2_3_p_3">The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data.</p> + </pre> <p id="doc_section_3_2_2_3_p_3">The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_4"> +<h4 id="doc_section_3_2_2_4"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_4">2.2.2.4</a> </div> +<a href="#doc_section_3_2_2_4">3.2.2.4</a> </div> <a id="e-modifier" href="#e-modifier">The Encoding Modifier ({e:})</a> </h4> -<p id="doc_section_2_2_2_4_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p> -<div id="doc_figure_u.51"></div> <pre> +<p id="doc_section_3_2_2_4_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p> +<div id="doc_figure_u.52"></div> <pre> EXAMPLE: xo_emit("{Lcw:Name}{:name} {e:id/%d}\n", "phil", 1); TEXT: Name: phil XML: <name>phil</name><id>1</id> - </pre> <p id="doc_section_2_2_2_4_p_3">The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data.</p> + </pre> <p id="doc_section_3_2_2_4_p_3">The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_5"> +<h4 id="doc_section_3_2_2_5"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_5">2.2.2.5</a> </div> +<a href="#doc_section_3_2_2_5">3.2.2.5</a> </div> <a id="gettext-modifier" href="#gettext-modifier">The Gettext Modifier ({g:})</a> </h4> -<p id="doc_section_2_2_2_5_p_1">The gettext modifier is used to translate individual fields using the gettext domain (typically set using the "{G:}" role) and current language settings. Once libxo renders the field value, it is passed to gettext(3), where it is used as a key to find the native language translation.</p> -<p id="doc_section_2_2_2_5_p_2">In the following example, the strings "State" and "full" are passed to gettext() to find locale-based translated strings.</p> -<div id="doc_figure_u.52"></div> <pre> +<p id="doc_section_3_2_2_5_p_1">The gettext modifier is used to translate individual fields using the gettext domain (typically set using the "{G:}" role) and current language settings. Once libxo renders the field value, it is passed to gettext(3), where it is used as a key to find the native language translation.</p> +<p id="doc_section_3_2_2_5_p_2">In the following example, the strings "State" and "full" are passed to gettext() to find locale-based translated strings.</p> +<div id="doc_figure_u.53"></div> <pre> xo_emit("{Lgwc:State}{g:state}\n", "full"); - </pre> <p id="doc_section_2_2_2_5_p_4">See <a href="#gettext-role" title="The Gettext Role ({G:})">Section 2.2.1.3</a>, <a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 2.2.2.10</a>, and <a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 9.5</a> for additional details.</p> + </pre> <p id="doc_section_3_2_2_5_p_4">See <a href="#gettext-role" title="The Gettext Role ({G:})">Section 3.2.1.3</a>, <a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 3.2.2.10</a>, and <a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 11.5</a> for additional details.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_6"> +<h4 id="doc_section_3_2_2_6"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_6">2.2.2.6</a> </div> +<a href="#doc_section_3_2_2_6">3.2.2.6</a> </div> <a id="the-humanize-modifier-h" href="#the-humanize-modifier-h">The Humanize Modifier ({h:})</a> </h4> -<p id="doc_section_2_2_2_6_p_1">The humanize modifier is used to render large numbers as in a human-readable format. While numbers like "44470272" are completely readable to computers and savants, humans will generally find "44M" more meaningful.</p> -<p id="doc_section_2_2_2_6_p_2">"hn" can be used as an alias for "humanize".</p> -<p id="doc_section_2_2_2_6_p_3">The humanize modifier only affects display styles (TEXT and HMTL). The "no‑humanize" option (See <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a>) will block the function of the humanize modifier.</p> -<p id="doc_section_2_2_2_6_p_4">There are a number of modifiers that affect details of humanization. These are only available in as full names, not single characters. The "hn‑space" modifier places a space between the number and any multiplier symbol, such as "M" or "K" (ex: "44 K"). The "hn‑decimal" modifier will add a decimal point and a single tenths digit when the number is less than 10 (ex: "4.4K"). The "hn‑1000" modifier will use 1000 as divisor instead of 1024, following the JEDEC-standard instead of the more natural binary powers-of-two tradition.</p> -<div id="doc_figure_u.53"></div> <pre> +<p id="doc_section_3_2_2_6_p_1">The humanize modifier is used to render large numbers as in a human-readable format. While numbers like "44470272" are completely readable to computers and savants, humans will generally find "44M" more meaningful.</p> +<p id="doc_section_3_2_2_6_p_2">"hn" can be used as an alias for "humanize".</p> +<p id="doc_section_3_2_2_6_p_3">The humanize modifier only affects display styles (TEXT and HMTL). The "no‑humanize" option (See <a href="#options" title="Command-line Arguments">Section 4</a>) will block the function of the humanize modifier.</p> +<p id="doc_section_3_2_2_6_p_4">There are a number of modifiers that affect details of humanization. These are only available in as full names, not single characters. The "hn‑space" modifier places a space between the number and any multiplier symbol, such as "M" or "K" (ex: "44 K"). The "hn‑decimal" modifier will add a decimal point and a single tenths digit when the number is less than 10 (ex: "4.4K"). The "hn‑1000" modifier will use 1000 as divisor instead of 1024, following the JEDEC-standard instead of the more natural binary powers-of-two tradition.</p> +<div id="doc_figure_u.54"></div> <pre> EXAMPLE: xo_emit("{h:input/%u}, {h,hn-space:output/%u}, " "{h,hn-decimal:errors/%u}, {h,hn-1000:capacity/%u}, " @@ -23555,19 +23597,19 @@ jQuery(function ($) { input, output, errors, capacity, remaining); TEXT: 21, 57 K, 96M, 44M, 1.2G - </pre> <p id="doc_section_2_2_2_6_p_6">In the HTML style, the original numeric value is rendered in the "data‑number" attribute on the <div> element:</p> -<div id="doc_figure_u.54"></div> <pre> + </pre> <p id="doc_section_3_2_2_6_p_6">In the HTML style, the original numeric value is rendered in the "data‑number" attribute on the <div> element:</p> +<div id="doc_figure_u.55"></div> <pre> <div class="data" data-tag="errors" data-number="100663296">96M</div> </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_2_7"> +<h4 id="doc_section_3_2_2_7"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_7">2.2.2.7</a> </div> +<a href="#doc_section_3_2_2_7">3.2.2.7</a> </div> <a id="the-key-modifier-k" href="#the-key-modifier-k">The Key Modifier ({k:})</a> </h4> -<p id="doc_section_2_2_2_7_p_1">The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data.</p> -<div id="doc_figure_u.55"></div> <pre> +<p id="doc_section_3_2_2_7_p_1">The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data.</p> +<div id="doc_figure_u.56"></div> <pre> EXAMPLE: xo_open_list("user"); for (i = 0; i < num_users; i++) { @@ -23577,16 +23619,16 @@ jQuery(function ($) { xo_close_instance("user"); } xo_close_list("user"); - </pre> <p id="doc_section_2_2_2_7_p_3">Currently the key modifier is only used when generating XPath value for the HTML output style when XOF_XPATH is set, but other uses are likely in the near future.</p> + </pre> <p id="doc_section_3_2_2_7_p_3">Currently the key modifier is only used when generating XPath value for the HTML output style when XOF_XPATH is set, but other uses are likely in the near future.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_8"> +<h4 id="doc_section_3_2_2_8"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_8">2.2.2.8</a> </div> +<a href="#doc_section_3_2_2_8">3.2.2.8</a> </div> <a id="the-leaf-list-modifier-l" href="#the-leaf-list-modifier-l">The Leaf-List Modifier ({l:})</a> </h4> -<p id="doc_section_2_2_2_8_p_1">The leaf-list modifier is used to distinguish lists where each instance consists of only a single value. In XML, these are rendered as single elements, where JSON renders them as arrays.</p> -<div id="doc_figure_u.56"></div> <pre> +<p id="doc_section_3_2_2_8_p_1">The leaf-list modifier is used to distinguish lists where each instance consists of only a single value. In XML, these are rendered as single elements, where JSON renders them as arrays.</p> +<div id="doc_figure_u.57"></div> <pre> EXAMPLE: for (i = 0; i < num_users; i++) { xo_emit("Member {l:user}\n", user[i].u_name); @@ -23596,16 +23638,16 @@ jQuery(function ($) { <user>pallavi</user> JSON: "user": [ "phil", "pallavi" ] - </pre> <p id="doc_section_2_2_2_8_p_3">The name of the field must match the name of the leaf list.</p> + </pre> <p id="doc_section_3_2_2_8_p_3">The name of the field must match the name of the leaf list.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_9"> +<h4 id="doc_section_3_2_2_9"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_9">2.2.2.9</a> </div> +<a href="#doc_section_3_2_2_9">3.2.2.9</a> </div> <a id="the-no-quotes-modifier-n" href="#the-no-quotes-modifier-n">The No-Quotes Modifier ({n:})</a> </h4> -<p id="doc_section_2_2_2_9_p_1">The no-quotes modifier (and its twin, the 'quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p> -<div id="doc_figure_u.57"></div> <pre> +<p id="doc_section_3_2_2_9_p_1">The no-quotes modifier (and its twin, the 'quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p> +<div id="doc_figure_u.58"></div> <pre> EXAMPLE: const char *bool = is_true ? "true" : "false"; xo_emit("{n:fancy/%s}", bool); @@ -23613,77 +23655,77 @@ jQuery(function ($) { "fancy": true </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_2_10"> +<h4 id="doc_section_3_2_2_10"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_10">2.2.2.10</a> </div> +<a href="#doc_section_3_2_2_10">3.2.2.10</a> </div> <a id="plural-modifier" href="#plural-modifier">The Plural Modifier ({p:})</a> </h4> -<p id="doc_section_2_2_2_10_p_1">The plural modifier selects the appropriate plural form of an expression based on the most recent number emitted and the current language settings. The contents of the field should be the singular and plural English values, separated by a comma:</p> -<div id="doc_figure_u.58"></div> <pre> +<p id="doc_section_3_2_2_10_p_1">The plural modifier selects the appropriate plural form of an expression based on the most recent number emitted and the current language settings. The contents of the field should be the singular and plural English values, separated by a comma:</p> +<div id="doc_figure_u.59"></div> <pre> xo_emit("{:bytes} {Ngp:byte,bytes}\n", bytes); - </pre> <p id="doc_section_2_2_2_10_p_3">The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. See <a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 2.2.2.5</a>.</p> -<p id="doc_section_2_2_2_10_p_4">When used without the gettext modifier or when the message does not appear in the message catalog, the first token is chosen when the last numeric value is equal to 1; otherwise the second value is used, mimicking the simple pluralization rules of English.</p> -<p id="doc_section_2_2_2_10_p_5">When used with the gettext modifier, the ngettext(3) function is called to handle the heavy lifting, using the message catalog to convert the singular and plural forms into the native language.</p> + </pre> <p id="doc_section_3_2_2_10_p_3">The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. See <a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 3.2.2.5</a>.</p> +<p id="doc_section_3_2_2_10_p_4">When used without the gettext modifier or when the message does not appear in the message catalog, the first token is chosen when the last numeric value is equal to 1; otherwise the second value is used, mimicking the simple pluralization rules of English.</p> +<p id="doc_section_3_2_2_10_p_5">When used with the gettext modifier, the ngettext(3) function is called to handle the heavy lifting, using the message catalog to convert the singular and plural forms into the native language.</p> </div> <div class="content"> -<h4 id="doc_section_2_2_2_11"> +<h4 id="doc_section_3_2_2_11"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_11">2.2.2.11</a> </div> +<a href="#doc_section_3_2_2_11">3.2.2.11</a> </div> <a id="the-quotes-modifier-q" href="#the-quotes-modifier-q">The Quotes Modifier ({q:})</a> </h4> -<p id="doc_section_2_2_2_11_p_1">The quotes modifier (and its twin, the 'no‑quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p> -<div id="doc_figure_u.59"></div> <pre> +<p id="doc_section_3_2_2_11_p_1">The quotes modifier (and its twin, the 'no‑quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p> +<div id="doc_figure_u.60"></div> <pre> EXAMPLE: xo_emit("{q:time/%d}", 2014); JSON: "year": "2014" - </pre> <p id="doc_section_2_2_2_11_p_3">The heuristic is based on the format; if the format uses any of the following conversion specifiers, then no quotes are used:</p> -<div id="doc_figure_u.60"></div> <pre> + </pre> <p id="doc_section_3_2_2_11_p_3">The heuristic is based on the format; if the format uses any of the following conversion specifiers, then no quotes are used:</p> +<div id="doc_figure_u.61"></div> <pre> d i o u x X D O U e E f F g G a A c C p </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_2_12"> +<h4 id="doc_section_3_2_2_12"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_12">2.2.2.12</a> </div> +<a href="#doc_section_3_2_2_12">3.2.2.12</a> </div> <a id="the-trim-modifier-t" href="#the-trim-modifier-t">The Trim Modifier ({t:})</a> </h4> -<p id="doc_section_2_2_2_12_p_1">The trim modifier removes any leading or trailing whitespace from the value.</p> -<div id="doc_figure_u.61"></div> <pre> +<p id="doc_section_3_2_2_12_p_1">The trim modifier removes any leading or trailing whitespace from the value.</p> +<div id="doc_figure_u.62"></div> <pre> EXAMPLE: xo_emit("{t:description}", " some input "); JSON: "description": "some input" </pre> </div> <div class="content"> -<h4 id="doc_section_2_2_2_13"> +<h4 id="doc_section_3_2_2_13"> <div class="self-section-number"> -<a href="#doc_section_2_2_2_13">2.2.2.13</a> </div> +<a href="#doc_section_3_2_2_13">3.2.2.13</a> </div> <a id="the-white-space-modifier-w" href="#the-white-space-modifier-w">The White Space Modifier ({w:})</a> </h4> -<p id="doc_section_2_2_2_13_p_1">The white space modifier appends a single space to the data value:</p> -<div id="doc_figure_u.62"></div> <pre> +<p id="doc_section_3_2_2_13_p_1">The white space modifier appends a single space to the data value:</p> +<div id="doc_figure_u.63"></div> <pre> EXAMPLE: xo_emit("{Lw:Name}{:name}\n", "phil"); TEXT: Name phil - </pre> <p id="doc_section_2_2_2_13_p_3">The white space modifier is only used for the TEXT and HTML output styles. It is commonly combined with the colon modifier ('{c:}'). It is purely a convenience feature.</p> -<p id="doc_section_2_2_2_13_p_4">Note that the sense of the 'w' modifier is reversed for the units role ({Uw:}); a blank is added before the contents, rather than after it.</p> + </pre> <p id="doc_section_3_2_2_13_p_3">The white space modifier is only used for the TEXT and HTML output styles. It is commonly combined with the colon modifier ('{c:}'). It is purely a convenience feature.</p> +<p id="doc_section_3_2_2_13_p_4">Note that the sense of the 'w' modifier is reversed for the units role ({Uw:}); a blank is added before the contents, rather than after it.</p> </div> </div> <div class="content"> -<h3 id="doc_section_2_2_3"> +<h3 id="doc_section_3_2_3"> <div class="self-section-number"> -<a href="#doc_section_2_2_3">2.2.3</a> </div> +<a href="#doc_section_3_2_3">3.2.3</a> </div> <a id="field-formatting" href="#field-formatting">Field Formatting</a> </h3> -<p id="doc_section_2_2_3_p_1">The field format is similar to the format string for printf(3). Its use varies based on the role of the field, but generally is used to format the field's contents.</p> -<p id="doc_section_2_2_3_p_2">If the format string is not provided for a value field, it defaults to "%s".</p> -<p id="doc_section_2_2_3_p_3">Note a field definition can contain zero or more printf-style 'directives', which are sequences that start with a '%' and end with one of following characters: "diouxXDOUeEfFgGaAcCsSp". Each directive is matched by one of more arguments to the xo_emit function.</p> -<p id="doc_section_2_2_3_p_4">The format string has the form:</p> -<div id="doc_figure_u.63"></div> <pre> +<p id="doc_section_3_2_3_p_1">The field format is similar to the format string for printf(3). Its use varies based on the role of the field, but generally is used to format the field's contents.</p> +<p id="doc_section_3_2_3_p_2">If the format string is not provided for a value field, it defaults to "%s".</p> +<p id="doc_section_3_2_3_p_3">Note a field definition can contain zero or more printf-style 'directives', which are sequences that start with a '%' and end with one of following characters: "diouxXDOUeEfFgGaAcCsSp". Each directive is matched by one of more arguments to the xo_emit function.</p> +<p id="doc_section_3_2_3_p_4">The format string has the form:</p> +<div id="doc_figure_u.64"></div> <pre> '%' format-modifier * format-character - </pre> <p id="doc_section_2_2_3_p_6">The format- modifier can be:</p> -<p id="doc_section_2_2_3_p_7"> </p> + </pre> <p id="doc_section_3_2_3_p_6">The format- modifier can be:</p> +<p id="doc_section_3_2_3_p_7"> </p> <ul> <li>a '#' character, indicating the output value should be prefixed with '0x', typically to indicate a base 16 (hex) value.</li> <li>a minus sign ('‑'), indicating the output value should be padded on the right instead of the left.</li> @@ -23698,8 +23740,8 @@ jQuery(function ($) { <li>a ' ' character, indicating a space should be emitted before positive numbers.</li> <li>a '+' character, indicating sign should emitted before any number.</li> </ul> -<p id="doc_section_2_2_3_p_8">Note that 'q', 'D', 'O', and 'U' are considered deprecated and will be removed eventually.</p> -<p id="doc_section_2_2_3_p_9">The format character is described in the following table:</p> +<p id="doc_section_3_2_3_p_8">Note that 'q', 'D', 'O', and 'U' are considered deprecated and will be removed eventually.</p> +<p id="doc_section_3_2_3_p_9">The format character is described in the following table:</p> <div id="doc_table_u.5"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Ltr</th> @@ -23819,7 +23861,7 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_2_2_3_p_10">The 'h' and 'l' modifiers affect the size and treatment of the argument:</p> +<p id="doc_section_3_2_3_p_10">The 'h' and 'l' modifiers affect the size and treatment of the argument:</p> <div id="doc_table_u.6"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Mod</th> @@ -23871,17 +23913,17 @@ jQuery(function ($) { </table></div> </div> <div class="content"> -<h3 id="doc_section_2_2_4"> +<h3 id="doc_section_3_2_4"> <div class="self-section-number"> -<a href="#doc_section_2_2_4">2.2.4</a> </div> +<a href="#doc_section_3_2_4">3.2.4</a> </div> <a id="utf-8-and-locale-strings" href="#utf-8-and-locale-strings">UTF-8 and Locale Strings</a> </h3> -<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‑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}", +<p id="doc_section_3_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‑8".</p> +<p id="doc_section_3_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.65"></div> <pre> + 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> + </pre> <p id="doc_section_3_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"> <thead><tr> <th class="left">Format</th> @@ -23911,8 +23953,8 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_2_2_4_p_5">For example, a function is passed a locale-base name, a hat size, and a time value. The hat size is formatted in a UTF-8 (ASCII) string, and the time value is formatted into a wchar_t string.</p> -<div id="doc_figure_u.65"></div> <pre> +<p id="doc_section_3_2_4_p_5">For example, a function is passed a locale-base name, a hat size, and a time value. The hat size is formatted in a UTF-8 (ASCII) string, and the time value is formatted into a wchar_t string.</p> +<div id="doc_figure_u.66"></div> <pre> void print_order (const char *name, int size, struct tm *timep) { char buf[32]; @@ -23931,20 +23973,20 @@ jQuery(function ($) { xo_emit("It was ordered on {:order-time/%ls}.\n", when); } - </pre> <p id="doc_section_2_2_4_p_7">It is important to note that xo_emit will perform the conversion required to make appropriate output. Text style output uses the current locale (as described above), while XML, JSON, and HTML use UTF-8.</p> -<p id="doc_section_2_2_4_p_8">UTF-8 and locale-encoded strings can use multiple bytes to encode one column of data. The traditional "precision'" (aka "max‑width") value for "%s" printf formatting becomes overloaded since it specifies both the number of bytes that can be safely referenced and the maximum number of columns to emit. xo_emit uses the precision as the former, and adds a third value for specifying the maximum number of columns.</p> -<p id="doc_section_2_2_4_p_9">In this example, the name field is printed with a minimum of 3 columns and a maximum of 6. Up to ten bytes of data at the location given by 'name' are in used in filling those columns.</p> -<div id="doc_figure_u.66"></div> <pre> + </pre> <p id="doc_section_3_2_4_p_7">It is important to note that xo_emit will perform the conversion required to make appropriate output. Text style output uses the current locale (as described above), while XML, JSON, and HTML use UTF-8.</p> +<p id="doc_section_3_2_4_p_8">UTF-8 and locale-encoded strings can use multiple bytes to encode one column of data. The traditional "precision'" (aka "max‑width") value for "%s" printf formatting becomes overloaded since it specifies both the number of bytes that can be safely referenced and the maximum number of columns to emit. xo_emit uses the precision as the former, and adds a third value for specifying the maximum number of columns.</p> +<p id="doc_section_3_2_4_p_9">In this example, the name field is printed with a minimum of 3 columns and a maximum of 6. Up to ten bytes of data at the location given by 'name' are in used in filling those columns.</p> +<div id="doc_figure_u.67"></div> <pre> xo_emit("{:name/%3.10.6s}", name); </pre> </div> <div class="content"> -<h3 id="doc_section_2_2_5"> +<h3 id="doc_section_3_2_5"> <div class="self-section-number"> -<a href="#doc_section_2_2_5">2.2.5</a> </div> +<a href="#doc_section_3_2_5">3.2.5</a> </div> <a id="characters-outside-of-field-definitions" href="#characters-outside-of-field-definitions">Characters Outside of Field Definitions</a> </h3> -<p id="doc_section_2_2_5_p_1">Characters in the format string that are not part of a field definition are copied to the output for the TEXT style, and are ignored for the JSON and XML styles. For HTML, these characters are placed in a <div> with class "text".</p> -<div id="doc_figure_u.67"></div> <pre> +<p id="doc_section_3_2_5_p_1">Characters in the format string that are not part of a field definition are copied to the output for the TEXT style, and are ignored for the JSON and XML styles. For HTML, these characters are placed in a <div> with class "text".</p> +<div id="doc_figure_u.68"></div> <pre> EXAMPLE: xo_emit("The hat is {:size/%s}.\n", size_val); TEXT: @@ -23959,51 +24001,51 @@ jQuery(function ($) { <div class="text">.</div> </pre> </div> <div class="content"> -<h3 id="doc_section_2_2_6"> +<h3 id="doc_section_3_2_6"> <div class="self-section-number"> -<a href="#doc_section_2_2_6">2.2.6</a> </div> +<a href="#doc_section_3_2_6">3.2.6</a> </div> <a id="m-is-supported" href="#m-is-supported">"%m" Is Supported</a> </h3> -<p id="doc_section_2_2_6_p_1">libxo supports the '%m' directive, which formats the error message associated with the current value of "errno". It is the equivalent of "%s" with the argument strerror(errno).</p> -<div id="doc_figure_u.68"></div> <pre> +<p id="doc_section_3_2_6_p_1">libxo supports the '%m' directive, which formats the error message associated with the current value of "errno". It is the equivalent of "%s" with the argument strerror(errno).</p> +<div id="doc_figure_u.69"></div> <pre> xo_emit("{:filename} cannot be opened: {:error/%m}", filename); xo_emit("{:filename} cannot be opened: {:error/%s}", filename, strerror(errno)); </pre> </div> <div class="content"> -<h3 id="doc_section_2_2_7"> +<h3 id="doc_section_3_2_7"> <div class="self-section-number"> -<a href="#doc_section_2_2_7">2.2.7</a> </div> +<a href="#doc_section_3_2_7">3.2.7</a> </div> <a id="n-is-not-supported" href="#n-is-not-supported">"%n" Is Not Supported</a> </h3> -<p id="doc_section_2_2_7_p_1">libxo does not support the '%n' directive. It's a bad idea and we just don't do it.</p> +<p id="doc_section_3_2_7_p_1">libxo does not support the '%n' directive. It's a bad idea and we just don't do it.</p> </div> <div class="content"> -<h3 id="doc_section_2_2_8"> +<h3 id="doc_section_3_2_8"> <div class="self-section-number"> -<a href="#doc_section_2_2_8">2.2.8</a> </div> +<a href="#doc_section_3_2_8">3.2.8</a> </div> <a id="the-encoding-format-eformat" href="#the-encoding-format-eformat">The Encoding Format (eformat)</a> </h3> -<p id="doc_section_2_2_8_p_1">The "eformat" string is the format string used when encoding the field for JSON and XML. If not provided, it defaults to the primary format with any minimum width removed. If the primary is not given, both default to "%s".</p> +<p id="doc_section_3_2_8_p_1">The "eformat" string is the format string used when encoding the field for JSON and XML. If not provided, it defaults to the primary format with any minimum width removed. If the primary is not given, both default to "%s".</p> </div> <div class="content"> -<h3 id="doc_section_2_2_9"> +<h3 id="doc_section_3_2_9"> <div class="self-section-number"> -<a href="#doc_section_2_2_9">2.2.9</a> </div> +<a href="#doc_section_3_2_9">3.2.9</a> </div> <a id="content-strings" href="#content-strings">Content Strings</a> </h3> -<p id="doc_section_2_2_9_p_1">For padding and labels, the content string is considered the content, unless a format is given.</p> +<p id="doc_section_3_2_9_p_1">For padding and labels, the content string is considered the content, unless a format is given.</p> </div> <div class="content"> -<h3 id="doc_section_2_2_10"> +<h3 id="doc_section_3_2_10"> <div class="self-section-number"> -<a href="#doc_section_2_2_10">2.2.10</a> </div> +<a href="#doc_section_3_2_10">3.2.10</a> </div> <a id="printf-like" href="#printf-like">Argument Validation</a> </h3> -<p id="doc_section_2_2_10_p_1">Many compilers and tool chains support validation of printf-like arguments. When the format string fails to match the argument list, a warning is generated. This is a valuable feature and while the formatting strings for libxo differ considerably from printf, many of these checks can still provide build-time protection against bugs.</p> -<p id="doc_section_2_2_10_p_2">libxo provide variants of functions that provide this ability, if the "‑‑enable‑printflike" option is passed to the "configure" script. These functions use the "_p" suffix, like "xo_emit_p()", xo_emit_hp()", etc.</p> -<p id="doc_section_2_2_10_p_3">The following are features of libxo formatting strings that are incompatible with printf-like testing:</p> -<p id="doc_section_2_2_10_p_4"> </p> +<p id="doc_section_3_2_10_p_1">Many compilers and tool chains support validation of printf-like arguments. When the format string fails to match the argument list, a warning is generated. This is a valuable feature and while the formatting strings for libxo differ considerably from printf, many of these checks can still provide build-time protection against bugs.</p> +<p id="doc_section_3_2_10_p_2">libxo provide variants of functions that provide this ability, if the "‑‑enable‑printflike" option is passed to the "configure" script. These functions use the "_p" suffix, like "xo_emit_p()", xo_emit_hp()", etc.</p> +<p id="doc_section_3_2_10_p_3">The following are features of libxo formatting strings that are incompatible with printf-like testing:</p> +<p id="doc_section_3_2_10_p_4"> </p> <ul> <li>implicit formats, where "{:tag}" has an implicit "%s";</li> <li>the "max" parameter for strings, where "{:tag/%4.10.6s}" means up to ten bytes of data can be inspected to fill a minimum of 4 columns and a maximum of 6;</li> @@ -24011,7 +24053,7 @@ jQuery(function ($) { <li>the "l" and "h" modifiers for strings, where "{:tag/%hs}" means locale-based string and "{:tag/%ls}" means a wide character string;</li> <li>distinct encoding formats, where "{:tag/#%s/%s}" means the display styles (text and HTML) will use "#%s" where other styles use "%s";</li> </ul> -<p id="doc_section_2_2_10_p_5">If none of these features are in use by your code, then using the "_p" variants might be wise.</p> +<p id="doc_section_3_2_10_p_5">If none of these features are in use by your code, then using the "_p" variants might be wise.</p> <div id="doc_table_u.8"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Function</th> @@ -24066,19 +24108,19 @@ jQuery(function ($) { </table></div> </div> <div class="content"> -<h3 id="doc_section_2_2_11"> +<h3 id="doc_section_3_2_11"> <div class="self-section-number"> -<a href="#doc_section_2_2_11">2.2.11</a> </div> +<a href="#doc_section_3_2_11">3.2.11</a> </div> <a id="retain" href="#retain">Retaining Parsed Format Information</a> </h3> -<p id="doc_section_2_2_11_p_1">libxo can retain the parsed internal information related to the given format string, allowing subsequent xo_emit calls, the retained information is used, avoiding repetitive parsing of the format string.</p> -<div id="doc_figure_u.69"></div> <pre> +<p id="doc_section_3_2_11_p_1">libxo can retain the parsed internal information related to the given format string, allowing subsequent xo_emit calls, the retained information is used, avoiding repetitive parsing of the format string.</p> +<div id="doc_figure_u.70"></div> <pre> SYNTAX: int xo_emit_f(xo_emit_flags_t flags, const char fmt, ...); EXAMPLE: xo_emit_f(XOEF_RETAIN, "{:some/%02d}{:thing/%-6s}{:fancy}\n", some, thing, fancy); - </pre> <p id="doc_section_2_2_11_p_3">To retain parsed format information, use the XOEF_RETAIN flag to the xo_emit_f() function. A complete set of xo_emit_f functions exist to match all the xo_emit function signatures (with handles, varadic argument, and printf-like flags):</p> + </pre> <p id="doc_section_3_2_11_p_3">To retain parsed format information, use the XOEF_RETAIN flag to the xo_emit_f() function. A complete set of xo_emit_f functions exist to match all the xo_emit function signatures (with handles, varadic argument, and printf-like flags):</p> <div id="doc_table_u.9"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Function</th> @@ -24111,29 +24153,29 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_2_2_11_p_4">The format string must be immutable across multiple calls to xo_emit_f(), since the library retains the string. Typically this is done by using static constant strings, such as string literals. If the string is not immutable, the XOEF_RETAIN flag must not be used.</p> -<p id="doc_section_2_2_11_p_5">The functions xo_retain_clear() and xo_retain_clear_all() release internal information on either a single format string or all format strings, respectively. Neither is required, but the library will retain this information until it is cleared or the process exits.</p> -<div id="doc_figure_u.70"></div> <pre> +<p id="doc_section_3_2_11_p_4">The format string must be immutable across multiple calls to xo_emit_f(), since the library retains the string. Typically this is done by using static constant strings, such as string literals. If the string is not immutable, the XOEF_RETAIN flag must not be used.</p> +<p id="doc_section_3_2_11_p_5">The functions xo_retain_clear() and xo_retain_clear_all() release internal information on either a single format string or all format strings, respectively. Neither is required, but the library will retain this information until it is cleared or the process exits.</p> +<div id="doc_figure_u.71"></div> <pre> const char *fmt = "{:name} {:count/%d}\n"; for (i = 0; i < 1000; i++) { xo_open_instance("item"); xo_emit_f(XOEF_RETAIN, fmt, name[i], count[i]); } xo_retain_clear(fmt); - </pre> <p id="doc_section_2_2_11_p_7">The retained information is kept as thread-specific data.</p> + </pre> <p id="doc_section_3_2_11_p_7">The retained information is kept as thread-specific data.</p> </div> <div class="content"> -<h3 id="doc_section_2_2_12"> +<h3 id="doc_section_3_2_12"> <div class="self-section-number"> -<a href="#doc_section_2_2_12">2.2.12</a> </div> +<a href="#doc_section_3_2_12">3.2.12</a> </div> <a id="example" href="#example">Example</a> </h3> -<p id="doc_section_2_2_12_p_1">In this example, the value for the number of items in stock is emitted:</p> -<div id="doc_figure_u.71"></div> <pre> +<p id="doc_section_3_2_12_p_1">In this example, the value for the number of items in stock is emitted:</p> +<div id="doc_figure_u.72"></div> <pre> xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\n", instock); - </pre> <p id="doc_section_2_2_12_p_3">This call will generate the following output:</p> -<div id="doc_figure_u.72"></div> <pre> + </pre> <p id="doc_section_3_2_12_p_3">This call will generate the following output:</p> +<div id="doc_figure_u.73"></div> <pre> TEXT: In stock: 144 XML: @@ -24148,8 +24190,8 @@ jQuery(function ($) { <div class="padding"> </div> <div class="data" data-tag="in-stock">144</div> </div> - </pre> <p id="doc_section_2_2_12_p_5">Clearly HTML wins the verbosity award, and this output does not include XOF_XPATH or XOF_INFO data, which would expand the penultimate line to:</p> -<div id="doc_figure_u.73"></div> <pre> + </pre> <p id="doc_section_3_2_12_p_5">Clearly HTML wins the verbosity award, and this output does not include XOF_XPATH or XOF_INFO data, which would expand the penultimate line to:</p> +<div id="doc_figure_u.74"></div> <pre> <div class="data" data-tag="in-stock" data-xpath="/top/data/item/in-stock" data-type="number" @@ -24157,45 +24199,45 @@ jQuery(function ($) { </pre> </div> </div> <div class="content"> -<h2 id="doc_section_2_3"> +<h2 id="doc_section_3_3"> <div class="self-section-number"> -<a href="#doc_section_2_3">2.3</a> </div> +<a href="#doc_section_3_3">3.3</a> </div> <a id="representing-hierarchy" href="#representing-hierarchy">Representing Hierarchy</a> </h2> -<p id="doc_section_2_3_p_1">For XML and JSON, individual fields appear inside hierarchies which provide context and meaning to the fields. Unfortunately, these encoding have a basic disconnect between how lists is similar objects are represented.</p> -<p id="doc_section_2_3_p_2">XML encodes lists as set of sequential elements:</p> -<div id="doc_figure_u.74"></div> <pre> +<p id="doc_section_3_3_p_1">For XML and JSON, individual fields appear inside hierarchies which provide context and meaning to the fields. Unfortunately, these encoding have a basic disconnect between how lists is similar objects are represented.</p> +<p id="doc_section_3_3_p_2">XML encodes lists as set of sequential elements:</p> +<div id="doc_figure_u.75"></div> <pre> <user>phil</user> <user>pallavi</user> <user>sjg</user> - </pre> <p id="doc_section_2_3_p_4">JSON encodes lists using a single name and square brackets:</p> -<div id="doc_figure_u.75"></div> <pre> + </pre> <p id="doc_section_3_3_p_4">JSON encodes lists using a single name and square brackets:</p> +<div id="doc_figure_u.76"></div> <pre> "user": [ "phil", "pallavi", "sjg" ] - </pre> <p id="doc_section_2_3_p_6">This means libxo needs three distinct indications of hierarchy: one for containers of hierarchy appear only once for any specific parent, one for lists, and one for each item in a list.</p> -<p id="doc_section_2_3_p_7">Section Contents: </p> + </pre> <p id="doc_section_3_3_p_6">This means libxo needs three distinct indications of hierarchy: one for containers of hierarchy appear only once for any specific parent, one for lists, and one for each item in a list.</p> +<p id="doc_section_3_3_p_7">Section Contents: </p> <ul> -<li><a href="#containers" title="Containers">Section 2.3.1</a></li> -<li><a href="#lists-and-instances" title="Lists and Instances">Section 2.3.2</a></li> -<li><a href="#dtrt-mode" title="DTRT Mode">Section 2.3.3</a></li> -<li><a href="#markers" title="Markers">Section 2.3.4</a></li> +<li><a href="#containers" title="Containers">Section 3.3.1</a></li> +<li><a href="#lists-and-instances" title="Lists and Instances">Section 3.3.2</a></li> +<li><a href="#dtrt-mode" title="DTRT Mode">Section 3.3.3</a></li> +<li><a href="#markers" title="Markers">Section 3.3.4</a></li> </ul> <div class="content"> -<h3 id="doc_section_2_3_1"> +<h3 id="doc_section_3_3_1"> <div class="self-section-number"> -<a href="#doc_section_2_3_1">2.3.1</a> </div> +<a href="#doc_section_3_3_1">3.3.1</a> </div> <a id="containers" href="#containers">Containers</a> </h3> -<p id="doc_section_2_3_1_p_1">A "container" is an element of a hierarchy that appears only once under any specific parent. The container has no value, but serves to contain other nodes.</p> -<p id="doc_section_2_3_1_p_2">To open a container, call xo_open_container() or xo_open_container_h(). The former uses the default handle and the latter accepts a specific handle.</p> -<div id="doc_figure_u.76"></div> <pre> +<p id="doc_section_3_3_1_p_1">A "container" is an element of a hierarchy that appears only once under any specific parent. The container has no value, but serves to contain other nodes.</p> +<p id="doc_section_3_3_1_p_2">To open a container, call xo_open_container() or xo_open_container_h(). The former uses the default handle and the latter accepts a specific handle.</p> +<div id="doc_figure_u.77"></div> <pre> int xo_open_container_h (xo_handle_t *xop, const char *name); int xo_open_container (const char *name); - </pre> <p id="doc_section_2_3_1_p_4">To close a level, use the xo_close_container() or xo_close_container_h() functions:</p> -<div id="doc_figure_u.77"></div> <pre> + </pre> <p id="doc_section_3_3_1_p_4">To close a level, use the xo_close_container() or xo_close_container_h() functions:</p> +<div id="doc_figure_u.78"></div> <pre> int xo_close_container_h (xo_handle_t *xop, const char *name); int xo_close_container (const char *name); - </pre> <p id="doc_section_2_3_1_p_6">Each open call must have a matching close call. If the XOF_WARN flag is set and the name given does not match the name of the currently open container, a warning will be generated.</p> -<div id="doc_figure_u.78"></div> <pre> + </pre> <p id="doc_section_3_3_1_p_6">Each open call must have a matching close call. If the XOF_WARN flag is set and the name given does not match the name of the currently open container, a warning will be generated.</p> +<div id="doc_figure_u.79"></div> <pre> Example: xo_open_container("top"); @@ -24225,13 +24267,13 @@ jQuery(function ($) { data-tag="host-name">my-host.example.org</div> </pre> </div> <div class="content"> -<h3 id="doc_section_2_3_2"> +<h3 id="doc_section_3_3_2"> <div class="self-section-number"> -<a href="#doc_section_2_3_2">2.3.2</a> </div> +<a href="#doc_section_3_3_2">3.3.2</a> </div> <a id="lists-and-instances" href="#lists-and-instances">Lists and Instances</a> </h3> -<p id="doc_section_2_3_2_p_1">A list is set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close each instance of the list:</p> -<div id="doc_figure_u.79"></div> <pre> +<p id="doc_section_3_3_2_p_1">A list is set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close each instance of the list:</p> +<div id="doc_figure_u.80"></div> <pre> xo_open_list("item"); for (ip = list; ip->i_title; ip++) { @@ -24241,24 +24283,24 @@ jQuery(function ($) { } xo_close_list("item"); - </pre> <p id="doc_section_2_3_2_p_3">Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.</p> + </pre> <p id="doc_section_3_3_2_p_3">Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.</p> </div> <div class="content"> -<h3 id="doc_section_2_3_3"> +<h3 id="doc_section_3_3_3"> <div class="self-section-number"> -<a href="#doc_section_2_3_3">2.3.3</a> </div> +<a href="#doc_section_3_3_3">3.3.3</a> </div> <a id="dtrt-mode" href="#dtrt-mode">DTRT Mode</a> </h3> -<p id="doc_section_2_3_3_p_1">Some users may find tracking the names of open containers, lists, and instances inconvenient. libxo offers a "Do The Right Thing" mode, where libxo will track the names of open containers, lists, and instances so the close function can be called without a name. To enable DTRT mode, turn on the XOF_DTRT flag prior to making any other libxo output.</p> -<div id="doc_figure_u.80"></div> <pre> - xo_set_flags(NULL, XOF_DTRT); - </pre> <p id="doc_section_2_3_3_p_3">Each open and close function has a version with the suffix "_d", which will close the open container, list, or instance:</p> +<p id="doc_section_3_3_3_p_1">Some users may find tracking the names of open containers, lists, and instances inconvenient. libxo offers a "Do The Right Thing" mode, where libxo will track the names of open containers, lists, and instances so the close function can be called without a name. To enable DTRT mode, turn on the XOF_DTRT flag prior to making any other libxo output.</p> <div id="doc_figure_u.81"></div> <pre> + xo_set_flags(NULL, XOF_DTRT); + </pre> <p id="doc_section_3_3_3_p_3">Each open and close function has a version with the suffix "_d", which will close the open container, list, or instance:</p> +<div id="doc_figure_u.82"></div> <pre> xo_open_container("top"); ... xo_close_container_d(); - </pre> <p id="doc_section_2_3_3_p_5">This also works for lists and instances:</p> -<div id="doc_figure_u.82"></div> <pre> + </pre> <p id="doc_section_3_3_3_p_5">This also works for lists and instances:</p> +<div id="doc_figure_u.83"></div> <pre> xo_open_list("item"); for (...) { xo_open_instance("item"); @@ -24266,18 +24308,18 @@ jQuery(function ($) { xo_close_instance_d(); } xo_close_list_d(); - </pre> <p id="doc_section_2_3_3_p_7">Note that the XOF_WARN flag will also cause libxo to track open containers, lists, and instances. A warning is generated when the name given to the close function and the name recorded do not match.</p> + </pre> <p id="doc_section_3_3_3_p_7">Note that the XOF_WARN flag will also cause libxo to track open containers, lists, and instances. A warning is generated when the name given to the close function and the name recorded do not match.</p> </div> <div class="content"> -<h3 id="doc_section_2_3_4"> +<h3 id="doc_section_3_3_4"> <div class="self-section-number"> -<a href="#doc_section_2_3_4">2.3.4</a> </div> +<a href="#doc_section_3_3_4">3.3.4</a> </div> <a id="markers" href="#markers">Markers</a> </h3> -<p id="doc_section_2_3_4_p_1">Markers are used to protect and restore the state of open constructs. While a marker is open, no other open constructs can be closed. When a marker is closed, all constructs open since the marker was opened will be closed.</p> -<p id="doc_section_2_3_4_p_2">Markers use names which are not user-visible, allowing the caller to choose appropriate internal names.</p> -<p id="doc_section_2_3_4_p_3">In this example, the code whiffles through a list of fish, calling a function to emit details about each fish. The marker "fish‑guts" is used to ensure that any constructs opened by the function are closed properly.</p> -<div id="doc_figure_u.83"></div> <pre> +<p id="doc_section_3_3_4_p_1">Markers are used to protect and restore the state of open constructs. While a marker is open, no other open constructs can be closed. When a marker is closed, all constructs open since the marker was opened will be closed.</p> +<p id="doc_section_3_3_4_p_2">Markers use names which are not user-visible, allowing the caller to choose appropriate internal names.</p> +<p id="doc_section_3_3_4_p_3">In this example, the code whiffles through a list of fish, calling a function to emit details about each fish. The marker "fish‑guts" is used to ensure that any constructs opened by the function are closed properly.</p> +<div id="doc_figure_u.84"></div> <pre> for (i = 0; fish[i]; i++) { xo_open_instance("fish"); xo_open_marker("fish-guts"); @@ -24286,21 +24328,40 @@ jQuery(function ($) { } </pre> </div> </div> +</div> +<hr class="noprint"> <div class="content"> -<h2 id="doc_section_2_4"> +<h1 id="doc_section_4" class="np"> <div class="self-section-number"> -<a href="#doc_section_2_4">2.4</a> </div> -<a id="command-line-arguments" href="#command-line-arguments">Command-line Arguments</a> -</h2> -<p id="doc_section_2_4_p_1">libxo uses command line options to trigger rendering behavior. The following options are recognised:</p> -<p id="doc_section_2_4_p_2"> </p> +<a href="#doc_section_4">4_</a> </div> +<a id="options" href="#options">Command-line Arguments</a> +</h1> +<p id="doc_section_4_p_1">libxo uses command line options to trigger rendering behavior. The following options are recognised:</p> +<p id="doc_section_4_p_2"> </p> <ul> <li>--libxo <options></li> <li>--libxo=<options></li> <li>--libxo:<brief‑options></li> </ul> -<p id="doc_section_2_4_p_3">Programs using libxo are expecting to call the xo_parse_args function to parse these arguments. See <a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 3.4.1</a> for details.</p> -<p id="doc_section_2_4_p_4">Options is a comma-separated list of tokens that correspond to output styles, flags, or features:</p> +<p id="doc_section_4_p_3">The following invocations are all identical in outcome:</p> +<div id="doc_figure_u.85"></div> <pre> + my-app --libxo warn,pretty arg1 + my-app --libxo=warn,pretty arg1 + my-app --libxo:WP arg1 + </pre> <p id="doc_section_4_p_5">Programs using libxo are expecting to call the xo_parse_args function to parse these arguments. See <a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 5.4.1</a> for details.</p> +<p id="doc_section_4_p_6">Section Contents: </p> +<ul> +<li><a href="#option-keywords" title="Option keywords">Section 4.1</a></li> +<li><a href="#brief-options" title="Brief Options">Section 4.2</a></li> +<li><a href="#color-mapping" title="Color Mapping">Section 4.3</a></li> +</ul> +<div class="content"> +<h2 id="doc_section_4_1"> +<div class="self-section-number"> +<a href="#doc_section_4_1">4.1</a> </div> +<a id="option-keywords" href="#option-keywords">Option keywords</a> +</h2> +<p id="doc_section_4_1_p_1">Options is a comma-separated list of tokens that correspond to output styles, flags, or features:</p> <div id="doc_table_u.10"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Token</th> @@ -24312,10 +24373,22 @@ jQuery(function ($) { <td>Enable colors/effects for display styles (TEXT, HTML)</td> </tr> <tr> +<td>colors=xxxx</td> +<td>Adjust color output values</td> +</tr> +<tr> <td>dtrt</td> <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 +24450,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> @@ -24401,117 +24474,253 @@ jQuery(function ($) { </tr> </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_4_1_p_2">Most of these option are simple and direct, but some require additional details:</p> +<p id="doc_section_4_1_p_3"> </p> +<ul> +<li>"colors" is described in <a href="#color-mapping" title="Color Mapping">Section 4.3</a>.</li> +<li>"flush‑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‑".</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‑humanize"avoids "humanizing" numeric output (see humanize_number(3) for details).</li> +<li>"no‑locale" instructs libxo to avoid translating output to the current locale.</li> +<li>"no‑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‑xml" causes those warnings to be placed in XML inside the output.</li> +</ul> +</div> +<div class="content"> +<h2 id="doc_section_4_2"> +<div class="self-section-number"> +<a href="#doc_section_4_2">4.2</a> </div> +<a id="brief-options" href="#brief-options">Brief Options</a> +</h2> +<p id="doc_section_4_2_p_1">The brief options are simple single-letter aliases to the normal keywords, as detailed below:</p> +<div id="doc_table_u.11"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> +<thead><tr> +<th class="left">Option</th> +<th class="left">Action</th> +</tr></thead> +<tbody> +<tr> +<td>c</td> +<td>Enable color/effects for TEXT/HTML</td> +</tr> +<tr> +<td>F</td> +<td>Force line-buffered flushing</td> +</tr> +<tr> +<td>H</td> +<td>Enable HTML output (XO_STYLE_HTML)</td> +</tr> +<tr> +<td>I</td> +<td>Enable info output (XOF_INFO)</td> +</tr> +<tr> +<td>i<num></td> +<td>Indent by <number></td> +</tr> +<tr> +<td>J</td> +<td>Enable JSON output (XO_STYLE_JSON)</td> +</tr> +<tr> +<td>k</td> +<td>Add keys to XPATH expressions in HTML</td> +</tr> +<tr> +<td>n</td> +<td>Disable humanization (TEXT, HTML)</td> +</tr> +<tr> +<td>P</td> +<td>Enable pretty-printed output (XOF_PRETTY)</td> +</tr> +<tr> +<td>T</td> +<td>Enable text output (XO_STYLE_TEXT)</td> +</tr> +<tr> +<td>U</td> +<td>Add units to HTML output</td> +</tr> +<tr> +<td>u</td> +<td>Change "-"s to "_"s in element names (JSON)</td> +</tr> +<tr> +<td>W</td> +<td>Enable warnings (XOF_WARN)</td> +</tr> +<tr> +<td>X</td> +<td>Enable XML output (XO_STYLE_XML)</td> +</tr> +<tr> +<td>x</td> +<td>Enable XPath data (XOF_XPATH)</td> +</tr> +</tbody> +</table></div> </div> +<div class="content"> +<h2 id="doc_section_4_3"> +<div class="self-section-number"> +<a href="#doc_section_4_3">4.3</a> </div> +<a id="color-mapping" href="#color-mapping">Color Mapping</a> +</h2> +<p id="doc_section_4_3_p_1">The "colors" option takes a value that is a set of mappings from the pre-defined set of colors to new foreground and background colors. The value is a series of "fg/bg" values, separated by a "+". Each pair of "fg/bg" values gives the colors to which a basic color is mapped when used as a foreground or background color. The order is the mappings is:</p> +<p id="doc_section_4_3_p_2"> </p> +<ul> +<li>black</li> +<li>red</li> +<li>green</li> +<li>yellow</li> +<li>blue</li> +<li>magenta</li> +<li>cyan</li> +<li>white</li> +</ul> +<p id="doc_section_4_3_p_3">Pairs may be skipped, leaving them mapped as normal, as are missing pairs or single colors.</p> +<p id="doc_section_4_3_p_4">For example consider the following xo_emit call:</p> +<div id="doc_figure_u.86"></div> <pre> + xo_emit("{C:fg-red,bg-green}Merry XMas!!{C:}\n"); + </pre> <p id="doc_section_4_3_p_6">To turn all colored output to red-on-blue, use eight pairs of "red/blue" mappings separated by "+"s:</p> +<div id="doc_figure_u.87"></div> <pre> + --libxo colors=red/blue+red/blue+red/blue+red/blue+\ + red/blue+red/blue+red/blue+red/blue + </pre> <p id="doc_section_4_3_p_8">To turn the red-on-green text to magenta-on-cyan, give a "magenta" foreground value for red (the second mapping) and a "cyan" background to green (the third mapping):</p> +<div id="doc_figure_u.88"></div> <pre> + --libxo colors=+magenta+/cyan + </pre> <p id="doc_section_4_3_p_10">Consider the common situation where blue output looks unreadable on a terminal session with a black background. To turn both "blue" foreground and background output to "yellow", give only the fifth mapping, skipping the first four mappings with bare "+"s:</p> +<div id="doc_figure_u.89"></div> <pre> + --libxo colors=++++yellow/yellow + </pre> </div> </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_3" class="np"> +<h1 id="doc_section_5" class="np"> <div class="self-section-number"> -<a href="#doc_section_3">3_</a> </div> +<a href="#doc_section_5">5_</a> </div> <a id="the-libxo-api" href="#the-libxo-api">The libxo API</a> </h1> -<p id="doc_section_3_p_1">This section gives details about the functions in libxo, how to call them, and the actions they perform.</p> -<p id="doc_section_3_p_2">Section Contents: </p> +<p id="doc_section_5_p_1">This section gives details about the functions in libxo, how to call them, and the actions they perform.</p> +<p id="doc_section_5_p_2">Section Contents: </p> <ul> -<li><a href="#handles" title="Handles">Section 3.1</a></li> -<li><a href="#emitting-content-xo_emit" title="Emitting Content (xo_emit)">Section 3.2</a></li> -<li><a href="#emitting-hierarchy" title="Emitting Hierarchy">Section 3.3</a></li> -<li><a href="#support-functions" title="Support Functions">Section 3.4</a></li> -<li><a href="#emitting-syslog-messages" title="Emitting syslog Messages">Section 3.5</a></li> -<li><a href="#creating-custom-encoders" title="Creating Custom Encoders">Section 3.6</a></li> +<li><a href="#handles" title="Handles">Section 5.1</a></li> +<li><a href="#emitting-content-xo_emit" title="Emitting Content (xo_emit)">Section 5.2</a></li> +<li><a href="#emitting-hierarchy" title="Emitting Hierarchy">Section 5.3</a></li> +<li><a href="#support-functions" title="Support Functions">Section 5.4</a></li> +<li><a href="#emitting-syslog-messages" title="Emitting syslog Messages">Section 5.5</a></li> +<li><a href="#creating-custom-encoders" title="Creating Custom Encoders">Section 5.6</a></li> </ul> <div class="content"> -<h2 id="doc_section_3_1"> +<h2 id="doc_section_5_1"> <div class="self-section-number"> -<a href="#doc_section_3_1">3.1</a> </div> +<a href="#doc_section_5_1">5.1</a> </div> <a id="handles" href="#handles">Handles</a> </h2> -<p id="doc_section_3_1_p_1">libxo uses "handles" to control its rendering functionality. The handle contains state and buffered data, as well as callback functions to process data.</p> -<p id="doc_section_3_1_p_2">Handles give an abstraction for libxo that encapsulates the state of a stream of output. Handles have the data type "xo_handle_t" and are opaque to the caller.</p> -<p id="doc_section_3_1_p_3">The library has a default handle that is automatically initialized. By default, this handle will send text style output (XO_STYLE_TEXT) to standard output. The xo_set_style and xo_set_flags functions can be used to change this behavior.</p> -<p id="doc_section_3_1_p_4">For the typical command that is generating output on standard output, there is no need to create an explicit handle, but they are available when needed, e.g., for daemons that generate multiple streams of output.</p> -<p id="doc_section_3_1_p_5">Many libxo functions take a handle as their first parameter; most that do not use the default handle. Any function taking a handle can be passed NULL to access the default handle. For the convenience of callers, the libxo library includes handle-less functions that implicitly use the default handle.</p> -<p id="doc_section_3_1_p_6">For example, the following are equivalent:</p> -<div id="doc_figure_u.84"></div> <pre> +<p id="doc_section_5_1_p_1">libxo uses "handles" to control its rendering functionality. The handle contains state and buffered data, as well as callback functions to process data.</p> +<p id="doc_section_5_1_p_2">Handles give an abstraction for libxo that encapsulates the state of a stream of output. Handles have the data type "xo_handle_t" and are opaque to the caller.</p> +<p id="doc_section_5_1_p_3">The library has a default handle that is automatically initialized. By default, this handle will send text style output (XO_STYLE_TEXT) to standard output. The xo_set_style and xo_set_flags functions can be used to change this behavior.</p> +<p id="doc_section_5_1_p_4">For the typical command that is generating output on standard output, there is no need to create an explicit handle, but they are available when needed, e.g., for daemons that generate multiple streams of output.</p> +<p id="doc_section_5_1_p_5">Many libxo functions take a handle as their first parameter; most that do not use the default handle. Any function taking a handle can be passed NULL to access the default handle. For the convenience of callers, the libxo library includes handle-less functions that implicitly use the default handle.</p> +<p id="doc_section_5_1_p_6">For example, the following are equivalent:</p> +<div id="doc_figure_u.90"></div> <pre> xo_emit("test"); xo_emit_h(NULL, "test"); - </pre> <p id="doc_section_3_1_p_8">Handles are created using xo_create() and destroy using xo_destroy().</p> -<p id="doc_section_3_1_p_9">Section Contents: </p> + </pre> <p id="doc_section_5_1_p_8">Handles are created using xo_create() and destroy using xo_destroy().</p> +<p id="doc_section_5_1_p_9">Section Contents: </p> <ul> -<li><a href="#xo_create" title="xo_create">Section 3.1.1</a></li> -<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_create" title="xo_create">Section 5.1.1</a></li> +<li><a href="#xo_create_to_file" title="xo_create_to_file">Section 5.1.2</a></li> +<li><a href="#xo_set_writer" title="xo_set_writer">Section 5.1.3</a></li> +<li><a href="#xo_set_style" title="xo_set_style">Section 5.1.4</a></li> +<li><a href="#xo_get_style" title="xo_get_style">Section 5.1.5</a></li> +<li><a href="#xo_set_flags" title="xo_set_flags">Section 5.1.6</a></li> +<li><a href="#xo_destroy" title="xo_destroy">Section 5.1.7</a></li> </ul> <div class="content"> -<h3 id="doc_section_3_1_1"> +<h3 id="doc_section_5_1_1"> <div class="self-section-number"> -<a href="#doc_section_3_1_1">3.1.1</a> </div> +<a href="#doc_section_5_1_1">5.1.1</a> </div> <a id="xo_create" href="#xo_create">xo_create</a> </h3> -<p id="doc_section_3_1_1_p_1">A handle can be allocated using the xo_create() function:</p> -<div id="doc_figure_u.85"></div> <pre> +<p id="doc_section_5_1_1_p_1">A handle can be allocated using the xo_create() function:</p> +<div id="doc_figure_u.91"></div> <pre> xo_handle_t *xo_create (unsigned style, unsigned flags); Example: 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_5_1_1_p_3">See also <a href="#styles" title="Output Styles (XO_STYLE_*)">Section 5.1.5.1</a> and <a href="#flags" title="Flags (XOF_*)">Section 5.1.6.1</a>.</p> </div> <div class="content"> -<h3 id="doc_section_3_1_2"> +<h3 id="doc_section_5_1_2"> <div class="self-section-number"> -<a href="#doc_section_3_1_2">3.1.2</a> </div> +<a href="#doc_section_5_1_2">5.1.2</a> </div> <a id="xo_create_to_file" href="#xo_create_to_file">xo_create_to_file</a> </h3> -<p id="doc_section_3_1_2_p_1">By default, libxo writes output to standard output. A convenience function is provided for situations when output should be written to a different file:</p> -<div id="doc_figure_u.86"></div> <pre> +<p id="doc_section_5_1_2_p_1">By default, libxo writes output to standard output. A convenience function is provided for situations when output should be written to a different file:</p> +<div id="doc_figure_u.92"></div> <pre> xo_handle_t *xo_create_to_file (FILE *fp, unsigned style, unsigned flags); - </pre> <p id="doc_section_3_1_2_p_3">Use the XOF_CLOSE_FP flag to trigger a call to fclose() for the FILE pointer when the handle is destroyed.</p> + </pre> <p id="doc_section_5_1_2_p_3">Use the XOF_CLOSE_FP flag to trigger a call to fclose() for the FILE pointer when the handle is destroyed.</p> </div> <div class="content"> -<h3 id="doc_section_3_1_3"> +<h3 id="doc_section_5_1_3"> <div class="self-section-number"> -<a href="#doc_section_3_1_3">3.1.3</a> </div> +<a href="#doc_section_5_1_3">5.1.3</a> </div> <a id="xo_set_writer" href="#xo_set_writer">xo_set_writer</a> </h3> -<p id="doc_section_3_1_3_p_1">The xo_set_writer function allows custom 'write' functions which can tailor how libxo writes data. An opaque argument is recorded and passed back to the write function, allowing the function to acquire context information. The 'close' function can release this opaque data and any other resources as needed. The flush function can flush buffered data associated with the opaque object.</p> -<div id="doc_figure_u.87"></div> <pre> +<p id="doc_section_5_1_3_p_1">The xo_set_writer function allows custom 'write' functions which can tailor how libxo writes data. An opaque argument is recorded and passed back to the write function, allowing the function to acquire context information. The 'close' function can release this opaque data and any other resources as needed. The flush function can flush buffered data associated with the opaque object.</p> +<div id="doc_figure_u.93"></div> <pre> void xo_set_writer (xo_handle_t *xop, void *opaque, xo_write_func_t write_func, xo_close_func_t close_func); xo_flush_func_t flush_func); </pre> </div> <div class="content"> -<h3 id="doc_section_3_1_4"> +<h3 id="doc_section_5_1_4"> <div class="self-section-number"> -<a href="#doc_section_3_1_4">3.1.4</a> </div> +<a href="#doc_section_5_1_4">5.1.4</a> </div> <a id="xo_set_style" href="#xo_set_style">xo_set_style</a> </h3> -<p id="doc_section_3_1_4_p_1">To set the style, use the xo_set_style() function:</p> -<div id="doc_figure_u.88"></div> <pre> +<p id="doc_section_5_1_4_p_1">To set the style, use the xo_set_style() function:</p> +<div id="doc_figure_u.94"></div> <pre> void xo_set_style(xo_handle_t *xop, unsigned style); - </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> + </pre> <p id="doc_section_5_1_4_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_4_p_5">Section Contents: </p> + </pre> </div> +<div class="content"> +<h3 id="doc_section_5_1_5"> +<div class="self-section-number"> +<a href="#doc_section_5_1_5">5.1.5</a> </div> +<a id="xo_get_style" href="#xo_get_style">xo_get_style</a> +</h3> +<p id="doc_section_5_1_5_p_1">To find the current style, use the xo_get_style() function:</p> +<div id="doc_figure_u.96"></div> <pre> + xo_style_t xo_get_style(xo_handle_t *xop); + </pre> <p id="doc_section_5_1_5_p_3">To use the default handle, pass a NULL handle:</p> +<div id="doc_figure_u.97"></div> <pre> + style = xo_get_style(NULL); + </pre> <p id="doc_section_5_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 5.1.5.1</a></li> +<li><a href="#xo_set_style_name" title="xo_set_style_name">Section 5.1.5.2</a></li> </ul> <div class="content"> -<h4 id="doc_section_3_1_4_1"> +<h4 id="doc_section_5_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_5_1_5_1">5.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> -<div id="doc_table_u.11"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> +<p id="doc_section_5_1_5_1_p_1">The libxo functions accept a set of output styles:</p> +<div id="doc_table_u.12"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Flag</th> <th class="left">Description</th> @@ -24537,46 +24746,46 @@ jQuery(function ($) { </table></div> </div> <div class="content"> -<h4 id="doc_section_3_1_4_2"> +<h4 id="doc_section_5_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_5_1_5_2">5.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_5_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.98"></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_5_1_5_2_p_3">The name can be any of the styles: "text", "xml", "json", or "html".</p> +<div id="doc_figure_u.99"></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_5_1_6"> <div class="self-section-number"> -<a href="#doc_section_3_1_5">3.1.5</a> </div> +<a href="#doc_section_5_1_6">5.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_5_1_6_p_1">To set the flags, use the xo_set_flags() function:</p> +<div id="doc_figure_u.100"></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_5_1_6_p_3">To use the default handle, pass a NULL handle:</p> +<div id="doc_figure_u.101"></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_5_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 5.1.6.1</a></li> +<li><a href="#xo_clear_flags" title="xo_clear_flags">Section 5.1.6.2</a></li> +<li><a href="#xo_set_options" title="xo_set_options">Section 5.1.6.3</a></li> </ul> <div class="content"> -<h4 id="doc_section_3_1_5_1"> +<h4 id="doc_section_5_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_5_1_6_1">5.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> -<div id="doc_table_u.12"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> +<p id="doc_section_5_1_6_1_p_1">The set of valid flags include:</p> +<div id="doc_table_u.13"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Flag</th> <th class="left">Description</th> @@ -24648,13 +24857,13 @@ 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> -<div id="doc_table_u.13"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> +<p id="doc_section_5_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_5_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_5_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_5_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_5_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_5_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.14"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Flag</th> <th class="left">Description</th> @@ -24670,10 +24879,10 @@ 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> -<div id="doc_table_u.14"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> +<p id="doc_section_5_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_5_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 5.4.4</a> for details.</p> +<p id="doc_section_5_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.15"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Flag</th> <th class="left">Description</th> @@ -24683,74 +24892,74 @@ 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_5_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.102"></div> <pre> xo_emit("{k:name}", item); XML: <name key="key">truck</name> </pre> </div> <div class="content"> -<h4 id="doc_section_3_1_5_2"> +<h4 id="doc_section_5_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_5_1_6_2">5.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_5_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.103"></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_5_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_5_1_6_3">5.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_5_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.104"></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_5_1_6_3_p_3">The options are identical to those listed in <a href="#options" title="Command-line Arguments">Section 4</a>.</p> </div> </div> <div class="content"> -<h3 id="doc_section_3_1_6"> +<h3 id="doc_section_5_1_7"> <div class="self-section-number"> -<a href="#doc_section_3_1_6">3.1.6</a> </div> +<a href="#doc_section_5_1_7">5.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_5_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.105"></div> <pre> void xo_destroy(xo_handle_t *xop); </pre> </div> </div> <div class="content"> -<h2 id="doc_section_3_2"> +<h2 id="doc_section_5_2"> <div class="self-section-number"> -<a href="#doc_section_3_2">3.2</a> </div> +<a href="#doc_section_5_2">5.2</a> </div> <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> +<p id="doc_section_5_2_p_1">The following functions are used to emit output:</p> +<div id="doc_figure_u.106"></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); - </pre> <p id="doc_section_3_2_p_3">The "fmt" argument is a string containing field descriptors as specified in <a href="#format-strings" title="Format Strings">Section 2.2</a>. The use of a handle is optional and NULL can be passed to access the internal 'default' handle. See <a href="#handles" title="Handles">Section 3.1</a>.</p> -<p id="doc_section_3_2_p_4">The remaining arguments to xo_emit() and xo_emit_h() are a set of arguments corresponding to the fields in the format string. Care must be taken to ensure the argument types match the fields in the format string, since an inappropriate cast can ruin your day. The vap argument to xo_emit_hv() points to a variable argument list that can be used to retrieve arguments via va_arg().</p> -<p id="doc_section_3_2_p_5">Section Contents: </p> + </pre> <p id="doc_section_5_2_p_3">The "fmt" argument is a string containing field descriptors as specified in <a href="#format-strings" title="Format Strings">Section 3.2</a>. The use of a handle is optional and NULL can be passed to access the internal 'default' handle. See <a href="#handles" title="Handles">Section 5.1</a>.</p> +<p id="doc_section_5_2_p_4">The remaining arguments to xo_emit() and xo_emit_h() are a set of arguments corresponding to the fields in the format string. Care must be taken to ensure the argument types match the fields in the format string, since an inappropriate cast can ruin your day. The vap argument to xo_emit_hv() points to a variable argument list that can be used to retrieve arguments via va_arg().</p> +<p id="doc_section_5_2_p_5">Section Contents: </p> <ul> -<li><a href="#xo_emit_field" title="Single Field Emitting Functions (xo_emit_field)">Section 3.2.1</a></li> -<li><a href="#xo_attr" title="Attributes (xo_attr)">Section 3.2.2</a></li> -<li><a href="#flushing-output-xo_flush" title="Flushing Output (xo_flush)">Section 3.2.3</a></li> -<li><a href="#finishing-output-xo_finish" title="Finishing Output (xo_finish)">Section 3.2.4</a></li> +<li><a href="#xo_emit_field" title="Single Field Emitting Functions (xo_emit_field)">Section 5.2.1</a></li> +<li><a href="#xo_attr" title="Attributes (xo_attr)">Section 5.2.2</a></li> +<li><a href="#flushing-output-xo_flush" title="Flushing Output (xo_flush)">Section 5.2.3</a></li> +<li><a href="#finishing-output-xo_finish" title="Finishing Output (xo_finish)">Section 5.2.4</a></li> </ul> <div class="content"> -<h3 id="doc_section_3_2_1"> +<h3 id="doc_section_5_2_1"> <div class="self-section-number"> -<a href="#doc_section_3_2_1">3.2.1</a> </div> +<a href="#doc_section_5_2_1">5.2.1</a> </div> <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> +<p id="doc_section_5_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.107"></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); @@ -24761,26 +24970,26 @@ 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> + </pre> <p id="doc_section_5_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.108"></div> <pre> xo_emit("T", "Host name is ", NULL, NULL); xo_emit("V", "host-name", NULL, NULL, host-name); </pre> </div> <div class="content"> -<h3 id="doc_section_3_2_2"> +<h3 id="doc_section_5_2_2"> <div class="self-section-number"> -<a href="#doc_section_3_2_2">3.2.2</a> </div> +<a href="#doc_section_5_2_2">5.2.2</a> </div> <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> +<p id="doc_section_5_2_2_p_1">The xo_attr() function emits attributes for the XML output style.</p> +<div id="doc_figure_u.109"></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> + </pre> <p id="doc_section_5_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.110"></div> <pre> EXAMPLE: xo_attr("seconds", "%ld", (unsigned long) login_time); struct tm *tmp = localtime(login_time); @@ -24788,45 +24997,45 @@ jQuery(function ($) { xo_emit("Logged in at {:login-time}\n", buf); XML: <login-time seconds="1408336270">00:14</login-time> - </pre> <p id="doc_section_3_2_2_p_5">xo_attr is placed on the next container, instance, leaf, or leaf list that is emitted.</p> -<p id="doc_section_3_2_2_p_6">Since attributes are only emitted in XML, their use should be limited to meta-data and additional or redundant representations of data already emitted in other form.</p> + </pre> <p id="doc_section_5_2_2_p_5">xo_attr is placed on the next container, instance, leaf, or leaf list that is emitted.</p> +<p id="doc_section_5_2_2_p_6">Since attributes are only emitted in XML, their use should be limited to meta-data and additional or redundant representations of data already emitted in other form.</p> </div> <div class="content"> -<h3 id="doc_section_3_2_3"> +<h3 id="doc_section_5_2_3"> <div class="self-section-number"> -<a href="#doc_section_3_2_3">3.2.3</a> </div> +<a href="#doc_section_5_2_3">5.2.3</a> </div> <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> +<p id="doc_section_5_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.111"></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> + </pre> <p id="doc_section_5_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> </div> <div class="content"> -<h3 id="doc_section_3_2_4"> +<h3 id="doc_section_5_2_4"> <div class="self-section-number"> -<a href="#doc_section_3_2_4">3.2.4</a> </div> +<a href="#doc_section_5_2_4">5.2.4</a> </div> <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> +<p id="doc_section_5_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.112"></div> <pre> int xo_finish (void); int xo_finish_h (xo_handle_t *xop); void xo_finish_atexit (void); - </pre> <p id="doc_section_3_2_4_p_3">Calling this function is vital to the proper operation of libxo, especially for the non-TEXT output styles.</p> -<p id="doc_section_3_2_4_p_4">xo_finish_atexit is suitable for use with atexit(3).</p> + </pre> <p id="doc_section_5_2_4_p_3">Calling this function is vital to the proper operation of libxo, especially for the non-TEXT output styles.</p> +<p id="doc_section_5_2_4_p_4">xo_finish_atexit is suitable for use with atexit(3).</p> </div> </div> <div class="content"> -<h2 id="doc_section_3_3"> +<h2 id="doc_section_5_3"> <div class="self-section-number"> -<a href="#doc_section_3_3">3.3</a> </div> +<a href="#doc_section_5_3">5.3</a> </div> <a id="emitting-hierarchy" href="#emitting-hierarchy">Emitting Hierarchy</a> </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> +<p id="doc_section_5_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_5_3_p_2">To create a container, use the xo_open_container and xo_close_container functions:</p> +<div id="doc_figure_u.113"></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); @@ -24836,28 +25045,28 @@ jQuery(function ($) { int xo_close_container_h (xo_handle_t *xop, const char *name); int xo_close_container_hd (xo_handle_t *xop); int xo_close_container_d (void); - </pre> <p id="doc_section_3_3_p_4">The name parameter gives the name of the container, encoded in UTF-8. Since ASCII is a proper subset of UTF-8, traditional C strings can be used directly.</p> -<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> + </pre> <p id="doc_section_5_3_p_4">The name parameter gives the name of the container, encoded in UTF-8. Since ASCII is a proper subset of UTF-8, traditional C strings can be used directly.</p> +<p id="doc_section_5_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_5_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_5_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.114"></div> <pre> EXAMPLE: xo_open_container("system"); xo_emit("The host name is {:host-name}\n", hn); xo_close_container("system"); XML: <system><host-name>foo</host-name></system> - </pre> <p id="doc_section_3_3_p_9">Section Contents: </p> -<ul><li><a href="#lists-and-instances-2" title="Lists and Instances">Section 3.3.1</a></li></ul> + </pre> <p id="doc_section_5_3_p_9">Section Contents: </p> +<ul><li><a href="#lists-and-instances-2" title="Lists and Instances">Section 5.3.1</a></li></ul> <div class="content"> -<h3 id="doc_section_3_3_1"> +<h3 id="doc_section_5_3_1"> <div class="self-section-number"> -<a href="#doc_section_3_3_1">3.3.1</a> </div> +<a href="#doc_section_5_3_1">5.3.1</a> </div> <a id="lists-and-instances-2" href="#lists-and-instances-2">Lists and Instances</a> </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> +<p id="doc_section_5_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_5_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.115"></div> <pre> EXAMPLE: xo_open_list("user"); for (i = 0; i < num_users; i++) { @@ -24902,68 +25111,68 @@ jQuery(function ($) { </pre> </div> </div> <div class="content"> -<h2 id="doc_section_3_4"> +<h2 id="doc_section_5_4"> <div class="self-section-number"> -<a href="#doc_section_3_4">3.4</a> </div> +<a href="#doc_section_5_4">5.4</a> </div> <a id="support-functions" href="#support-functions">Support Functions</a> </h2> -<p id="doc_section_3_4_p_1">Section Contents: </p> +<p id="doc_section_5_4_p_1">Section Contents: </p> <ul> -<li><a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 3.4.1</a></li> -<li><a href="#xo_set_program" title="xo_set_program">Section 3.4.2</a></li> -<li><a href="#xo_set_version" title="xo_set_version">Section 3.4.3</a></li> -<li><a href="#info" title="Field Information (xo_info_t)">Section 3.4.4</a></li> -<li><a href="#memory-allocation" title="Memory Allocation">Section 3.4.5</a></li> -<li><a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a></li> -<li><a href="#errors-warnings-and-messages" title="Errors, Warnings, and Messages">Section 3.4.7</a></li> -<li><a href="#xo_error" title="xo_error">Section 3.4.8</a></li> -<li><a href="#xo_no_setlocale" title="xo_no_setlocale">Section 3.4.9</a></li> +<li><a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 5.4.1</a></li> +<li><a href="#xo_set_program" title="xo_set_program">Section 5.4.2</a></li> +<li><a href="#xo_set_version" title="xo_set_version">Section 5.4.3</a></li> +<li><a href="#info" title="Field Information (xo_info_t)">Section 5.4.4</a></li> +<li><a href="#memory-allocation" title="Memory Allocation">Section 5.4.5</a></li> +<li><a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 5.4.6</a></li> +<li><a href="#errors-warnings-and-messages" title="Errors, Warnings, and Messages">Section 5.4.7</a></li> +<li><a href="#xo_error" title="xo_error">Section 5.4.8</a></li> +<li><a href="#xo_no_setlocale" title="xo_no_setlocale">Section 5.4.9</a></li> </ul> <div class="content"> -<h3 id="doc_section_3_4_1"> +<h3 id="doc_section_5_4_1"> <div class="self-section-number"> -<a href="#doc_section_3_4_1">3.4.1</a> </div> +<a href="#doc_section_5_4_1">5.4.1</a> </div> <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> +<p id="doc_section_5_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.116"></div> <pre> argc = xo_parse_args(argc, argv); if (argc < 0) exit(EXIT_FAILURE); - </pre> <p id="doc_section_3_4_1_p_3">Following the call to xo_parse_args, the application can process the remaining arguments in a normal manner. See <a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a> for a description of valid arguments.</p> + </pre> <p id="doc_section_5_4_1_p_3">Following the call to xo_parse_args, the application can process the remaining arguments in a normal manner. See <a href="#options" title="Command-line Arguments">Section 4</a> for a description of valid arguments.</p> </div> <div class="content"> -<h3 id="doc_section_3_4_2"> +<h3 id="doc_section_5_4_2"> <div class="self-section-number"> -<a href="#doc_section_3_4_2">3.4.2</a> </div> +<a href="#doc_section_5_4_2">5.4.2</a> </div> <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> +<p id="doc_section_5_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.117"></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> + </pre> <p id="doc_section_5_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> <div class="content"> -<h3 id="doc_section_3_4_3"> +<h3 id="doc_section_5_4_3"> <div class="self-section-number"> -<a href="#doc_section_3_4_3">3.4.3</a> </div> +<a href="#doc_section_5_4_3">5.4.3</a> </div> <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> +<p id="doc_section_5_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.118"></div> <pre> void xo_set_version (const char *version); void xo_set_version_h (xo_handle_t *xop, const char *version); </pre> </div> <div class="content"> -<h3 id="doc_section_3_4_4"> +<h3 id="doc_section_5_4_4"> <div class="self-section-number"> -<a href="#doc_section_3_4_4">3.4.4</a> </div> +<a href="#doc_section_5_4_4">5.4.4</a> </div> <a id="info" href="#info">Field Information (xo_info_t)</a> </h3> -<p id="doc_section_3_4_4_p_1">HTML data can include additional information in attributes that begin with "data‑". 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> +<p id="doc_section_5_4_4_p_1">HTML data can include additional information in attributes that begin with "data‑". To enable this, three things must occur:</p> +<p id="doc_section_5_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_5_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.119"></div> <pre> typedef struct xo_info_s { const char *xi_name; /* Name of the element */ const char *xi_type; /* Type of field */ @@ -24971,9 +25180,9 @@ jQuery(function ($) { } xo_info_t; 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> + </pre> <p id="doc_section_5_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_5_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.120"></div> <pre> xo_info_t info[] = { { "in-stock", "number", "Number of items in stock" }, { "name", "string", "Name of the item" }, @@ -24984,116 +25193,59 @@ jQuery(function ($) { int info_count = (sizeof(info) / sizeof(info[0])); ... 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 "‑‑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‑type" and "data‑help" attributes:</p> -<div id="doc_figure_u.113"></div> <pre> + </pre> <p id="doc_section_5_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 "‑‑libxo=info" command line argument.</p> +<p id="doc_section_5_4_4_p_9">The type and help values, if present, are emitted as the "data‑type" and "data‑help" attributes:</p> +<div id="doc_figure_u.121"></div> <pre> <div class="data" data-tag="sku" data-type="string" data-help="Stock Keeping Unit">GRO-000-533</div> </pre> </div> <div class="content"> -<h3 id="doc_section_3_4_5"> +<h3 id="doc_section_5_4_5"> <div class="self-section-number"> -<a href="#doc_section_3_4_5">3.4.5</a> </div> +<a href="#doc_section_5_4_5">5.4.5</a> </div> <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> +<p id="doc_section_5_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.122"></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> -<p id="doc_section_3_4_5_p_4">By default, the standard realloc() and free() functions are used.</p> + </pre> <p id="doc_section_5_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> +<p id="doc_section_5_4_5_p_4">By default, the standard realloc() and free() functions are used.</p> </div> <div class="content"> -<h3 id="doc_section_3_4_6"> +<h3 id="doc_section_5_4_6"> <div class="self-section-number"> -<a href="#doc_section_3_4_6">3.4.6</a> </div> +<a href="#doc_section_5_4_6">5.4.6</a> </div> <a id="LIBXO_OPTIONS" href="#LIBXO_OPTIONS">LIBXO_OPTIONS</a> </h3> -<p id="doc_section_3_4_6_p_1">The environment variable "LIBXO_OPTIONS" can be set to a string of options:</p> -<div id="doc_table_u.15"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> -<thead><tr> -<th class="left">Option</th> -<th class="left">Action</th> -</tr></thead> -<tbody> -<tr> -<td>c</td> -<td>Enable color/effects for TEXT/HTML</td> -</tr> -<tr> -<td>F</td> -<td>Force line-buffered flushing</td> -</tr> -<tr> -<td>H</td> -<td>Enable HTML output (XO_STYLE_HTML)</td> -</tr> -<tr> -<td>I</td> -<td>Enable info output (XOF_INFO)</td> -</tr> -<tr> -<td>i<num></td> -<td>Indent by <number></td> -</tr> -<tr> -<td>J</td> -<td>Enable JSON output (XO_STYLE_JSON)</td> -</tr> -<tr> -<td>k</td> -<td>Add keys to XPATH expressions in HTML</td> -</tr> -<tr> -<td>n</td> -<td>Disable humanization (TEXT, HTML)</td> -</tr> -<tr> -<td>P</td> -<td>Enable pretty-printed output (XOF_PRETTY)</td> -</tr> -<tr> -<td>T</td> -<td>Enable text output (XO_STYLE_TEXT)</td> -</tr> -<tr> -<td>U</td> -<td>Add units to HTML output</td> -</tr> -<tr> -<td>u</td> -<td>Change "-"s to "_"s in element names (JSON)</td> -</tr> -<tr> -<td>W</td> -<td>Enable warnings (XOF_WARN)</td> -</tr> -<tr> -<td>X</td> -<td>Enable XML output (XO_STYLE_XML)</td> -</tr> -<tr> -<td>x</td> -<td>Enable XPath data (XOF_XPATH)</td> -</tr> -</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> - % 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> - % 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 "‑‑libxo" option is preferable in most situations.</p> +<p id="doc_section_5_4_6_p_1">The environment variable "LIBXO_OPTIONS" can be set to a subset of libxo options, including:</p> +<p id="doc_section_5_4_6_p_2"> </p> +<ul> +<li>color</li> +<li>flush</li> +<li>flush-line</li> +<li>no-color</li> +<li>no-humanize</li> +<li>no-locale</li> +<li>no-retain</li> +<li>pretty</li> +<li>retain</li> +<li>underscores</li> +<li>warn</li> +</ul> +<p id="doc_section_5_4_6_p_3">For example, warnings can be enabled by:</p> +<div id="doc_figure_u.123"></div> <pre> + % env LIBXO_OPTIONS=warn my-app + </pre> <p id="doc_section_5_4_6_p_5">Since environment variables are inherited, child processes will have the same options, which may be undesirable, making the use of the "‑‑libxo" option is preferable in most situations.</p> </div> <div class="content"> -<h3 id="doc_section_3_4_7"> +<h3 id="doc_section_5_4_7"> <div class="self-section-number"> -<a href="#doc_section_3_4_7">3.4.7</a> </div> +<a href="#doc_section_5_4_7">5.4.7</a> </div> <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> +<p id="doc_section_5_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.124"></div> <pre> void xo_warn (const char *fmt, ...); void xo_warnx (const char *fmt, ...); void xo_warn_c (int code, const char *fmt, ...); @@ -25108,20 +25260,20 @@ jQuery(function ($) { const char *fmt, ...); 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> + </pre> <p id="doc_section_5_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.125"></div> <pre> EXAMPLE: if (open(filename, O_RDONLY) < 0) xo_err(1, "cannot open file '%s'", filename); </pre> </div> <div class="content"> -<h3 id="doc_section_3_4_8"> +<h3 id="doc_section_5_4_8"> <div class="self-section-number"> -<a href="#doc_section_3_4_8">3.4.8</a> </div> +<a href="#doc_section_5_4_8">5.4.8</a> </div> <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> +<p id="doc_section_5_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.126"></div> <pre> EXAMPLE:: xo_error("Does not %s", "compute"); XML:: @@ -25130,29 +25282,29 @@ jQuery(function ($) { "error": { "message": "Does not compute" } </pre> </div> <div class="content"> -<h3 id="doc_section_3_4_9"> +<h3 id="doc_section_5_4_9"> <div class="self-section-number"> -<a href="#doc_section_3_4_9">3.4.9</a> </div> +<a href="#doc_section_5_4_9">5.4.9</a> </div> <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‑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> +<p id="doc_section_5_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‑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.127"></div> <pre> void xo_no_setlocale (void); </pre> </div> </div> <div class="content"> -<h2 id="doc_section_3_5"> +<h2 id="doc_section_5_5"> <div class="self-section-number"> -<a href="#doc_section_3_5">3.5</a> </div> +<a href="#doc_section_5_5">5.5</a> </div> <a id="emitting-syslog-messages" href="#emitting-syslog-messages">Emitting syslog Messages</a> </h2> -<p id="doc_section_3_5_p_1">syslog is the system logging facility used throughout the unix world. Messages are sent from commands, applications, and daemons to a hierarchy of servers, where they are filtered, saved, and forwarded based on configuration behaviors.</p> -<p id="doc_section_3_5_p_2">syslog is an older protocol, originally documented only in source code. By the time RFC 3164 published, variation and mutation left the leading "<pri>" string as only common content. RFC 5424 defines a new version (version 1) of syslog and introduces structured data into the messages. Structured data is a set of name/value pairs transmitted distinctly alongside the traditional text message, allowing filtering on precise values instead of regular expressions.</p> -<p id="doc_section_3_5_p_3">These name/value pairs are scoped by a two-part identifier; an enterprise identifier names the party responsible for the message catalog and a name identifying that message. Enterprise IDs are defined by IANA, the Internet Assigned Numbers Authority:</p> -<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> +<p id="doc_section_5_5_p_1">syslog is the system logging facility used throughout the unix world. Messages are sent from commands, applications, and daemons to a hierarchy of servers, where they are filtered, saved, and forwarded based on configuration behaviors.</p> +<p id="doc_section_5_5_p_2">syslog is an older protocol, originally documented only in source code. By the time RFC 3164 published, variation and mutation left the leading "<pri>" string as only common content. RFC 5424 defines a new version (version 1) of syslog and introduces structured data into the messages. Structured data is a set of name/value pairs transmitted distinctly alongside the traditional text message, allowing filtering on precise values instead of regular expressions.</p> +<p id="doc_section_5_5_p_3">These name/value pairs are scoped by a two-part identifier; an enterprise identifier names the party responsible for the message catalog and a name identifying that message. Enterprise IDs are defined by IANA, the Internet Assigned Numbers Authority:</p> +<p id="doc_section_5_5_p_4">https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers</p> +<p id="doc_section_5_5_p_5">Use the <a href="#xo_set_syslog_enterprise_id" title="xo_set_syslog_enterprise_id">Section 5.5.3.5</a>() function to set the Enterprise ID, as needed.</p> +<p id="doc_section_5_5_p_6">The message name should follow the conventions in <a href="#good-field-names" title="What makes a good field name?">Section 10.1.3</a>, as should the fields within the message.</p> +<div id="doc_figure_u.128"></div> <pre> /* Both of these calls are optional */ xo_set_syslog_enterprise_id(32473); xo_open_log("my-program", 0, LOG_DAEMON); @@ -25166,26 +25318,26 @@ jQuery(function ($) { xo_syslog(LOG_INFO, "poofd-invalid-state", "state {:current/%u} is invalid {:connection/%u}", state, conn); - </pre> <p id="doc_section_3_5_p_8">The developer should be aware that the message name may be used in the future to allow access to further information, including documentation. Care should be taken to choose quality, descriptive names.</p> -<p id="doc_section_3_5_p_9">Section Contents: </p> + </pre> <p id="doc_section_5_5_p_8">The developer should be aware that the message name may be used in the future to allow access to further information, including documentation. Care should be taken to choose quality, descriptive names.</p> +<p id="doc_section_5_5_p_9">Section Contents: </p> <ul> -<li><a href="#priority" title="Priority, Facility, and Flags">Section 3.5.1</a></li> -<li><a href="#xo_syslog" title="xo_syslog">Section 3.5.2</a></li> -<li><a href="#support-functions-2" title="Support functions">Section 3.5.3</a></li> +<li><a href="#priority" title="Priority, Facility, and Flags">Section 5.5.1</a></li> +<li><a href="#xo_syslog" title="xo_syslog">Section 5.5.2</a></li> +<li><a href="#support-functions-2" title="Support functions">Section 5.5.3</a></li> </ul> <div class="content"> -<h3 id="doc_section_3_5_1"> +<h3 id="doc_section_5_5_1"> <div class="self-section-number"> -<a href="#doc_section_3_5_1">3.5.1</a> </div> +<a href="#doc_section_5_5_1">5.5.1</a> </div> <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> +<p id="doc_section_5_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.129"></div> <pre> xo_syslog(LOG_ERR | LOG_AUTH, "login-failed", "Login failed; user '{:user}' from host '{:address}'", user, addr); - </pre> <p id="doc_section_3_5_1_p_3">These values are defined in <syslog.h>.</p> -<p id="doc_section_3_5_1_p_4">The priority value indicates the importance and potential impact of each message.</p> + </pre> <p id="doc_section_5_5_1_p_3">These values are defined in <syslog.h>.</p> +<p id="doc_section_5_5_1_p_4">The priority value indicates the importance and potential impact of each message.</p> <div id="doc_table_u.16"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Priority</th> @@ -25226,7 +25378,7 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_3_5_1_p_5">The facility value indicates the source of message, in fairly generic terms.</p> +<p id="doc_section_5_5_1_p_5">The facility value indicates the source of message, in fairly generic terms.</p> <div id="doc_table_u.17"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Facility</th> @@ -25291,7 +25443,7 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_3_5_1_p_6">In addition to the values listed above, xo_open_log accepts a set of addition flags requesting specific behaviors.</p> +<p id="doc_section_5_5_1_p_6">In addition to the values listed above, xo_open_log accepts a set of addition flags requesting specific behaviors.</p> <div id="doc_table_u.18"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Flag</th> @@ -25318,14 +25470,14 @@ jQuery(function ($) { </table></div> </div> <div class="content"> -<h3 id="doc_section_3_5_2"> +<h3 id="doc_section_5_5_2"> <div class="self-section-number"> -<a href="#doc_section_3_5_2">3.5.2</a> </div> +<a href="#doc_section_5_5_2">5.5.2</a> </div> <a id="xo_syslog" href="#xo_syslog">xo_syslog</a> </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> +<p id="doc_section_5_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_5_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.130"></div> <pre> xo_syslog(LOG_ERR, "poofd-missing-file", "'{:filename}' not found: {:error/%m}", filename); @@ -25334,27 +25486,27 @@ jQuery(function ($) { found: Permission denied </pre> </div> <div class="content"> -<h3 id="doc_section_3_5_3"> +<h3 id="doc_section_5_5_3"> <div class="self-section-number"> -<a href="#doc_section_3_5_3">3.5.3</a> </div> +<a href="#doc_section_5_5_3">5.5.3</a> </div> <a id="support-functions-2" href="#support-functions-2">Support functions</a> </h3> -<p id="doc_section_3_5_3_p_1">Section Contents: </p> +<p id="doc_section_5_5_3_p_1">Section Contents: </p> <ul> -<li><a href="#xo_vsyslog" title="xo_vsyslog">Section 3.5.3.1</a></li> -<li><a href="#xo_open_log" title="xo_open_log">Section 3.5.3.2</a></li> -<li><a href="#xo_close_log" title="xo_close_log">Section 3.5.3.3</a></li> -<li><a href="#xo_set_logmask" title="xo_set_logmask">Section 3.5.3.4</a></li> -<li><a href="#xo_set_syslog_enterprise_id" title="xo_set_syslog_enterprise_id">Section 3.5.3.5</a></li> +<li><a href="#xo_vsyslog" title="xo_vsyslog">Section 5.5.3.1</a></li> +<li><a href="#xo_open_log" title="xo_open_log">Section 5.5.3.2</a></li> +<li><a href="#xo_close_log" title="xo_close_log">Section 5.5.3.3</a></li> +<li><a href="#xo_set_logmask" title="xo_set_logmask">Section 5.5.3.4</a></li> +<li><a href="#xo_set_syslog_enterprise_id" title="xo_set_syslog_enterprise_id">Section 5.5.3.5</a></li> </ul> <div class="content"> -<h4 id="doc_section_3_5_3_1"> +<h4 id="doc_section_5_5_3_1"> <div class="self-section-number"> -<a href="#doc_section_3_5_3_1">3.5.3.1</a> </div> +<a href="#doc_section_5_5_3_1">5.5.3.1</a> </div> <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> +<p id="doc_section_5_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.131"></div> <pre> void my_log (const char *name, const char *fmt, ...) { va_list vap; @@ -25364,35 +25516,35 @@ jQuery(function ($) { } </pre> </div> <div class="content"> -<h4 id="doc_section_3_5_3_2"> +<h4 id="doc_section_5_5_3_2"> <div class="self-section-number"> -<a href="#doc_section_3_5_3_2">3.5.3.2</a> </div> +<a href="#doc_section_5_5_3_2">5.5.3.2</a> </div> <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> +<p id="doc_section_5_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 5.5.1</a>.</p> +<div id="doc_figure_u.132"></div> <pre> void xo_open_log (const char *ident, int logopt, int facility); </pre> </div> <div class="content"> -<h4 id="doc_section_3_5_3_3"> +<h4 id="doc_section_5_5_3_3"> <div class="self-section-number"> -<a href="#doc_section_3_5_3_3">3.5.3.3</a> </div> +<a href="#doc_section_5_5_3_3">5.5.3.3</a> </div> <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> +<p id="doc_section_5_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.133"></div> <pre> void xo_close_log (void); </pre> </div> <div class="content"> -<h4 id="doc_section_3_5_3_4"> +<h4 id="doc_section_5_5_3_4"> <div class="self-section-number"> -<a href="#doc_section_3_5_3_4">3.5.3.4</a> </div> +<a href="#doc_section_5_5_3_4">5.5.3.4</a> </div> <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> +<p id="doc_section_5_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.134"></div> <pre> int xo_set_logmask (int maskpri); @@ -25400,85 +25552,85 @@ jQuery(function ($) { setlogmask(LOG_UPTO(LOG_WARN)); </pre> </div> <div class="content"> -<h4 id="doc_section_3_5_3_5"> +<h4 id="doc_section_5_5_3_5"> <div class="self-section-number"> -<a href="#doc_section_3_5_3_5">3.5.3.5</a> </div> +<a href="#doc_section_5_5_3_5">5.5.3.5</a> </div> <a id="xo_set_syslog_enterprise_id" href="#xo_set_syslog_enterprise_id">xo_set_syslog_enterprise_id</a> </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> +<p id="doc_section_5_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_5_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.135"></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> -<p id="doc_section_3_5_3_5_p_5"> <a href="https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers">https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers</a></p> -<p id="doc_section_3_5_3_5_p_6">New EIDs can be requested from IANA using the following page:</p> -<p id="doc_section_3_5_3_5_p_7"> <a href="http://pen.iana.org/pen/PenApplication.page">http://pen.iana.org/pen/PenApplication.page</a></p> -<p id="doc_section_3_5_3_5_p_8">Each software development organization that defines a set of syslog messages should register their own EID and use that value in their software to ensure that messages can be uniquely identified by the combination of EID + message name.</p> + </pre> <p id="doc_section_5_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> +<p id="doc_section_5_5_3_5_p_5"> <a href="https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers">https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers</a></p> +<p id="doc_section_5_5_3_5_p_6">New EIDs can be requested from IANA using the following page:</p> +<p id="doc_section_5_5_3_5_p_7"> <a href="http://pen.iana.org/pen/PenApplication.page">http://pen.iana.org/pen/PenApplication.page</a></p> +<p id="doc_section_5_5_3_5_p_8">Each software development organization that defines a set of syslog messages should register their own EID and use that value in their software to ensure that messages can be uniquely identified by the combination of EID + message name.</p> </div> </div> </div> <div class="content"> -<h2 id="doc_section_3_6"> +<h2 id="doc_section_5_6"> <div class="self-section-number"> -<a href="#doc_section_3_6">3.6</a> </div> +<a href="#doc_section_5_6">5.6</a> </div> <a id="creating-custom-encoders" href="#creating-custom-encoders">Creating Custom Encoders</a> </h2> -<p id="doc_section_3_6_p_1">The number of encoding schemes in current use is staggering, with new and distinct schemes appearing daily. While libxo provide XML, JSON, HMTL, and text natively, there are requirements for other encodings.</p> -<p id="doc_section_3_6_p_2">Rather than bake support for all possible encoders into libxo, the API allows them to be defined externally. libxo can then interfaces with these encoding modules using a simplistic API. libxo processes all functions calls, handles state transitions, performs all formatting, and then passes the results as operations to a customized encoding function, which implements specific encoding logic as required. This means your encoder doesn't need to detect errors with unbalanced open/close operations but can rely on libxo to pass correct data.</p> -<p id="doc_section_3_6_p_3">By making a simple API, libxo internals are not exposed, insulating the encoder and the library from future or internal changes.</p> -<p id="doc_section_3_6_p_4">The three elements of the API are:</p> -<p id="doc_section_3_6_p_5"> </p> +<p id="doc_section_5_6_p_1">The number of encoding schemes in current use is staggering, with new and distinct schemes appearing daily. While libxo provide XML, JSON, HMTL, and text natively, there are requirements for other encodings.</p> +<p id="doc_section_5_6_p_2">Rather than bake support for all possible encoders into libxo, the API allows them to be defined externally. libxo can then interfaces with these encoding modules using a simplistic API. libxo processes all functions calls, handles state transitions, performs all formatting, and then passes the results as operations to a customized encoding function, which implements specific encoding logic as required. This means your encoder doesn't need to detect errors with unbalanced open/close operations but can rely on libxo to pass correct data.</p> +<p id="doc_section_5_6_p_3">By making a simple API, libxo internals are not exposed, insulating the encoder and the library from future or internal changes.</p> +<p id="doc_section_5_6_p_4">The three elements of the API are:</p> +<p id="doc_section_5_6_p_5"> </p> <ul> <li>loading</li> <li>initialization</li> <li>operations</li> </ul> -<p id="doc_section_3_6_p_6">The following sections provide details about these topics.</p> -<p id="doc_section_3_6_p_7">libxo source contain an encoder for Concise Binary Object Representation, aka CBOR (RFC 7049) which can be used as used as an example for the API.</p> -<p id="doc_section_3_6_p_8">Section Contents: </p> +<p id="doc_section_5_6_p_6">The following sections provide details about these topics.</p> +<p id="doc_section_5_6_p_7">libxo source contain an encoder for Concise Binary Object Representation, aka CBOR (RFC 7049) which can be used as used as an example for the API.</p> +<p id="doc_section_5_6_p_8">Section Contents: </p> <ul> -<li><a href="#loading-encoders" title="Loading Encoders">Section 3.6.1</a></li> -<li><a href="#encoder-initialization" title="Encoder Initialization">Section 3.6.2</a></li> -<li><a href="#operations" title="Operations">Section 3.6.3</a></li> +<li><a href="#loading-encoders" title="Loading Encoders">Section 5.6.1</a></li> +<li><a href="#encoder-initialization" title="Encoder Initialization">Section 5.6.2</a></li> +<li><a href="#operations" title="Operations">Section 5.6.3</a></li> </ul> <div class="content"> -<h3 id="doc_section_3_6_1"> +<h3 id="doc_section_5_6_1"> <div class="self-section-number"> -<a href="#doc_section_3_6_1">3.6.1</a> </div> +<a href="#doc_section_5_6_1">5.6.1</a> </div> <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> +<p id="doc_section_5_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.136"></div> <pre> % ls -1 lib/libxo/extensions/*.enc lib/libxo/extensions/cbor.enc lib/libxo/extensions/test.enc </pre> </div> <div class="content"> -<h3 id="doc_section_3_6_2"> +<h3 id="doc_section_5_6_2"> <div class="self-section-number"> -<a href="#doc_section_3_6_2">3.6.2</a> </div> +<a href="#doc_section_5_6_2">5.6.2</a> </div> <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> +<p id="doc_section_5_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.137"></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> + </pre> <p id="doc_section_5_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_5_6_2_p_4"> </p> <ul> <li>xei_version is the version number of the API as implemented within libxo. This version is currently as 1 using XO_ENCODER_VERSION. This number can be checked to ensure compatibility. The working assumption is that all versions should be backward compatible, but each side may need to accurately know the version supported by the other side. xo_encoder_library_init can optionally check this value, and must then set it to the version number used by the encoder, allowing libxo to detect version differences and react accordingly. For example, if version 2 adds new operations, then libxo will know that an encoding library that set xei_version to 1 cannot be expected to handle those new operations.</li> <li>xei_handler must be set to a pointer to a function of type xo_encoder_func_t, as defined in xo_encoder.h. This function takes a set of parameters: -- xop is a pointer to the opaque xo_handle_t structure -- op is an integer representing the current operation -- name is a string whose meaning differs by operation -- value is a string whose meaning differs by operation -- private is an opaque structure provided by the encoder</li> </ul> -<p id="doc_section_3_6_2_p_5">Additional arguments may be added in the future, so handler functions should use the XO_ENCODER_HANDLER_ARGS macro. An appropriate "extern" declaration is provided to help catch errors.</p> -<p id="doc_section_3_6_2_p_6">Once the encoder initialization function has completed processing, it should return zero to indicate that no error has occurred. A non-zero return code will cause the handle initialization to fail.</p> +<p id="doc_section_5_6_2_p_5">Additional arguments may be added in the future, so handler functions should use the XO_ENCODER_HANDLER_ARGS macro. An appropriate "extern" declaration is provided to help catch errors.</p> +<p id="doc_section_5_6_2_p_6">Once the encoder initialization function has completed processing, it should return zero to indicate that no error has occurred. A non-zero return code will cause the handle initialization to fail.</p> </div> <div class="content"> -<h3 id="doc_section_3_6_3"> +<h3 id="doc_section_5_6_3"> <div class="self-section-number"> -<a href="#doc_section_3_6_3">3.6.3</a> </div> +<a href="#doc_section_5_6_3">5.6.3</a> </div> <a id="operations" href="#operations">Operations</a> </h3> -<p id="doc_section_3_6_3_p_1">The encoder API defines a set of operations representing the processing model of libxo. Content is formatted within libxo, and callbacks are made to the encoder's handler function when data is ready to be processed.</p> +<p id="doc_section_5_6_3_p_1">The encoder API defines a set of operations representing the processing model of libxo. Content is formatted within libxo, and callbacks are made to the encoder's handler function when data is ready to be processed.</p> <div id="doc_table_u.19"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Operation</th> @@ -25551,22 +25703,22 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_3_6_3_p_2">For all the open and close operations, the name parameter holds the name of the construct. For string, content, and attribute operations, the name parameter is the name of the field and the value parameter is the value. "string" are differentiated from "content" to allow differing treatment of true, false, null, and numbers from real strings, though content values are formatted as strings before the handler is called. For version operations, the value parameter contains the version.</p> -<p id="doc_section_3_6_3_p_3">All strings are encoded in UTF-8.</p> +<p id="doc_section_5_6_3_p_2">For all the open and close operations, the name parameter holds the name of the construct. For string, content, and attribute operations, the name parameter is the name of the field and the value parameter is the value. "string" are differentiated from "content" to allow differing treatment of true, false, null, and numbers from real strings, though content values are formatted as strings before the handler is called. For version operations, the value parameter contains the version.</p> +<p id="doc_section_5_6_3_p_3">All strings are encoded in UTF-8.</p> </div> </div> </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_4" class="np"> +<h1 id="doc_section_6" class="np"> <div class="self-section-number"> -<a href="#doc_section_4">4_</a> </div> +<a href="#doc_section_6">6_</a> </div> <a id="the-xo-utility" href="#the-xo-utility">The "xo" Utility</a> </h1> -<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: "‑X" for XML, "‑J" for JSON, "‑H" for HTML, or "‑T" for TEXT, which is the default. The "--style <style>" 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> +<p id="doc_section_6_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_6_p_2">The style of output can be selected using a specific option: "‑X" for XML, "‑J" for JSON, "‑H" for HTML, or "‑T" for TEXT, which is the default. The "--style <style>" option can also be used. The standard set of "‑‑libxo" options are available (see <a href="#options" title="Command-line Arguments">Section 4</a>), as well as the LIBXO_OPTIONS environment variable (see <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 5.4.6</a>).</p> +<p id="doc_section_6_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.138"></div> <pre> xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6 TEXT: @@ -25585,8 +25737,8 @@ jQuery(function ($) { <div class="data" data-tag="weight">6</div> <div class="text"> pounds.</div> </div> - </pre> <p id="doc_section_4_p_5">The "--wrap <path>" 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> + </pre> <p id="doc_section_6_p_5">The "--wrap <path>" 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.139"></div> <pre> xo --wrap top/a/b/c '{:tag}' value XML: @@ -25609,8 +25761,8 @@ jQuery(function ($) { } } } - </pre> <p id="doc_section_4_p_7">The "--open <path>" and "--close <path>" 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 "‑‑depth" option may be used to set the depth for indentation. The "‑‑leading‑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> + </pre> <p id="doc_section_6_p_7">The "--open <path>" and "--close <path>" 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 "‑‑depth" option may be used to set the depth for indentation. The "‑‑leading‑xpath" may be used to prepend data to the XPath values used for HTML output style.</p> +<div id="doc_figure_u.140"></div> <pre> #!/bin/sh xo --open top/data xo --depth 2 '{tag}' value @@ -25627,19 +25779,19 @@ jQuery(function ($) { "tag": "value" } } - </pre> <p id="doc_section_4_p_9">Section Contents: </p> + </pre> <p id="doc_section_6_p_9">Section Contents: </p> <ul> -<li><a href="#command-line-options" title="Command Line Options">Section 4.1</a></li> -<li><a href="#example-2" title="Example">Section 4.2</a></li> +<li><a href="#command-line-options" title="Command Line Options">Section 6.1</a></li> +<li><a href="#example-2" title="Example">Section 6.2</a></li> </ul> <div class="content"> -<h2 id="doc_section_4_1"> +<h2 id="doc_section_6_1"> <div class="self-section-number"> -<a href="#doc_section_4_1">4.1</a> </div> +<a href="#doc_section_6_1">6.1</a> </div> <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> +<p id="doc_section_6_1_p_1">Usage: xo [options] format [fields]</p> +<div id="doc_figure_u.141"></div> <pre> --close <path> Close tags for the given path --depth <num> Set the depth for pretty printing --help Display this help text @@ -25658,12 +25810,12 @@ jQuery(function ($) { --xpath Add XPath data to HTML output); </pre> </div> <div class="content"> -<h2 id="doc_section_4_2"> +<h2 id="doc_section_6_2"> <div class="self-section-number"> -<a href="#doc_section_4_2">4.2</a> </div> +<a href="#doc_section_6_2">6.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.142"></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" @@ -25673,13 +25825,13 @@ jQuery(function ($) { </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_5" class="np"> +<h1 id="doc_section_7" class="np"> <div class="self-section-number"> -<a href="#doc_section_5">5_</a> </div> +<a href="#doc_section_7">7_</a> </div> <a id="xolint" href="#xolint">xolint</a> </h1> -<p id="doc_section_5_p_1">xolint is a tool for reporting common mistakes in format strings in source code that invokes xo_emit(). It allows these errors to be diagnosed at build time, rather than waiting until runtime.</p> -<p id="doc_section_5_p_2">xolint takes the one or more C files as arguments, and reports and errors, warning, or informational messages as needed.</p> +<p id="doc_section_7_p_1">xolint is a tool for reporting common mistakes in format strings in source code that invokes xo_emit(). It allows these errors to be diagnosed at build time, rather than waiting until runtime.</p> +<p id="doc_section_7_p_2">xolint takes the one or more C files as arguments, and reports and errors, warning, or informational messages as needed.</p> <div id="doc_table_u.20"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Option</th> @@ -25720,23 +25872,23 @@ jQuery(function ($) { </tr> </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> +<p id="doc_section_7_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.143"></div> <pre> % xolint.pl -t xolint.c xolint.c: 16: error: anchor format should be "%d" 16 xo_emit("{[:/%s}"); - </pre> <p id="doc_section_5_p_5">The "‑I" option will generate a table of xo_info_t structures ,</p> -<p id="doc_section_5_p_6">The "‑V" option does not report errors, but prints a complete list of all field names, sorted alphabetically. The output can help spot inconsistencies and spelling errors.</p> + </pre> <p id="doc_section_7_p_5">The "‑I" option will generate a table of xo_info_t structures ,</p> +<p id="doc_section_7_p_6">The "‑V" option does not report errors, but prints a complete list of all field names, sorted alphabetically. The output can help spot inconsistencies and spelling errors.</p> </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_6" class="np"> +<h1 id="doc_section_8" class="np"> <div class="self-section-number"> -<a href="#doc_section_6">6_</a> </div> +<a href="#doc_section_8">8_</a> </div> <a id="xohtml" href="#xohtml">xohtml</a> </h1> -<p id="doc_section_6_p_1">xohtml is a tool for turning the output of libxo-enabled commands into html files suitable for display in modern HTML web browsers. It can be used to test and debug HTML output, as well as to make the user ache to escape the world of 70s terminal devices.</p> -<p id="doc_section_6_p_2">xohtml is given a command, either on the command line or via the "‑c" option. If not command is given, standard input is used. The command's output is wrapped in HTML tags, with references to supporting CSS and Javascript files, and written to standard output or the file given in the "‑f" option. The "‑b" option can be used to provide an alternative base path for the support files.</p> +<p id="doc_section_8_p_1">xohtml is a tool for turning the output of libxo-enabled commands into html files suitable for display in modern HTML web browsers. It can be used to test and debug HTML output, as well as to make the user ache to escape the world of 70s terminal devices.</p> +<p id="doc_section_8_p_2">xohtml is given a command, either on the command line or via the "‑c" option. If not command is given, standard input is used. The command's output is wrapped in HTML tags, with references to supporting CSS and Javascript files, and written to standard output or the file given in the "‑f" option. The "‑b" option can be used to provide an alternative base path for the support files.</p> <div id="doc_table_u.21"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Option</th> @@ -25757,18 +25909,18 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<p id="doc_section_6_p_3">The "‑c" option takes a full command with arguments, including any libxo options needed to generate html ("‑‑libxo=html"). This value must be quoted if it consists of multiple tokens.</p> +<p id="doc_section_8_p_3">The "‑c" option takes a full command with arguments, including any libxo options needed to generate html ("‑‑libxo=html"). This value must be quoted if it consists of multiple tokens.</p> </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_7" class="np"> +<h1 id="doc_section_9" class="np"> <div class="self-section-number"> -<a href="#doc_section_7">7_</a> </div> +<a href="#doc_section_9">9_</a> </div> <a id="xopo" href="#xopo">xopo</a> </h1> -<p id="doc_section_7_p_1">The "xopo" utility filters ".pot" files generated by the "xgettext" utility to remove formatting information suitable for use with the "{G:}" modifier. This means that when the developer changes the formatting portion of the field definitions, or the fields modifiers, the string passed to gettext(3) is unchanged, avoiding the expense of updating any existing translation files (".po" files).</p> -<p id="doc_section_7_p_2">The syntax for the xopo command is one of two forms; it can be used as a filter for processing a .po or .pot file, rewriting the "msgid" strings with a simplified message string. In this mode, the input is either standard input or a file given by the "‑f" option, and the output is either standard output or a file given by the "‑o" option.</p> -<p id="doc_section_7_p_3">In the second mode, a simple message given using the "‑s" option on the command, and the simplified version of that message is printed on stdout.</p> +<p id="doc_section_9_p_1">The "xopo" utility filters ".pot" files generated by the "xgettext" utility to remove formatting information suitable for use with the "{G:}" modifier. This means that when the developer changes the formatting portion of the field definitions, or the fields modifiers, the string passed to gettext(3) is unchanged, avoiding the expense of updating any existing translation files (".po" files).</p> +<p id="doc_section_9_p_2">The syntax for the xopo command is one of two forms; it can be used as a filter for processing a .po or .pot file, rewriting the "msgid" strings with a simplified message string. In this mode, the input is either standard input or a file given by the "‑f" option, and the output is either standard output or a file given by the "‑o" option.</p> +<p id="doc_section_9_p_3">In the second mode, a simple message given using the "‑s" option on the command, and the simplified version of that message is printed on stdout.</p> <div id="doc_table_u.22"><table summary="" class="tt full" cellpadding="3" cellspacing="0"> <thead><tr> <th class="left">Option</th> @@ -25789,7 +25941,7 @@ jQuery(function ($) { </tr> </tbody> </table></div> -<div id="doc_figure_u.137"></div> <pre> +<div id="doc_figure_u.144"></div> <pre> EXAMPLE: % xopo -s "There are {:count/%u} {:event/%.6s} events\n" There are {:count} {:event} events\n @@ -25799,56 +25951,56 @@ jQuery(function ($) { --keyword=xo_emit_warn -C -E -n --foreign-user \ -o foo.pot.raw foo.c % xopo -f foo.pot.raw -o foo.pot - </pre> <p id="doc_section_7_p_5">Use of the "‑‑no‑wrap" option for xgettext is required to ensure that incoming msgid strings are not wrapped across multiple lines.</p> + </pre> <p id="doc_section_9_p_5">Use of the "‑‑no‑wrap" option for xgettext is required to ensure that incoming msgid strings are not wrapped across multiple lines.</p> </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_8" class="np"> +<h1 id="doc_section_10" class="np"> <div class="self-section-number"> -<a href="#doc_section_8">8_</a> </div> +<a href="#doc_section_10">10_</a> </div> <a id="faqs" href="#faqs">FAQs</a> </h1> -<p id="doc_section_8_p_1">This section contains the set of questions that users typically ask, along with answers that might be helpful.</p> -<p id="doc_section_8_p_2">Section Contents: </p> +<p id="doc_section_10_p_1">This section contains the set of questions that users typically ask, along with answers that might be helpful.</p> +<p id="doc_section_10_p_2">Section Contents: </p> <ul> -<li><a href="#general" title="General">Section 8.1</a></li> -<li><a href="#what-does-this-message-mean" title="What does this message mean?">Section 8.2</a></li> +<li><a href="#general" title="General">Section 10.1</a></li> +<li><a href="#what-does-this-message-mean" title="What does this message mean?">Section 10.2</a></li> </ul> -<p id="doc_section_8_p_3">Section Contents: </p> +<p id="doc_section_10_p_3">Section Contents: </p> <ul> -<li><a href="#general" title="General">Section 8.1</a></li> -<li><a href="#what-does-this-message-mean" title="What does this message mean?">Section 8.2</a></li> +<li><a href="#general" title="General">Section 10.1</a></li> +<li><a href="#what-does-this-message-mean" title="What does this message mean?">Section 10.2</a></li> </ul> <div class="content"> -<h2 id="doc_section_8_1"> +<h2 id="doc_section_10_1"> <div class="self-section-number"> -<a href="#doc_section_8_1">8.1</a> </div> +<a href="#doc_section_10_1">10.1</a> </div> <a id="general" href="#general">General</a> </h2> -<p id="doc_section_8_1_p_1">Section Contents: </p> +<p id="doc_section_10_1_p_1">Section Contents: </p> <ul> -<li><a href="#can-you-share-the-history-of-libxo" title="Can you share the history of libxo?">Section 8.1.1</a></li> -<li><a href="#did-the-complex-semantics-of-format-strings-evolve-over-time" title="Did the complex semantics of format strings evolve over time?">Section 8.1.2</a></li> -<li><a href="#good-field-names" title="What makes a good field name?">Section 8.1.3</a></li> +<li><a href="#can-you-share-the-history-of-libxo" title="Can you share the history of libxo?">Section 10.1.1</a></li> +<li><a href="#did-the-complex-semantics-of-format-strings-evolve-over-time" title="Did the complex semantics of format strings evolve over time?">Section 10.1.2</a></li> +<li><a href="#good-field-names" title="What makes a good field name?">Section 10.1.3</a></li> </ul> <div class="content"> -<h3 id="doc_section_8_1_1"> +<h3 id="doc_section_10_1_1"> <div class="self-section-number"> -<a href="#doc_section_8_1_1">8.1.1</a> </div> +<a href="#doc_section_10_1_1">10.1.1</a> </div> <a id="can-you-share-the-history-of-libxo" href="#can-you-share-the-history-of-libxo">Can you share the history of libxo?</a> </h3> -<p id="doc_section_8_1_1_p_1">In 2001, we added an XML API to the JUNOS operating system, which is built on top of FreeBSD. Eventually this API became standardized as the NETCONF API (RFC 6241). As part of this effort, we modified many FreeBSD utilities to emit XML, typically via a "‑X" switch. The results were mixed. The cost of maintaining this code, updating it, and carrying it were non-trivial, and contributed to our expense (and the associated delay) with upgrading the version of FreeBSD on which each release of JUNOS is based.</p> -<p id="doc_section_8_1_1_p_2">A recent (2014) effort within JUNOS aims at removing our modifications to the underlying FreeBSD code as a means of reducing the expense and delay in tracking HEAD. JUNOS is structured to have system components generate XML that is rendered by the CLI (think: login shell) into human-readable text. This allows the API to use the same plumbing as the CLI, and ensures that all components emit XML, and that it is emitted with knowledge of the consumer of that XML, yielding an API that have no incremental cost or feature delay.</p> -<p id="doc_section_8_1_1_p_3">libxo is an effort to mix the best aspects of the JUNOS strategy into FreeBSD in a seemless way, allowing commands to make printf-like output calls with a single code path.</p> +<p id="doc_section_10_1_1_p_1">In 2001, we added an XML API to the JUNOS operating system, which is built on top of FreeBSD. Eventually this API became standardized as the NETCONF API (RFC 6241). As part of this effort, we modified many FreeBSD utilities to emit XML, typically via a "‑X" switch. The results were mixed. The cost of maintaining this code, updating it, and carrying it were non-trivial, and contributed to our expense (and the associated delay) with upgrading the version of FreeBSD on which each release of JUNOS is based.</p> +<p id="doc_section_10_1_1_p_2">A recent (2014) effort within JUNOS aims at removing our modifications to the underlying FreeBSD code as a means of reducing the expense and delay in tracking HEAD. JUNOS is structured to have system components generate XML that is rendered by the CLI (think: login shell) into human-readable text. This allows the API to use the same plumbing as the CLI, and ensures that all components emit XML, and that it is emitted with knowledge of the consumer of that XML, yielding an API that have no incremental cost or feature delay.</p> +<p id="doc_section_10_1_1_p_3">libxo is an effort to mix the best aspects of the JUNOS strategy into FreeBSD in a seemless way, allowing commands to make printf-like output calls with a single code path.</p> </div> <div class="content"> -<h3 id="doc_section_8_1_2"> +<h3 id="doc_section_10_1_2"> <div class="self-section-number"> -<a href="#doc_section_8_1_2">8.1.2</a> </div> +<a href="#doc_section_10_1_2">10.1.2</a> </div> <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> +<p id="doc_section_10_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.145"></div> <pre> tag docsis-state { help "State of the DOCSIS interface"; type string; @@ -25901,20 +26053,20 @@ jQuery(function ($) { field power; } } - </pre> <p id="doc_section_8_1_2_p_3">These tag definitions are compiled into field definitions that are triggered when matching XML elements are seen. ODL also supports other means of defining output.</p> -<p id="doc_section_8_1_2_p_4">The roles and modifiers describe these details.</p> -<p id="doc_section_8_1_2_p_5">In moving these ideas to bsd, two things had to happen: the formatting had to happen at the source since BSD won't have a JUNOS-like CLI to do the rendering, and we can't depend on external data models like ODL, which was seen as too hard a sell to the BSD community.</p> -<p id="doc_section_8_1_2_p_6">The results were that the xo_emit strings are used to encode the roles, modifiers, names, and formats. They are dense and a bit cryptic, but not so unlike printf format strings that developers will be lost.</p> -<p id="doc_section_8_1_2_p_7">libxo is a new implementation of these ideas and is distinct from the previous implementation in JUNOS.</p> + </pre> <p id="doc_section_10_1_2_p_3">These tag definitions are compiled into field definitions that are triggered when matching XML elements are seen. ODL also supports other means of defining output.</p> +<p id="doc_section_10_1_2_p_4">The roles and modifiers describe these details.</p> +<p id="doc_section_10_1_2_p_5">In moving these ideas to bsd, two things had to happen: the formatting had to happen at the source since BSD won't have a JUNOS-like CLI to do the rendering, and we can't depend on external data models like ODL, which was seen as too hard a sell to the BSD community.</p> +<p id="doc_section_10_1_2_p_6">The results were that the xo_emit strings are used to encode the roles, modifiers, names, and formats. They are dense and a bit cryptic, but not so unlike printf format strings that developers will be lost.</p> +<p id="doc_section_10_1_2_p_7">libxo is a new implementation of these ideas and is distinct from the previous implementation in JUNOS.</p> </div> <div class="content"> -<h3 id="doc_section_8_1_3"> +<h3 id="doc_section_10_1_3"> <div class="self-section-number"> -<a href="#doc_section_8_1_3">8.1.3</a> </div> +<a href="#doc_section_10_1_3">10.1.3</a> </div> <a id="good-field-names" href="#good-field-names">What makes a good field name?</a> </h3> -<p id="doc_section_8_1_3_p_1">To make useful, consistent field names, follow these guidelines:</p> -<p id="doc_section_8_1_3_p_2"> </p> +<p id="doc_section_10_1_3_p_1">To make useful, consistent field names, follow these guidelines:</p> +<p id="doc_section_10_1_3_p_2"> </p> <dl> <dt>Use lower case, even for TLAs</dt> <dd>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. Using "xpath" is simpler and better.</dd> @@ -25927,422 +26079,422 @@ 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.146"></div> <pre> if ($src1/process[pid == $pid]/name == $src2/proc-table/proc-list /proc-entry[process-id == $pid]/proc-name) { ... } - </pre> <p id="doc_section_8_1_3_p_4">Find someone else who is expressing similar data and follow their fields and hierarchy. Remember the quote is not "Consistency is the hobgoblin of little minds", but "A foolish consistency is the hobgoblin of little minds".</p> -<p id="doc_section_8_1_3_p_5"> </p> + </pre> <p id="doc_section_10_1_3_p_4">Find someone else who is expressing similar data and follow their fields and hierarchy. Remember the quote is not "Consistency is the hobgoblin of little minds", but "A foolish consistency is the hobgoblin of little minds".</p> +<p id="doc_section_10_1_3_p_5"> </p> <dl> <dt>Use containment as scoping</dt> <dd>In the previous example, all the names are prefixed with "proc‑", which is redundant given that they are nested under the process table.</dd> <dt>Think about your users</dt> -<dd>Have empathy for your users, choosing clear and useful fields that contain clear and useful data. You may need to augment the display content with xo_attr() calls (<a href="#xo_attr" title="Attributes (xo_attr)">Section 3.2.2</a>) or "{e:}" fields (<a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 2.2.2.4</a>) to make the data useful.</dd> +<dd>Have empathy for your users, choosing clear and useful fields that contain clear and useful data. You may need to augment the display content with xo_attr() calls (<a href="#xo_attr" title="Attributes (xo_attr)">Section 5.2.2</a>) or "{e:}" fields (<a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 3.2.2.4</a>) to make the data useful.</dd> <dt>Don't use an arbitrary number postfix</dt> <dd>What does "errors2" mean? No one will know. "errors‑after‑restart" would be a better choice. Think of your users, and think of the future. If you make "errors2", the next guy will happily make "errors3" and before you know it, someone will be asking what's the difference between errors37 and errors63.</dd> <dt>Be consistent, uniform, unsurprising, and predictable</dt> <dd>Think of your field vocabulary as an API. You want it useful, expressive, meaningful, direct, and obvious. You want the client application's programmer to move between without the need to understand a variety of opinions on how fields are named. They should see the system as a single cohesive whole, not a sack of cats.</dd> </dl> -<p id="doc_section_8_1_3_p_6">Field names constitute the means by which client programmers interact with our system. By choosing wise names now, you are making their lives better.</p> -<p id="doc_section_8_1_3_p_7">After using "xolint" to find errors in your field descriptors, use "xolint -V" to spell check your field names and to detect different names for the same data. "dropped‑short" and "dropped‑too‑short" are both reasonable names, but using them both will lead users to ask the difference between the two fields. If there is no difference, use only one of the field names. If there is a difference, change the names to make that difference more obvious.</p> +<p id="doc_section_10_1_3_p_6">Field names constitute the means by which client programmers interact with our system. By choosing wise names now, you are making their lives better.</p> +<p id="doc_section_10_1_3_p_7">After using "xolint" to find errors in your field descriptors, use "xolint -V" to spell check your field names and to detect different names for the same data. "dropped‑short" and "dropped‑too‑short" are both reasonable names, but using them both will lead users to ask the difference between the two fields. If there is no difference, use only one of the field names. If there is a difference, change the names to make that difference more obvious.</p> </div> </div> <div class="content"> -<h2 id="doc_section_8_2"> +<h2 id="doc_section_10_2"> <div class="self-section-number"> -<a href="#doc_section_8_2">8.2</a> </div> +<a href="#doc_section_10_2">10.2</a> </div> <a id="what-does-this-message-mean" href="#what-does-this-message-mean">What does this message mean?</a> </h2> -<p id="doc_section_8_2_p_1">Section Contents: </p> +<p id="doc_section_10_2_p_1">Section Contents: </p> <ul> -<li><a href="#a-percent-sign-appearing-in-text-is-a-literal" title="'A percent sign appearing in text is a literal'">Section 8.2.1</a></li> -<li><a href="#unknown-long-name-for-rolemodifier" title="'Unknown long name for role/modifier'">Section 8.2.2</a></li> -<li><a href="#last-character-before-field-definition-is-a-field-type" title="'Last character before field definition is a field type'">Section 8.2.3</a></li> -<li><a href="#encoding-format-uses-different-number-of-arguments" title="'Encoding format uses different number of arguments'">Section 8.2.4</a></li> -<li><a href="#only-one-field-role-can-be-used" title="'Only one field role can be used'">Section 8.2.5</a></li> -<li><a href="#potential-missing-slash-after-c-d-n-l-or-t-with-format" title="'Potential missing slash after C, D, N, L, or T with format'">Section 8.2.6</a></li> -<li><a href="#an-encoding-format-cannot-be-given-roles-dnlt" title="'An encoding format cannot be given (roles: DNLT)'">Section 8.2.7</a></li> -<li><a href="#format-cannot-be-given-when-content-is-present-roles-cdln" title="'Format cannot be given when content is present (roles: CDLN)'">Section 8.2.8</a></li> -<li><a href="#field-has-color-without-fg--or-bg--role-c" title="'Field has color without fg- or bg- (role: C)'">Section 8.2.9</a></li> -<li><a href="#field-has-invalid-color-or-effect-role-c" title="'Field has invalid color or effect (role: C)'">Section 8.2.10</a></li> -<li><a href="#field-has-humanize-modifier-but-no-format-string" title="'Field has humanize modifier but no format string'">Section 8.2.11</a></li> -<li><a href="#field-has-hn--modifier-but-not-h-modifier" title="'Field has hn-* modifier but not 'h' modifier'">Section 8.2.12</a></li> -<li><a href="#value-field-must-have-a-name-as-content" title="'Value field must have a name (as content)")'">Section 8.2.13</a></li> -<li><a href="#use-hyphens-not-underscores-for-value-field-name" title="'Use hyphens, not underscores, for value field name'">Section 8.2.14</a></li> -<li><a href="#value-field-name-cannot-start-with-digit" title="'Value field name cannot start with digit'">Section 8.2.15</a></li> -<li><a href="#value-field-name-should-be-lower-case" title="'Value field name should be lower case'">Section 8.2.16</a></li> -<li><a href="#value-field-name-should-be-longer-than-two-characters" title="'Value field name should be longer than two characters'">Section 8.2.17</a></li> -<li><a href="#value-field-name-contains-invalid-character" title="'Value field name contains invalid character'">Section 8.2.18</a></li> -<li><a href="#decoration-field-contains-invalid-character" title="'decoration field contains invalid character'">Section 8.2.19</a></li> -<li><a href="#anchor-content-should-be-decimal-width" title="'Anchor content should be decimal width'">Section 8.2.20</a></li> -<li><a href="#anchor-format-should-be-d" title="'Anchor format should be "%d"'">Section 8.2.21</a></li> -<li><a href="#anchor-cannot-have-both-format-and-encoding-format" title="'Anchor cannot have both format and encoding format")'">Section 8.2.22</a></li> -<li><a href="#max-width-only-valid-for-strings" title="'Max width only valid for strings'">Section 8.2.23</a></li> +<li><a href="#a-percent-sign-appearing-in-text-is-a-literal" title="'A percent sign appearing in text is a literal'">Section 10.2.1</a></li> +<li><a href="#unknown-long-name-for-rolemodifier" title="'Unknown long name for role/modifier'">Section 10.2.2</a></li> +<li><a href="#last-character-before-field-definition-is-a-field-type" title="'Last character before field definition is a field type'">Section 10.2.3</a></li> +<li><a href="#encoding-format-uses-different-number-of-arguments" title="'Encoding format uses different number of arguments'">Section 10.2.4</a></li> +<li><a href="#only-one-field-role-can-be-used" title="'Only one field role can be used'">Section 10.2.5</a></li> +<li><a href="#potential-missing-slash-after-c-d-n-l-or-t-with-format" title="'Potential missing slash after C, D, N, L, or T with format'">Section 10.2.6</a></li> +<li><a href="#an-encoding-format-cannot-be-given-roles-dnlt" title="'An encoding format cannot be given (roles: DNLT)'">Section 10.2.7</a></li> +<li><a href="#format-cannot-be-given-when-content-is-present-roles-cdln" title="'Format cannot be given when content is present (roles: CDLN)'">Section 10.2.8</a></li> +<li><a href="#field-has-color-without-fg--or-bg--role-c" title="'Field has color without fg- or bg- (role: C)'">Section 10.2.9</a></li> +<li><a href="#field-has-invalid-color-or-effect-role-c" title="'Field has invalid color or effect (role: C)'">Section 10.2.10</a></li> +<li><a href="#field-has-humanize-modifier-but-no-format-string" title="'Field has humanize modifier but no format string'">Section 10.2.11</a></li> +<li><a href="#field-has-hn--modifier-but-not-h-modifier" title="'Field has hn-* modifier but not 'h' modifier'">Section 10.2.12</a></li> +<li><a href="#value-field-must-have-a-name-as-content" title="'Value field must have a name (as content)")'">Section 10.2.13</a></li> +<li><a href="#use-hyphens-not-underscores-for-value-field-name" title="'Use hyphens, not underscores, for value field name'">Section 10.2.14</a></li> +<li><a href="#value-field-name-cannot-start-with-digit" title="'Value field name cannot start with digit'">Section 10.2.15</a></li> +<li><a href="#value-field-name-should-be-lower-case" title="'Value field name should be lower case'">Section 10.2.16</a></li> +<li><a href="#value-field-name-should-be-longer-than-two-characters" title="'Value field name should be longer than two characters'">Section 10.2.17</a></li> +<li><a href="#value-field-name-contains-invalid-character" title="'Value field name contains invalid character'">Section 10.2.18</a></li> +<li><a href="#decoration-field-contains-invalid-character" title="'decoration field contains invalid character'">Section 10.2.19</a></li> +<li><a href="#anchor-content-should-be-decimal-width" title="'Anchor content should be decimal width'">Section 10.2.20</a></li> +<li><a href="#anchor-format-should-be-d" title="'Anchor format should be "%d"'">Section 10.2.21</a></li> +<li><a href="#anchor-cannot-have-both-format-and-encoding-format" title="'Anchor cannot have both format and encoding format")'">Section 10.2.22</a></li> +<li><a href="#max-width-only-valid-for-strings" title="'Max width only valid for strings'">Section 10.2.23</a></li> </ul> <div class="content"> -<h3 id="doc_section_8_2_1"> +<h3 id="doc_section_10_2_1"> <div class="self-section-number"> -<a href="#doc_section_8_2_1">8.2.1</a> </div> +<a href="#doc_section_10_2_1">10.2.1</a> </div> <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> +<p id="doc_section_10_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.147"></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> + </pre> <p id="doc_section_10_2_1_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.148"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_2"> +<h3 id="doc_section_10_2_2"> <div class="self-section-number"> -<a href="#doc_section_8_2_2">8.2.2</a> </div> +<a href="#doc_section_10_2_2">10.2.2</a> </div> <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> +<p id="doc_section_10_2_2_p_1">The message "Unknown long name for role/modifier" can be caused by code like:</p> +<div id="doc_figure_u.149"></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> + </pre> <p id="doc_section_10_2_2_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.150"></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> + </pre> <p id="doc_section_10_2_2_p_5">The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.</p> </div> <div class="content"> -<h3 id="doc_section_8_2_3"> +<h3 id="doc_section_10_2_3"> <div class="self-section-number"> -<a href="#doc_section_8_2_3">8.2.3</a> </div> +<a href="#doc_section_10_2_3">10.2.3</a> </div> <a id="last-character-before-field-definition-is-a-field-type" href="#last-character-before-field-definition-is-a-field-type">'Last character before field definition is a field type'</a> </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> +<p id="doc_section_10_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_10_2_3_p_2">A common typo:</p> +<div id="doc_figure_u.151"></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> + </pre> <p id="doc_section_10_2_3_p_4">This code should be replaced with code like:</p> +<div id="doc_figure_u.152"></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> + </pre> <p id="doc_section_10_2_3_p_6">Twiddling the "{" and the field role is a common typo.</p> </div> <div class="content"> -<h3 id="doc_section_8_2_4"> +<h3 id="doc_section_10_2_4"> <div class="self-section-number"> -<a href="#doc_section_8_2_4">8.2.4</a> </div> +<a href="#doc_section_10_2_4">10.2.4</a> </div> <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> +<p id="doc_section_10_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.153"></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> + </pre> <p id="doc_section_10_2_4_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.154"></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> + </pre> <p id="doc_section_10_2_4_p_5">Both format should consume the same number of arguments off the stack</p> </div> <div class="content"> -<h3 id="doc_section_8_2_5"> +<h3 id="doc_section_10_2_5"> <div class="self-section-number"> -<a href="#doc_section_8_2_5">8.2.5</a> </div> +<a href="#doc_section_10_2_5">10.2.5</a> </div> <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> +<p id="doc_section_10_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.155"></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> + </pre> <p id="doc_section_10_2_5_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.156"></div> <pre> xo_emit("{T:Max}"); </pre> </div> <div class="content"> -<h3 id="doc_section_8_2_6"> +<h3 id="doc_section_10_2_6"> <div class="self-section-number"> -<a href="#doc_section_8_2_6">8.2.6</a> </div> +<a href="#doc_section_10_2_6">10.2.6</a> </div> <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> +<p id="doc_section_10_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.157"></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> + </pre> <p id="doc_section_10_2_6_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.158"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_7"> +<h3 id="doc_section_10_2_7"> <div class="self-section-number"> -<a href="#doc_section_8_2_7">8.2.7</a> </div> +<a href="#doc_section_10_2_7">10.2.7</a> </div> <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> +<p id="doc_section_10_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.159"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_8"> +<h3 id="doc_section_10_2_8"> <div class="self-section-number"> -<a href="#doc_section_8_2_8">8.2.8</a> </div> +<a href="#doc_section_10_2_8">10.2.8</a> </div> <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> +<p id="doc_section_10_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.160"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_9"> +<h3 id="doc_section_10_2_9"> <div class="self-section-number"> -<a href="#doc_section_8_2_9">8.2.9</a> </div> +<a href="#doc_section_10_2_9">10.2.9</a> </div> <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> +<p id="doc_section_10_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.161"></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> + </pre> <p id="doc_section_10_2_9_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.162"></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‑" or "bg‑".</p> + </pre> <p id="doc_section_10_2_9_p_5">Colors must be prefixed by either "fg‑" or "bg‑".</p> </div> <div class="content"> -<h3 id="doc_section_8_2_10"> +<h3 id="doc_section_10_2_10"> <div class="self-section-number"> -<a href="#doc_section_8_2_10">8.2.10</a> </div> +<a href="#doc_section_10_2_10">10.2.10</a> </div> <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> +<p id="doc_section_10_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.163"></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> + </pre> <p id="doc_section_10_2_10_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.164"></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‑" or "bg‑". Effects are limited to bold, no-bold, underline, no-underline, inverse, no-inverse, normal, and reset. Values must be separated by commas.</p> + </pre> <p id="doc_section_10_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‑" or "bg‑". Effects are limited to bold, no-bold, underline, no-underline, inverse, no-inverse, normal, and reset. Values must be separated by commas.</p> </div> <div class="content"> -<h3 id="doc_section_8_2_11"> +<h3 id="doc_section_10_2_11"> <div class="self-section-number"> -<a href="#doc_section_8_2_11">8.2.11</a> </div> +<a href="#doc_section_10_2_11">10.2.11</a> </div> <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> +<p id="doc_section_10_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.165"></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> + </pre> <p id="doc_section_10_2_11_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.166"></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> + </pre> <p id="doc_section_10_2_11_p_5">Humanization is only value for numbers, which are not likely to use the default format ("%s").</p> </div> <div class="content"> -<h3 id="doc_section_8_2_12"> +<h3 id="doc_section_10_2_12"> <div class="self-section-number"> -<a href="#doc_section_8_2_12">8.2.12</a> </div> +<a href="#doc_section_10_2_12">10.2.12</a> </div> <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> +<p id="doc_section_10_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.167"></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> + </pre> <p id="doc_section_10_2_12_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.168"></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> + </pre> <p id="doc_section_10_2_12_p_5">The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.</p> </div> <div class="content"> -<h3 id="doc_section_8_2_13"> +<h3 id="doc_section_10_2_13"> <div class="self-section-number"> -<a href="#doc_section_8_2_13">8.2.13</a> </div> +<a href="#doc_section_10_2_13">10.2.13</a> </div> <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> +<p id="doc_section_10_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.169"></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> + </pre> <p id="doc_section_10_2_13_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.170"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_14"> +<h3 id="doc_section_10_2_14"> <div class="self-section-number"> -<a href="#doc_section_8_2_14">8.2.14</a> </div> +<a href="#doc_section_10_2_14">10.2.14</a> </div> <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> +<p id="doc_section_10_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.171"></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> + </pre> <p id="doc_section_10_2_14_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.172"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_15"> +<h3 id="doc_section_10_2_15"> <div class="self-section-number"> -<a href="#doc_section_8_2_15">8.2.15</a> </div> +<a href="#doc_section_10_2_15">10.2.15</a> </div> <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> +<p id="doc_section_10_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.173"></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> + </pre> <p id="doc_section_10_2_15_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.174"></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> + </pre> <p id="doc_section_10_2_15_p_5">XML element names cannot start with a digit.</p> </div> <div class="content"> -<h3 id="doc_section_8_2_16"> +<h3 id="doc_section_10_2_16"> <div class="self-section-number"> -<a href="#doc_section_8_2_16">8.2.16</a> </div> +<a href="#doc_section_10_2_16">10.2.16</a> </div> <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> +<p id="doc_section_10_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.175"></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> + </pre> <p id="doc_section_10_2_16_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.176"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_17"> +<h3 id="doc_section_10_2_17"> <div class="self-section-number"> -<a href="#doc_section_8_2_17">8.2.17</a> </div> +<a href="#doc_section_10_2_17">10.2.17</a> </div> <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> +<p id="doc_section_10_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.177"></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> + </pre> <p id="doc_section_10_2_17_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.178"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_18"> +<h3 id="doc_section_10_2_18"> <div class="self-section-number"> -<a href="#doc_section_8_2_18">8.2.18</a> </div> +<a href="#doc_section_10_2_18">10.2.18</a> </div> <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> +<p id="doc_section_10_2_18_p_1">The message "Value field name contains invalid character" can be caused by code like:</p> +<div id="doc_figure_u.179"></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> + </pre> <p id="doc_section_10_2_18_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.180"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_19"> +<h3 id="doc_section_10_2_19"> <div class="self-section-number"> -<a href="#doc_section_8_2_19">8.2.19</a> </div> +<a href="#doc_section_10_2_19">10.2.19</a> </div> <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> +<p id="doc_section_10_2_19_p_1">The message "decoration field contains invalid character" can be caused by code like:</p> +<div id="doc_figure_u.181"></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> + </pre> <p id="doc_section_10_2_19_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.182"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_20"> +<h3 id="doc_section_10_2_20"> <div class="self-section-number"> -<a href="#doc_section_8_2_20">8.2.20</a> </div> +<a href="#doc_section_10_2_20">10.2.20</a> </div> <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> +<p id="doc_section_10_2_20_p_1">The message "Anchor content should be decimal width" can be caused by code like:</p> +<div id="doc_figure_u.183"></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> + </pre> <p id="doc_section_10_2_20_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.184"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_21"> +<h3 id="doc_section_10_2_21"> <div class="self-section-number"> -<a href="#doc_section_8_2_21">8.2.21</a> </div> +<a href="#doc_section_10_2_21">10.2.21</a> </div> <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> +<p id="doc_section_10_2_21_p_1">The message "Anchor format should be "%d"" can be caused by code like:</p> +<div id="doc_figure_u.185"></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> + </pre> <p id="doc_section_10_2_21_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.186"></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> + </pre> <p id="doc_section_10_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> <div class="content"> -<h3 id="doc_section_8_2_22"> +<h3 id="doc_section_10_2_22"> <div class="self-section-number"> -<a href="#doc_section_8_2_22">8.2.22</a> </div> +<a href="#doc_section_10_2_22">10.2.22</a> </div> <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> +<p id="doc_section_10_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.187"></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> + </pre> <p id="doc_section_10_2_22_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.188"></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> + </pre> <p id="doc_section_10_2_22_p_5">Anchors can have a static value or argument for the width, but cannot have both.</p> </div> <div class="content"> -<h3 id="doc_section_8_2_23"> +<h3 id="doc_section_10_2_23"> <div class="self-section-number"> -<a href="#doc_section_8_2_23">8.2.23</a> </div> +<a href="#doc_section_10_2_23">10.2.23</a> </div> <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> +<p id="doc_section_10_2_23_p_1">The message "Max width only valid for strings" can be caused by code like:</p> +<div id="doc_figure_u.189"></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> + </pre> <p id="doc_section_10_2_23_p_3">This code should be replaced with code like:</p> +<div id="doc_figure_u.190"></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> + </pre> <p id="doc_section_10_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> </div> </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_9" class="np"> +<h1 id="doc_section_11" class="np"> <div class="self-section-number"> -<a href="#doc_section_9">9_</a> </div> +<a href="#doc_section_11">11_</a> </div> <a id="howtos-focused-directions" href="#howtos-focused-directions">Howtos: Focused Directions</a> </h1> -<p id="doc_section_9_p_1">This section provides task-oriented instructions for selected tasks. If you have a task that needs instructions, please open a request as an enhancement issue on github.</p> -<p id="doc_section_9_p_2">Section Contents: </p> +<p id="doc_section_11_p_1">This section provides task-oriented instructions for selected tasks. If you have a task that needs instructions, please open a request as an enhancement issue on github.</p> +<p id="doc_section_11_p_2">Section Contents: </p> <ul> -<li><a href="#howto-report-bugs" title="Howto: Report bugs">Section 9.1</a></li> -<li><a href="#howto-install-libxo" title="Howto: Install libxo">Section 9.2</a></li> -<li><a href="#howto-convert-command-line-applications" title="Howto: Convert command line applications">Section 9.3</a></li> -<li><a href="#howto-use-xo-in-shell-scripts" title='Howto: Use "xo" in Shell Scripts'>Section 9.4</a></li> -<li><a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 9.5</a></li> +<li><a href="#howto-report-bugs" title="Howto: Report bugs">Section 11.1</a></li> +<li><a href="#howto-install-libxo" title="Howto: Install libxo">Section 11.2</a></li> +<li><a href="#howto-convert-command-line-applications" title="Howto: Convert command line applications">Section 11.3</a></li> +<li><a href="#howto-use-xo-in-shell-scripts" title='Howto: Use "xo" in Shell Scripts'>Section 11.4</a></li> +<li><a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 11.5</a></li> </ul> <div class="content"> -<h2 id="doc_section_9_1"> +<h2 id="doc_section_11_1"> <div class="self-section-number"> -<a href="#doc_section_9_1">9.1</a> </div> +<a href="#doc_section_11_1">11.1</a> </div> <a id="howto-report-bugs" href="#howto-report-bugs">Howto: Report bugs</a> </h2> -<p id="doc_section_9_1_p_1">libxo uses github to track bugs or request enhancements. Please use the following URL:</p> -<p id="doc_section_9_1_p_2"> <a href="https://github.com/Juniper/libxo/issues">https://github.com/Juniper/libxo/issues</a></p> +<p id="doc_section_11_1_p_1">libxo uses github to track bugs or request enhancements. Please use the following URL:</p> +<p id="doc_section_11_1_p_2"> <a href="https://github.com/Juniper/libxo/issues">https://github.com/Juniper/libxo/issues</a></p> </div> <div class="content"> -<h2 id="doc_section_9_2"> +<h2 id="doc_section_11_2"> <div class="self-section-number"> -<a href="#doc_section_9_2">9.2</a> </div> +<a href="#doc_section_11_2">11.2</a> </div> <a id="howto-install-libxo" href="#howto-install-libxo">Howto: Install libxo</a> </h2> -<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> +<p id="doc_section_11_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_11_2_p_2"> <a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a></p> +<p id="doc_section_11_2_p_3">After downloading and untarring the source code, building involves the following steps:</p> +<div id="doc_figure_u.191"></div> <pre> sh bin/setup.sh cd build ../configure make make test 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> + </pre> <p id="doc_section_11_2_p_5">libxo uses a distinct "build" directory to keep generated files separated from source files.</p> +<p id="doc_section_11_2_p_6">Use "../configure --help" to display available configuration options, which include the following:</p> +<div id="doc_figure_u.192"></div> <pre> --enable-warnings Turn on compiler warnings --enable-debug Turn on debugging --enable-text-only Turn on text-only rendering @@ -26350,46 +26502,46 @@ jQuery(function ($) { --disable-libxo-options Turn off support for LIBXO_OPTIONS --with-gettext=PFX Specify location of gettext installation --with-libslax-prefix=PFX Specify location of libslax config - </pre> <p id="doc_section_9_2_p_8">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.</p> -<p id="doc_section_9_2_p_9">libxo provides the --enable-text-only option to reduce the footprint of the library for smaller installations. XML, JSON, and HTML rendering logic is removed.</p> -<p id="doc_section_9_2_p_10">The gettext library does not provide a simple means of learning its location, but libxo will look for it in /usr and /opt/local. If installed elsewhere, the installer will need to provide this information using the --with-gettext=/dir/path option.</p> -<p id="doc_section_9_2_p_11">libslax is not required by libxo; it contains the "oxtradoc" program used to format documentation.</p> -<p id="doc_section_9_2_p_12">For additional information, see <a href="#building-libxo" title="Building libxo">Section 1.1.2</a>.</p> + </pre> <p id="doc_section_11_2_p_8">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.</p> +<p id="doc_section_11_2_p_9">libxo provides the --enable-text-only option to reduce the footprint of the library for smaller installations. XML, JSON, and HTML rendering logic is removed.</p> +<p id="doc_section_11_2_p_10">The gettext library does not provide a simple means of learning its location, but libxo will look for it in /usr and /opt/local. If installed elsewhere, the installer will need to provide this information using the --with-gettext=/dir/path option.</p> +<p id="doc_section_11_2_p_11">libslax is not required by libxo; it contains the "oxtradoc" program used to format documentation.</p> +<p id="doc_section_11_2_p_12">For additional information, see <a href="#building-libxo" title="Building libxo">Section 2.2</a>.</p> </div> <div class="content"> -<h2 id="doc_section_9_3"> +<h2 id="doc_section_11_3"> <div class="self-section-number"> -<a href="#doc_section_9_3">9.3</a> </div> +<a href="#doc_section_11_3">11.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.193"></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> + </pre> <p id="doc_section_11_3_p_2">There are three basic steps for converting command line application to use libxo.</p> +<p id="doc_section_11_3_p_3"> </p> <ul> <li>Setting up the context</li> <li>Converting printf calls</li> <li>Creating hierarchy</li> <li>Converting error functions</li> </ul> -<p id="doc_section_9_3_p_4">Section Contents: </p> +<p id="doc_section_11_3_p_4">Section Contents: </p> <ul> -<li><a href="#setting-up-the-context" title="Setting up the context">Section 9.3.1</a></li> -<li><a href="#converting-printf-calls" title="Converting printf Calls">Section 9.3.2</a></li> -<li><a href="#creating-hierarchy" title="Creating Hierarchy">Section 9.3.3</a></li> -<li><a href="#converting-error-functions" title="Converting Error Functions">Section 9.3.4</a></li> +<li><a href="#setting-up-the-context" title="Setting up the context">Section 11.3.1</a></li> +<li><a href="#converting-printf-calls" title="Converting printf Calls">Section 11.3.2</a></li> +<li><a href="#creating-hierarchy" title="Creating Hierarchy">Section 11.3.3</a></li> +<li><a href="#converting-error-functions" title="Converting Error Functions">Section 11.3.4</a></li> </ul> <div class="content"> -<h3 id="doc_section_9_3_1"> +<h3 id="doc_section_11_3_1"> <div class="self-section-number"> -<a href="#doc_section_9_3_1">9.3.1</a> </div> +<a href="#doc_section_11_3_1">11.3.1</a> </div> <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> +<p id="doc_section_11_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.194"></div> <pre> #include <libxo/xo.h> - </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> + </pre> <p id="doc_section_11_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 5.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.195"></div> <pre> int main (int argc, char **argv) { argc = xo_parse_args(argc, argv); @@ -26397,31 +26549,31 @@ jQuery(function ($) { return argc; .... } - </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> + </pre> <p id="doc_section_11_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 5.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.196"></div> <pre> atexit(xo_finish_atexit); </pre> </div> <div class="content"> -<h3 id="doc_section_9_3_2"> +<h3 id="doc_section_11_3_2"> <div class="self-section-number"> -<a href="#doc_section_9_3_2">9.3.2</a> </div> +<a href="#doc_section_11_3_2">11.3.2</a> </div> <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> +<p id="doc_section_11_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.197"></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> + </pre> <p id="doc_section_11_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_11_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 3.2.1.6</a>).</p> +<p id="doc_section_11_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.198"></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> + </pre> <p id="doc_section_11_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 3.2.1.1</a>).</p> +<div id="doc_figure_u.199"></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> + </pre> <p id="doc_section_11_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 3.2.1.10</a>).</p> +<div id="doc_figure_u.200"></div> <pre> snprintf(buf, sizeof(buf), "(%u/%u/%u)", min, ave, max); printf("%30s", buf); @@ -26429,13 +26581,13 @@ jQuery(function ($) { min, ave, max); </pre> </div> <div class="content"> -<h3 id="doc_section_9_3_3"> +<h3 id="doc_section_11_3_3"> <div class="self-section-number"> -<a href="#doc_section_9_3_3">9.3.3</a> </div> +<a href="#doc_section_11_3_3">11.3.3</a> </div> <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> +<p id="doc_section_11_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.201"></div> <pre> printf("table %d\n", tnum); for (i = 0; i < tmax; i++) { printf(" %s %d\n", table[i].name, table[i].size); @@ -26450,10 +26602,10 @@ jQuery(function ($) { xo_close_instance("table"); } xo_close_list("table"); - </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> + </pre> <p id="doc_section_11_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_11_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_11_3_3_p_5">In addition, the open and close container functions allow for organization levels of hierarchy.</p> +<div id="doc_figure_u.202"></div> <pre> printf("Paging information:\n"); printf(" Free: %lu\n", free); printf(" Active: %lu\n", active); @@ -26466,36 +26618,36 @@ jQuery(function ($) { xo_close_container("paging-information"); </pre> </div> <div class="content"> -<h3 id="doc_section_9_3_4"> +<h3 id="doc_section_11_3_4"> <div class="self-section-number"> -<a href="#doc_section_9_3_4">9.3.4</a> </div> +<a href="#doc_section_11_3_4">11.3.4</a> </div> <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> +<p id="doc_section_11_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.203"></div> <pre> err(1, "cannot open output file: %s", file); xo_err(1, "cannot open output file: %s", file); xo_emit_err(1, "cannot open output file: {:filename}", file); </pre> </div> </div> -<div class="content"><h2 id="doc_section_9_4"> +<div class="content"><h2 id="doc_section_11_4"> <div class="self-section-number"> -<a href="#doc_section_9_4">9.4</a> </div> +<a href="#doc_section_11_4">11.4</a> </div> <a id="howto-use-xo-in-shell-scripts" href="#howto-use-xo-in-shell-scripts">Howto: Use "xo" in Shell Scripts</a> </h2></div> <div class="content"> -<h2 id="doc_section_9_5"> +<h2 id="doc_section_11_5"> <div class="self-section-number"> -<a href="#doc_section_9_5">9.5</a> </div> +<a href="#doc_section_11_5">11.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.204"></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 <text>" command, or an entire .pot can be translated using the "xopo -f <input> -o <output>" command.</p> -<div id="doc_figure_u.198"></div> <pre> + </pre> <p id="doc_section_11_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_11_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_11_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 <text>" command, or an entire .pot can be translated using the "xopo -f <input> -o <output>" command.</p> +<div id="doc_figure_u.205"></div> <pre> EXAMPLE: % xopo -s "There are {:count/%u} {:event/%.6s} events\n" There are {:count} {:event} events\n @@ -26527,44 +26679,44 @@ jQuery(function ($) { # Install the .mo file 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> + </pre> <p id="doc_section_11_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.206"></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> + </pre> <p id="doc_section_11_5_p_8">Section Contents: </p> +<ul><li><a href="#i18n-and-xo_emit" title="i18n and xo_emit">Section 11.5.1</a></li></ul> <div class="content"> -<h3 id="doc_section_9_5_1"> +<h3 id="doc_section_11_5_1"> <div class="self-section-number"> -<a href="#doc_section_9_5_1">9.5.1</a> </div> +<a href="#doc_section_11_5_1">11.5.1</a> </div> <a id="i18n-and-xo_emit" href="#i18n-and-xo_emit">i18n and xo_emit</a> </h3> -<p id="doc_section_9_5_1_p_1">There are three features used in libxo used to support i18n:</p> -<p id="doc_section_9_5_1_p_2"> </p> +<p id="doc_section_11_5_1_p_1">There are three features used in libxo used to support i18n:</p> +<p id="doc_section_11_5_1_p_2"> </p> <ul> <li>The "{G:}" role looks for a translation of the format string.</li> <li>The "{g:}" modifier looks for a translation of the field.</li> <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> +<p id="doc_section_11_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.207"></div> <pre> printf(gettext("Received %zu %s from {g:server} server\n"), counter, ngettext("byte", "bytes", counter), gettext("web")); 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> + </pre> <p id="doc_section_11_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.208"></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> + </pre> <p id="doc_section_11_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.209"></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> + </pre> <p id="doc_section_11_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_11_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_11_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_11_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.210"></div> <pre> printf(dgettext("dns", "Host %s not found: %d(%s)\n"), name, errno, dgettext("strerror", strerror(errno))); @@ -26575,21 +26727,21 @@ jQuery(function ($) { </div> <hr class="noprint"> <div class="content"> -<h1 id="doc_section_10" class="np"> +<h1 id="doc_section_12" class="np"> <div class="self-section-number"> -<a href="#doc_section_10">10_</a> </div> +<a href="#doc_section_12">12_</a> </div> <a id="examples" href="#examples">Examples</a> </h1> -<p id="doc_section_10_p_1">Section Contents: </p> -<ul><li><a href="#unit-test" title="Unit Test">Section 10.1</a></li></ul> +<p id="doc_section_12_p_1">Section Contents: </p> +<ul><li><a href="#unit-test" title="Unit Test">Section 12.1</a></li></ul> <div class="content"> -<h2 id="doc_section_10_1"> +<h2 id="doc_section_12_1"> <div class="self-section-number"> -<a href="#doc_section_10_1">10.1</a> </div> +<a href="#doc_section_12_1">12.1</a> </div> <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> +<p id="doc_section_12_1_p_1">Here is the unit test example:</p> +<div id="doc_figure_u.211"></div> <pre> int main (int argc, char **argv) { @@ -26681,8 +26833,8 @@ jQuery(function ($) { return 0; } - </pre> <p id="doc_section_10_1_p_3">Text output:</p> -<div id="doc_figure_u.205"></div> <pre> + </pre> <p id="doc_section_12_1_p_3">Text output:</p> +<div id="doc_figure_u.212"></div> <pre> % ./testxo --libxo text Item 'gum': Total sold: 1412.0 @@ -26714,8 +26866,8 @@ jQuery(function ($) { In stock: 45 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> + </pre> <p id="doc_section_12_1_p_5">JSON output:</p> +<div id="doc_figure_u.213"></div> <pre> % ./testxo --libxo json,pretty "top": { "data": { @@ -26769,8 +26921,8 @@ jQuery(function ($) { ] } } - </pre> <p id="doc_section_10_1_p_7">XML output:</p> -<div id="doc_figure_u.207"></div> <pre> + </pre> <p id="doc_section_12_1_p_7">XML output:</p> +<div id="doc_figure_u.214"></div> <pre> % ./testxo --libxo pretty,xml <top> <data> @@ -26820,8 +26972,8 @@ jQuery(function ($) { </item> </data> </top> - </pre> <p id="doc_section_10_1_p_9">HMTL output:</p> -<div id="doc_figure_u.208"></div> <pre> + </pre> <p id="doc_section_12_1_p_9">HMTL output:</p> +<div id="doc_figure_u.215"></div> <pre> % ./testxo --libxo pretty,html <div class="line"> <div class="label">Item</div> @@ -27015,8 +27167,8 @@ jQuery(function ($) { <div class="text">: </div> <div class="data" data-tag="sku">GRO-000-533</div> </div> - </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> + </pre> <p id="doc_section_12_1_p_11">HTML output with xpath and info flags:</p> +<div id="doc_figure_u.216"></div> <pre> % ./testxo --libxo pretty,html,xpath,info <div class="line"> <div class="label">Item</div> diff --git a/contrib/libxo/doc/libxo.txt b/contrib/libxo/doc/libxo.txt index 4cd51cc..3e8e954 100644 --- a/contrib/libxo/doc/libxo.txt +++ b/contrib/libxo/doc/libxo.txt @@ -16,11 +16,28 @@ You want to prepare for the future, but you need to live in the present. You'd love a flying car, but need to get to work today. You want to support features like XML, JSON, and HTML rendering to allow integration with NETCONF, REST, and web browsers, but you need to make -text output for command line users. And you don't want multiple code -paths that can't help but get out of sync. None of this "if (xml) -{... } else {...}" logic. And ifdefs are right out. But you'd -really, really like all the fancy features that modern encoding -formats can provide. libxo can help. +text output for command line users. + +And you don't want multiple code paths that can't help but get out of +sync: + + /* None of this "if (xml) {... } else {...}" logic */ + if (xml) { + /* some code to make xml*/ + } else { + /* other code to make text */ + /* oops forgot to add something on both clauses! */ + } + + /* And ifdefs are right out. */ + #ifdef MAKE_XML + /* icky */ + #else + /* pooh */ + #endif + +But you'd really, really like all the fancy features that modern +encoding formats can provide. libxo can help. The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application @@ -35,8 +52,11 @@ braces with a printf-like format string (^format-strings^): linect, wordct, charct, file); Each field can have a role, with the 'value' role being the default, -and the role tells libxo how and when to render that field. Output -can then be generated in various style, using the "--libxo" option: +and the role tells libxo how and when to render that field (see +^field-roles^ for details). Modifiers change how the field is +rendered in different output styles (see ^field-modifiers^ for +details. Output can then be generated in various style, using the +"--libxo" option: % wc /etc/motd 25 165 1140 /etc/motd @@ -74,7 +94,12 @@ can then be generated in various style, using the "--libxo" option: <div class="data" data-tag="filename">/etc/motd</div> </div> -** Getting libxo +Same code path, same format strings, same information, but it's +rendered in distinct styles based on run-time flags. + +* Getting libxo + +libxo now ships as part of the FreeBSD Operating System (as of -11). libxo lives on github as: @@ -101,7 +126,7 @@ as part of the FreeBSD operating system starting with release 11.0. Issues, problems, and bugs should be directly to the issues page on our github site. -*** Downloading libxo Source Code +** Downloading libxo Source Code You can retrieve the source for libxo in two ways: @@ -140,7 +165,7 @@ download the source code from svn, then you'll need to run "autoreconf" by hand. This step is done for you by the "setup.sh" script, described in the next section. -*** Building libxo +** Building libxo To build libxo, you'll need to set up the build, run the "configure" script, run the "make" command, and run the regression tests. @@ -159,7 +184,7 @@ The following sections will walk through each of these steps with additional details and options, but the above directions should be all that's needed. -**** Setting up the build +*** Setting up the build [If you downloaded a distfile, you can skip this step.] @@ -171,7 +196,7 @@ generated files. Note: We're are currently using autoreconf version 2.69. -**** Running the "configure" Script +*** Running the "configure" Script Configure (and autoconf in general) provides a means of building software in diverse environments. Our configure script supports @@ -221,7 +246,7 @@ machine. To run the regression tests: make test -**** Installing libxo +*** Installing libxo Once the software is built, you'll need to install libxo using the "make install" command. If you are the root user, or the owner of the @@ -544,6 +569,15 @@ The following color names are supported: | yellow | | |---------+--------------------------------------------| +When using colors, the developer should remember that users will +change the foreground and background colors of terminal session +according to their own tastes, so assuming that "blue" looks nice is +never safe, and is a constant annoyance to your dear author. In +addition, a significant percentage of users (1 in 12) will be color +blind. Depending on color to convey critical information is not a +good idea. Color should enhance output, but should not be used as the +sole means of encoding information. + **** The Decoration Role ({D:}) Decorations are typically punctuation marks such as colons, @@ -818,7 +852,7 @@ more meaningful. "hn" can be used as an alias for "humanize". The humanize modifier only affects display styles (TEXT and HMTL). -The "no-humanize" option (See ^LIBXO_OPTIONS^) will block the function of +The "no-humanize" option (See ^options^) will block the function of the humanize modifier. There are a number of modifiers that affect details of humanization. @@ -1070,7 +1104,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". @@ -1444,7 +1478,7 @@ properly. xo_close_marker("fish-guts"); } -** Command-line Arguments +* Command-line Arguments @options@ libxo uses command line options to trigger rendering behavior. The following options are recognised: @@ -1453,9 +1487,17 @@ following options are recognised: - --libxo=<options> - --libxo:<brief-options> +The following invocations are all identical in outcome: + + my-app --libxo warn,pretty arg1 + my-app --libxo=warn,pretty arg1 + my-app --libxo:WP arg1 + Programs using libxo are expecting to call the xo_parse_args function to parse these arguments. See ^xo_parse_args^ for details. +** Option keywords + Options is a comma-separated list of tokens that correspond to output styles, flags, or features: @@ -1463,7 +1505,10 @@ styles, flags, or features: | Token | Action | |-------------+-------------------------------------------------------| | color | Enable colors/effects for display styles (TEXT, HTML) | +| colors=xxxx | Adjust color output values | | 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 +1524,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 | @@ -1487,7 +1532,96 @@ styles, flags, or features: | xpath | Add XPath expressions (HTML) | |-------------+-------------------------------------------------------| -The brief options are detailed in ^LIBXO_OPTIONS^. +Most of these option are simple and direct, but some require +additional details: + +- "colors" is described in ^color-mapping^. +- "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. + +** Brief Options + +The brief options are simple single-letter aliases to the normal +keywords, as detailed below: + +|--------+---------------------------------------------| +| Option | Action | +|--------+---------------------------------------------| +| c | Enable color/effects for TEXT/HTML | +| F | Force line-buffered flushing | +| H | Enable HTML output (XO_STYLE_HTML) | +| I | Enable info output (XOF_INFO) | +| i<num> | Indent by <number> | +| J | Enable JSON output (XO_STYLE_JSON) | +| k | Add keys to XPATH expressions in HTML | +| n | Disable humanization (TEXT, HTML) | +| P | Enable pretty-printed output (XOF_PRETTY) | +| T | Enable text output (XO_STYLE_TEXT) | +| U | Add units to HTML output | +| u | Change "-"s to "_"s in element names (JSON) | +| W | Enable warnings (XOF_WARN) | +| X | Enable XML output (XO_STYLE_XML) | +| x | Enable XPath data (XOF_XPATH) | +|--------+---------------------------------------------| + +** Color Mapping +The "colors" option takes a value that is a set of mappings from the +pre-defined set of colors to new foreground and background colors. +The value is a series of "fg/bg" values, separated by a "+". Each +pair of "fg/bg" values gives the colors to which a basic color is +mapped when used as a foreground or background color. The order is +the mappings is: + +- black +- red +- green +- yellow +- blue +- magenta +- cyan +- white + +Pairs may be skipped, leaving them mapped as normal, as are missing +pairs or single colors. + +For example consider the following xo_emit call: + + xo_emit("{C:fg-red,bg-green}Merry XMas!!{C:}\n"); + +To turn all colored output to red-on-blue, use eight pairs of +"red/blue" mappings separated by "+"s: + + --libxo colors=red/blue+red/blue+red/blue+red/blue+\ + red/blue+red/blue+red/blue+red/blue + +To turn the red-on-green text to magenta-on-cyan, give a "magenta" +foreground value for red (the second mapping) and a "cyan" background +to green (the third mapping): + + --libxo colors=+magenta+/cyan + +Consider the common situation where blue output looks unreadable on a +terminal session with a black background. To turn both "blue" +foreground and background output to "yellow", give only the fifth +mapping, skipping the first four mappings with bare "+"s: + + --libxo colors=++++yellow/yellow * The libxo API @@ -1577,6 +1711,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: @@ -1706,7 +1850,7 @@ and flags and enables them for a specific handle. int xo_set_options (xo_handle_t *xop, const char *input); -The options are identical to those listed in ^command-line-arguments^. +The options are identical to those listed in ^options^. *** xo_destroy @@ -1930,7 +2074,7 @@ is returned. On failure, a message it emitted and -1 is returned. exit(EXIT_FAILURE); Following the call to xo_parse_args, the application can process the -remaining arguments in a normal manner. See ^command-line-arguments^ +remaining arguments in a normal manner. See ^options^ for a description of valid arguments. *** xo_set_program @@ -2021,36 +2165,24 @@ By default, the standard realloc() and free() functions are used. *** LIBXO_OPTIONS @LIBXO_OPTIONS@ -The environment variable "LIBXO_OPTIONS" can be set to a string of -options: - -|--------+---------------------------------------------| -| Option | Action | -|--------+---------------------------------------------| -| c | Enable color/effects for TEXT/HTML | -| F | Force line-buffered flushing | -| H | Enable HTML output (XO_STYLE_HTML) | -| I | Enable info output (XOF_INFO) | -| i<num> | Indent by <number> | -| J | Enable JSON output (XO_STYLE_JSON) | -| k | Add keys to XPATH expressions in HTML | -| n | Disable humanization (TEXT, HTML) | -| P | Enable pretty-printed output (XOF_PRETTY) | -| T | Enable text output (XO_STYLE_TEXT) | -| U | Add units to HTML output | -| u | Change "-"s to "_"s in element names (JSON) | -| W | Enable warnings (XOF_WARN) | -| X | Enable XML output (XO_STYLE_XML) | -| x | Enable XPath data (XOF_XPATH) | -|--------+---------------------------------------------| +The environment variable "LIBXO_OPTIONS" can be set to a subset of +libxo options, including: + +- color +- flush +- flush-line +- no-color +- no-humanize +- no-locale +- no-retain +- pretty +- retain +- underscores +- warn For example, warnings can be enabled by: - % env LIBXO_OPTIONS=W my-app - -Complete HTML output can be generated with: - - % env LIBXO_OPTIONS=HXI my-app + % env LIBXO_OPTIONS=warn my-app Since environment variables are inherited, child processes will have the same options, which may be undesirable, making the use of the @@ -2439,9 +2571,9 @@ HTML using the same commands that emit text output. The style of output can be selected using a specific option: "-X" for XML, "-J" for JSON, "-H" for HTML, or "-T" for TEXT, which is the -default. The "--style <style>" option can also be used. The -LIBXO_OPTIONS environment variable can also be used to set the style, -as well as other flags. +default. The "--style <style>" option can also be used. The standard +set of "--libxo" options are available (see ^options^), as well as the +LIBXO_OPTIONS environment variable (see ^LIBXO_OPTIONS^). 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. @@ -2883,9 +3015,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/contrib/libxo/encoder/cbor/enc_cbor.c b/contrib/libxo/encoder/cbor/enc_cbor.c index 7c0a1d3..08ed4a0 100644 --- a/contrib/libxo/encoder/cbor/enc_cbor.c +++ b/contrib/libxo/encoder/cbor/enc_cbor.c @@ -249,7 +249,7 @@ cbor_handler (XO_ENCODER_HANDLER_ARGS) if (xo_get_flags(xop) & XOF_PRETTY) { printf("%*sop %s: [%s] [%s]\n", cbor ? cbor->c_indent * 2 + 4 : 0, "", - xo_encoder_op_name(op), name ?: "", value ?: ""); + xo_encoder_op_name(op), name, value); fflush(stdout); } diff --git a/contrib/libxo/encoder/test/enc_test.c b/contrib/libxo/encoder/test/enc_test.c index ec49499..1f1783a 100644 --- a/contrib/libxo/encoder/test/enc_test.c +++ b/contrib/libxo/encoder/test/enc_test.c @@ -14,8 +14,8 @@ static int test_handler (XO_ENCODER_HANDLER_ARGS) { - printf("op %s: [%s] [%s]\n", xo_encoder_op_name(op), - name ?: "", value ?: ""); + printf("op %s: [%s] [%s] [%#llx]\n", xo_encoder_op_name(op), + name ?: "", value ?: "", flags); return 0; } diff --git a/contrib/libxo/libxo/Makefile.am b/contrib/libxo/libxo/Makefile.am index b11c311..a484a9b 100644 --- a/contrib/libxo/libxo/Makefile.am +++ b/contrib/libxo/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/contrib/libxo/libxo/libxo.3 b/contrib/libxo/libxo/libxo.3 index 4e2488c..f079620 100644 --- a/contrib/libxo/libxo/libxo.3 +++ b/contrib/libxo/libxo/libxo.3 @@ -311,3 +311,13 @@ to use an alternative set of low-level output functions. .Xr xo_set_style 3 , .Xr xo_set_writer 3 , .Xr xo_format 5 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/libxo.c b/contrib/libxo/libxo/libxo.c index 7a714b1..84e9c01 100644 --- a/contrib/libxo/libxo/libxo.c +++ b/contrib/libxo/libxo/libxo.c @@ -95,6 +95,14 @@ #include <libintl.h> #endif /* HAVE_GETTEXT */ +/* Rather lame that we can't count on these... */ +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + /* * Three styles of specifying thread-local variables are supported. * configure.ac has the brains to run each possibility through the @@ -129,7 +137,7 @@ static const char xo_default_format[] = "%s"; #define XO_INDENT_BY 2 /* Amount to indent when pretty printing */ #define XO_DEPTH 128 /* Default stack depth */ -#define XO_MAX_ANCHOR_WIDTH (8*1024) /* Anything wider is just sillyb */ +#define XO_MAX_ANCHOR_WIDTH (8*1024) /* Anything wider is just silly */ #define XO_FAILURE_NAME "failure" @@ -203,6 +211,7 @@ typedef struct xo_stack_s { * XO_COL_* ("colors") refers to fancy ansi codes, while X__EFF_* * ("effects") are bits since we need to maintain state. */ +typedef uint8_t xo_color_t; #define XO_COL_DEFAULT 0 #define XO_COL_BLACK 1 #define XO_COL_RED 2 @@ -238,7 +247,6 @@ typedef struct xo_stack_s { #define XO_EFF_CLEAR_BITS XO_EFF_RESET /* Reset gets reset, surprisingly */ typedef uint8_t xo_effect_t; -typedef uint8_t xo_color_t; typedef struct xo_colors_s { xo_effect_t xoc_effects; /* Current effect set */ xo_color_t xoc_col_fg; /* Foreground color */ @@ -274,13 +282,15 @@ 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 */ +#ifndef LIBXO_TEXT_ONLY uint8_t xo_color_map_fg[XO_NUM_COLORS]; /* Foreground color mappings */ uint8_t xo_color_map_bg[XO_NUM_COLORS]; /* Background color mappings */ +#endif /* LIBXO_TEXT_ONLY */ xo_colors_t xo_colors; /* Current color and effect values */ xo_buffer_t xo_color_buf; /* HTML: buffer of colors and effects */ char *xo_version; /* Version string */ @@ -426,10 +436,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 +467,22 @@ 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 int +xo_set_options_simple (xo_handle_t *xop, const char *input); + +static int +xo_color_find (const char *str); + 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 *fmt, ssize_t flen, + const char *encoding, ssize_t elen); static void xo_anchor_clear (xo_handle_t *xop); @@ -491,7 +508,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; @@ -628,13 +645,6 @@ xo_init_handle (xo_handle_t *xop) XOF_SET(xop, XOF_FLUSH_LINE); /* - * We only want to do color output on terminals, but we only want - * to do this if the user has asked for color. - */ - if (XOF_ISSET(xop, XOF_COLOR_ALLOWED) && isatty(1)) - XOF_SET(xop, XOF_COLOR); - - /* * We need to initialize the locale, which isn't really pretty. * Libraries should depend on their caller to set up the * environment. But we really can't count on the caller to do @@ -667,15 +677,6 @@ xo_init_handle (xo_handle_t *xop) xop->xo_indent_by = XO_INDENT_BY; xo_depth_check(xop, XO_DEPTH); -#if !defined(NO_LIBXO_OPTIONS) - if (!XOF_ISSET(xop, XOF_NO_ENV)) { - char *env = getenv("LIBXO_OPTIONS"); - if (env) - xo_set_options(xop, env); - - } -#endif /* NO_GETENV */ - XOIF_CLEAR(xop, XOIF_INIT_IN_PROGRESS); } @@ -689,6 +690,16 @@ xo_default_init (void) xo_init_handle(xop); +#if !defined(NO_LIBXO_OPTIONS) + if (!XOF_ISSET(xop, XOF_NO_ENV)) { + char *env = getenv("LIBXO_OPTIONS"); + + if (env) + xo_set_options_simple(xop, env); + + } +#endif /* NO_LIBXO_OPTIONS */ + xo_default_inited = 1; } @@ -750,14 +761,14 @@ static char xo_xml_lt[] = "<"; static char xo_xml_gt[] = ">"; static char xo_xml_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 +817,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 +865,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 +903,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 +932,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 +956,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 +1001,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 +1034,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,47 +1052,50 @@ 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_data_bits[5] = { 0, 0x7f, 0x1f, 0x0f, 0x07 }; +static uint8_t xo_utf8_len_bits[5] = { 0, 0x00, 0xc0, 0xe0, 0xf0 }; +/* + * If the byte has a high-bit set, it's UTF-8, not ASCII. + */ static int xo_is_utf8 (char ch) { return (ch & 0x80); } -static inline int +/* + * Look at the high bits of the first byte to determine the length + * of the UTF-8 character. + */ +static inline ssize_t xo_utf8_to_wc_len (const char *buf) { - unsigned b = (unsigned char) *buf; - int len; + uint8_t bval = (uint8_t) *buf; + ssize_t len; - if ((b & 0x80) == 0x0) + if ((bval & 0x80) == 0x0) len = 1; - else if ((b & 0xe0) == 0xc0) + else if ((bval & 0xe0) == 0xc0) len = 2; - else if ((b & 0xf0) == 0xe0) + else if ((bval & 0xf0) == 0xe0) len = 3; - else if ((b & 0xf8) == 0xf0) + else if ((bval & 0xf8) == 0xf0) len = 4; - else if ((b & 0xfc) == 0xf8) - len = 5; - else if ((b & 0xfe) == 0xfc) - len = 6; else len = -1; 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) { + if (len < 0) { xo_failure(xop, "invalid UTF-8 data: %02hhx", b); return -1; } @@ -1109,19 +1123,19 @@ 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; - wc = *cp & xo_utf8_bits[len]; + wc = *cp & xo_utf8_data_bits[len]; for (i = 1; i < len; i++) { - wc <<= 6; + wc <<= 6; /* Low six bits have data */ wc |= cp[i] & 0x3f; if ((cp[i] & 0xc0) != 0x80) return (wchar_t) -1; @@ -1133,52 +1147,60 @@ 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 */ + if ((wc & ((1 << 7) - 1)) == wc) /* Simple case */ len = 1; - else if ((wc & ((1<<11) - 1)) == wc) + else if ((wc & ((1 << 11) - 1)) == wc) len = 2; - else if ((wc & ((1<<16) - 1)) == wc) + else if ((wc & ((1 << 16) - 1)) == wc) len = 3; - else if ((wc & ((1<<21) - 1)) == wc) + else if ((wc & ((1 << 21) - 1)) == wc) len = 4; - else if ((wc & ((1<<26) - 1)) == wc) - len = 5; else - len = 6; + len = -1; /* Invalid */ return len; } +/* + * Emit one wide character into the given buffer + */ 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; return; } + /* Start with the low bits and insert them, six bits at a time */ for (i = len - 1; i >= 0; i--) { buf[i] = 0x80 | (wc & 0x3f); - wc >>= 6; + wc >>= 6; /* Drop the low six bits */ } - buf[0] &= xo_utf8_bits[len]; - buf[0] |= ~xo_utf8_bits[len] << 1; + /* Finish off the first byte with the length bits */ + buf[0] &= xo_utf8_data_bits[len]; /* Clear out the length bits */ + buf[0] |= xo_utf8_len_bits[len]; /* Drop in new length bits */ } -static int +/* + * Append a single UTF-8 character to a buffer, converting it to locale + * encoding. Returns the number of columns consumed by that character, + * as best we can determine it. + */ +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 @@ -1187,7 +1209,7 @@ xo_buf_append_locale_from_utf8 (xo_handle_t *xop, xo_buffer_t *xbp, */ wc = xo_utf8_char(ibuf, ilen); if (wc == (wchar_t) -1) { - xo_failure(xop, "invalid utf-8 byte sequence"); + xo_failure(xop, "invalid UTF-8 byte sequence"); return 0; } @@ -1216,13 +1238,16 @@ xo_buf_append_locale_from_utf8 (xo_handle_t *xop, xo_buffer_t *xbp, return xo_wcwidth(wc); } +/* + * Append a UTF-8 string to a buffer, converting it into locale encoding + */ 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 +1299,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 +1308,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 +1478,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 +1518,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) { @@ -1502,6 +1527,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn, newfmt[plen++] = ':'; newfmt[plen++] = ' '; } + memcpy(newfmt + plen, fmt, len); newfmt[len + plen] = '\0'; @@ -1519,8 +1545,9 @@ 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); @@ -1533,6 +1560,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn, left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp); rc = vsnprintf(xbp->xb_curp, left, fmt, vap); } + va_end(va_local); rc = xo_escape_xml(xbp, rc, 1); @@ -1543,6 +1571,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn, if (code >= 0) { const char *msg = strerror(code); + if (msg) { xo_buf_append(xbp, ": ", 2); xo_buf_append(xbp, msg, strlen(msg)); @@ -1556,6 +1585,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn, vfprintf(stderr, newfmt, vap); if (code >= 0) { const char *msg = strerror(code); + if (msg) fprintf(stderr, ": %s", msg); } @@ -1652,7 +1682,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 +1701,8 @@ 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)) { @@ -1685,6 +1716,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp); rc = vsnprintf(xbp->xb_curp, left, fmt, vap); } + va_end(va_local); rc = xo_escape_xml(xbp, rc, 0); @@ -1692,6 +1724,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) if (need_nl && code > 0) { const char *msg = strerror(code); + if (msg) { xo_buf_append(xbp, ": ", 2); xo_buf_append(xbp, msg, strlen(msg)); @@ -1712,8 +1745,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); @@ -1725,6 +1758,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) va_copy(va_local, vap); rc = vsnprintf(bp, bufsiz, fmt, va_local); } + va_end(va_local); cp = bp + rc; @@ -1736,7 +1770,8 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) rc += rc2; } - xo_buf_append_div(xop, "message", 0, NULL, 0, bp, rc, NULL, 0); + xo_buf_append_div(xop, "message", 0, NULL, 0, bp, rc, + NULL, 0, NULL, 0); } break; @@ -1760,6 +1795,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) if (need_nl && code > 0) { const char *msg = strerror(code); + if (msg) { xo_printf(xop, ": %s", msg); } @@ -1774,6 +1810,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) case XO_STYLE_HTML: if (XOIF_ISSET(xop, XOIF_DIV_OPEN)) { static char div_close[] = "</div>"; + XOIF_CLEAR(xop, XOIF_DIV_OPEN); xo_data_append(xop, div_close, sizeof(div_close) - 1); @@ -1846,8 +1883,10 @@ xo_failure (xo_handle_t *xop, const char *fmt, ...) * Note: normal use of libxo does not require a distinct handle, since * the default handle (used when NULL is passed) generates text on stdout. * - * @style Style of output desired (XO_STYLE_* value) - * @flags Set of XOF_* flags in use with this handle + * @param style Style of output desired (XO_STYLE_* value) + * @param flags Set of XOF_* flags in use with this handle + * @return Newly allocated handle + * @see xo_destroy */ xo_handle_t * xo_create (xo_style_t style, xo_xof_flags_t flags) @@ -1869,9 +1908,12 @@ xo_create (xo_style_t style, xo_xof_flags_t flags) /** * Create a handle that will write to the given file. Use * the XOF_CLOSE_FP flag to have the file closed on xo_destroy(). - * @fp FILE pointer to use - * @style Style of output desired (XO_STYLE_* value) - * @flags Set of XOF_* flags to use with this handle + * + * @param fp FILE pointer to use + * @param style Style of output desired (XO_STYLE_* value) + * @param flags Set of XOF_* flags to use with this handle + * @return Newly allocated handle + * @see xo_destroy */ xo_handle_t * xo_create_to_file (FILE *fp, xo_style_t style, xo_xof_flags_t flags) @@ -1890,8 +1932,10 @@ xo_create_to_file (FILE *fp, xo_style_t style, xo_xof_flags_t flags) /** * Set the default handler to output to a file. - * @xop libxo handle - * @fp FILE pointer to use + * + * @param xop libxo handle + * @param fp FILE pointer to use + * @return 0 on success, non-zero on failure */ int xo_set_file_h (xo_handle_t *xop, FILE *fp) @@ -1913,7 +1957,9 @@ xo_set_file_h (xo_handle_t *xop, FILE *fp) /** * Set the default handler to output to a file. - * @fp FILE pointer to use + * + * @param fp FILE pointer to use + * @return 0 on success, non-zero on failure */ int xo_set_file (FILE *fp) @@ -1923,7 +1969,8 @@ xo_set_file (FILE *fp) /** * Release any resources held by the handle. - * @xop XO handle to alter (or NULL for default handle) + * + * @param xop XO handle to alter (or NULL for default handle) */ void xo_destroy (xo_handle_t *xop_arg) @@ -1956,8 +2003,8 @@ xo_destroy (xo_handle_t *xop_arg) * Record a new output style to use for the given handle (or default if * handle is NULL). This output style will be used for any future output. * - * @xop XO handle to alter (or NULL for default handle) - * @style new output style (XO_STYLE_*) + * @param xop XO handle to alter (or NULL for default handle) + * @param style new output style (XO_STYLE_*) */ void xo_set_style (xo_handle_t *xop, xo_style_t style) @@ -1966,6 +2013,12 @@ xo_set_style (xo_handle_t *xop, xo_style_t style) xop->xo_style = style; } +/** + * Return the current style of a handle + * + * @param xop XO handle to access + * @return The handle's current style + */ xo_style_t xo_get_style (xo_handle_t *xop) { @@ -1973,6 +2026,12 @@ xo_get_style (xo_handle_t *xop) return xo_style(xop); } +/** + * Return the XO_STYLE_* value matching a given name + * + * @param name String name of a style + * @return XO_STYLE_* value + */ static int xo_name_to_style (const char *name) { @@ -2008,12 +2067,12 @@ xo_style_is_encoding (xo_handle_t *xop) /* Simple name-value mapping */ typedef struct xo_mapping_s { - xo_xff_flags_t xm_value; - const char *xm_name; + xo_xff_flags_t xm_value; /* Flag value */ + const char *xm_name; /* String name */ } 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; @@ -2056,9 +2115,11 @@ xo_value_lookup (xo_mapping_t *map, xo_xff_flags_t value) static xo_mapping_t xo_xof_names[] = { { XOF_COLOR_ALLOWED, "color" }, + { XOF_COLOR, "color-force" }, { 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" }, @@ -2079,6 +2140,21 @@ static xo_mapping_t xo_xof_names[] = { { 0, NULL } }; +/* Options available via the environment variable ($LIBXO_OPTIONS) */ +static xo_mapping_t xo_xof_simple_names[] = { + { XOF_COLOR_ALLOWED, "color" }, + { XOF_FLUSH, "flush" }, + { XOF_FLUSH_LINE, "flush-line" }, + { XOF_NO_HUMANIZE, "no-humanize" }, + { XOF_NO_LOCALE, "no-locale" }, + { XOF_RETAIN_NONE, "no-retain" }, + { XOF_PRETTY, "pretty" }, + { XOF_RETAIN_ALL, "retain" }, + { XOF_UNDERSCORES, "underscores" }, + { XOF_WARN, "warn" }, + { 0, NULL } +}; + /* * Convert string name to XOF_* flag value. * Not all are useful. Or safe. Or sane. @@ -2089,6 +2165,13 @@ xo_name_to_flag (const char *name) return (unsigned) xo_name_lookup(xo_xof_names, name, -1); } +/** + * Set the style of an libxo handle based on a string name + * + * @param xop XO handle + * @param name String value of name + * @return 0 on success, non-zero on failure + */ int xo_set_style_name (xo_handle_t *xop, const char *name) { @@ -2096,6 +2179,7 @@ xo_set_style_name (xo_handle_t *xop, const char *name) return -1; int style = xo_name_to_style(name); + if (style < 0) return -1; @@ -2104,15 +2188,102 @@ xo_set_style_name (xo_handle_t *xop, const char *name) } /* + * Fill in the color map, based on the input string; currently unimplemented + * Look for something like "colors=red/blue+green/yellow" as fg/bg pairs. + */ +static void +xo_set_color_map (xo_handle_t *xop, char *value) +{ +#ifdef LIBXO_TEXT_ONLY + return; +#endif /* LIBXO_TEXT_ONLY */ + + char *cp, *ep, *vp, *np; + ssize_t len = value ? strlen(value) + 1 : 0; + int num = 1, fg, bg; + + for (cp = value, ep = cp + len - 1; cp && *cp && cp < ep; cp = np) { + np = strchr(cp, '+'); + if (np) + *np++ = '\0'; + + vp = strchr(cp, '/'); + if (vp) + *vp++ = '\0'; + + fg = *cp ? xo_color_find(cp) : -1; + bg = (vp && *vp) ? xo_color_find(vp) : -1; + + xop->xo_color_map_fg[num] = (fg < 0) ? num : fg; + xop->xo_color_map_bg[num] = (bg < 0) ? num : bg; + if (++num > XO_NUM_COLORS) + break; + } + + /* If no color initialization happened, then we don't need the map */ + if (num > 0) + XOF_SET(xop, XOF_COLOR_MAP); + else + XOF_CLEAR(xop, XOF_COLOR_MAP); + + /* Fill in the rest of the colors with the defaults */ + for ( ; num < XO_NUM_COLORS; num++) + xop->xo_color_map_fg[num] = xop->xo_color_map_bg[num] = num; +} + +static int +xo_set_options_simple (xo_handle_t *xop, const char *input) +{ + xo_xof_flags_t new_flag; + char *cp, *ep, *vp, *np, *bp; + ssize_t len = strlen(input) + 1; + + bp = alloca(len); + memcpy(bp, input, len); + + for (cp = bp, ep = cp + len - 1; cp && cp < ep; cp = np) { + np = strchr(cp, ','); + if (np) + *np++ = '\0'; + + vp = strchr(cp, '='); + if (vp) + *vp++ = '\0'; + + if (strcmp("colors", cp) == 0) { + xo_set_color_map(xop, vp); + continue; + } + + new_flag = xo_name_lookup(xo_xof_simple_names, cp, -1); + if (new_flag != 0) { + XOF_SET(xop, new_flag); + } else if (strcmp(cp, "no-color") == 0) { + XOF_CLEAR(xop, XOF_COLOR_ALLOWED); + } else { + xo_failure(xop, "unknown simple option: %s", cp); + return -1; + } + } + + return 0; +} + +/** * Set the options for a handle using a string of options * passed in. The input is a comma-separated set of names * and optional values: "xml,pretty,indent=4" + * + * @param xop XO handle + * @param input Comma-separated set of option values + * @return 0 on success, non-zero on failure */ 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 +2302,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) { @@ -2225,7 +2396,7 @@ xo_set_options (xo_handle_t *xop, const char *input) *vp++ = '\0'; if (strcmp("colors", cp) == 0) { - /* XXX Look for colors=red-blue+green-yellow */ + xo_set_color_map(xop, vp); continue; } @@ -2243,28 +2414,26 @@ xo_set_options (xo_handle_t *xop, const char *input) new_flag = xo_name_to_flag(cp); if (new_flag != 0) XOF_SET(xop, new_flag); - else { - if (strcmp(cp, "no-color") == 0) { - XOF_CLEAR(xop, XOF_COLOR_ALLOWED); - } else if (strcmp(cp, "indent") == 0) { - if (vp) - xop->xo_indent_by = atoi(vp); - else - xo_failure(xop, "missing value for indent option"); - } else if (strcmp(cp, "encoder") == 0) { - if (vp == NULL) - xo_failure(xop, "missing value for encoder option"); - else { - if (xo_encoder_init(xop, vp)) { - xo_failure(xop, "encoder not found: %s", vp); - rc = -1; - } + else if (strcmp(cp, "no-color") == 0) + XOF_CLEAR(xop, XOF_COLOR_ALLOWED); + else if (strcmp(cp, "indent") == 0) { + if (vp) + xop->xo_indent_by = atoi(vp); + else + xo_failure(xop, "missing value for indent option"); + } else if (strcmp(cp, "encoder") == 0) { + if (vp == NULL) + xo_failure(xop, "missing value for encoder option"); + else { + if (xo_encoder_init(xop, vp)) { + xo_failure(xop, "encoder not found: %s", vp); + rc = -1; } - - } else { - xo_warnx("unknown libxo option value: '%s'", cp); - rc = -1; } + + } else { + xo_warnx("unknown libxo option value: '%s'", cp); + rc = -1; } } } @@ -2279,8 +2448,8 @@ xo_set_options (xo_handle_t *xop, const char *input) * Set one or more flags for a given handle (or default if handle is NULL). * These flags will affect future output. * - * @xop XO handle to alter (or NULL for default handle) - * @flags Flags to be set (XOF_*) + * @param xop XO handle to alter (or NULL for default handle) + * @param flags Flags to be set (XOF_*) */ void xo_set_flags (xo_handle_t *xop, xo_xof_flags_t flags) @@ -2290,6 +2459,11 @@ xo_set_flags (xo_handle_t *xop, xo_xof_flags_t flags) XOF_SET(xop, flags); } +/** + * Accessor to return the current set of flags for a handle + * @param xop XO handle + * @return Current set of flags + */ xo_xof_flags_t xo_get_flags (xo_handle_t *xop) { @@ -2298,11 +2472,11 @@ xo_get_flags (xo_handle_t *xop) return xop->xo_flags; } -/* - * strndup with a twist: len < 0 means strlen +/** + * strndup with a twist: len < 0 means len = strlen(str) */ static char * -xo_strndup (const char *str, int len) +xo_strndup (const char *str, ssize_t len) { if (len < 0) len = strlen(str); @@ -2321,8 +2495,8 @@ xo_strndup (const char *str, int len) * generated data to be placed within an XML hierarchy but still have * accurate XPath expressions. * - * @xop XO handle to alter (or NULL for default handle) - * @path The XPath expression + * @param xop XO handle to alter (or NULL for default handle) + * @param path The XPath expression */ void xo_set_leading_xpath (xo_handle_t *xop, const char *path) @@ -2343,9 +2517,9 @@ xo_set_leading_xpath (xo_handle_t *xop, const char *path) /** * Record the info data for a set of tags * - * @xop XO handle to alter (or NULL for default handle) - * @info Info data (xo_info_t) to be recorded (or NULL) (MUST BE SORTED) - * @count Number of entries in info (or -1 to count them ourselves) + * @param xop XO handle to alter (or NULL for default handle) + * @param info Info data (xo_info_t) to be recorded (or NULL) (MUST BE SORTED) + * @pararm count Number of entries in info (or -1 to count them ourselves) */ void xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count) @@ -2382,8 +2556,8 @@ xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, * Clear one or more flags for a given handle (or default if handle is NULL). * These flags will affect future output. * - * @xop XO handle to alter (or NULL for default handle) - * @flags Flags to be cleared (XOF_*) + * @param xop XO handle to alter (or NULL for default handle) + * @param flags Flags to be cleared (XOF_*) */ void xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags) @@ -2476,7 +2650,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 +2689,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)) @@ -2537,6 +2713,8 @@ xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp, if ((flags & XFF_UNESCAPE) && (*cp == '\\' || *cp == '%')) { cp += 1; len -= 1; + if (len == 0 || *cp == '\0') + break; } } @@ -2629,7 +2807,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 +2892,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 +2901,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 +3031,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 +3052,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 +3075,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 +3146,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 +3158,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 +3222,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 +3232,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, @@ -3072,6 +3251,11 @@ xo_data_append_content (xo_handle_t *xop, const char *str, int len, xop->xo_anchor_columns += cols; } +/** + * Bump one of the 'width' values in a format strings (e.g. "%40.50.60s"). + * @param xfp Formatting instructions + * @param digit Single digit (0-9) of input + */ static void xo_bump_width (xo_format_t *xfp, int digit) { @@ -3080,11 +3264,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 +3302,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 +3322,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 +3474,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 +3502,8 @@ 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 +3644,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)) @@ -3471,6 +3656,10 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp, return 0; } +/* + * Remove any numeric precision/width format from the format string by + * inserting the "%" after the [0-9]+, returning the substring. + */ static char * xo_fix_encoding (xo_handle_t *xop UNUSED, char *encoding) { @@ -3484,8 +3673,7 @@ xo_fix_encoding (xo_handle_t *xop UNUSED, char *encoding) break; } - cp -= 1; - *cp = '%'; + *--cp = '%'; /* Back off and insert the '%' */ return cp; } @@ -3512,8 +3700,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 +3727,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 +3744,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 +3769,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 +3782,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; @@ -3605,11 +3792,36 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp, } } +/* + * Convenience function that either append a fixed value (if one is + * given) or formats a field using a format string. If it's + * encode_only, then we can't skip formatting the field, since it may + * be pulling arguments off the stack. + */ +static inline void +xo_simple_field (xo_handle_t *xop, unsigned encode_only, + const char *value, ssize_t vlen, + const char *fmt, ssize_t flen, xo_xff_flags_t flags) +{ + if (encode_only) + flags |= XFF_NO_OUTPUT; + + if (vlen == 0) + xo_do_format_field(xop, NULL, fmt, flen, flags); + else if (!encode_only) + xo_data_append_content(xop, value, vlen, flags); +} + +/* + * Html mode: append a <div> to the output buffer contain a field + * along with all the supporting information indicated by the flags. + */ 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 *fmt, ssize_t flen, + const char *encoding, ssize_t elen) { static char div_start[] = "<div class=\""; static char div_tag[] = "\" data-tag=\""; @@ -3619,10 +3831,10 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags, static char div_close[] = "</div>"; /* The encoding format defaults to the normal format */ - if (encoding == NULL) { - char *enc = alloca(vlen + 1); - memcpy(enc, value, vlen); - enc[vlen] = '\0'; + if (encoding == NULL && fmt != NULL) { + char *enc = alloca(flen + 1); + memcpy(enc, fmt, flen); + enc[flen] = '\0'; encoding = xo_fix_encoding(xop, enc); elen = strlen(encoding); } @@ -3636,7 +3848,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 +3879,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) { @@ -3689,10 +3901,10 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags, /* * Even if this is encode-only, we need to go through the * work of formatting it to make sure the args are cleared - * from xo_vap. + * from xo_vap. This is not true when vlen is zero, since + * that means our "value" isn't on the stack. */ - xo_do_format_field(xop, NULL, encoding, elen, - flags | XFF_NO_OUTPUT); + xo_simple_field(xop, TRUE, NULL, 0, encoding, elen, flags); return; } @@ -3790,7 +4002,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); @@ -3800,7 +4012,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags, save.xhs_columns = xop->xo_columns; save.xhs_anchor_columns = xop->xo_anchor_columns; - xo_do_format_field(xop, NULL, value, vlen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); if (flags & XFF_HUMANIZE) { /* @@ -3808,10 +4020,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 +4032,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 +4055,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: @@ -3851,17 +4063,17 @@ xo_format_text (xo_handle_t *xop, const char *str, int len) break; case XO_STYLE_HTML: - xo_buf_append_div(xop, "text", 0, NULL, 0, str, len, NULL, 0); + xo_buf_append_div(xop, "text", 0, NULL, 0, str, len, NULL, 0, NULL, 0); break; } } static void xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip, - const char *str, unsigned len) + const char *value, ssize_t vlen) { 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"; @@ -3882,15 +4094,14 @@ xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip, * Even though we don't care about text, we need to do * enough parsing work to skip over the right bits of xo_vap. */ - if (len == 0) - xo_do_format_field(xop, NULL, fmt, flen, flags | XFF_NO_OUTPUT); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); return; } 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); @@ -3902,17 +4113,17 @@ xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip, } start = xbp->xb_curp - xbp->xb_bufp; /* Reset start */ - if (len) { + if (vlen) { char *newfmt = alloca(flen + 1); memcpy(newfmt, fmt, flen); newfmt[flen] = '\0'; /* If len is non-zero, the format string apply to the name */ - char *newstr = alloca(len + 1); - memcpy(newstr, str, len); - newstr[len] = '\0'; + char *newstr = alloca(vlen + 1); + memcpy(newstr, value, vlen); + newstr[vlen] = '\0'; - if (newstr[len - 1] == 's') { + if (newstr[vlen - 1] == 's') { char *bp; rc = snprintf(NULL, 0, newfmt, newstr); @@ -3993,9 +4204,10 @@ 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 *value, ssize_t vlen, + const char *fmt, 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 +4228,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 +4252,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 +4270,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 @@ -4081,7 +4293,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, save.xhs_columns = xop->xo_columns; save.xhs_anchor_columns = xop->xo_anchor_columns; - xo_do_format_field(xop, NULL, format, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); if (flags & XFF_HUMANIZE) xo_format_humanize(xop, xbp, &save, flags); @@ -4091,8 +4303,8 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, if (flags & XFF_ENCODE_ONLY) flags |= XFF_NO_OUTPUT; - xo_buf_append_div(xop, "data", flags, name, nlen, - format, flen, encoding, elen); + xo_buf_append_div(xop, "data", flags, name, nlen, value, vlen, + fmt, flen, encoding, elen); break; case XO_STYLE_XML: @@ -4101,25 +4313,24 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, * let the formatting code handle the va_arg popping. */ if (flags & XFF_DISPLAY_ONLY) { - flags |= XFF_NO_OUTPUT; - xo_do_format_field(xop, NULL, format, flen, flags); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } if (encoding) { - format = encoding; + fmt = encoding; flen = elen; } else { char *enc = alloca(flen + 1); - memcpy(enc, format, flen); + memcpy(enc, fmt, flen); enc[flen] = '\0'; - format = xo_fix_encoding(xop, enc); - flen = strlen(format); + fmt = xo_fix_encoding(xop, enc); + flen = strlen(fmt); } if (nlen == 0) { static char missing[] = "missing-field-name"; - xo_failure(xop, "missing field name: %s", format); + xo_failure(xop, "missing field name: %s", fmt); name = missing; nlen = sizeof(missing) - 1; } @@ -4155,7 +4366,9 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, } xo_data_append(xop, ">", 1); - xo_do_format_field(xop, NULL, format, flen, flags); + + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); + xo_data_append(xop, "</", 2); xo_data_escape(xop, name, nlen); xo_data_append(xop, ">", 1); @@ -4165,23 +4378,23 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, case XO_STYLE_JSON: if (flags & XFF_DISPLAY_ONLY) { - flags |= XFF_NO_OUTPUT; - xo_do_format_field(xop, NULL, format, flen, flags); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } if (encoding) { - format = encoding; + fmt = encoding; flen = elen; } else { char *enc = alloca(flen + 1); - memcpy(enc, format, flen); + memcpy(enc, fmt, flen); enc[flen] = '\0'; - format = xo_fix_encoding(xop, enc); - flen = strlen(format); + fmt = xo_fix_encoding(xop, enc); + flen = strlen(fmt); } - 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); @@ -4189,18 +4402,20 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, quote = 1; else if (flags & XFF_NOQUOTE) quote = 0; + else if (vlen != 0) + quote = 1; else if (flen == 0) { quote = 0; - format = "true"; /* JSON encodes empty tags as a boolean true */ + fmt = "true"; /* JSON encodes empty tags as a boolean true */ flen = 4; - } else if (strchr("diouxXDOUeEfFgGaAcCp", format[flen - 1]) == NULL) + } else if (strchr("diouDOUeEfFgG", fmt[flen - 1]) == NULL) quote = 1; else quote = 0; if (nlen == 0) { static char missing[] = "missing-field-name"; - xo_failure(xop, "missing field name: %s", format); + xo_failure(xop, "missing field name: %s", fmt); name = missing; nlen = sizeof(missing) - 1; } @@ -4216,13 +4431,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] = '_'; } @@ -4234,7 +4449,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, if (quote) xo_data_append(xop, "\"", 1); - xo_do_format_field(xop, NULL, format, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); if (quote) xo_data_append(xop, "\"", 1); @@ -4242,39 +4457,39 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, case XO_STYLE_SDPARAMS: if (flags & XFF_DISPLAY_ONLY) { - flags |= XFF_NO_OUTPUT; - xo_do_format_field(xop, NULL, format, flen, flags); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } if (encoding) { - format = encoding; + fmt = encoding; flen = elen; } else { char *enc = alloca(flen + 1); - memcpy(enc, format, flen); + memcpy(enc, fmt, flen); enc[flen] = '\0'; - format = xo_fix_encoding(xop, enc); - flen = strlen(format); + fmt = xo_fix_encoding(xop, enc); + flen = strlen(fmt); } if (nlen == 0) { static char missing[] = "missing-field-name"; - xo_failure(xop, "missing field name: %s", format); + xo_failure(xop, "missing field name: %s", fmt); name = missing; nlen = sizeof(missing) - 1; } xo_data_escape(xop, name, nlen); xo_data_append(xop, "=\"", 2); - xo_do_format_field(xop, NULL, format, flen, flags); + + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); + xo_data_append(xop, "\" ", 2); break; case XO_STYLE_ENCODER: if (flags & XFF_DISPLAY_ONLY) { - flags |= XFF_NO_OUTPUT; - xo_do_format_field(xop, NULL, format, flen, flags); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } @@ -4284,42 +4499,44 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen, quote = 0; else if (flen == 0) { quote = 0; - format = "true"; /* JSON encodes empty tags as a boolean true */ + fmt = "true"; /* JSON encodes empty tags as a boolean true */ flen = 4; - } else if (strchr("diouxXDOUeEfFgGaAcCp", format[flen - 1]) == NULL) + } else if (strchr("diouxXDOUeEfFgGaAcCp", fmt[flen - 1]) == NULL) quote = 1; else quote = 0; if (encoding) { - format = encoding; + fmt = encoding; flen = elen; } else { char *enc = alloca(flen + 1); - memcpy(enc, format, flen); + memcpy(enc, fmt, flen); enc[flen] = '\0'; - format = xo_fix_encoding(xop, enc); - flen = strlen(format); + fmt = xo_fix_encoding(xop, enc); + flen = strlen(fmt); } if (nlen == 0) { static char missing[] = "missing-field-name"; - xo_failure(xop, "missing field name: %s", format); + xo_failure(xop, "missing field name: %s", fmt); name = missing; 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); - xo_do_format_field(xop, NULL, format, flen, flags); + ssize_t value_offset = xo_buf_offset(&xop->xo_data); + + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); + xo_data_append(xop, "", 1); xo_encoder_handle(xop, quote ? XO_OP_STRING : XO_OP_CONTENT, xo_buf_data(&xop->xo_data, name_offset), - xo_buf_data(&xop->xo_data, value_offset)); + xo_buf_data(&xop->xo_data, value_offset), flags); xo_buf_reset(&xop->xo_data); break; } @@ -4327,10 +4544,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 +4559,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,37 +4580,27 @@ 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 *value, ssize_t vlen, + const char *fmt, ssize_t flen, xo_xff_flags_t flags) { switch (xo_style(xop)) { case XO_STYLE_TEXT: - if (len) - xo_data_append_content(xop, str, len, flags); - else - xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); break; case XO_STYLE_HTML: - if (len == 0) { - str = fmt; - len = flen; - } - - xo_buf_append_div(xop, class_name, flags, NULL, 0, str, len, NULL, 0); + xo_buf_append_div(xop, class_name, flags, NULL, 0, + value, vlen, fmt, flen, NULL, 0); break; case XO_STYLE_XML: case XO_STYLE_JSON: case XO_STYLE_SDPARAMS: if (tag_name) { - if (len == 0) { - str = fmt; - len = flen; - } - xo_open_container_h(xop, tag_name); - xo_format_value(xop, "message", 7, str, len, NULL, 0, flags); + xo_format_value(xop, "message", 7, value, vlen, + fmt, flen, NULL, 0, flags); xo_close_container_h(xop, tag_name); } else { @@ -4401,16 +4608,12 @@ xo_format_content (xo_handle_t *xop, const char *class_name, * Even though we don't care about labels, we need to do * enough parsing work to skip over the right bits of xo_vap. */ - if (len == 0) - xo_do_format_field(xop, NULL, fmt, flen, - flags | XFF_NO_OUTPUT); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); } break; case XO_STYLE_ENCODER: - if (len == 0) - xo_do_format_field(xop, NULL, fmt, flen, - flags | XFF_NO_OUTPUT); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } } @@ -4500,7 +4703,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; /* @@ -4576,6 +4779,28 @@ xo_colors_enabled (xo_handle_t *xop UNUSED) #endif /* LIBXO_TEXT_ONLY */ } +/* + * If the color map is in use (--libxo colors=xxxx), then update + * the incoming foreground and background colors from the map. + */ +static void +xo_colors_update (xo_handle_t *xop, xo_colors_t *newp) +{ +#ifdef LIBXO_TEXT_ONLY + return; +#endif /* LIBXO_TEXT_ONLY */ + + xo_color_t fg = newp->xoc_col_fg; + if (XOF_ISSET(xop, XOF_COLOR_MAP) && fg < XO_NUM_COLORS) + fg = xop->xo_color_map_fg[fg]; /* Fetch from color map */ + newp->xoc_col_fg = fg; + + xo_color_t bg = newp->xoc_col_bg; + if (XOF_ISSET(xop, XOF_COLOR_MAP) && bg < XO_NUM_COLORS) + bg = xop->xo_color_map_bg[bg]; /* Fetch from color map */ + newp->xoc_col_bg = bg; +} + static void xo_colors_handle_text (xo_handle_t *xop, xo_colors_t *newp) { @@ -4622,16 +4847,16 @@ xo_colors_handle_text (xo_handle_t *xop, xo_colors_t *newp) } } - if (newp->xoc_col_fg != oldp->xoc_col_fg) { + xo_color_t fg = newp->xoc_col_fg; + if (fg != oldp->xoc_col_fg) { cp += snprintf(cp, ep - cp, ";3%u", - (newp->xoc_col_fg != XO_COL_DEFAULT) - ? newp->xoc_col_fg - 1 : 9); + (fg != XO_COL_DEFAULT) ? fg - 1 : 9); } - if (newp->xoc_col_bg != oldp->xoc_col_bg) { + xo_color_t bg = newp->xoc_col_bg; + if (bg != oldp->xoc_col_bg) { cp += snprintf(cp, ep - cp, ";4%u", - (newp->xoc_col_bg != XO_COL_DEFAULT) - ? newp->xoc_col_bg - 1 : 9); + (bg != XO_COL_DEFAULT) ? bg - 1 : 9); } if (cp - buf != 1 && cp < ep - 3) { @@ -4703,21 +4928,21 @@ 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 *value, ssize_t vlen) { const char *fmt = xfip->xfi_format; - unsigned flen = xfip->xfi_flen; + ssize_t flen = xfip->xfi_flen; xo_buffer_t xb; /* If the string is static and we've in an encoding style, bail */ - if (len != 0 && xo_style_is_encoding(xop)) + if (vlen != 0 && xo_style_is_encoding(xop)) return; xo_buf_init(&xb); - if (len) - xo_buf_append(&xb, str, len); + if (vlen) + xo_buf_append(&xb, value, vlen); else if (flen) xo_do_format_field(xop, &xb, fmt, flen, 0); else @@ -4731,6 +4956,7 @@ xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip, xo_colors_t xoc = xop->xo_colors; xo_colors_parse(xop, &xoc, xb.xb_bufp); + xo_colors_update(xop, &xoc); if (xo_style(xop) == XO_STYLE_TEXT) { /* @@ -4776,23 +5002,23 @@ 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 *value, ssize_t vlen) { 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=\""; static char units_start_html[] = " data-units=\""; if (!XOIF_ISSET(xop, XOIF_UNITS_PENDING)) { - xo_format_content(xop, "units", NULL, str, len, fmt, flen, flags); + xo_format_content(xop, "units", NULL, value, vlen, fmt, flen, flags); return; } 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); @@ -4801,15 +5027,15 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip, else return; - if (len) - xo_data_escape(xop, str, len); + if (vlen) + xo_data_escape(xop, value, vlen); else xo_do_format_field(xop, NULL, fmt, flen, flags); 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,33 +5054,77 @@ 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 *value, ssize_t vlen) { const char *fmt = xfip->xfi_format; - unsigned flen = xfip->xfi_flen; + ssize_t flen = xfip->xfi_flen; long width = 0; char *bp; char *cp; - if (len) { - bp = alloca(len + 1); /* Make local NUL-terminated copy of str */ - memcpy(bp, str, len); - bp[len] = '\0'; + if (vlen) { + bp = alloca(vlen + 1); /* Make local NUL-terminated copy of value */ + memcpy(bp, value, vlen); + bp[vlen] = '\0'; width = strtol(bp, &cp, 0); - if (width == LONG_MIN || width == LONG_MAX - || bp == cp || *cp != '\0' ) { + if (width == LONG_MIN || width == LONG_MAX || bp == cp || *cp != '\0') { width = 0; xo_failure(xop, "invalid width for anchor: '%s'", bp); } } else if (flen) { - if (flen != 2 || strncmp("%d", fmt, flen) != 0) - xo_failure(xop, "invalid width format: '%*.*s'", flen, flen, fmt); - if (!XOF_ISSET(xop, XOF_NO_VA_ARG)) - width = va_arg(xop->xo_vap, int); + /* + * We really expect the format for width to be "{:/%d}" or + * "{:/%u}", so if that's the case, we just grab our width off + * the argument list. But we need to avoid optimized logic if + * there's a custom formatter. + */ + if (xop->xo_formatter == NULL && flen == 2 + && strncmp("%d", fmt, flen) == 0) { + if (!XOF_ISSET(xop, XOF_NO_VA_ARG)) + width = va_arg(xop->xo_vap, int); + } else if (xop->xo_formatter == NULL && flen == 2 + && strncmp("%u", fmt, flen) == 0) { + if (!XOF_ISSET(xop, XOF_NO_VA_ARG)) + width = va_arg(xop->xo_vap, unsigned); + } else { + /* + * So we have a format and it's not a simple one like + * "{:/%d}". That means we need to format the field, + * extract the value from the formatted output, and then + * discard that output. + */ + int anchor_was_set = FALSE; + xo_buffer_t *xbp = &xop->xo_data; + ssize_t start_offset = xo_buf_offset(xbp); + bp = xo_buf_cur(xbp); /* Save start of the string */ + cp = NULL; + + if (XOIF_ISSET(xop, XOIF_ANCHOR)) { + XOIF_CLEAR(xop, XOIF_ANCHOR); + anchor_was_set = TRUE; + } + + ssize_t rc = xo_do_format_field(xop, xbp, fmt, flen, 0); + if (rc >= 0) { + xo_buf_append(xbp, "", 1); /* Append a NUL */ + + width = strtol(bp, &cp, 0); + if (width == LONG_MIN || width == LONG_MAX + || bp == cp || *cp != '\0') { + width = 0; + xo_failure(xop, "invalid width for anchor: '%s'", bp); + } + } + + /* Reset the cur pointer to where we found it */ + xbp->xb_curp = xbp->xb_bufp + start_offset; + if (anchor_was_set) + XOIF_SET(xop, XOIF_ANCHOR); + } } return width; @@ -4879,11 +5149,8 @@ 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 *value, ssize_t vlen) { - if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML) - return; - if (XOIF_ISSET(xop, XOIF_ANCHOR)) xo_failure(xop, "the anchor already recording is discarded"); @@ -4896,16 +5163,13 @@ xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip, * Now we find the width, if possible. If it's not there, * we'll get it on the end anchor. */ - xop->xo_anchor_min_width = xo_find_width(xop, xfip, str, len); + xop->xo_anchor_min_width = xo_find_width(xop, xfip, value, vlen); } static void xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip, - const char *str, unsigned len) + const char *value, ssize_t vlen) { - if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML) - return; - if (!XOIF_ISSET(xop, XOIF_ANCHOR)) { xo_failure(xop, "no start anchor"); return; @@ -4913,7 +5177,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, value, vlen); if (width == 0) width = xop->xo_anchor_min_width; @@ -4921,10 +5185,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 +5207,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 +5412,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 +5704,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 +5887,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 ?: ""); } } @@ -5832,12 +6096,12 @@ xo_gettext_build_format (xo_handle_t *xop, if (gtfmt == NULL || gtfmt == fmt || strcmp(gtfmt, fmt) == 0) goto bail2; - xo_buf_cleanup(&xb); - char *new_fmt = xo_strndup(gtfmt, -1); if (new_fmt == NULL) goto bail2; + xo_buf_cleanup(&xb); + *new_fmtp = new_fmt; return new_fmt; @@ -5850,13 +6114,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 +6132,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 +6188,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 +6198,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 +6210,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,12 +6229,12 @@ 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; + for (xfip = fields, field = 0; field < max_fields && xfip->xfi_ftype; xfip++, field++) { ftype = xfip->xfi_ftype; flags = xfip->xfi_flags; @@ -5982,7 +6247,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) { /* @@ -6016,12 +6281,12 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields, if (flags & XFF_WS) { xo_format_content(xop, "padding", NULL, " ", 1, NULL, 0, flags); - flags &= ~XFF_WS; /* Block later handling of this */ + flags &= ~XFF_WS; /* Prevent later handling of this flag */ } } if (ftype == 'V') - xo_format_value(xop, content, clen, + xo_format_value(xop, content, clen, NULL, 0, xfip->xfi_format, xfip->xfi_flen, xfip->xfi_encoding, xfip->xfi_elen, flags); else if (ftype == '[') @@ -6060,7 +6325,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 +6420,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 +6503,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 +6517,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 +6531,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 +6545,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 +6560,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 +6574,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 +6594,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 +6630,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 +6639,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 +6653,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 +6667,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: @@ -6454,17 +6717,17 @@ xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap) *xbp->xb_curp = '\0'; rc = xo_encoder_handle(xop, XO_OP_ATTRIBUTE, xo_buf_data(xbp, name_offset), - xo_buf_data(xbp, value_offset)); + xo_buf_data(xbp, value_offset), 0); } } 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 +6737,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); @@ -6532,7 +6795,7 @@ xo_depth_change (xo_handle_t *xop, const char *name, xo_stack_t *xsp = &xop->xo_stack[xop->xo_depth]; if (XOF_ISSET(xop, XOF_WARN)) { const char *top = xsp->xs_name; - if (top && strcmp(name, top) != 0) { + if (top != NULL && name != NULL && strcmp(name, top) != 0) { xo_failure(xop, "incorrect close: '%s' .vs. '%s'", name, top); return; @@ -6576,7 +6839,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 +6860,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 = ""; @@ -6644,7 +6907,7 @@ xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name) break; case XO_STYLE_ENCODER: - rc = xo_encoder_handle(xop, XO_OP_OPEN_CONTAINER, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_OPEN_CONTAINER, name, NULL, flags); break; } @@ -6660,25 +6923,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 +6952,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 +6961,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); @@ -6734,32 +6997,32 @@ xo_do_close_container (xo_handle_t *xop, const char *name) case XO_STYLE_ENCODER: xo_depth_change(xop, name, -1, 0, XSS_CLOSE_CONTAINER, 0); - rc = xo_encoder_handle(xop, XO_OP_CLOSE_CONTAINER, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_CLOSE_CONTAINER, name, NULL, 0); break; } 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 +7031,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); @@ -6800,7 +7063,7 @@ xo_do_open_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name) break; case XO_STYLE_ENCODER: - rc = xo_encoder_handle(xop, XO_OP_OPEN_LIST, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_OPEN_LIST, name, NULL, flags); break; } @@ -6816,25 +7079,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 +7106,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 +7114,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); @@ -6875,7 +7138,7 @@ xo_do_close_list (xo_handle_t *xop, const char *name) case XO_STYLE_ENCODER: xo_depth_change(xop, name, -1, 0, XSS_CLOSE_LIST, XSF_LIST); - rc = xo_encoder_handle(xop, XO_OP_CLOSE_LIST, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_CLOSE_LIST, name, NULL, 0); break; default: @@ -6887,25 +7150,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 +7177,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); @@ -6949,7 +7212,7 @@ xo_do_open_leaf_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name) break; case XO_STYLE_ENCODER: - rc = xo_encoder_handle(xop, XO_OP_OPEN_LEAF_LIST, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_OPEN_LEAF_LIST, name, NULL, flags); break; } @@ -6962,7 +7225,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 +7233,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); @@ -6993,7 +7256,7 @@ xo_do_close_leaf_list (xo_handle_t *xop, const char *name) break; case XO_STYLE_ENCODER: - rc = xo_encoder_handle(xop, XO_OP_CLOSE_LEAF_LIST, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_CLOSE_LEAF_LIST, name, NULL, 0); /* FALLTHRU */ default: @@ -7010,7 +7273,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 = ""; @@ -7050,7 +7313,7 @@ xo_do_open_instance (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name) break; case XO_STYLE_ENCODER: - rc = xo_encoder_handle(xop, XO_OP_OPEN_INSTANCE, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_OPEN_INSTANCE, name, NULL, flags); break; } @@ -7065,25 +7328,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 +7357,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 +7366,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); @@ -7138,32 +7401,32 @@ xo_do_close_instance (xo_handle_t *xop, const char *name) case XO_STYLE_ENCODER: xo_depth_change(xop, name, -1, 0, XSS_CLOSE_INSTANCE, 0); - rc = xo_encoder_handle(xop, XO_OP_CLOSE_INSTANCE, name, NULL); + rc = xo_encoder_handle(xop, XO_OP_CLOSE_INSTANCE, name, NULL, 0); break; } 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 +7436,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 +7485,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 +7545,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 +7814,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 +7825,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 +7839,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,16 +7868,16 @@ 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); switch (xo_style(xop)) { case XO_STYLE_ENCODER: - xo_encoder_handle(xop, XO_OP_FLUSH, NULL, NULL); + xo_encoder_handle(xop, XO_OP_FLUSH, NULL, NULL, 0); } rc = xo_write(xop); @@ -7626,13 +7888,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 = ""; @@ -7653,14 +7915,14 @@ xo_finish_h (xo_handle_t *xop) break; case XO_STYLE_ENCODER: - xo_encoder_handle(xop, XO_OP_FINISH, NULL, NULL); + xo_encoder_handle(xop, XO_OP_FINISH, NULL, NULL, 0); break; } return xo_flush_h(xop); } -int +xo_ssize_t xo_finish (void) { return xo_finish_h(NULL); @@ -7688,7 +7950,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); @@ -7705,7 +7967,8 @@ xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap) case XO_STYLE_HTML: va_copy(xop->xo_vap, vap); - xo_buf_append_div(xop, "error", 0, NULL, 0, fmt, strlen(fmt), NULL, 0); + xo_buf_append_div(xop, "error", 0, NULL, 0, NULL, 0, + fmt, strlen(fmt), NULL, 0); if (XOIF_ISSET(xop, XOIF_DIV_OPEN)) xo_line_close(xop); @@ -7721,7 +7984,8 @@ xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap) va_copy(xop->xo_vap, vap); xo_open_container_h(xop, "error"); - xo_format_value(xop, "message", 7, fmt, strlen(fmt), NULL, 0, 0); + xo_format_value(xop, "message", 7, NULL, 0, + fmt, strlen(fmt), NULL, 0, 0); xo_close_container_h(xop, "error"); va_end(xop->xo_vap); @@ -7776,6 +8040,8 @@ xo_parse_args (int argc, char **argv) if (cp) xo_program = cp + 1; + xo_handle_t *xop = xo_default(NULL); + for (save = i = 1; i < argc; i++) { if (argv[i] == NULL || strncmp(argv[i], libxo_opt, sizeof(libxo_opt) - 1) != 0) { @@ -7793,14 +8059,14 @@ xo_parse_args (int argc, char **argv) return -1; } - if (xo_set_options(NULL, cp) < 0) + if (xo_set_options(xop, cp) < 0) return -1; } else if (*cp == ':') { - if (xo_set_options(NULL, cp) < 0) + if (xo_set_options(xop, cp) < 0) return -1; } else if (*cp == '=') { - if (xo_set_options(NULL, ++cp) < 0) + if (xo_set_options(xop, ++cp) < 0) return -1; } else if (*cp == '-') { @@ -7818,6 +8084,13 @@ xo_parse_args (int argc, char **argv) } } + /* + * We only want to do color output on terminals, but we only want + * to do this if the user has asked for color. + */ + if (XOF_ISSET(xop, XOF_COLOR_ALLOWED) && isatty(1)) + XOF_SET(xop, XOF_COLOR); + argv[save] = NULL; return save; } @@ -7867,7 +8140,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: @@ -7879,7 +8152,7 @@ xo_set_version_h (xo_handle_t *xop, const char *version) break; case XO_STYLE_ENCODER: - xo_encoder_handle(xop, XO_OP_VERSION, NULL, version); + xo_encoder_handle(xop, XO_OP_VERSION, NULL, version, 0); break; } } @@ -7929,7 +8202,7 @@ xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code, xo_buffer_t *src = &temp.xo_data; xo_format_value(xop, "message", 7, src->xb_bufp, - src->xb_curp - src->xb_bufp, NULL, 0, 0); + src->xb_curp - src->xb_bufp, NULL, 0, NULL, 0, 0); xo_free(temp.xo_stack); xo_buf_cleanup(src); @@ -7937,7 +8210,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/contrib/libxo/libxo/xo.h b/contrib/libxo/libxo/xo.h index 310b21c..c39fa47 100644 --- a/contrib/libxo/libxo/xo.h +++ b/contrib/libxo/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) @@ -97,6 +101,8 @@ typedef unsigned long long xo_xof_flags_t; #define XOF_RETAIN_ALL XOF_BIT(30) /** Force use of XOEF_RETAIN */ #define XOF_RETAIN_NONE XOF_BIT(31) /** Prevent use of XOEF_RETAIN */ +#define XOF_COLOR_MAP XOF_BIT(32) /** Color map has been initialized */ + typedef unsigned xo_emit_flags_t; /* Flags to xo_emit() and friends */ #define XOEF_RETAIN (1<<0) /* Retain parsed formatting information */ @@ -115,7 +121,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 +143,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 +199,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 +277,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 +379,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 +661,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/contrib/libxo/libxo/xo_attr.3 b/contrib/libxo/libxo/xo_attr.3 index c71377f..9e61acd 100644 --- a/contrib/libxo/libxo/xo_attr.3 +++ b/contrib/libxo/libxo/xo_attr.3 @@ -58,3 +58,13 @@ already emitted in other form. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_buf.h b/contrib/libxo/libxo/xo_buf.h index 01eb397..d6a0500 100644 --- a/contrib/libxo/libxo/xo_buf.h +++ b/contrib/libxo/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,9 +131,9 @@ 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)) + if (str == NULL || len == 0 || !xo_buf_has_room(xbp, len)) return; memcpy(xbp->xb_curp, str, len); @@ -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/contrib/libxo/libxo/xo_create.3 b/contrib/libxo/libxo/xo_create.3 index bfbadc4..03d5176 100644 --- a/contrib/libxo/libxo/xo_create.3 +++ b/contrib/libxo/libxo/xo_create.3 @@ -65,3 +65,13 @@ resources associated with the default handle. .Xr xo_emit 3 , .Xr xo_set_options 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_emit.3 b/contrib/libxo/libxo/xo_emit.3 index 155ea75..eceb38e 100644 --- a/contrib/libxo/libxo/xo_emit.3 +++ b/contrib/libxo/libxo/xo_emit.3 @@ -102,3 +102,13 @@ then the number of display columns consumed by the output will be returned. .Xr xo_open_list 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_emit_err.3 b/contrib/libxo/libxo/xo_emit_err.3 index bb1ca64..eae44b7 100644 --- a/contrib/libxo/libxo/xo_emit_err.3 +++ b/contrib/libxo/libxo/xo_emit_err.3 @@ -70,3 +70,13 @@ parameter. .Xr xo_format 5 , .Xr xo_err 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_emit_f.3 b/contrib/libxo/libxo/xo_emit_f.3 index 0879546..2edfa79 100644 --- a/contrib/libxo/libxo/xo_emit_f.3 +++ b/contrib/libxo/libxo/xo_emit_f.3 @@ -109,3 +109,13 @@ for details. .Xr xo_open_list 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_encoder.c b/contrib/libxo/libxo/xo_encoder.c index eb2960b..a073e69 100644 --- a/contrib/libxo/libxo/xo_encoder.c +++ b/contrib/libxo/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) { @@ -308,7 +308,7 @@ xo_encoder_init (xo_handle_t *xop, const char *name) xo_set_encoder(xop, xep->xe_handler); - return xo_encoder_handle(xop, XO_OP_CREATE, NULL, NULL); + return xo_encoder_handle(xop, XO_OP_CREATE, NULL, NULL, 0); } /* @@ -334,7 +334,7 @@ xo_encoder_create (const char *name, xo_xof_flags_t flags) int xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op, - const char *name, const char *value) + const char *name, const char *value, xo_xof_flags_t flags) { void *private = xo_get_private(xop); xo_encoder_func_t func = xo_get_encoder(xop); @@ -342,7 +342,7 @@ xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op, if (func == NULL) return -1; - return func(xop, op, name, value, private); + return func(xop, op, name, value, private, flags); } const char * diff --git a/contrib/libxo/libxo/xo_encoder.h b/contrib/libxo/libxo/xo_encoder.h index f73552b..0e20e72 100644 --- a/contrib/libxo/libxo/xo_encoder.h +++ b/contrib/libxo/libxo/xo_encoder.h @@ -50,7 +50,8 @@ typedef unsigned xo_encoder_op_t; xo_encoder_op_t op __attribute__ ((__unused__)), \ const char *name __attribute__ ((__unused__)), \ const char *value __attribute__ ((__unused__)), \ - void *private __attribute__ ((__unused__)) + void *private __attribute__ ((__unused__)), \ + xo_xof_flags_t flags __attribute__ ((__unused__)) typedef int (*xo_encoder_func_t)(XO_ENCODER_HANDLER_ARGS); @@ -105,7 +106,7 @@ xo_encoder_create (const char *name, xo_xof_flags_t flags); int xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op, - const char *name, const char *value); + const char *name, const char *value, xo_xof_flags_t flags); void xo_encoders_clean (void); diff --git a/contrib/libxo/libxo/xo_err.3 b/contrib/libxo/libxo/xo_err.3 index 532899a..87cf201 100644 --- a/contrib/libxo/libxo/xo_err.3 +++ b/contrib/libxo/libxo/xo_err.3 @@ -72,3 +72,13 @@ parameter. .Xr xo_emit 3 , .Xr xo_emit_err 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_error.3 b/contrib/libxo/libxo/xo_error.3 index e5c99e9..0330af4 100644 --- a/contrib/libxo/libxo/xo_error.3 +++ b/contrib/libxo/libxo/xo_error.3 @@ -39,3 +39,13 @@ calls. .Xr printf 3 , .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_finish.3 b/contrib/libxo/libxo/xo_finish.3 index 221b1c1..f9c6b3d 100644 --- a/contrib/libxo/libxo/xo_finish.3 +++ b/contrib/libxo/libxo/xo_finish.3 @@ -37,3 +37,13 @@ especially for the non-TEXT output styles. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_flush.3 b/contrib/libxo/libxo/xo_flush.3 index e43bae0..a785c68 100644 --- a/contrib/libxo/libxo/xo_flush.3 +++ b/contrib/libxo/libxo/xo_flush.3 @@ -33,3 +33,13 @@ function is used for this. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_format.5 b/contrib/libxo/libxo/xo_format.5 index abd1b6f..5265359 100644 --- a/contrib/libxo/libxo/xo_format.5 +++ b/contrib/libxo/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 @@ -965,3 +965,13 @@ names to make that difference more obvious. .Xr libxo 3 , .Xr xolint 1 , .Xr xo_emit 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_message.3 b/contrib/libxo/libxo/xo_message.3 index 36f0148..ce979a5 100644 --- a/contrib/libxo/libxo/xo_message.3 +++ b/contrib/libxo/libxo/xo_message.3 @@ -66,3 +66,13 @@ and .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_no_setlocale.3 b/contrib/libxo/libxo/xo_no_setlocale.3 index f91abc0..da3e8a3 100644 --- a/contrib/libxo/libxo/xo_no_setlocale.3 +++ b/contrib/libxo/libxo/xo_no_setlocale.3 @@ -41,3 +41,13 @@ function. .Xr xo_open_list 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_open_container.3 b/contrib/libxo/libxo/xo_open_container.3 index e765089..16cd9c9 100644 --- a/contrib/libxo/libxo/xo_open_container.3 +++ b/contrib/libxo/libxo/xo_open_container.3 @@ -186,3 +186,13 @@ and the name recorded do not match. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_open_list.3 b/contrib/libxo/libxo/xo_open_list.3 index 6d65b8f..e4d3080 100644 --- a/contrib/libxo/libxo/xo_open_list.3 +++ b/contrib/libxo/libxo/xo_open_list.3 @@ -156,3 +156,13 @@ are rendered as multiple leaf elements. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_open_marker.3 b/contrib/libxo/libxo/xo_open_marker.3 index e7356ba..2df3bff 100644 --- a/contrib/libxo/libxo/xo_open_marker.3 +++ b/contrib/libxo/libxo/xo_open_marker.3 @@ -103,3 +103,13 @@ properly. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_options.7 b/contrib/libxo/libxo/xo_options.7 new file mode 100644 index 0000000..297dcba --- /dev/null +++ b/contrib/libxo/libxo/xo_options.7 @@ -0,0 +1,156 @@ +.\" # +.\" # 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 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . diff --git a/contrib/libxo/libxo/xo_parse_args.3 b/contrib/libxo/libxo/xo_parse_args.3 index 487b50b..b014e60 100644 --- a/contrib/libxo/libxo/xo_parse_args.3 +++ b/contrib/libxo/libxo/xo_parse_args.3 @@ -150,3 +150,13 @@ must be maintained by the caller. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_allocator.3 b/contrib/libxo/libxo/xo_set_allocator.3 index c20a0f5..c0e731e 100644 --- a/contrib/libxo/libxo/xo_set_allocator.3 +++ b/contrib/libxo/libxo/xo_set_allocator.3 @@ -52,3 +52,13 @@ functions are used. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_flags.3 b/contrib/libxo/libxo/xo_set_flags.3 index 52997c5..a4c5754 100644 --- a/contrib/libxo/libxo/xo_set_flags.3 +++ b/contrib/libxo/libxo/xo_set_flags.3 @@ -137,3 +137,13 @@ handle. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_info.3 b/contrib/libxo/libxo/xo_set_info.3 index 8ea0657..c9c653f 100644 --- a/contrib/libxo/libxo/xo_set_info.3 +++ b/contrib/libxo/libxo/xo_set_info.3 @@ -100,3 +100,13 @@ and "data-help" attributes: .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_options.3 b/contrib/libxo/libxo/xo_set_options.3 index 5b7c8ed..bb44c9c 100644 --- a/contrib/libxo/libxo/xo_set_options.3 +++ b/contrib/libxo/libxo/xo_set_options.3 @@ -29,3 +29,13 @@ The options are identical to those listed in .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_style.3 b/contrib/libxo/libxo/xo_set_style.3 index 8e34033..6cac9cd 100644 --- a/contrib/libxo/libxo/xo_set_style.3 +++ b/contrib/libxo/libxo/xo_set_style.3 @@ -51,3 +51,13 @@ The name can be any of the styles: "text", "xml", "json", or "html". .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_syslog_enterprise_id.3 b/contrib/libxo/libxo/xo_set_syslog_enterprise_id.3 index da2eed7..79eda02 100644 --- a/contrib/libxo/libxo/xo_set_syslog_enterprise_id.3 +++ b/contrib/libxo/libxo/xo_set_syslog_enterprise_id.3 @@ -34,3 +34,13 @@ https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers .Sh SEE ALSO .Xr xo_syslog 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_version.3 b/contrib/libxo/libxo/xo_set_version.3 index 5f9394d..271d235 100644 --- a/contrib/libxo/libxo/xo_set_version.3 +++ b/contrib/libxo/libxo/xo_set_version.3 @@ -32,3 +32,13 @@ is in use. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_set_writer.3 b/contrib/libxo/libxo/xo_set_writer.3 index 2f93bd9..22c8ee9 100644 --- a/contrib/libxo/libxo/xo_set_writer.3 +++ b/contrib/libxo/libxo/xo_set_writer.3 @@ -54,3 +54,13 @@ flush any pending data associated with the opaque pointer. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_syslog.3 b/contrib/libxo/libxo/xo_syslog.3 index db92d36..c56c1dc 100644 --- a/contrib/libxo/libxo/xo_syslog.3 +++ b/contrib/libxo/libxo/xo_syslog.3 @@ -77,3 +77,13 @@ function names. .Xr xo_set_syslog_enterprise_id 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/libxo/xo_syslog.c b/contrib/libxo/libxo/xo_syslog.c index c7d67f3..35c64e9 100644 --- a/contrib/libxo/libxo/xo_syslog.c +++ b/contrib/libxo/libxo/xo_syslog.c @@ -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__)) @@ -173,8 +176,8 @@ xo_send_syslog (char *full_msg, char *v0_hdr, int fd; int full_len = strlen(full_msg); - /* Output to stderr if requested. */ - if (xo_logstat & LOG_PERROR) { + /* Output to stderr if requested, then we've been passed a v0 header */ + if (v0_hdr) { struct iovec iov[3]; struct iovec *v = iov; char newline[] = "\n"; @@ -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/contrib/libxo/tests/core/Makefile.am b/contrib/libxo/tests/core/Makefile.am index 7e61f55..7f19472 100644 --- a/contrib/libxo/tests/core/Makefile.am +++ b/contrib/libxo/tests/core/Makefile.am @@ -66,7 +66,9 @@ EXTRA_DIST = \ ${addprefix saved/, ${TEST_CASES:.c=.H.err}} \ ${addprefix saved/, ${TEST_CASES:.c=.H.out}} \ ${addprefix saved/, ${TEST_CASES:.c=.HIPx.err}} \ - ${addprefix saved/, ${TEST_CASES:.c=.HIPx.out}} + ${addprefix saved/, ${TEST_CASES:.c=.HIPx.out}} \ + ${addprefix saved/, ${TEST_CASES:.c=.E.err}} \ + ${addprefix saved/, ${TEST_CASES:.c=.E.out}} S2O = | ${SED} '1,/@@/d' @@ -79,17 +81,11 @@ valgrind: #TEST_TRACE = set -x ; TEST_JIG = \ - ${CHECKER} ./$$base.test ${TEST_OPTS} \ + ${CHECKER} ./$$base.test --libxo$$xoopts ${TEST_OPTS} \ > out/$$base.$$fmt.out 2> out/$$base.$$fmt.err ; \ ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.out out/$$base.$$fmt.out ${S2O} ; \ ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.err out/$$base.$$fmt.err ${S2O} -TEST_ONE = \ - LIBXO_OPTIONS=:W$$fmt ${TEST_JIG} - -TEST_TWO = \ - LIBXO_OPTIONS=warn,encoder=test ${TEST_JIG} - TEST_FORMATS = T XP JP HP X J H HIPx test tests: ${bin_PROGRAMS} @@ -98,12 +94,14 @@ test tests: ${bin_PROGRAMS} base=`${BASENAME} $$test .c` ; \ (for fmt in ${TEST_FORMATS}; do \ echo "... $$test ... $$fmt ..."; \ - ${TEST_ONE}; \ + xoopts=:W$$fmt ; \ + ${TEST_JIG}; \ true; \ done) ; \ (for fmt in E; do \ echo "... $$test ... $$fmt ..."; \ - ${TEST_TWO}; \ + xoopts==warn,encoder=test ; \ + ${TEST_JIG}; \ true; \ done) \ done) diff --git a/contrib/libxo/tests/core/saved/test_01.E.out b/contrib/libxo/tests/core/saved/test_01.E.out index de23baa..a4ed657 100644 --- a/contrib/libxo/tests/core/saved/test_01.E.out +++ b/contrib/libxo/tests/core/saved/test_01.E.out @@ -1,137 +1,149 @@ -op create: [] [] -op open_container: [top] [] -op string: [host] [my-box] -op string: [domain] [example.com] -op string: [host] [my-box] -op string: [domain] [example.com] -op string: [label] [value] -op string: [max-chaos] [very] -op content: [min-chaos] [42] -op string: [some-chaos] [[42]] -op string: [host] [my-box] -op string: [domain] [example.com] -op attr: [test] [value] -op open_container: [data] [] -op open_list: [item] [] -op attr: [test2] [value2] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [GRO-000-415] -op string: [name] [gum] -op content: [sold] [1412] -op content: [in-stock] [54] -op content: [on-order] [10] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [HRD-000-212] -op string: [name] [rope] -op content: [sold] [85] -op content: [in-stock] [4] -op content: [on-order] [2] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [HRD-000-517] -op string: [name] [ladder] -op content: [sold] [0] -op content: [in-stock] [2] -op content: [on-order] [1] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [HRD-000-632] -op string: [name] [bolt] -op content: [sold] [4123] -op content: [in-stock] [144] -op content: [on-order] [42] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [GRO-000-2331] -op string: [name] [water] -op content: [sold] [17] -op content: [in-stock] [14] -op content: [on-order] [2] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [data] [] -op open_container: [data2] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [sku] [GRO-000-415] -op string: [name] [gum] -op content: [sold] [1412.0] -op content: [in-stock] [54] -op content: [on-order] [10] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [HRD-000-212] -op string: [name] [rope] -op content: [sold] [85.0] -op content: [in-stock] [4] -op content: [on-order] [2] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [HRD-000-517] -op string: [name] [ladder] -op content: [sold] [0] -op content: [in-stock] [2] -op content: [on-order] [1] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [HRD-000-632] -op string: [name] [bolt] -op content: [sold] [4123.0] -op content: [in-stock] [144] -op content: [on-order] [42] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [GRO-000-2331] -op string: [name] [water] -op content: [sold] [17.0] -op content: [in-stock] [14] -op content: [on-order] [2] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [data2] [] -op open_container: [data3] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [sku] [GRO-000-533] -op string: [name] [fish] -op content: [sold] [1321.0] -op content: [in-stock] [45] -op content: [on-order] [1] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [data3] [] -op open_container: [data4] [] -op open_list: [item] [] -op attr: [test4] [value4] -op string: [item] [gum] -op attr: [test4] [value4] -op string: [item] [rope] -op attr: [test4] [value4] -op string: [item] [ladder] -op attr: [test4] [value4] -op string: [item] [bolt] -op attr: [test4] [value4] -op string: [item] [water] -op close_list: [item] [] -op close_container: [data4] [] -op content: [cost] [425] -op content: [cost] [455] -op string: [mode] [mode] -op string: [mode_octal] [octal] -op string: [links] [links] -op string: [user] [user] -op string: [group] [group] -op string: [mode] [/some/file] -op content: [mode_octal] [640] -op content: [links] [1] -op string: [user] [user] -op string: [group] [group] -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [top] [] [0x810] +op content: [address] [0x0] [0] +op content: [port] [1] [0] +op content: [address] [0x0] [0] +op content: [port] [1] [0] +op content: [address] [0x0] [0] +op content: [port] [1] [0] +op content: [used-percent] [12] [0] +op content: [kve_start] [0xdeadbeef] [0x8] +op content: [kve_end] [0xcabb1e] [0x8] +op string: [host] [my-box] [0x200000] +op string: [domain] [example.com] [0x200000] +op string: [host] [my-box] [0x200008] +op string: [domain] [example.com] [0x200000] +op string: [label] [value] [0x200000] +op string: [max-chaos] [very] [0x1000] +op content: [min-chaos] [42] [0] +op string: [some-chaos] [[42]] [0] +op string: [host] [my-box] [0] +op string: [domain] [example.com] [0] +op attr: [test] [value] [0] +op open_container: [data] [] [0x810] +op open_list: [item] [] [0] +op attr: [test2] [value2] [0] +op open_instance: [item] [] [0x810] +op attr: [test3] [value3] [0] +op string: [sku] [GRO-000-415] [0x98] +op string: [name] [gum] [0x80] +op content: [sold] [1412] [0x20] +op content: [in-stock] [54] [0] +op content: [on-order] [10] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op attr: [test3] [value3] [0] +op string: [sku] [HRD-000-212] [0x98] +op string: [name] [rope] [0x80] +op content: [sold] [85] [0x20] +op content: [in-stock] [4] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op attr: [test3] [value3] [0] +op string: [sku] [HRD-000-517] [0x98] +op string: [name] [ladder] [0x80] +op content: [sold] [0] [0x20] +op content: [in-stock] [2] [0] +op content: [on-order] [1] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op attr: [test3] [value3] [0] +op string: [sku] [HRD-000-632] [0x98] +op string: [name] [bolt] [0x80] +op content: [sold] [4123] [0x20] +op content: [in-stock] [144] [0] +op content: [on-order] [42] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op attr: [test3] [value3] [0] +op string: [sku] [GRO-000-2331] [0x98] +op string: [name] [water] [0x80] +op content: [sold] [17] [0x20] +op content: [in-stock] [14] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [data] [] [0] +op open_container: [data2] [] [0x810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [sku] [GRO-000-415] [0x98] +op string: [name] [gum] [0x80] +op content: [sold] [1412.0] [0x20] +op content: [in-stock] [54] [0] +op content: [on-order] [10] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [sku] [HRD-000-212] [0x98] +op string: [name] [rope] [0x80] +op content: [sold] [85.0] [0x20] +op content: [in-stock] [4] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [sku] [HRD-000-517] [0x98] +op string: [name] [ladder] [0x80] +op content: [sold] [0] [0x20] +op content: [in-stock] [2] [0] +op content: [on-order] [1] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [sku] [HRD-000-632] [0x98] +op string: [name] [bolt] [0x80] +op content: [sold] [4123.0] [0x20] +op content: [in-stock] [144] [0] +op content: [on-order] [42] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [sku] [GRO-000-2331] [0x98] +op string: [name] [water] [0x80] +op content: [sold] [17.0] [0x20] +op content: [in-stock] [14] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [data2] [] [0] +op open_container: [data3] [] [0x810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [sku] [GRO-000-533] [0x98] +op string: [name] [fish] [0x80] +op content: [sold] [1321.0] [0x20] +op content: [in-stock] [45] [0] +op content: [on-order] [1] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [data3] [] [0] +op open_container: [data4] [] [0x810] +op open_list: [item] [] [0] +op attr: [test4] [value4] [0] +op string: [item] [gum] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [rope] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [ladder] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [bolt] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [water] [0x2000] +op close_list: [item] [] [0] +op close_container: [data4] [] [0] +op content: [cost] [425] [0] +op content: [cost] [455] [0] +op string: [mode] [mode] [0x8] +op string: [mode_octal] [octal] [0x8] +op string: [links] [links] [0x1000] +op string: [user] [user] [0x1000] +op string: [group] [group] [0x1000] +op string: [pre] [that] [0x8] +op content: [links] [3] [0x1000] +op string: [post] [this] [0x1000] +op string: [mode] [/some/file] [0x1000] +op content: [mode_octal] [640] [0x8] +op content: [links] [1] [0x1000] +op string: [user] [user] [0x1000] +op string: [group] [group] [0x1000] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_01.H.out b/contrib/libxo/tests/core/saved/test_01.H.out index 7c0b3de..ebe75e6 100644 --- a/contrib/libxo/tests/core/saved/test_01.H.out +++ b/contrib/libxo/tests/core/saved/test_01.H.out @@ -1,2 +1,2 @@ -<div class="line"><div class="text">testing argument modifier </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="text">testing argument modifier with encoding to </div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="label">Label text</div><div class="text"> </div><div class="data" data-tag="label">value</div></div><div class="line"><div class="data" data-tag="max-chaos"> very </div><div class="data" data-tag="min-chaos">42</div><div class="data" data-tag="some-chaos">42 -</div><div class="text">Connecting to </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="title">Item </div><div class="title"> Total Sold</div><div class="title"> In Stock</div><div class="title"> On Order</div><div class="title"> SKU</div></div><div class="line"><div class="data" data-tag="name" data-key="key">gum </div><div class="data" data-tag="sold"> 1412</div><div class="data" data-tag="in-stock"> 54</div><div class="data" data-tag="on-order"> 10</div><div class="data" data-tag="sku" data-key="key"> GRO-000-415</div></div><div class="line"><div class="data" data-tag="name" data-key="key">rope </div><div class="data" data-tag="sold"> 85</div><div class="data" data-tag="in-stock"> 4</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> HRD-000-212</div></div><div class="line"><div class="data" data-tag="name" data-key="key">ladder </div><div class="data" data-tag="sold"> 0</div><div class="data" data-tag="in-stock"> 2</div><div class="data" data-tag="on-order"> 1</div><div class="data" data-tag="sku" data-key="key"> HRD-000-517</div></div><div class="line"><div class="data" data-tag="name" data-key="key">bolt </div><div class="data" data-tag="sold"> 4123</div><div class="data" data-tag="in-stock"> 144</div><div class="data" data-tag="on-order"> 42</div><div class="data" data-tag="sku" data-key="key"> HRD-000-632</div></div><div class="line"><div class="data" data-tag="name" data-key="key">water </div><div class="data" data-tag="sold"> 17</div><div class="data" data-tag="in-stock"> 14</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> GRO-000-2331</div></div><div class="line"></div><div class="line"></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">gum</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1412.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">54</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">10</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-415</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">rope</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">85.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">4</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-212</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">ladder</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">2</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-517</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">bolt</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">4123.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">144</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">42</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-632</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">water</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">17.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">14</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-2331</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">fish</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1321.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">45</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-533</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">gum</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">rope</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">ladder</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">bolt</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">water</div></div><div class="line"><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">425</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">455</div></div><div class="line"><div class="text"> </div><div class="data" data-tag="links">links</div><div class="text"> </div><div class="data" data-tag="user">user</div><div class="text"> </div><div class="data" data-tag="group">group</div><div class="text"> </div></div><div class="line"><div class="data" data-tag="mode">/some/file</div><div class="text"> </div><div class="data" data-tag="links"> 1</div><div class="text"> </div><div class="data" data-tag="user">user </div><div class="text"> </div><div class="data" data-tag="group">group </div><div class="text"> </div></div>
\ No newline at end of file +<div class="line"><div class="text">anchor </div><div class="padding"> </div><div class="data" data-tag="address">0x0</div><div class="text">..</div><div class="data" data-tag="port">1</div></div><div class="line"><div class="text">anchor </div><div class="padding"> </div><div class="data" data-tag="address">0x0</div><div class="text">..</div><div class="data" data-tag="port">1</div></div><div class="line"><div class="text">anchor </div><div class="padding"> </div><div class="data" data-tag="address">0x0</div><div class="text">..</div><div class="data" data-tag="port">1</div></div><div class="line"><div class="text">df </div><div class="data" data-tag="used-percent"> 12</div><div class="units">%</div></div><div class="line"><div class="text">testing argument modifier </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="text">testing argument modifier with encoding to </div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="label">Label text</div><div class="text"> </div><div class="data" data-tag="label">value</div></div><div class="line"><div class="data" data-tag="max-chaos"> very </div><div class="data" data-tag="min-chaos">42</div><div class="data" data-tag="some-chaos">42 +</div><div class="text">Connecting to </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="title">Item </div><div class="title"> Total Sold</div><div class="title"> In Stock</div><div class="title"> On Order</div><div class="title"> SKU</div></div><div class="line"><div class="data" data-tag="name" data-key="key">gum </div><div class="data" data-tag="sold"> 1412</div><div class="data" data-tag="in-stock"> 54</div><div class="data" data-tag="on-order"> 10</div><div class="data" data-tag="sku" data-key="key"> GRO-000-415</div></div><div class="line"><div class="data" data-tag="name" data-key="key">rope </div><div class="data" data-tag="sold"> 85</div><div class="data" data-tag="in-stock"> 4</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> HRD-000-212</div></div><div class="line"><div class="data" data-tag="name" data-key="key">ladder </div><div class="data" data-tag="sold"> 0</div><div class="data" data-tag="in-stock"> 2</div><div class="data" data-tag="on-order"> 1</div><div class="data" data-tag="sku" data-key="key"> HRD-000-517</div></div><div class="line"><div class="data" data-tag="name" data-key="key">bolt </div><div class="data" data-tag="sold"> 4123</div><div class="data" data-tag="in-stock"> 144</div><div class="data" data-tag="on-order"> 42</div><div class="data" data-tag="sku" data-key="key"> HRD-000-632</div></div><div class="line"><div class="data" data-tag="name" data-key="key">water </div><div class="data" data-tag="sold"> 17</div><div class="data" data-tag="in-stock"> 14</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> GRO-000-2331</div></div><div class="line"></div><div class="line"></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">gum</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1412.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">54</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">10</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-415</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">rope</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">85.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">4</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-212</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">ladder</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">2</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-517</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">bolt</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">4123.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">144</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">42</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-632</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">water</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">17.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">14</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-2331</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">fish</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1321.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">45</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-533</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">gum</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">rope</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">ladder</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">bolt</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">water</div></div><div class="line"><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">425</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">455</div></div><div class="line"><div class="text"> </div><div class="data" data-tag="links">links</div><div class="text"> </div><div class="data" data-tag="user">user</div><div class="text"> </div><div class="data" data-tag="group">group</div><div class="text"> </div></div><div class="line"><div class="data" data-tag="links">3 </div><div class="data" data-tag="post">this </div></div><div class="line"><div class="data" data-tag="mode">/some/file</div><div class="text"> </div><div class="data" data-tag="links"> 1</div><div class="text"> </div><div class="data" data-tag="user">user </div><div class="text"> </div><div class="data" data-tag="group">group </div><div class="text"> </div></div>
\ No newline at end of file diff --git a/contrib/libxo/tests/core/saved/test_01.HIPx.out b/contrib/libxo/tests/core/saved/test_01.HIPx.out index f6c7290..d96b855 100644 --- a/contrib/libxo/tests/core/saved/test_01.HIPx.out +++ b/contrib/libxo/tests/core/saved/test_01.HIPx.out @@ -1,4 +1,30 @@ <div class="line"> + <div class="text">anchor </div> + <div class="padding"> </div> + <div class="data" data-tag="address" data-xpath="/top/address">0x0</div> + <div class="text">..</div> + <div class="data" data-tag="port" data-xpath="/top/port">1</div> +</div> +<div class="line"> + <div class="text">anchor </div> + <div class="padding"> </div> + <div class="data" data-tag="address" data-xpath="/top/address">0x0</div> + <div class="text">..</div> + <div class="data" data-tag="port" data-xpath="/top/port">1</div> +</div> +<div class="line"> + <div class="text">anchor </div> + <div class="padding"> </div> + <div class="data" data-tag="address" data-xpath="/top/address">0x0</div> + <div class="text">..</div> + <div class="data" data-tag="port" data-xpath="/top/port">1</div> +</div> +<div class="line"> + <div class="text">df </div> + <div class="data" data-tag="used-percent" data-xpath="/top/used-percent"> 12</div> + <div class="units">%</div> +</div> +<div class="line"> <div class="text">testing argument modifier </div> <div class="data" data-tag="host" data-xpath="/top/host">my-box</div> <div class="text">.</div> @@ -333,6 +359,10 @@ <div class="text"> </div> </div> <div class="line"> + <div class="data" data-tag="links" data-xpath="/top/links">3 </div> + <div class="data" data-tag="post" data-xpath="/top/post">this </div> +</div> +<div class="line"> <div class="data" data-tag="mode" data-xpath="/top/mode">/some/file</div> <div class="text"> </div> <div class="data" data-tag="links" data-xpath="/top/links"> 1</div> diff --git a/contrib/libxo/tests/core/saved/test_01.HP.out b/contrib/libxo/tests/core/saved/test_01.HP.out index 0fdcbd1..3253aa0 100644 --- a/contrib/libxo/tests/core/saved/test_01.HP.out +++ b/contrib/libxo/tests/core/saved/test_01.HP.out @@ -1,4 +1,30 @@ <div class="line"> + <div class="text">anchor </div> + <div class="padding"> </div> + <div class="data" data-tag="address">0x0</div> + <div class="text">..</div> + <div class="data" data-tag="port">1</div> +</div> +<div class="line"> + <div class="text">anchor </div> + <div class="padding"> </div> + <div class="data" data-tag="address">0x0</div> + <div class="text">..</div> + <div class="data" data-tag="port">1</div> +</div> +<div class="line"> + <div class="text">anchor </div> + <div class="padding"> </div> + <div class="data" data-tag="address">0x0</div> + <div class="text">..</div> + <div class="data" data-tag="port">1</div> +</div> +<div class="line"> + <div class="text">df </div> + <div class="data" data-tag="used-percent"> 12</div> + <div class="units">%</div> +</div> +<div class="line"> <div class="text">testing argument modifier </div> <div class="data" data-tag="host">my-box</div> <div class="text">.</div> @@ -333,6 +359,10 @@ <div class="text"> </div> </div> <div class="line"> + <div class="data" data-tag="links">3 </div> + <div class="data" data-tag="post">this </div> +</div> +<div class="line"> <div class="data" data-tag="mode">/some/file</div> <div class="text"> </div> <div class="data" data-tag="links"> 1</div> diff --git a/contrib/libxo/tests/core/saved/test_01.J.out b/contrib/libxo/tests/core/saved/test_01.J.out index 3fc12a1..ad73058 100644 --- a/contrib/libxo/tests/core/saved/test_01.J.out +++ b/contrib/libxo/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": {"address":"0x0","port":1,"address":"0x0","port":1,"address":"0x0","port":1,"used-percent":12,"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","pre":"that","links":3,"post":"this","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"} } diff --git a/contrib/libxo/tests/core/saved/test_01.JP.out b/contrib/libxo/tests/core/saved/test_01.JP.out index 2c7397f..6aeef16 100644 --- a/contrib/libxo/tests/core/saved/test_01.JP.out +++ b/contrib/libxo/tests/core/saved/test_01.JP.out @@ -1,5 +1,14 @@ { "top": { + "address": "0x0", + "port": 1, + "address": "0x0", + "port": 1, + "address": "0x0", + "port": 1, + "used-percent": 12, + "kve_start": "0xdeadbeef", + "kve_end": "0xcabb1e", "host": "my-box", "domain": "example.com", "host": "my-box", @@ -115,6 +124,9 @@ "links": "links", "user": "user", "group": "group", + "pre": "that", + "links": 3, + "post": "this", "mode": "/some/file", "mode_octal": 640, "links": 1, diff --git a/contrib/libxo/tests/core/saved/test_01.T.out b/contrib/libxo/tests/core/saved/test_01.T.out index 71cd130..d454270 100644 --- a/contrib/libxo/tests/core/saved/test_01.T.out +++ b/contrib/libxo/tests/core/saved/test_01.T.out @@ -1,3 +1,7 @@ +anchor 0x0..1 +anchor 0x0..1 +anchor 0x0..1 +df 12% testing argument modifier my-box.example.com... testing argument modifier with encoding to .example.com... Label text value @@ -50,4 +54,5 @@ XXXXXXXX X XCost: 425 X XCost: 455 links user group +3 this /some/file 1 user group diff --git a/contrib/libxo/tests/core/saved/test_01.X.out b/contrib/libxo/tests/core/saved/test_01.X.out index da80e68..226a4a4 100644 --- a/contrib/libxo/tests/core/saved/test_01.X.out +++ b/contrib/libxo/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><address>0x0</address><port>1</port><address>0x0</address><port>1</port><address>0x0</address><port>1</port><used-percent>12</used-percent><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><pre>that</pre><links>3</links><post>this</post><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/contrib/libxo/tests/core/saved/test_01.XP.out b/contrib/libxo/tests/core/saved/test_01.XP.out index c331dce..1e1be56 100644 --- a/contrib/libxo/tests/core/saved/test_01.XP.out +++ b/contrib/libxo/tests/core/saved/test_01.XP.out @@ -1,4 +1,13 @@ <top> + <address>0x0</address> + <port>1</port> + <address>0x0</address> + <port>1</port> + <address>0x0</address> + <port>1</port> + <used-percent>12</used-percent> + <kve_start>0xdeadbeef</kve_start> + <kve_end>0xcabb1e</kve_end> <host>my-box</host> <domain>example.com</domain> <host>my-box</host> @@ -106,6 +115,9 @@ <links>links</links> <user>user</user> <group>group</group> + <pre>that</pre> + <links>3</links> + <post>this</post> <mode>/some/file</mode> <mode_octal>640</mode_octal> <links>1</links> diff --git a/contrib/libxo/tests/core/saved/test_02.E.out b/contrib/libxo/tests/core/saved/test_02.E.out index 9e1ec96..6cc40e4 100644 --- a/contrib/libxo/tests/core/saved/test_02.E.out +++ b/contrib/libxo/tests/core/saved/test_02.E.out @@ -1,68 +1,68 @@ -op create: [] [] -op open_container: [top] [] -op open_container: [data] [] -op string: [what] [braces] -op string: [length] [abcdef] -op content: [fd] [-1] -op string: [error] [Bad file descriptor] -op string: [test] [good] -op content: [fd] [-1] -op string: [error] [Bad fi] -op string: [test] [good] -op content: [lines] [20] -op content: [words] [30] -op content: [characters] [40] -op open_leaf_list: [bytes] [] -op content: [bytes] [0] -op content: [bytes] [1] -op content: [bytes] [2] -op content: [bytes] [3] -op content: [bytes] [4] -op close_leaf_list: [bytes] [] -op content: [mbuf-current] [10] -op content: [mbuf-cache] [20] -op content: [mbuf-total] [30] -op content: [distance] [50] -op string: [location] [Boston] -op content: [memory] [64] -op content: [total] [640] -op content: [memory] [64] -op content: [total] [640] -op content: [ten] [10] -op content: [eleven] [11] -op content: [unknown] [1010] -op content: [unknown] [1010] -op content: [min] [15] -op content: [cur] [20] -op content: [max] [30] -op content: [min] [15] -op content: [cur] [20] -op content: [max] [125] -op content: [min] [15] -op content: [cur] [20] -op content: [max] [125] -op content: [min] [15] -op content: [cur] [20] -op content: [max] [125] -op content: [val1] [21] -op content: [val2] [58368] -op content: [val3] [100663296] -op content: [val4] [44470272] -op content: [val5] [1342172800] -op open_list: [flag] [] -op string: [flag] [one] -op string: [flag] [two] -op string: [flag] [three] -op close_list: [flag] [] -op content: [works] [null] -op content: [empty-tag] [true] -op string: [t1] [1000] -op string: [t2] [test5000] -op string: [t3] [ten-longx] -op string: [t4] [xtest] -op content: [count] [10] -op content: [test] [4] -op close_container: [data] [] -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [top] [] [0x40010] +op open_container: [data] [] [0x40010] +op string: [what] [braces] [0] +op string: [length] [abcdef] [0] +op content: [fd] [-1] [0] +op string: [error] [Bad file descriptor] [0] +op string: [test] [good] [0] +op content: [fd] [-1] [0] +op string: [error] [Bad fi] [0] +op string: [test] [good] [0] +op content: [lines] [20] [0] +op content: [words] [30] [0] +op content: [characters] [40] [0] +op open_leaf_list: [bytes] [] [0] +op content: [bytes] [0] [0x2004] +op content: [bytes] [1] [0x2004] +op content: [bytes] [2] [0x2004] +op content: [bytes] [3] [0x2004] +op content: [bytes] [4] [0x2004] +op close_leaf_list: [bytes] [] [0] +op content: [mbuf-current] [10] [0] +op content: [mbuf-cache] [20] [0] +op content: [mbuf-total] [30] [0] +op content: [distance] [50] [0] +op string: [location] [Boston] [0] +op content: [memory] [64] [0] +op content: [total] [640] [0] +op content: [memory] [64] [0] +op content: [total] [640] [0] +op content: [ten] [10] [0] +op content: [eleven] [11] [0] +op content: [unknown] [1010] [0] +op content: [unknown] [1010] [0] +op content: [min] [15] [0x20] +op content: [cur] [20] [0x20] +op content: [max] [125] [0] +op content: [min] [15] [0] +op content: [cur] [20] [0] +op content: [max] [125] [0] +op content: [min] [15] [0x20] +op content: [cur] [20] [0x20] +op content: [max] [125] [0x20] +op content: [min] [15] [0] +op content: [cur] [20] [0] +op content: [max] [125] [0] +op content: [val1] [21] [0x8000] +op content: [val2] [58368] [0x18000] +op content: [val3] [100663296] [0x28000] +op content: [val4] [44470272] [0x48000] +op content: [val5] [1342172800] [0x28000] +op open_list: [flag] [] [0] +op string: [flag] [one] [0x2010] +op string: [flag] [two] [0x2010] +op string: [flag] [three] [0x2010] +op close_list: [flag] [] [0] +op content: [works] [null] [0x20] +op content: [empty-tag] [true] [0x8] +op string: [t1] [1000] [0x1010] +op string: [t2] [test5000] [0x1010] +op string: [t3] [ten-longx] [0x1010] +op string: [t4] [xtest] [0x1010] +op content: [count] [10] [0] +op content: [test] [4] [0] +op close_container: [data] [] [0] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_02.J.out b/contrib/libxo/tests/core/saved/test_02.J.out index 5578389..cafe771 100644 --- a/contrib/libxo/tests/core/saved/test_02.J.out +++ b/contrib/libxo/tests/core/saved/test_02.J.out @@ -1,2 +1,2 @@ -{"top": {"data": {"what":"braces","length":"abcdef","fd":-1,"error":"Bad file descriptor","test":"good","fd":-1,"error":"Bad fi","test":"good","lines":20,"words":30,"characters":40, "bytes": [0,1,2,3,4],"mbuf-current":10,"mbuf-cache":20,"mbuf-total":30,"distance":50,"location":"Boston","memory":64,"total":640,"memory":64,"total":640,"ten":10,"eleven":11,"unknown":1010,"unknown":1010,"min":15,"cur":20,"max":30,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"val1":21,"val2":58368,"val3":100663296,"val4":44470272,"val5":1342172800, "flag": ["one","two","three"],"works":null,"empty-tag":true,"t1":"1000","t2":"test5000","t3":"ten-longx","t4":"xtest", "__error": {"message":"this is an error"}, "__error": {"message":"two more errors"}, "__warning": {"message":this is an warning}, "__warning": {"message":"two more warnings"},"count":10,"test":4, "error": {"message":"Shut 'er down, Clancey! She's a-pumpin' mud! <>!,\"!<>\n"}}} +{"top": {"data": {"what":"braces","length":"abcdef","fd":-1,"error":"Bad file descriptor","test":"good","fd":-1,"error":"Bad fi","test":"good","lines":20,"words":30,"characters":40, "bytes": [0,1,2,3,4],"mbuf-current":10,"mbuf-cache":20,"mbuf-total":30,"distance":50,"location":"Boston","memory":64,"total":640,"memory":64,"total":640,"ten":10,"eleven":11,"unknown":1010,"unknown":1010,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"val1":21,"val2":58368,"val3":100663296,"val4":44470272,"val5":1342172800, "flag": ["one","two","three"],"works":null,"empty-tag":true,"t1":"1000","t2":"test5000","t3":"ten-longx","t4":"xtest", "__error": {"message":"this is an error"}, "__error": {"message":"two more errors"}, "__warning": {"message":"this is an warning"}, "__warning": {"message":"two more warnings"},"count":10,"test":4, "error": {"message":"Shut 'er down, Clancey! She's a-pumpin' mud! <>!,\"!<>\n"}}} } diff --git a/contrib/libxo/tests/core/saved/test_02.JP.out b/contrib/libxo/tests/core/saved/test_02.JP.out index fd910aa..9e40703 100644 --- a/contrib/libxo/tests/core/saved/test_02.JP.out +++ b/contrib/libxo/tests/core/saved/test_02.JP.out @@ -34,7 +34,7 @@ "unknown": 1010, "min": 15, "cur": 20, - "max": 30, + "max": 125, "min": 15, "cur": 20, "max": 125, @@ -67,7 +67,7 @@ "message": "two more errors" }, "__warning": { - "message": this is an warning + "message": "this is an warning" }, "__warning": { "message": "two more warnings" diff --git a/contrib/libxo/tests/core/saved/test_02.X.out b/contrib/libxo/tests/core/saved/test_02.X.out index 30421ea..49e9355 100644 --- a/contrib/libxo/tests/core/saved/test_02.X.out +++ b/contrib/libxo/tests/core/saved/test_02.X.out @@ -2,6 +2,6 @@ </message><message>abcdef: Bad file descriptor </message><message>improper use of profanity; ten yard penalty; first down </message><length>abcdef</length><fd>-1</fd><error>Bad file descriptor</error><test>good</test><fd>-1</fd><error>Bad fi</error><test>good</test><message>improper use of profanity; ten yard penalty; first down -</message><lines>20</lines><words>30</words><characters>40</characters><bytes>0</bytes><bytes>1</bytes><bytes>2</bytes><bytes>3</bytes><bytes>4</bytes><mbuf-current>10</mbuf-current><mbuf-cache>20</mbuf-cache><mbuf-total>30</mbuf-total><distance units="miles">50</distance><location>Boston</location><memory units="k">64</memory><total units="kb">640</total><memory units="k">64</memory><total units="kilobytes">640</total><ten>10</ten><eleven>11</eleven><unknown>1010</unknown><unknown>1010</unknown><min>15</min><cur>20</cur><max>30</max><min>15</min><cur>20</cur><max>125</max><min>15</min><cur>20</cur><max>125</max><min>15</min><cur>20</cur><max>125</max><val1>21</val1><val2>58368</val2><val3>100663296</val3><val4>44470272</val4><val5>1342172800</val5><flag>one</flag><flag>two</flag><flag>three</flag><works>null</works><empty-tag></empty-tag><t1>1000</t1><t2>test5000</t2><t3>ten-longx</t3><t4>xtest</t4><__error><message>this is an error</message></__error><__error><message>two more errors</message></__error><__warning><message>this is an warning</message></__warning><__warning><message>two more warnings</message></__warning><count>10</count><test>4</test><message>improper use of profanity; ten yard penalty; first down +</message><lines>20</lines><words>30</words><characters>40</characters><bytes>0</bytes><bytes>1</bytes><bytes>2</bytes><bytes>3</bytes><bytes>4</bytes><mbuf-current>10</mbuf-current><mbuf-cache>20</mbuf-cache><mbuf-total>30</mbuf-total><distance units="miles">50</distance><location>Boston</location><memory units="k">64</memory><total units="kb">640</total><memory units="k">64</memory><total units="kilobytes">640</total><ten>10</ten><eleven>11</eleven><unknown>1010</unknown><unknown>1010</unknown><min>15</min><cur>20</cur><max>125</max><min>15</min><cur>20</cur><max>125</max><min>15</min><cur>20</cur><max>125</max><min>15</min><cur>20</cur><max>125</max><val1>21</val1><val2>58368</val2><val3>100663296</val3><val4>44470272</val4><val5>1342172800</val5><flag>one</flag><flag>two</flag><flag>three</flag><works>null</works><empty-tag></empty-tag><t1>1000</t1><t2>test5000</t2><t3>ten-longx</t3><t4>xtest</t4><__error><message>this is an error</message></__error><__error><message>two more errors</message></__error><__warning><message>this is an warning</message></__warning><__warning><message>two more warnings</message></__warning><count>10</count><test>4</test><message>improper use of profanity; ten yard penalty; first down </message><error><message>Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<> </message></error></data></top>
\ No newline at end of file diff --git a/contrib/libxo/tests/core/saved/test_02.XP.out b/contrib/libxo/tests/core/saved/test_02.XP.out index e70e6ef..e5172d3 100644 --- a/contrib/libxo/tests/core/saved/test_02.XP.out +++ b/contrib/libxo/tests/core/saved/test_02.XP.out @@ -39,7 +39,7 @@ <unknown>1010</unknown> <min>15</min> <cur>20</cur> - <max>30</max> + <max>125</max> <min>15</min> <cur>20</cur> <max>125</max> diff --git a/contrib/libxo/tests/core/saved/test_03.E.out b/contrib/libxo/tests/core/saved/test_03.E.out index c68081f..21bf7d2 100644 --- a/contrib/libxo/tests/core/saved/test_03.E.out +++ b/contrib/libxo/tests/core/saved/test_03.E.out @@ -1,34 +1,34 @@ -op create: [] [] -op open_container: [employees] [] -op open_list: [employee] [] -op close_list: [employee] [] -op string: [extra] [] -op open_list: [memory] [] -op open_instance: [memory] [] -op string: [type] [name] -op content: [in-use] [12345] -op content: [memory-use] [54321] -op string: [high-use] [-] -op content: [requests] [32145] -op close_instance: [memory] [] -op close_list: [memory] [] -op open_list: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Terry] -op string: [last-name] [Jones] -op content: [department] [660] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Leslie] -op string: [last-name] [Patterson] -op content: [department] [341] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Ashley] -op string: [last-name] [Smith] -op content: [department] [1440] -op close_instance: [employee] [] -op close_list: [employee] [] -op close_container: [employees] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [employees] [] [0x10] +op open_list: [employee] [] [0] +op close_list: [employee] [] [0] +op string: [extra] [] [0] +op open_list: [memory] [] [0] +op open_instance: [memory] [] [0x10] +op string: [type] [name] [0x80] +op content: [in-use] [12345] [0] +op content: [memory-use] [54321] [0] +op string: [high-use] [-] [0] +op content: [requests] [32145] [0] +op close_instance: [memory] [] [0] +op close_list: [memory] [] [0] +op open_list: [employee] [] [0] +op open_instance: [employee] [] [0x10] +op string: [first-name] [Terry] [0] +op string: [last-name] [Jones] [0] +op content: [department] [660] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x10] +op string: [first-name] [Leslie] [0] +op string: [last-name] [Patterson] [0] +op content: [department] [341] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x10] +op string: [first-name] [Ashley] [0] +op string: [last-name] [Smith] [0] +op content: [department] [1440] [0] +op close_instance: [employee] [] [0] +op close_list: [employee] [] [0] +op close_container: [employees] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_04.E.out b/contrib/libxo/tests/core/saved/test_04.E.out index 3965783..cfb751d 100644 --- a/contrib/libxo/tests/core/saved/test_04.E.out +++ b/contrib/libxo/tests/core/saved/test_04.E.out @@ -1,22 +1,22 @@ -op create: [] [] -op open_container: [employees] [] -op open_list: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Terry] -op string: [last-name] [Jones] -op content: [department] [660] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Leslie] -op string: [last-name] [Patterson] -op content: [department] [341] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Ashley] -op string: [last-name] [Smith] -op content: [department] [1440] -op close_instance: [employee] [] -op close_list: [employee] [] -op close_container: [employees] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [employees] [] [0x10] +op open_list: [employee] [] [0] +op open_instance: [employee] [] [0x10] +op string: [first-name] [Terry] [0] +op string: [last-name] [Jones] [0] +op content: [department] [660] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x10] +op string: [first-name] [Leslie] [0] +op string: [last-name] [Patterson] [0] +op content: [department] [341] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x10] +op string: [first-name] [Ashley] [0] +op string: [last-name] [Smith] [0] +op content: [department] [1440] [0] +op close_instance: [employee] [] [0] +op close_list: [employee] [] [0] +op close_container: [employees] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_05.E.out b/contrib/libxo/tests/core/saved/test_05.E.out index 0ca15f4..8e8fcfe 100644 --- a/contrib/libxo/tests/core/saved/test_05.E.out +++ b/contrib/libxo/tests/core/saved/test_05.E.out @@ -1,96 +1,96 @@ -op create: [] [] -op open_container: [indian-languages] [] -op string: [gurmukhi] [ਲਹੌਰ ਪਾਕਿਸਤਾਨੀ ਪੰਜਾਬ ਦੀ ਰਾਜਧਾਨੀ ਹੈ । ਲੋਕ ਗਿਣਤੀ ਦੇ ਨਾਲ ਕਰਾਚੀ ਤੋਂ ਬਾਅਦ ਲਹੌਰ ਦੂਜਾ ਸਠਤੋਂ ਵੱਡਾ ਸ਼ਹਿਰ ਹੈ । ਲਹੌਰ ਪਾਕਿਸਤਾਨ ਦਾ ਸਿਆਸੀ, ਰਹਤਲੀ ਤੇ ਪੜà©à¨¹à¨¾à¨ˆ ਦਾ ਗੜà©à¨¹ ਹੈ ਅਤੇ ਇਸ ਲਈ ਇਹਨੂੰ ਪਾਕਿਸਤਾਨ ਦਾ ਦਿਲ ਵੀ ਕਿਹਾ ਜਾਂਦਾ ਹੈ । ਲਹੌਰ ਦਰਿਆ-à¨-ਰਾਵੀ ਦੇ ਕੰਢੇ ਤੇ ਵਸਦਾ ਹੈ ਤੇ ਇਸਦੀ ਲੋਕ ਗਿਣਤੀ ਇੱਕ ਕਰੋੜ ਦੇ ਨੇੜੇ ਹੈ ।] -op string: [shahmukhi] [Ù„Ûور پاکستانی پنجاب دا دارالØکومت اے۔ لوک گنتی دے نال کراچی توں بعد Ù„Ûور دوجا سبھ توں وڈا Ø´Ûر اے۔ Ù„Ûور پاکستان دا سیاسی، رÛتلی تے پڑھائی دا Ú¯Ú‘Ú¾ اے تے اس لئی ایھنوں پاکستان دا دل ÙˆÛŒ کیھا جاندا اے۔ Ù„Ûور دریاۓ راوی دے Ú©Ù†ÚˆÚ¾Û’ تے وسدا اے اسدی لوک گنتی اک کروڑ دے نیڑے اے Û”] -op string: [tranliteration] [lahor pÄkistÄn panjÄb dÄ dÄrul hakÅ«mat Ä“. lÅk giṇtÄ« dÄ“ nÄḷ karÄcÄ« tÅá·ˆ bÄad lahor dÅ«jÄ sab tÅá·ˆ vaá¸á¸Ä shahr Ä“. lahor pÄkistÄn dÄ siÄsÄ«, rahtalÄ« tÄ“ paá¹›Ä̀ī dÄ gÄÌá¹› Ä“ tÄ“ is laÄ« ihnÅ«á·ˆ pÄkistÄn dÄ dil vÄ« kehÄ jÄndÄ Ä“. lahor dariÄÄ“ rÄvÄ« dÄ“ kaná¸Ä“ tÄ“ vasdÄ Ä“. isdÄ« lÅk giṇtÄ« ikk karÅá¹› dÄ“ nēṛē Ä“.] -op close_container: [indian-languages] [] -op open_container: [employees] [] -op open_leaf_list: [wc] [] -op string: [wc] [à·´ - 0xdf4 - 1] -op string: [wc] [ණ - 0xdab - 1] -op string: [wc] [à·Š - 0xdca - 0] -op string: [wc] [ණ - 0xdab - 1] -op string: [wc] [្ - 0x17d2 - 0] -op string: [wc] [à·´ - 0xdf4 - 1] -op string: [wc] [1 - 0x31 - 1] -op string: [wc] [Í - 0x34f - 0] -op string: [wc] [2 - 0x32 - 1] -op string: [wc] [⃠- 0x20dd - 0] -op close_leaf_list: [wc] [] -op string: [fancy] [1Í2âƒ] -op string: [v1] [γιγνώσκειν] -op string: [v2] [ὦ ἄνδÏες ᾿Αθηναῖοι] -op string: [v1] [áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ] -op string: [v2] [Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] -op content: [width] [55] -op string: [sinhala] [෴ණ්ණ෴] -op content: [width] [4] -op string: [sinhala] [à·´] -op content: [width] [1] -op string: [sinhala] [෴ණ්ණ෴෴ණ්ණ෴] -op content: [width] [8] -op string: [not-sinhala] [123456] -op string: [tag] [ර්â€à¶] -op content: [width] [2] -op open_list: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Jim] -op string: [nic-name] ["რეგტ"] -op string: [last-name] [გთხáƒáƒ•áƒ— áƒáƒ®] -op content: [department] [431] -op content: [percent-time] [90] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Terry] -op string: [nic-name] ["<one"] -op string: [last-name] [Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones] -op content: [department] [660] -op content: [percent-time] [90] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Leslie] -op string: [nic-name] ["Les"] -op string: [last-name] [Patterson] -op content: [department] [341] -op content: [percent-time] [60] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Ashley] -op string: [nic-name] ["Ash"] -op string: [last-name] [Meter & Smith] -op content: [department] [1440] -op content: [percent-time] [40] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [0123456789] -op string: [nic-name] ["0123456789"] -op string: [last-name] [012345678901234567890] -op content: [department] [1440] -op content: [percent-time] [40] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [áƒáƒ®áƒšáƒ] -op string: [nic-name] ["გáƒáƒ˜áƒáƒ áƒ"] -op string: [last-name] [სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] -op content: [department] [123] -op content: [percent-time] [90] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [෴ණ්ණ෴෴ණ්ණ෴] -op string: [nic-name] ["Mick"] -op string: [last-name] [෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴] -op content: [department] [110] -op content: [percent-time] [20] -op close_instance: [employee] [] -op close_list: [employee] [] -op close_container: [employees] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [indian-languages] [] [0x200010] +op string: [gurmukhi] [ਲਹੌਰ ਪਾਕਿਸਤਾਨੀ ਪੰਜਾਬ ਦੀ ਰਾਜਧਾਨੀ ਹੈ । ਲੋਕ ਗਿਣਤੀ ਦੇ ਨਾਲ ਕਰਾਚੀ ਤੋਂ ਬਾਅਦ ਲਹੌਰ ਦੂਜਾ ਸਠਤੋਂ ਵੱਡਾ ਸ਼ਹਿਰ ਹੈ । ਲਹੌਰ ਪਾਕਿਸਤਾਨ ਦਾ ਸਿਆਸੀ, ਰਹਤਲੀ ਤੇ ਪੜà©à¨¹à¨¾à¨ˆ ਦਾ ਗੜà©à¨¹ ਹੈ ਅਤੇ ਇਸ ਲਈ ਇਹਨੂੰ ਪਾਕਿਸਤਾਨ ਦਾ ਦਿਲ ਵੀ ਕਿਹਾ ਜਾਂਦਾ ਹੈ । ਲਹੌਰ ਦਰਿਆ-à¨-ਰਾਵੀ ਦੇ ਕੰਢੇ ਤੇ ਵਸਦਾ ਹੈ ਤੇ ਇਸਦੀ ਲੋਕ ਗਿਣਤੀ ਇੱਕ ਕਰੋੜ ਦੇ ਨੇੜੇ ਹੈ ।] [0] +op string: [shahmukhi] [Ù„Ûور پاکستانی پنجاب دا دارالØکومت اے۔ لوک گنتی دے نال کراچی توں بعد Ù„Ûور دوجا سبھ توں وڈا Ø´Ûر اے۔ Ù„Ûور پاکستان دا سیاسی، رÛتلی تے پڑھائی دا Ú¯Ú‘Ú¾ اے تے اس لئی ایھنوں پاکستان دا دل ÙˆÛŒ کیھا جاندا اے۔ Ù„Ûور دریاۓ راوی دے Ú©Ù†ÚˆÚ¾Û’ تے وسدا اے اسدی لوک گنتی اک کروڑ دے نیڑے اے Û”] [0] +op string: [tranliteration] [lahor pÄkistÄn panjÄb dÄ dÄrul hakÅ«mat Ä“. lÅk giṇtÄ« dÄ“ nÄḷ karÄcÄ« tÅá·ˆ bÄad lahor dÅ«jÄ sab tÅá·ˆ vaá¸á¸Ä shahr Ä“. lahor pÄkistÄn dÄ siÄsÄ«, rahtalÄ« tÄ“ paá¹›Ä̀ī dÄ gÄÌá¹› Ä“ tÄ“ is laÄ« ihnÅ«á·ˆ pÄkistÄn dÄ dil vÄ« kehÄ jÄndÄ Ä“. lahor dariÄÄ“ rÄvÄ« dÄ“ kaná¸Ä“ tÄ“ vasdÄ Ä“. isdÄ« lÅk giṇtÄ« ikk karÅá¹› dÄ“ nēṛē Ä“.] [0] +op close_container: [indian-languages] [] [0] +op open_container: [employees] [] [0x200010] +op open_leaf_list: [wc] [] [0] +op string: [wc] [à·´ - 0xdf4 - 1] [0x2010] +op string: [wc] [ණ - 0xdab - 1] [0x2010] +op string: [wc] [à·Š - 0xdca - 0] [0x2010] +op string: [wc] [ණ - 0xdab - 1] [0x2010] +op string: [wc] [្ - 0x17d2 - 0] [0x2010] +op string: [wc] [à·´ - 0xdf4 - 1] [0x2010] +op string: [wc] [1 - 0x31 - 1] [0x2010] +op string: [wc] [Í - 0x34f - 0] [0x2010] +op string: [wc] [2 - 0x32 - 1] [0x2010] +op string: [wc] [⃠- 0x20dd - 0] [0x2010] +op close_leaf_list: [wc] [] [0] +op string: [fancy] [1Í2âƒ] [0] +op string: [v1] [γιγνώσκειν] [0] +op string: [v2] [ὦ ἄνδÏες ᾿Αθηναῖοι] [0] +op string: [v1] [áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ] [0] +op string: [v2] [Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] [0] +op content: [width] [55] [0] +op string: [sinhala] [෴ණ්ණ෴] [0] +op content: [width] [4] [0] +op string: [sinhala] [à·´] [0] +op content: [width] [1] [0] +op string: [sinhala] [෴ණ්ණ෴෴ණ්ණ෴] [0] +op content: [width] [8] [0] +op string: [not-sinhala] [123456] [0] +op string: [tag] [ර්â€à¶] [0] +op content: [width] [2] [0] +op open_list: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Jim] [0] +op string: [nic-name] ["რეგტ"] [0] +op string: [last-name] [გთხáƒáƒ•áƒ— áƒáƒ®] [0] +op content: [department] [431] [0] +op content: [percent-time] [90] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Terry] [0] +op string: [nic-name] ["<one"] [0] +op string: [last-name] [Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones] [0] +op content: [department] [660] [0] +op content: [percent-time] [90] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Leslie] [0] +op string: [nic-name] ["Les"] [0] +op string: [last-name] [Patterson] [0] +op content: [department] [341] [0] +op content: [percent-time] [60] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Ashley] [0] +op string: [nic-name] ["Ash"] [0] +op string: [last-name] [Meter & Smith] [0] +op content: [department] [1440] [0] +op content: [percent-time] [40] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [0123456789] [0] +op string: [nic-name] ["0123456789"] [0] +op string: [last-name] [012345678901234567890] [0] +op content: [department] [1440] [0] +op content: [percent-time] [40] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [áƒáƒ®áƒšáƒ] [0] +op string: [nic-name] ["გáƒáƒ˜áƒáƒ áƒ"] [0] +op string: [last-name] [სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] [0] +op content: [department] [123] [0] +op content: [percent-time] [90] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [෴ණ්ණ෴෴ණ්ණ෴] [0] +op string: [nic-name] ["Mick"] [0] +op string: [last-name] [෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴] [0] +op content: [department] [110] [0] +op content: [percent-time] [20] [0] +op close_instance: [employee] [] [0] +op close_list: [employee] [] [0] +op close_container: [employees] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_06.E.out b/contrib/libxo/tests/core/saved/test_06.E.out index 3965783..12ba8aa 100644 --- a/contrib/libxo/tests/core/saved/test_06.E.out +++ b/contrib/libxo/tests/core/saved/test_06.E.out @@ -1,22 +1,22 @@ -op create: [] [] -op open_container: [employees] [] -op open_list: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Terry] -op string: [last-name] [Jones] -op content: [department] [660] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Leslie] -op string: [last-name] [Patterson] -op content: [department] [341] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Ashley] -op string: [last-name] [Smith] -op content: [department] [1440] -op close_instance: [employee] [] -op close_list: [employee] [] -op close_container: [employees] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [employees] [] [0x410] +op open_list: [employee] [] [0] +op open_instance: [employee] [] [0x410] +op string: [first-name] [Terry] [0] +op string: [last-name] [Jones] [0] +op content: [department] [660] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x410] +op string: [first-name] [Leslie] [0] +op string: [last-name] [Patterson] [0] +op content: [department] [341] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x410] +op string: [first-name] [Ashley] [0] +op string: [last-name] [Smith] [0] +op content: [department] [1440] [0] +op close_instance: [employee] [] [0] +op close_list: [employee] [] [0] +op close_container: [employees] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_07.E.out b/contrib/libxo/tests/core/saved/test_07.E.out index 45e4b69..8503ce8 100644 --- a/contrib/libxo/tests/core/saved/test_07.E.out +++ b/contrib/libxo/tests/core/saved/test_07.E.out @@ -1,76 +1,76 @@ -op create: [] [] -op open_container: [employees] [] -op open_list: [test] [] -op open_instance: [test] [] -op string: [filename] [(null)] -op close_instance: [test] [] -op close_list: [test] [] -op string: [v1] [γιγνώσκειν] -op string: [v2] [ὦ ἄνδÏες ᾿Αθηναῖοι] -op content: [columns] [28] -op content: [columns] [2] -op string: [v1] [áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ] -op string: [v2] [Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] -op content: [columns] [55] -op content: [columns] [0] -op open_list: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Jim] -op string: [nic-name] ["რეგტ"] -op string: [last-name] [გთხáƒáƒ•áƒ— áƒáƒ®] -op content: [department] [431] -op content: [percent-time] [90] -op content: [columns] [23] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Terry] -op string: [nic-name] ["<one"] -op string: [last-name] [Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones] -op content: [department] [660] -op content: [percent-time] [90] -op content: [columns] [47] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Leslie] -op string: [nic-name] ["Les"] -op string: [last-name] [Patterson] -op content: [department] [341] -op content: [percent-time] [60] -op content: [columns] [25] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [Ashley] -op string: [nic-name] ["Ash"] -op string: [last-name] [Meter & Smith] -op content: [department] [1440] -op content: [percent-time] [40] -op content: [columns] [30] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [0123456789] -op string: [nic-name] ["0123456789"] -op string: [last-name] [012345678901234567890] -op content: [department] [1440] -op content: [percent-time] [40] -op content: [columns] [49] -op close_instance: [employee] [] -op open_instance: [employee] [] -op string: [first-name] [áƒáƒ®áƒšáƒ] -op string: [nic-name] ["გáƒáƒ˜áƒáƒ áƒ"] -op string: [last-name] [სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] -op content: [department] [123] -op content: [percent-time] [90] -op content: [columns] [29] -op attr: [full-time] [honest & for true] -op string: [benefits] [full] -op close_instance: [employee] [] -op close_list: [employee] [] -op close_container: [employees] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [employees] [] [0x200010] +op open_list: [test] [] [0] +op open_instance: [test] [] [0x200010] +op string: [filename] [(null)] [0x88] +op close_instance: [test] [] [0] +op close_list: [test] [] [0] +op string: [v1] [γιγνώσκειν] [0] +op string: [v2] [ὦ ἄνδÏες ᾿Αθηναῖοι] [0] +op content: [columns] [28] [0] +op content: [columns] [2] [0] +op string: [v1] [áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ] [0] +op string: [v2] [Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] [0] +op content: [columns] [55] [0] +op content: [columns] [0] [0] +op open_list: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Jim] [0] +op string: [nic-name] ["რეგტ"] [0] +op string: [last-name] [გთხáƒáƒ•áƒ— áƒáƒ®] [0] +op content: [department] [431] [0] +op content: [percent-time] [90] [0] +op content: [columns] [23] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Terry] [0] +op string: [nic-name] ["<one"] [0] +op string: [last-name] [Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones] [0] +op content: [department] [660] [0] +op content: [percent-time] [90] [0] +op content: [columns] [47] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Leslie] [0] +op string: [nic-name] ["Les"] [0] +op string: [last-name] [Patterson] [0] +op content: [department] [341] [0] +op content: [percent-time] [60] [0] +op content: [columns] [25] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [Ashley] [0] +op string: [nic-name] ["Ash"] [0] +op string: [last-name] [Meter & Smith] [0] +op content: [department] [1440] [0] +op content: [percent-time] [40] [0] +op content: [columns] [30] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [0123456789] [0] +op string: [nic-name] ["0123456789"] [0] +op string: [last-name] [012345678901234567890] [0] +op content: [department] [1440] [0] +op content: [percent-time] [40] [0] +op content: [columns] [49] [0] +op close_instance: [employee] [] [0] +op open_instance: [employee] [] [0x200010] +op string: [first-name] [áƒáƒ®áƒšáƒ] [0] +op string: [nic-name] ["გáƒáƒ˜áƒáƒ áƒ"] [0] +op string: [last-name] [სáƒáƒ”რთáƒáƒ¨áƒáƒ ისáƒ] [0] +op content: [department] [123] [0] +op content: [percent-time] [90] [0] +op content: [columns] [29] [0] +op attr: [full-time] [honest & for true] [0] +op string: [benefits] [full] [0x8] +op close_instance: [employee] [] [0] +op close_list: [employee] [] [0] +op close_container: [employees] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_08.E.out b/contrib/libxo/tests/core/saved/test_08.E.out index c00f4b8..389a4bd 100644 --- a/contrib/libxo/tests/core/saved/test_08.E.out +++ b/contrib/libxo/tests/core/saved/test_08.E.out @@ -1,186 +1,186 @@ -op create: [] [] -op open_container: [top] [] -op open_container: [data] [] -op open_container: [contents] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [name] [gum] -op content: [count] [1412] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [rope] -op content: [count] [85] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [ladder] -op content: [count] [0] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [bolt] -op content: [count] [4123] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [water] -op content: [count] [17] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [contents] [] -op close_container: [data] [] -op open_container: [data2] [] -op open_container: [contents] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [name] [gum] -op content: [count] [1412] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [rope] -op content: [count] [85] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [ladder] -op content: [count] [0] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [bolt] -op content: [count] [4123] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [water] -op content: [count] [17] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [contents] [] -op close_container: [data2] [] -op open_container: [data3] [] -op open_container: [contents] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [name] [gum] -op content: [count] [1412] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [rope] -op content: [count] [85] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [ladder] -op content: [count] [0] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [bolt] -op content: [count] [4123] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [water] -op content: [count] [17] -op string: [test] [one] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [contents] [] -op close_container: [data3] [] -op open_container: [data4] [] -op open_container: [contents] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [name] [gum] -op content: [count] [1412] -op open_list: [sub] [] -op open_instance: [sub] [] -op content: [name] [0] -op content: [next] [1] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [1] -op content: [next] [2] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [2] -op content: [next] [3] -op close_instance: [sub] [] -op close_list: [sub] [] -op content: [last] [3] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [rope] -op content: [count] [85] -op open_list: [sub] [] -op open_instance: [sub] [] -op content: [name] [0] -op content: [next] [1] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [1] -op content: [next] [2] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [2] -op content: [next] [3] -op close_instance: [sub] [] -op close_list: [sub] [] -op content: [last] [3] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [ladder] -op content: [count] [0] -op open_list: [sub] [] -op open_instance: [sub] [] -op content: [name] [0] -op content: [next] [1] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [1] -op content: [next] [2] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [2] -op content: [next] [3] -op close_instance: [sub] [] -op close_list: [sub] [] -op content: [last] [3] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [bolt] -op content: [count] [4123] -op open_list: [sub] [] -op open_instance: [sub] [] -op content: [name] [0] -op content: [next] [1] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [1] -op content: [next] [2] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [2] -op content: [next] [3] -op close_instance: [sub] [] -op close_list: [sub] [] -op content: [last] [3] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [name] [water] -op content: [count] [17] -op open_list: [sub] [] -op open_instance: [sub] [] -op content: [name] [0] -op content: [next] [1] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [1] -op content: [next] [2] -op close_instance: [sub] [] -op open_instance: [sub] [] -op content: [name] [2] -op content: [next] [3] -op close_instance: [sub] [] -op close_list: [sub] [] -op content: [last] [3] -op string: [test] [one] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [contents] [] -op close_container: [data4] [] -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [top] [] [0x810] +op open_container: [data] [] [0x810] +op open_container: [contents] [] [0x810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [gum] [0x80] +op content: [count] [1412] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [rope] [0x80] +op content: [count] [85] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [ladder] [0x80] +op content: [count] [0] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [bolt] [0x80] +op content: [count] [4123] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [water] [0x80] +op content: [count] [17] [0x20] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [contents] [] [0] +op close_container: [data] [] [0] +op open_container: [data2] [] [0x810] +op open_container: [contents] [] [0x810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [gum] [0x80] +op content: [count] [1412] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [rope] [0x80] +op content: [count] [85] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [ladder] [0x80] +op content: [count] [0] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [bolt] [0x80] +op content: [count] [4123] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [water] [0x80] +op content: [count] [17] [0x20] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [contents] [] [0] +op close_container: [data2] [] [0] +op open_container: [data3] [] [0x810] +op open_container: [contents] [] [0x810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [gum] [0x80] +op content: [count] [1412] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [rope] [0x80] +op content: [count] [85] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [ladder] [0x80] +op content: [count] [0] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [bolt] [0x80] +op content: [count] [4123] [0x20] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [water] [0x80] +op content: [count] [17] [0x20] +op string: [test] [one] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [contents] [] [0] +op close_container: [data3] [] [0] +op open_container: [data4] [] [0x810] +op open_container: [contents] [] [0x810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [gum] [0x80] +op content: [count] [1412] [0x20] +op open_list: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [0] [0] +op content: [next] [1] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [1] [0] +op content: [next] [2] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [2] [0] +op content: [next] [3] [0] +op close_instance: [sub] [] [0] +op close_list: [sub] [] [0] +op content: [last] [3] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [rope] [0x80] +op content: [count] [85] [0x20] +op open_list: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [0] [0] +op content: [next] [1] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [1] [0] +op content: [next] [2] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [2] [0] +op content: [next] [3] [0] +op close_instance: [sub] [] [0] +op close_list: [sub] [] [0] +op content: [last] [3] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [ladder] [0x80] +op content: [count] [0] [0x20] +op open_list: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [0] [0] +op content: [next] [1] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [1] [0] +op content: [next] [2] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [2] [0] +op content: [next] [3] [0] +op close_instance: [sub] [] [0] +op close_list: [sub] [] [0] +op content: [last] [3] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [bolt] [0x80] +op content: [count] [4123] [0x20] +op open_list: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [0] [0] +op content: [next] [1] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [1] [0] +op content: [next] [2] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [2] [0] +op content: [next] [3] [0] +op close_instance: [sub] [] [0] +op close_list: [sub] [] [0] +op content: [last] [3] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x810] +op string: [name] [water] [0x80] +op content: [count] [17] [0x20] +op open_list: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [0] [0] +op content: [next] [1] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [1] [0] +op content: [next] [2] [0] +op close_instance: [sub] [] [0] +op open_instance: [sub] [] [0x810] +op content: [name] [2] [0] +op content: [next] [3] [0] +op close_instance: [sub] [] [0] +op close_list: [sub] [] [0] +op content: [last] [3] [0] +op string: [test] [one] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [contents] [] [0] +op close_container: [data4] [] [0] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_09.E.out b/contrib/libxo/tests/core/saved/test_09.E.out index bb808d5..abc69cf 100644 --- a/contrib/libxo/tests/core/saved/test_09.E.out +++ b/contrib/libxo/tests/core/saved/test_09.E.out @@ -1,40 +1,40 @@ -op create: [] [] -op open_container: [top] [] -op open_container: [data] [] -op open_container: [contents] [] -op open_leaf_list: [name] [] -op string: [name] [gum] -op string: [name] [rope] -op string: [name] [ladder] -op string: [name] [bolt] -op string: [name] [water] -op close_leaf_list: [name] [] -op close_container: [contents] [] -op open_container: [contents] [] -op open_leaf_list: [item] [] -op string: [item] [gum] -op string: [item] [rope] -op string: [item] [ladder] -op string: [item] [bolt] -op string: [item] [water] -op close_leaf_list: [item] [] -op close_container: [contents] [] -op open_container: [contents] [] -op open_list: [item] [] -op string: [item] [gum] -op string: [item] [rope] -op string: [item] [ladder] -op string: [item] [bolt] -op string: [item] [water] -op close_list: [item] [] -op string: [total] [six] -op string: [one] [one] -op open_leaf_list: [two] [] -op string: [two] [two] -op close_leaf_list: [two] [] -op string: [three] [three] -op close_container: [contents] [] -op close_container: [data] [] -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [top] [] [0x810] +op open_container: [data] [] [0x810] +op open_container: [contents] [] [0x810] +op open_leaf_list: [name] [] [0] +op string: [name] [gum] [0x2000] +op string: [name] [rope] [0x2000] +op string: [name] [ladder] [0x2000] +op string: [name] [bolt] [0x2000] +op string: [name] [water] [0x2000] +op close_leaf_list: [name] [] [0] +op close_container: [contents] [] [0] +op open_container: [contents] [] [0x810] +op open_leaf_list: [item] [] [0] +op string: [item] [gum] [0x2000] +op string: [item] [rope] [0x2000] +op string: [item] [ladder] [0x2000] +op string: [item] [bolt] [0x2000] +op string: [item] [water] [0x2000] +op close_leaf_list: [item] [] [0] +op close_container: [contents] [] [0] +op open_container: [contents] [] [0x810] +op open_list: [item] [] [0] +op string: [item] [gum] [0x2000] +op string: [item] [rope] [0x2000] +op string: [item] [ladder] [0x2000] +op string: [item] [bolt] [0x2000] +op string: [item] [water] [0x2000] +op close_list: [item] [] [0] +op string: [total] [six] [0] +op string: [one] [one] [0] +op open_leaf_list: [two] [] [0] +op string: [two] [two] [0x2000] +op close_leaf_list: [two] [] [0] +op string: [three] [three] [0] +op close_container: [contents] [] [0] +op close_container: [data] [] [0] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_10.E.out b/contrib/libxo/tests/core/saved/test_10.E.out index 4f21cda..dc50d92 100644 --- a/contrib/libxo/tests/core/saved/test_10.E.out +++ b/contrib/libxo/tests/core/saved/test_10.E.out @@ -1,126 +1,126 @@ -op create: [] [] -op version: [] [3.1.4] -op open_container: [top] [] -op attr: [test] [value] -op open_container: [data] [] -op open_list: [item] [] -op attr: [test2] [value2] -op close_list: [item] [] -op string: [data] [bold] -op string: [data] [bold-ul] -op string: [data] [triple] -op string: [data] [inv-ul] -op string: [data] [underline] -op string: [data] [plain] -op open_list: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [GRO-000-415] -op string: [name] [gum] -op content: [sold] [1412] -op content: [in-stock] [54] -op content: [on-order] [10] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [HRD-000-212] -op string: [name] [rope] -op content: [sold] [85] -op content: [in-stock] [4] -op content: [on-order] [2] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [HRD-000-517] -op string: [name] [ladder] -op content: [sold] [0] -op content: [in-stock] [2] -op content: [on-order] [1] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [HRD-000-632] -op string: [name] [bolt] -op content: [sold] [4123] -op content: [in-stock] [144] -op content: [on-order] [42] -op close_instance: [item] [] -op open_instance: [item] [] -op attr: [test3] [value3] -op string: [sku] [GRO-000-2331] -op string: [name] [water] -op content: [sold] [17] -op content: [in-stock] [14] -op content: [on-order] [2] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [data] [] -op open_container: [data] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [sku] [GRO-000-415] -op string: [name] [gum] -op content: [sold] [1412.0] -op content: [in-stock] [54] -op content: [on-order] [10] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [HRD-000-212] -op string: [name] [rope] -op content: [sold] [85.0] -op content: [in-stock] [4] -op content: [on-order] [2] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [HRD-000-517] -op string: [name] [ladder] -op content: [sold] [0] -op content: [in-stock] [2] -op content: [on-order] [1] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [HRD-000-632] -op string: [name] [bolt] -op content: [sold] [4123.0] -op content: [in-stock] [144] -op content: [on-order] [42] -op close_instance: [item] [] -op open_instance: [item] [] -op string: [sku] [GRO-000-2331] -op string: [name] [water] -op content: [sold] [17.0] -op content: [in-stock] [14] -op content: [on-order] [2] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [data] [] -op open_container: [data] [] -op open_list: [item] [] -op open_instance: [item] [] -op string: [sku] [GRO-000-533] -op string: [name] [fish] -op content: [sold] [1321.0] -op content: [in-stock] [45] -op content: [on-order] [1] -op close_instance: [item] [] -op close_list: [item] [] -op close_container: [data] [] -op open_container: [data] [] -op open_list: [item] [] -op attr: [test4] [value4] -op string: [item] [gum] -op attr: [test4] [value4] -op string: [item] [rope] -op attr: [test4] [value4] -op string: [item] [ladder] -op attr: [test4] [value4] -op string: [item] [bolt] -op attr: [test4] [value4] -op string: [item] [water] -op close_list: [item] [] -op close_container: [data] [] -op content: [cost] [425] -op content: [cost] [455] -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op version: [] [3.1.4] [0] +op open_container: [top] [] [0x4000810] +op attr: [test] [value] [0] +op open_container: [data] [] [0x4000810] +op open_list: [item] [] [0] +op attr: [test2] [value2] [0] +op close_list: [item] [] [0] +op string: [data] [bold] [0] +op string: [data] [bold-ul] [0] +op string: [data] [triple] [0] +op string: [data] [inv-ul] [0] +op string: [data] [underline] [0] +op string: [data] [plain] [0] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op attr: [test3] [value3] [0] +op string: [sku] [GRO-000-415] [0x98] +op string: [name] [gum] [0x80] +op content: [sold] [1412] [0x20] +op content: [in-stock] [54] [0] +op content: [on-order] [10] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op attr: [test3] [value3] [0] +op string: [sku] [HRD-000-212] [0x98] +op string: [name] [rope] [0x80] +op content: [sold] [85] [0x20] +op content: [in-stock] [4] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op attr: [test3] [value3] [0] +op string: [sku] [HRD-000-517] [0x98] +op string: [name] [ladder] [0x80] +op content: [sold] [0] [0x20] +op content: [in-stock] [2] [0] +op content: [on-order] [1] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op attr: [test3] [value3] [0] +op string: [sku] [HRD-000-632] [0x98] +op string: [name] [bolt] [0x80] +op content: [sold] [4123] [0x20] +op content: [in-stock] [144] [0] +op content: [on-order] [42] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op attr: [test3] [value3] [0] +op string: [sku] [GRO-000-2331] [0x98] +op string: [name] [water] [0x80] +op content: [sold] [17] [0x20] +op content: [in-stock] [14] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [data] [] [0] +op open_container: [data] [] [0x4000810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op string: [sku] [GRO-000-415] [0x98] +op string: [name] [gum] [0x80] +op content: [sold] [1412.0] [0x20] +op content: [in-stock] [54] [0] +op content: [on-order] [10] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op string: [sku] [HRD-000-212] [0x98] +op string: [name] [rope] [0x80] +op content: [sold] [85.0] [0x20] +op content: [in-stock] [4] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op string: [sku] [HRD-000-517] [0x98] +op string: [name] [ladder] [0x80] +op content: [sold] [0] [0x20] +op content: [in-stock] [2] [0] +op content: [on-order] [1] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op string: [sku] [HRD-000-632] [0x98] +op string: [name] [bolt] [0x80] +op content: [sold] [4123.0] [0x20] +op content: [in-stock] [144] [0] +op content: [on-order] [42] [0] +op close_instance: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op string: [sku] [GRO-000-2331] [0x98] +op string: [name] [water] [0x80] +op content: [sold] [17.0] [0x20] +op content: [in-stock] [14] [0] +op content: [on-order] [2] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [data] [] [0] +op open_container: [data] [] [0x4000810] +op open_list: [item] [] [0] +op open_instance: [item] [] [0x4000810] +op string: [sku] [GRO-000-533] [0x98] +op string: [name] [fish] [0x80] +op content: [sold] [1321.0] [0x20] +op content: [in-stock] [45] [0] +op content: [on-order] [1] [0] +op close_instance: [item] [] [0] +op close_list: [item] [] [0] +op close_container: [data] [] [0] +op open_container: [data] [] [0x4000810] +op open_list: [item] [] [0] +op attr: [test4] [value4] [0] +op string: [item] [gum] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [rope] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [ladder] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [bolt] [0x2000] +op attr: [test4] [value4] [0] +op string: [item] [water] [0x2000] +op close_list: [item] [] [0] +op close_container: [data] [] [0] +op content: [cost] [425] [0] +op content: [cost] [455] [0] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_10.X.out b/contrib/libxo/tests/core/saved/test_10.X.out index 49c6dd8..c932156 100644 --- a/contrib/libxo/tests/core/saved/test_10.X.out +++ b/contrib/libxo/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/contrib/libxo/tests/core/saved/test_10.XP.out b/contrib/libxo/tests/core/saved/test_10.XP.out index 33c88d9..ec1aa93 100644 --- a/contrib/libxo/tests/core/saved/test_10.XP.out +++ b/contrib/libxo/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/contrib/libxo/tests/core/saved/test_11.E.out b/contrib/libxo/tests/core/saved/test_11.E.out index 9fd70fa..76b8f21 100644 --- a/contrib/libxo/tests/core/saved/test_11.E.out +++ b/contrib/libxo/tests/core/saved/test_11.E.out @@ -1,26 +1,22 @@ -op create: [] [] -op version: [] [3.1.4] -op open_container: [top] [] -op create: [] [] +op create: [] [] [0] +op version: [] [3.1.4] [0] +op open_container: [top] [] [0x10] {{<14>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-status [animal-status@42 animal="snake" state="loose"] The snake is loose}} {{test-program: }} {{The snake is loose}} -op create: [] [] {{<22>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-consumed [animal-consumed@42 animal="snake" pet="hamster"] My snake ate your hamster}} {{test-program: }} {{My snake ate your hamster}} -op create: [] [] {{<29>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-talk [animal-talk@42 count="1" animal="owl" quote="\"e=m\\c[2\]\""] 1 owl said "e=m\c[2]"}} {{test-program: }} {{1 owl said "e=m\c[2]"}} -op create: [] [] {{<165>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 ID47 [ID47@32473 iut="3" event-source="application" event-id="1011"] An application 1011 log entry}} {{test-program: }} {{An application 1011 log entry}} -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_11.HIPx.out b/contrib/libxo/tests/core/saved/test_11.HIPx.out index 8b726f4..0786c34 100644 --- a/contrib/libxo/tests/core/saved/test_11.HIPx.out +++ b/contrib/libxo/tests/core/saved/test_11.HIPx.out @@ -1,16 +1,16 @@ -{{<14>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-status [animal-status@42 animal="" state=""] The snake is loose}} +{{<14>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-status [animal-status@42 animal="snake" state="loose"] The snake is loose}} {{test-program: }} {{The snake is loose}} -{{<22>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-consumed [animal-consumed@42 animal="" pet=""] My snake ate your hamster}} +{{<22>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-consumed [animal-consumed@42 animal="snake" pet="hamster"] My snake ate your hamster}} {{test-program: }} {{My snake ate your hamster}} -{{<29>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-talk [animal-talk@42 count="" animal="" quote=""] 1 owl said "e=m\c[2]"}} +{{<29>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 animal-talk [animal-talk@42 count="1" animal="owl" quote="\"e=m\\c[2\]\""] 1 owl said "e=m\c[2]"}} {{test-program: }} {{1 owl said "e=m\c[2]"}} -{{<165>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 ID47 [ID47@32473 iut="" event-source="" event-id=""] An application 1011 log entry}} +{{<165>1 2015-06-23T13:47:09.123-0500 worker-host test-program 222 ID47 [ID47@32473 iut="3" event-source="application" event-id="1011"] An application 1011 log entry}} {{test-program: }} {{An application 1011 log entry}} diff --git a/contrib/libxo/tests/core/saved/test_11.X.out b/contrib/libxo/tests/core/saved/test_11.X.out index bb73a42..5c279b7 100644 --- a/contrib/libxo/tests/core/saved/test_11.X.out +++ b/contrib/libxo/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/contrib/libxo/tests/core/saved/test_11.XP.out b/contrib/libxo/tests/core/saved/test_11.XP.out index 46b5dd0..0276561 100644 --- a/contrib/libxo/tests/core/saved/test_11.XP.out +++ b/contrib/libxo/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/contrib/libxo/tests/core/saved/test_12.E.out b/contrib/libxo/tests/core/saved/test_12.E.out index 1c899a1..a831f5c 100644 --- a/contrib/libxo/tests/core/saved/test_12.E.out +++ b/contrib/libxo/tests/core/saved/test_12.E.out @@ -1,89 +1,91 @@ -op create: [] [] -op open_container: [top] [] -op open_container: [data] [] -op open_list: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op open_instance: [thing] [] -op string: [name] [thing] -op string: [color] [green] -op content: [time] [2:15] -op string: [hand] [left] -op string: [color] [blue] -op content: [time] [3:45] -op close_instance: [thing] [] -op close_list: [thing] [] -op close_container: [data] [] -op close_container: [top] [] -op finish: [] [] -op flush: [] [] +op create: [] [] [0] +op open_container: [top] [] [0x4040010] +op open_container: [data] [] [0x4040010] +op string: [animal] [fish] [0] +op string: [animal] [fish] [0] +op open_list: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op open_instance: [thing] [] [0x4040010] +op string: [name] [thing] [0x80] +op string: [color] [green] [0] +op content: [time] [2:15] [0] +op string: [hand] [left] [0] +op string: [color] [blue] [0] +op content: [time] [3:45] [0] +op close_instance: [thing] [] [0] +op close_list: [thing] [] [0] +op close_container: [data] [] [0] +op close_container: [top] [] [0] +op finish: [] [] [0] +op flush: [] [] [0] diff --git a/contrib/libxo/tests/core/saved/test_12.H.out b/contrib/libxo/tests/core/saved/test_12.H.out index 5cbac17..2bd9a44 100644 --- a/contrib/libxo/tests/core/saved/test_12.H.out +++ b/contrib/libxo/tests/core/saved/test_12.H.out @@ -1 +1 @@ -<div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div>
\ No newline at end of file +<div class="line"><div class="text color-fg-red color-bg-green">Merry XMas!!</div></div><div class="line"><div class="text">One </div><div class="data color-fg-yellow color-bg-blue" data-tag="animal">fish</div><div class="text">, Two </div><div class="data color-fg-green color-bg-yellow" data-tag="animal">fish</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data color-fg-red" data-tag="name">thing</div><div class="text"> is </div><div class="data color-fg-green" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data color-fg-red" data-tag="hand">left</div><div class="text"> hand is </div><div class="data color-fg-blue" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div>
\ No newline at end of file diff --git a/contrib/libxo/tests/core/saved/test_12.HIPx.out b/contrib/libxo/tests/core/saved/test_12.HIPx.out index 9b5fea1..dab1975 100644 --- a/contrib/libxo/tests/core/saved/test_12.HIPx.out +++ b/contrib/libxo/tests/core/saved/test_12.HIPx.out @@ -1,160 +1,169 @@ <div class="line"> + <div class="text color-fg-red color-bg-green">Merry XMas!!</div> +</div> +<div class="line"> + <div class="text">One </div> + <div class="data color-fg-yellow color-bg-blue" data-tag="animal" data-xpath="/top/data/animal">fish</div> + <div class="text">, Two </div> + <div class="data color-fg-green color-bg-yellow" data-tag="animal" data-xpath="/top/data/animal">fish</div> +</div> +<div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div> + <div class="data color-fg-red" data-tag="name" data-xpath="/top/data/thing/name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> + <div class="data color-fg-green" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> + <div class="data color-fg-red" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> + <div class="data color-fg-blue" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div> </div> diff --git a/contrib/libxo/tests/core/saved/test_12.HP.out b/contrib/libxo/tests/core/saved/test_12.HP.out index 1e0e923..54e3dfb 100644 --- a/contrib/libxo/tests/core/saved/test_12.HP.out +++ b/contrib/libxo/tests/core/saved/test_12.HP.out @@ -1,160 +1,169 @@ <div class="line"> + <div class="text color-fg-red color-bg-green">Merry XMas!!</div> +</div> +<div class="line"> + <div class="text">One </div> + <div class="data color-fg-yellow color-bg-blue" data-tag="animal">fish</div> + <div class="text">, Two </div> + <div class="data color-fg-green color-bg-yellow" data-tag="animal">fish</div> +</div> +<div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> <div class="line"> <div class="text">The </div> - <div class="data" data-tag="name">thing</div> + <div class="data color-fg-red" data-tag="name">thing</div> <div class="text"> is </div> - <div class="data" data-tag="color">green</div> + <div class="data color-fg-green" data-tag="color">green</div> <div class="text"> til </div> <div class="data" data-tag="time">02:15</div> </div> <div class="line"> <div class="text">My </div> - <div class="data" data-tag="hand">left</div> + <div class="data color-fg-red" data-tag="hand">left</div> <div class="text"> hand is </div> - <div class="data" data-tag="color">blue</div> + <div class="data color-fg-blue" data-tag="color">blue</div> <div class="text"> til </div> <div class="data" data-tag="time">03:45</div> </div> diff --git a/contrib/libxo/tests/core/saved/test_12.J.out b/contrib/libxo/tests/core/saved/test_12.J.out index 118bb76..7cfee6d 100644 --- a/contrib/libxo/tests/core/saved/test_12.J.out +++ b/contrib/libxo/tests/core/saved/test_12.J.out @@ -1,2 +1,2 @@ -{"top": {"data": {"thing": [{"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}]}} +{"top": {"data": {"animal":"fish","animal":"fish", "thing": [{"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}]}} } diff --git a/contrib/libxo/tests/core/saved/test_12.JP.out b/contrib/libxo/tests/core/saved/test_12.JP.out index 3e15e0d..f76ede1 100644 --- a/contrib/libxo/tests/core/saved/test_12.JP.out +++ b/contrib/libxo/tests/core/saved/test_12.JP.out @@ -1,6 +1,8 @@ { "top": { "data": { + "animal": "fish", + "animal": "fish", "thing": [ { "name": "thing", diff --git a/contrib/libxo/tests/core/saved/test_12.T.out b/contrib/libxo/tests/core/saved/test_12.T.out index 6f777c7..83a96a1 100644 --- a/contrib/libxo/tests/core/saved/test_12.T.out +++ b/contrib/libxo/tests/core/saved/test_12.T.out @@ -1,20 +1,22 @@ -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 -The thing is green til 02:15 -My left hand is blue til 03:45 +[31;42mMerry XMas!![0m +One [33;44mfish[0m, Two [32;43mfish[0m +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 +The [31mthing[0m is [32mgreen[0m til 02:15 +My [31mleft[0m hand is [34mblue[0m til 03:45 diff --git a/contrib/libxo/tests/core/saved/test_12.X.out b/contrib/libxo/tests/core/saved/test_12.X.out index ed2d8e4..28a30f7 100644 --- a/contrib/libxo/tests/core/saved/test_12.X.out +++ b/contrib/libxo/tests/core/saved/test_12.X.out @@ -1 +1 @@ -<top><data><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing></data></top>
\ No newline at end of file +<top><data><animal>fish</animal><animal>fish</animal><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing></data></top>
\ No newline at end of file diff --git a/contrib/libxo/tests/core/saved/test_12.XP.out b/contrib/libxo/tests/core/saved/test_12.XP.out index 73eec4c..37ef1bd 100644 --- a/contrib/libxo/tests/core/saved/test_12.XP.out +++ b/contrib/libxo/tests/core/saved/test_12.XP.out @@ -1,5 +1,7 @@ <top> <data> + <animal>fish</animal> + <animal>fish</animal> <thing> <name>thing</name> <color>green</color> diff --git a/contrib/libxo/tests/core/test_01.c b/contrib/libxo/tests/core/test_01.c index 05d778a..15948a3 100644 --- a/contrib/libxo/tests/core/test_01.c +++ b/contrib/libxo/tests/core/test_01.c @@ -9,6 +9,7 @@ */ #include <stdlib.h> +#include <stdint.h> #include <string.h> #include <unistd.h> @@ -79,6 +80,15 @@ main (int argc, char **argv) xo_open_container_h(NULL, "top"); + xo_emit("anchor {[:/%d}{:address/%p}..{:port/%u}{]:}\n", 18, NULL, 1); + xo_emit("anchor {[:18}{:address/%p}..{:port/%u}{]:}\n", NULL, 1); + xo_emit("anchor {[:/18}{:address/%p}..{:port/%u}{]:}\n", NULL, 1); + + xo_emit("df {:used-percent/%5.0f}{U:%%}\n", (double) 12); + + 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"); @@ -186,6 +196,8 @@ main (int argc, char **argv) "mode", "octal", "links", "user", "group", "extra1", "extra2", "extra3"); + xo_emit("{e:pre/%s}{t:links/%-*u}{t:post/%-*s}\n", "that", 8, 3, 8, "this"); + xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*u} " "{t:user/%-*s} {t:group/%-*s} \n", "/some/file", (int) 0640, 8, 1, diff --git a/contrib/libxo/tests/core/test_12.c b/contrib/libxo/tests/core/test_12.c index 17d26a6..f6021e7 100644 --- a/contrib/libxo/tests/core/test_12.c +++ b/contrib/libxo/tests/core/test_12.c @@ -22,6 +22,7 @@ main (int argc, char **argv) int i, count = 10; int mon = 0; xo_emit_flags_t flags = XOEF_RETAIN; + int opt_color = 1; argc = xo_parse_args(argc, argv); if (argc < 0) @@ -36,6 +37,8 @@ main (int argc, char **argv) xo_set_style(NULL, XO_STYLE_TEXT); else if (strcmp(argv[argc], "html") == 0) xo_set_style(NULL, XO_STYLE_HTML); + else if (strcmp(argv[argc], "no-color") == 0) + opt_color = 0; else if (strcmp(argv[argc], "pretty") == 0) xo_set_flags(NULL, XOF_PRETTY); else if (strcmp(argv[argc], "xpath") == 0) @@ -51,11 +54,19 @@ main (int argc, char **argv) } xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */ + if (opt_color) + xo_set_flags(NULL, XOF_COLOR); /* Force color output */ xo_set_file(stdout); xo_open_container("top"); xo_open_container("data"); + xo_emit("{C:fg-red,bg-green}Merry XMas!!{C:}\n"); + + xo_emit("One {C:fg-yellow,bg-blue}{:animal}{C:}, " + "Two {C:fg-green,bg-yellow}{:animal}{C:}\n", + "fish", "fish"); + const char *fmt1 = "The {C:fg-red}{k:name}{C:reset} is " "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n"; const char *fmt2 = "My {C:fg-red}{:hand}{C:reset} hand is " diff --git a/contrib/libxo/tests/gettext/Makefile.am b/contrib/libxo/tests/gettext/Makefile.am index fb70142..2e6596a 100644 --- a/contrib/libxo/tests/gettext/Makefile.am +++ b/contrib/libxo/tests/gettext/Makefile.am @@ -72,8 +72,7 @@ valgrind: #TEST_TRACE = set -x ; TEST_ONE = \ - LIBXO_OPTIONS=:W$$fmt \ - ${CHECKER} ./$$base.test ${TEST_OPTS} \ + ${CHECKER} ./$$base.test --libxo:W$$fmt ${TEST_OPTS} \ > out/$$base.$$fmt.out 2> out/$$base.$$fmt.err ; \ ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.out out/$$base.$$fmt.out ${S2O} ; \ ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.err out/$$base.$$fmt.err ${S2O} diff --git a/contrib/libxo/tests/gettext/saved/gt_01.J.out b/contrib/libxo/tests/gettext/saved/gt_01.J.out index 86527d1..e6c2dd0 100644 --- a/contrib/libxo/tests/gettext/saved/gt_01.J.out +++ b/contrib/libxo/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/contrib/libxo/tests/gettext/saved/gt_01.JP.out b/contrib/libxo/tests/gettext/saved/gt_01.JP.out index 537ab21..6fcfcd6 100644 --- a/contrib/libxo/tests/gettext/saved/gt_01.JP.out +++ b/contrib/libxo/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/contrib/libxo/tests/xo/Makefile.am b/contrib/libxo/tests/xo/Makefile.am index 1687f09..22698f8 100644 --- a/contrib/libxo/tests/xo/Makefile.am +++ b/contrib/libxo/tests/xo/Makefile.am @@ -51,8 +51,7 @@ all: XO=../../xo/xo TEST_ONE = \ - LIBXO_OPTIONS=:W$$fmt \ - ${CHECKER} sh ${srcdir}/$$base.sh ${XO} ${TEST_OPTS} \ + ${CHECKER} sh ${srcdir}/$$base.sh "${XO} --libxo:W$$fmt" ${TEST_OPTS} \ > out/$$base.$$fmt.out 2> out/$$base.$$fmt.err ; \ ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.out out/$$base.$$fmt.out ${S2O} ; \ ${DIFF} -Nu ${srcdir}/saved/$$base.$$fmt.err out/$$base.$$fmt.err ${S2O} diff --git a/contrib/libxo/tests/xo/saved/xo_01.H.out b/contrib/libxo/tests/xo/saved/xo_01.H.out index dd82a1c..6d115c9 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.H.out +++ b/contrib/libxo/tests/xo/saved/xo_01.H.out @@ -1 +1 @@ -<div class="line"><div class="text">Item </div><div class="data" data-tag="name">one</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">001</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">red</div></div><div class="line"><div class="text">Item </div><div class="data" data-tag="name">two</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">002</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">blue</div></div><div class="line"><div class="text">Item </div><div class="data" data-tag="name">three</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">003</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">green</div></div><div class="line"><div class="text">Item </div><div class="data" data-tag="name">four</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">004</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">yellow</div></div>
\ No newline at end of file +<div class="line"><div class="text">Item </div><div class="data" data-tag="name">one</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">001</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">red</div></div><div class="line"><div class="text">Item </div><div class="data" data-tag="name">two</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">002</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">blue</div></div><div class="line"><div class="text">Item </div><div class="data" data-tag="name">three</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">003</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">green</div></div><div class="line"><div class="text">Item </div><div class="data" data-tag="name">four</div><div class="text"> is </div><div class="label">number</div><div class="padding"> </div><div class="data" data-tag="value">004</div><div class="text">, </div><div class="label">color</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="color">yellow</div></div><div class="padding"> </div><div class="line"><div class="data" data-tag="address">0xdeadbeef</div><div class="text">..</div><div class="data" data-tag="foo">1</div></div><div class="padding"> </div><div class="line"><div class="data" data-tag="address">0xdeadbeef</div><div class="text">..</div><div class="data" data-tag="foo">1</div></div><div class="padding"> </div><div class="line"><div class="data" data-tag="address">0xdeadbeef</div><div class="text">..</div><div class="data" data-tag="foo">1</div></div><div class="padding"> </div><div class="line"><div class="data" data-tag="address">0xdeadbeef</div><div class="text">..</div><div class="data" data-tag="foo">1</div></div>
\ No newline at end of file diff --git a/contrib/libxo/tests/xo/saved/xo_01.HIPx.out b/contrib/libxo/tests/xo/saved/xo_01.HIPx.out index 12e36b1..66ba7b6 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.HIPx.out +++ b/contrib/libxo/tests/xo/saved/xo_01.HIPx.out @@ -50,3 +50,27 @@ <div class="padding"> </div> <div class="data" data-tag="color" data-xpath="/top/item[name = 'four']/color">yellow</div> </div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address" data-xpath="/anchor/address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo" data-xpath="/anchor/foo">1</div> +</div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address" data-xpath="/anchor/address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo" data-xpath="/anchor/foo">1</div> +</div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address" data-xpath="/anchor/address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo" data-xpath="/anchor/foo">1</div> +</div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address" data-xpath="/anchor/address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo" data-xpath="/anchor/foo">1</div> +</div> diff --git a/contrib/libxo/tests/xo/saved/xo_01.HP.out b/contrib/libxo/tests/xo/saved/xo_01.HP.out index de91936..2bda085 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.HP.out +++ b/contrib/libxo/tests/xo/saved/xo_01.HP.out @@ -50,3 +50,27 @@ <div class="padding"> </div> <div class="data" data-tag="color">yellow</div> </div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo">1</div> +</div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo">1</div> +</div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo">1</div> +</div> + <div class="padding"> </div> +<div class="line"> + <div class="data" data-tag="address">0xdeadbeef</div> + <div class="text">..</div> + <div class="data" data-tag="foo">1</div> +</div> diff --git a/contrib/libxo/tests/xo/saved/xo_01.J.out b/contrib/libxo/tests/xo/saved/xo_01.J.out index 86ce4ef..7bf4226 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.J.out +++ b/contrib/libxo/tests/xo/saved/xo_01.J.out @@ -1 +1 @@ -"top": {"item": {"name":"one","value":1,"color":"red"}, "item": {"name":"two","value":2,"color":"blue"}, "item": {"name":"three","value":3,"color":"green"}, "item": {"name":"four","value":4,"color":"yellow"}} +"top": {"item": {"name":"one","value":1,"color":"red"}, "item": {"name":"two","value":2,"color":"blue"}, "item": {"name":"three","value":3,"color":"green"}, "item": {"name":"four","value":4,"color":"yellow"}, "anchor": {"address":"0xdeadbeef","foo":1}, "anchor": {"address":"0xdeadbeef","foo":1}, "anchor": {"address":"0xdeadbeef","foo":1}, "anchor": {"address":"0xdeadbeef","foo":1}} diff --git a/contrib/libxo/tests/xo/saved/xo_01.JP.out b/contrib/libxo/tests/xo/saved/xo_01.JP.out index 5a25b17..95ac0e2 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.JP.out +++ b/contrib/libxo/tests/xo/saved/xo_01.JP.out @@ -18,5 +18,21 @@ "name": "four", "value": 4, "color": "yellow" + }, + "anchor": { + "address": "0xdeadbeef", + "foo": 1 + }, + "anchor": { + "address": "0xdeadbeef", + "foo": 1 + }, + "anchor": { + "address": "0xdeadbeef", + "foo": 1 + }, + "anchor": { + "address": "0xdeadbeef", + "foo": 1 } } diff --git a/contrib/libxo/tests/xo/saved/xo_01.T.out b/contrib/libxo/tests/xo/saved/xo_01.T.out index ed2ea35..8b67427 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.T.out +++ b/contrib/libxo/tests/xo/saved/xo_01.T.out @@ -2,3 +2,7 @@ Item one is number 001, color: red Item two is number 002, color: blue Item three is number 003, color: green Item four is number 004, color: yellow + 0xdeadbeef..1 + 0xdeadbeef..1 + 0xdeadbeef..1 + 0xdeadbeef..1 diff --git a/contrib/libxo/tests/xo/saved/xo_01.X.out b/contrib/libxo/tests/xo/saved/xo_01.X.out index 7539566..ffe77fa 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.X.out +++ b/contrib/libxo/tests/xo/saved/xo_01.X.out @@ -1 +1 @@ -<top><item><name>one</name><value>1</value><color>red</color></item><item><name>two</name><value>2</value><color>blue</color></item><item><name>three</name><value>3</value><color>green</color></item><item><name>four</name><value>4</value><color>yellow</color></item></top>
\ No newline at end of file +<top><item><name>one</name><value>1</value><color>red</color></item><item><name>two</name><value>2</value><color>blue</color></item><item><name>three</name><value>3</value><color>green</color></item><item><name>four</name><value>4</value><color>yellow</color></item><anchor><address>0xdeadbeef</address><foo>1</foo></anchor><anchor><address>0xdeadbeef</address><foo>1</foo></anchor><anchor><address>0xdeadbeef</address><foo>1</foo></anchor><anchor><address>0xdeadbeef</address><foo>1</foo></anchor></top>
\ No newline at end of file diff --git a/contrib/libxo/tests/xo/saved/xo_01.XP.out b/contrib/libxo/tests/xo/saved/xo_01.XP.out index 7f069c8..a9d3951 100644 --- a/contrib/libxo/tests/xo/saved/xo_01.XP.out +++ b/contrib/libxo/tests/xo/saved/xo_01.XP.out @@ -19,4 +19,20 @@ <value>4</value> <color>yellow</color> </item> + <anchor> + <address>0xdeadbeef</address> + <foo>1</foo> + </anchor> + <anchor> + <address>0xdeadbeef</address> + <foo>1</foo> + </anchor> + <anchor> + <address>0xdeadbeef</address> + <foo>1</foo> + </anchor> + <anchor> + <address>0xdeadbeef</address> + <foo>1</foo> + </anchor> </top> diff --git a/contrib/libxo/tests/xo/xo_01.sh b/contrib/libxo/tests/xo/xo_01.sh index 8de9410..504f175 100755 --- a/contrib/libxo/tests/xo/xo_01.sh +++ b/contrib/libxo/tests/xo/xo_01.sh @@ -24,4 +24,10 @@ for i in one:1:red two:2:blue three:3:green four:4:yellow ; do NF=--not-first done -${XO} --close top
\ No newline at end of file +XOAN="${XO} --wrap anchor --not-first --warn --depth 1" +${XOAN} "{[:18}{:address/%p}..{:foo/%u}{]:}\n" 0xdeadbeef 1 +${XOAN} "{[:/18}{:address/%p}..{:foo/%u}{]:}\n" 0xdeadbeef 1 +${XOAN} "{[:/%d}{:address/%p}..{:foo/%u}{]:}\n" 18 0xdeadbeef 1 +${XOAN} "{[:/%s}{:address/%p}..{:foo/%u}{]:}\n" 18 0xdeadbeef 1 + +${XO} --close top diff --git a/contrib/libxo/xo/xo.1 b/contrib/libxo/xo/xo.1 index 54a97e7..55a6717 100644 --- a/contrib/libxo/xo/xo.1 +++ b/contrib/libxo/xo/xo.1 @@ -33,38 +33,38 @@ or .Em HTML using the same commands that emit text output. .Pp -.Bl -tag -width "12345678901234567" -.It Fl "-close <path>" +.Bl -tag -width indent +.It Ic --close Ar path Close tags for the given path -.It Fl "-depth <num>" +.It Ic --depth Ar num Set the depth for pretty printing -.It Fl "-help" -Display this help text -.It Fl "-html OR -H" +.It Ic --help +Display help text +.It Ic -H | Ic --html Generate HTML output -.It Fl "-json OR -J" +.It Ic -J | Ic --json Generate JSON output -.It Fl "-leading-xpath <path>" +.It Ic --leading-xpath Ar path Add a prefix to generated XPaths (HTML) -.It Fl "-open <path>" +.It Ic --open Ar path Open tags for the given path -.It Fl "-pretty OR -p" +.It Ic -p | Ic --pretty Make 'pretty' output (add indent, newlines) -.It Fl "-style <style>" +.It Ic --style Ar style Generate given style (xml, json, text, html) -.It Fl "-text OR -T" +.It Ic -T | Ic --text Generate text output (the default style) -.It Fl "-version" +.It Ic --version Display version information -.It Fl "-warn OR -W" +.It Ic -W | Ic --warn Display warnings in text on stderr -.It Fl "-warn-xml" +.It Ic --warn-xml Display warnings in xml on stdout -.It Fl "-wrap <path>" +.It Ic --wrap Ar path Wrap output in a set of containers -.It Fl "-xml OR -X" +.It Ic -X | Ic --xml Generate XML output -.It Fl "-xpath" +.It Ic --xpath Add XPath data to HTML output .El .Pp @@ -73,9 +73,32 @@ The utility accepts a format string suitable for .Xr xo_emit 3 and a set of zero or more arguments used to supply data for that string. +.Pp +In addition, +.Nm +accepts any of the +.Nm libxo +options listed in +.Xr xo_options 7 . +.Sh EXAMPLES +In this example, +.Nm +is used to emit the same data encoded in text and then in XML by +adding the "-p" (pretty) and "-X" (XML output) flags: .Bd -literal -offset indent - xo "The {k:name} weighs {:weight/%d} pounds.\\n" fish 6 - + % xo 'The {:product} is {:status}\\n' stereo "in route" + The stereo is in route + % xo -p -X 'The {:product} is {:status}\\n' stereo "in route" + <product>stereo</product> + <status>in route</status> +.Ed +.Pp +In this example, the output from a +.Nm +command is shown in several styles: +.Bd -literal -offset indent + xo "The {k:name} weighs {:weight/%d} pounds.\\n" fish 6 +.Pp TEXT: The fish weighs 6 pounds. XML: @@ -101,8 +124,8 @@ specific hierarchy. The path is a set of hierarchical names separated by the '/' character. .Bd -literal -offset indent - xo --wrap top/a/b/c '{:tag}' value - + xo --wrap top/a/b/c '{:tag}' value +.Pp XML: <top> <a> @@ -143,10 +166,11 @@ The may be used to prepend data to the XPath values used for HTML output style. .Bd -literal -offset indent - #!/bin/sh - xo --open top/data - xo --depth 2 '{tag}' value - xo --close top/data + #!/bin/sh + xo --open top/data + xo --depth 2 '{tag}' value + xo --close top/data +.Pp XML: <top> <data> @@ -160,14 +184,17 @@ prepend data to the XPath values used for HTML output style. } } .Ed -.Sh EXAMPLE -.Bd -literal - % xo 'The {:product} is {:status}\n' stereo "in route" - The stereo is in route - % xo -p -X 'The {:product} is {:status}\n' stereo "in route" - <product>stereo</product> - <status>in route</status> -.Ed .Sh SEE ALSO .Xr libxo 3 , -.Xr xo_emit 3 +.Xr xo_emit 3 , +.Xr xo_options 7 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/xo/xo.c b/contrib/libxo/xo/xo.c index ce758af..e48d2f8 100644 --- a/contrib/libxo/xo/xo.c +++ b/contrib/libxo/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 */ diff --git a/contrib/libxo/xohtml/xohtml.1 b/contrib/libxo/xohtml/xohtml.1 index 723225b..7ae12dd 100644 --- a/contrib/libxo/xohtml/xohtml.1 +++ b/contrib/libxo/xohtml/xohtml.1 @@ -16,11 +16,11 @@ .Xr xo_emit 3 .Sh SYNOPSIS .Nm xohtml -.Op Fl c .Op Fl "b <base>" .Op Fl "c" <command>" .Op Fl "f" <output> -.Op Ar command argument... +.Op Fl "w" +.Op Ar command [argument ...] .Sh DESCRIPTION .Nm is a tool for preparing @@ -53,26 +53,29 @@ will add the "--libxo=html" option needed to generate HTML output from .Nm libxo "-enabled" applications. See -.Xr libxo 3 +.Xr xo_options 7 for details. .Pp The following options are available: .Bl -tag -width indent -.It Fl "b <base>" -.It Fl "-base <base>" +.It Ic -b Ar base | Ic --base Ar base Supplies a source path for the CSS and Javascript files referenced in the output of .Nm xohtml . -.It Fl "c <command>" -.It Fl "-command <command>" +.It Ic -c Ar command | Ic --command Ar command Use the given command instead of one on the command line. This command should be quoted if it consists of multiple tokens, and should contain the "--libxo=html" option or equivalent, since the command is used directly. -.It Fl "f <file>" -.It Fl "-file <file>" +.It Ic -f Ar file | Ic --file Ar file Output is saved to the given file, rather than to the standard output descriptor. +.It Ic -w | --web +Uses the official +.Nm libxo +website URL as the source path for the CSS and Javascript files +referenced in the output of +.Nm xohtml . .El .Pp .Sh EXAMPLES @@ -96,4 +99,5 @@ the output to /tmp/src.html: .Pp .Sh SEE ALSO .Xr libxo 3 , -.Xr xo_emit 3 +.Xr xo_emit 3 , +.Xr xo_options 7 diff --git a/contrib/libxo/xohtml/xohtml.css b/contrib/libxo/xohtml/xohtml.css index fc9ea06..67c3bff 100644 --- a/contrib/libxo/xohtml/xohtml.css +++ b/contrib/libxo/xohtml/xohtml.css @@ -124,7 +124,7 @@ div.muxer-buttons { padding: 20px; } -div.text, div.decoration, div.data, div.header, div.pad, div.item { +div.text, div.decoration, div.data, div.header, div.pad, div.item, div.units { font-family: monospace; display: inline; vertical-align: middle; diff --git a/contrib/libxo/xohtml/xohtml.sh.in b/contrib/libxo/xohtml/xohtml.sh.in index a15d82e..aeb5d7b 100644 --- a/contrib/libxo/xohtml/xohtml.sh.in +++ b/contrib/libxo/xohtml/xohtml.sh.in @@ -10,8 +10,10 @@ # BASE=@XO_SHAREDIR@ +VERSION=@LIBXO_VERSION@ CMD=cat DONE= +WEB=http://juniper.github.io/libxo/${VERSION}/xohtml do_help () { echo "xohtml: wrap libxo-enabled output in HTML" @@ -41,6 +43,11 @@ while [ -z "$DONE" -a ! -z "$1" ]; do shift; exec > "$FILE"; ;; + -w|--web) + shift; + BASE="${WEB}"; + ;; + -*) do_help ;; @@ -57,7 +64,8 @@ if [ "$CMD" = "cat" -a -t 0 ]; then do_help fi -echo "<html>\n<head>\n" +echo '<html>' +echo '<head>' echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>' echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">' echo '<link rel="stylesheet" href="'$BASE'/external/jquery.qtip.css"/>' @@ -66,10 +74,12 @@ echo '<script type="text/javascript" src="'$BASE'/external/jquery.qtip.js"></scr echo '<script type="text/javascript" src="'$BASE'/xohtml.js"></script>' echo '<script>' echo '</script>' -echo "</head>\n<body>\n" +echo '</head>' +echo '<body>' $CMD -echo "</body>\n</html>\n" +echo '</body>' +echo '</html>' exit 0 diff --git a/contrib/libxo/xolint/xolint.1 b/contrib/libxo/xolint/xolint.1 index 11b5975..247536f 100644 --- a/contrib/libxo/xolint/xolint.1 +++ b/contrib/libxo/xolint/xolint.1 @@ -77,3 +77,13 @@ line that contains the error: .Sh SEE ALSO .Xr libxo 3 , .Xr xo_emit 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/xopo/xopo.1 b/contrib/libxo/xopo/xopo.1 index c1a9ae8..1634202 100644 --- a/contrib/libxo/xopo/xopo.1 +++ b/contrib/libxo/xopo/xopo.1 @@ -53,18 +53,18 @@ output stream, allowing .Nm to operated as a filter. .Pp -.Bl -tag -width "12345678901234567" -.It Fl "-simplify OR -s <text>" -Generate the simplified version of a single text string. -.It Fl "-po OR -f <pofile>" +.Bl -tag -width indent +.It Ic -f Ar pofile | Ic --po Ar pofile Use the given po file for input. -.It Fl "-help" +.It Ic --help Display this help text -.It Fl "-output OR -o <file>" +.It Ic -o Ar file | Ic --output Ar file Write output content to the given file -.It Fl "-warn OR -W" +.It Ic -s Ar text | Ic --simplify Ar text +Generate the simplified version of a single text string. +.It Ic -W | Ic --warn Generate warnings while parsing the format strings -.It Fl "-version" +.It Ic --version Display version information .El .Pp @@ -75,3 +75,13 @@ Display version information .Sh SEE ALSO .Xr libxo 3 , .Xr xo_format 5 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/contrib/libxo/xopo/xopo.c b/contrib/libxo/xopo/xopo.c index 991b757..d802e9d 100644 --- a/contrib/libxo/xopo/xopo.c +++ b/contrib/libxo/xopo/xopo.c @@ -114,7 +114,6 @@ static struct option long_opts[] = { int main (int argc UNUSED, char **argv) { - char *fmt = NULL; char *opt_options = NULL; char *opt_input = NULL; char *opt_output = NULL; @@ -189,10 +188,8 @@ main (int argc UNUSED, char **argv) xo_errx(1, "invalid options: %s", opt_options); } - fmt = *argv++; - if (opt_simplify) { - fmt = xo_simplify_format(NULL, opt_simplify, opt_numbers, NULL); + char *fmt = xo_simplify_format(NULL, opt_simplify, opt_numbers, NULL); if (fmt) { xo_emit("{:format}\n", fmt); free(fmt); |