From owner-svn-src-all@freebsd.org Fri Apr 15 18:03:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 285E0AED685; Fri, 15 Apr 2016 18:03:32 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ACAF218D8; Fri, 15 Apr 2016 18:03:31 +0000 (UTC) (envelope-from phil@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3FI3UXJ028536; Fri, 15 Apr 2016 18:03:30 GMT (envelope-from phil@FreeBSD.org) Received: (from phil@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3FI3UXE028532; Fri, 15 Apr 2016 18:03:30 GMT (envelope-from phil@FreeBSD.org) Message-Id: <201604151803.u3FI3UXE028532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: phil set sender to phil@FreeBSD.org using -f From: Phil Shafer Date: Fri, 15 Apr 2016 18:03:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r298077 - in vendor/Juniper/libxo/dist: . doc encoder/cbor libxo packaging tests/core tests/core/saved tests/gettext X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2016 18:03:32 -0000 Author: phil Date: Fri Apr 15 18:03:30 2016 New Revision: 298077 URL: https://svnweb.freebsd.org/changeset/base/298077 Log: Import libxo 0.6.0 Added: vendor/Juniper/libxo/dist/libxo/xo_emit_f.3 (contents, props changed) vendor/Juniper/libxo/dist/tests/core/saved/test_12.E.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.E.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.H.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.H.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.HIPx.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.HIPx.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.HP.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.HP.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.J.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.J.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.JP.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.JP.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.T.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.T.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.X.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.X.out vendor/Juniper/libxo/dist/tests/core/saved/test_12.XP.err vendor/Juniper/libxo/dist/tests/core/saved/test_12.XP.out vendor/Juniper/libxo/dist/tests/core/test_12.c (contents, props changed) Modified: vendor/Juniper/libxo/dist/Makefile.am vendor/Juniper/libxo/dist/configure.ac vendor/Juniper/libxo/dist/doc/libxo-manual.html vendor/Juniper/libxo/dist/doc/libxo.txt vendor/Juniper/libxo/dist/encoder/cbor/enc_cbor.c vendor/Juniper/libxo/dist/libxo-config.in vendor/Juniper/libxo/dist/libxo/libxo.c vendor/Juniper/libxo/dist/libxo/xo.h vendor/Juniper/libxo/dist/libxo/xo_format.5 vendor/Juniper/libxo/dist/libxo/xo_parse_args.3 vendor/Juniper/libxo/dist/packaging/libxo.pc.in vendor/Juniper/libxo/dist/packaging/libxo.rb.base.in vendor/Juniper/libxo/dist/tests/core/Makefile.am vendor/Juniper/libxo/dist/tests/core/saved/test_01.E.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.H.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.HIPx.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.HP.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.J.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.JP.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.T.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.X.out vendor/Juniper/libxo/dist/tests/core/saved/test_01.XP.out vendor/Juniper/libxo/dist/tests/core/test_01.c vendor/Juniper/libxo/dist/tests/core/test_02.c vendor/Juniper/libxo/dist/tests/gettext/gt_01.c Modified: vendor/Juniper/libxo/dist/Makefile.am ============================================================================== --- vendor/Juniper/libxo/dist/Makefile.am Fri Apr 15 17:45:12 2016 (r298076) +++ vendor/Juniper/libxo/dist/Makefile.am Fri Apr 15 18:03:30 2016 (r298077) @@ -77,6 +77,7 @@ GH_PAGES_PACKAGE_DIR = ${GH_PAGES_DIR}/$ packages: @-[ -d ${GH_PAGES_DIR} ] && set -x \ && echo "Updating packages on gh-pages ..." \ + && mkdir -p ${GH_PAGES_DIR}/${GH_PACKAGING_DIR} \ && SHA1="`openssl sha1 ${PACKAGE_FILE} | awk '{print $$2}'`" \ && SHA256="`openssl sha256 ${PACKAGE_FILE} | awk '{print $$2}'`" \ && SIZE="`ls -l ${PACKAGE_FILE} | awk '{print $$5}'`" \ Modified: vendor/Juniper/libxo/dist/configure.ac ============================================================================== --- vendor/Juniper/libxo/dist/configure.ac Fri Apr 15 17:45:12 2016 (r298076) +++ vendor/Juniper/libxo/dist/configure.ac Fri Apr 15 18:03:30 2016 (r298077) @@ -12,7 +12,7 @@ # AC_PREREQ(2.2) -AC_INIT([libxo], [0.4.7], [phil@juniper.net]) +AC_INIT([libxo], [0.5.0], [phil@juniper.net]) AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability]) # Support silent build rules. Requires at least automake-1.11. @@ -74,6 +74,7 @@ AC_CHECK_HEADERS([ctype.h errno.h stdio. AC_CHECK_HEADERS([string.h sys/param.h unistd.h ]) AC_CHECK_HEADERS([sys/sysctl.h]) AC_CHECK_HEADERS([threads.h]) +AC_CHECK_HEADERS([monitor.h]) dnl humanize_number(3) is a great function, but it's not standard. dnl Note Macosx has the function in libutil.a but doesn't ship the @@ -148,10 +149,18 @@ fi AC_SUBST(GETTEXT_CFLAGS) AC_SUBST(GETTEXT_LIBS) -GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin -AC_SUBST(GETTEXT_BINDIR) GETTEXT_LIBDIR=${GETTEXT_PREFIX}/lib AC_SUBST(GETTEXT_LIBDIR) +if test -x ${GETTEXT_PREFIX}/bin/msgfmt ; then + GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin +elif test -x ${GETTEXT_PREFIX}/local/bin/msgfmt ; then + GETTEXT_BINDIR=${GETTEXT_PREFIX}/local/bin +else + AC_MSG_NOTICE("could not find msgfmt tool") + # Use a (bad) fall back value + GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin +fi +AC_SUBST(GETTEXT_BINDIR) AM_CONDITIONAL([HAVE_GETTEXT], [test "$HAVE_GETTEXT" = "yes"]) @@ -287,6 +296,18 @@ if test "${LIBXO_WCWIDTH}" != "no"; then AC_DEFINE([LIBXO_WCWIDTH], [1], [Enable local wcwidth implementation]) fi +AC_MSG_CHECKING([retain hash bucket size]) +AC_ARG_WITH(retain-size, + [ --with-retain-size=[DIR] Specify retain hash bucket size (in bits)], + [XO_RETAIN_SIZE=$withval], + [XO_RETAIN_SIZE=default] +) + +AC_MSG_RESULT([$XO_RETAIN_SIZE]) +if test "${XO_RETAIN_SIZE}" != "default"; then + AC_DEFINE_UNQUOTED([XO_RETAIN_SIZE], ${XO_RETAIN_SIZE}, [Retain hash bucket size]) +fi + AC_CHECK_LIB([m], [lrint]) AM_CONDITIONAL([HAVE_LIBM], [test "$HAVE_LIBM" != "no"]) @@ -347,12 +368,15 @@ XO_SRCDIR=${srcdir} XO_LIBDIR=${libdir} XO_BINDIR=${bindir} XO_INCLUDEDIR=${includedir} +XO_CFLAGS="${CFLAGS}" +AC_SUBST(XO_LIBS) AC_SUBST(XO_SRCDIR) AC_SUBST(XO_LIBDIR) AC_SUBST(XO_BINDIR) AC_SUBST(XO_INCLUDEDIR) AC_SUBST(XO_LIBEXT) +AC_SUBST(XO_CFLAGS) AC_ARG_WITH(encoder-dir, [ --with-encoder-dir=[DIR] Specify location of encoder libraries], @@ -449,4 +473,5 @@ AC_MSG_NOTICE([summary of build options: isthreaded: ${HAVE_ISTHREADED:-no} thread-local: ${THREAD_LOCAL:-no} local wcwidth: ${LIBXO_WCWIDTH:-no} + retain size: ${XO_RETAIN_SIZE:-no} ]) Modified: vendor/Juniper/libxo/dist/doc/libxo-manual.html ============================================================================== --- vendor/Juniper/libxo/dist/doc/libxo-manual.html Fri Apr 15 17:45:12 2016 (r298076) +++ vendor/Juniper/libxo/dist/doc/libxo-manual.html Fri Apr 15 18:03:30 2016 (r298077) @@ -515,7 +515,7 @@ li.indline1 { } @top-right { - content: "December 2015"; + content: "April 2016"; } @top-center { @@ -22009,7 +22009,7 @@ jQuery(function ($) { -December 30, 2015 +April 15, 2016

libxo: The Easy Way to Generate text, XML, JSON, and HTML output
libxo-manual

@@ -22130,46 +22130,54 @@ jQuery(function ($) { Field Modifiers @@ -22208,42 +22216,38 @@ jQuery(function ($) {
  • 2.2.11   
    +Retaining Parsed Format Information +
  • +
  • +
    2.2.12   
    Example
  • 2.3   
    -Command-line Arguments -
  • -
  • -
    2.4   
    Representing Hierarchy
  • -
    2.5   
    -Handles -
  • -
  • -
    2.6   
    -UTF-8 +
    2.4   
    +Command-line Arguments
  • @@ -22252,7 +22256,7 @@ jQuery(function ($) { The libxo API
    • 3.1   
      -Handles
        +Handles

        @@ -23356,6 +23363,11 @@ jQuery(function ($) { +a +argument +The content appears as a 'const char *' argument + + c colon A colon (":") is appended after the label @@ -23435,87 +23447,107 @@ jQuery(function ($) {

        Roles and modifiers can also use more verbose names, when preceeded 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.

        Section Contents:

        -The Colon Modifier ({c:}) +The Argument Modifier ({a:})

        -

        The colon modifier appends a single colon to the data value:

        +

        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.

             EXAMPLE:
        -      xo_emit("{Lc:Name}{:name}\n", "phil");
        +      xo_emit("{La:} {a:}\n", "Label text", "label", "value");
             TEXT:
        -      Name:phil
        -	    

        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.

        + Label text value + JSON: + "label": "value" + XML: + <label>value</label> +

        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}".

        -The Display Modifier ({d:}) +The Colon Modifier ({c:})

        -

        The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.

        +

        The colon modifier appends a single colon to the data value:

             EXAMPLE:
        +      xo_emit("{Lc:Name}{:name}\n", "phil");
        +    TEXT:
        +      Name:phil
        +	    

        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.

        +
        +
        +

        + +The Display Modifier ({d:}) +

        +

        The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.

        +
        +    EXAMPLE:
               xo_emit("{Lcw:Name}{d:name} {:id/%d}\n", "phil", 1);
             TEXT:
               Name: phil 1
             XML:
               <id>1</id>
        -	    

        The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data.

        +

        The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data.

        -

        +

        +2.2.2.4 

        The Encoding Modifier ({e:})

        -

        The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.

        -
        +

        The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.

        +
             EXAMPLE:
               xo_emit("{Lcw:Name}{:name} {e:id/%d}\n", "phil", 1);
             TEXT:
               Name: phil
             XML:
               <name>phil</name><id>1</id>
        -	    

        The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data.

        +

        The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data.

        -

        +

        +2.2.2.5 

        The Gettext Modifier ({g:}) -

        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.

        -

        In the following example, the strings "State" and "full" are passed to gettext() to find locale-based translated strings.

        -
        +

        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.

        +

        In the following example, the strings "State" and "full" are passed to gettext() to find locale-based translated strings.

        +
             xo_emit("{Lgwc:State}{g:state}\n", "full");
        -	    

        See Section 2.2.1.3, Section 2.2.2.9, and Section 9.5 for additional details.

        +

        See Section 2.2.1.3, Section 2.2.2.10, and Section 9.5 for additional details.

        -

        +

        +2.2.2.6 

        The Humanize Modifier ({h:}) -

        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.

        -

        "hn" can be used as an alias for "humanize".

        -

        The humanize modifier only affects display styles (TEXT and HMTL). The "no‑humanize" option (See Section 3.4.6) will block the function of the humanize modifier.

        -

        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.

        -
        +

        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.

        +

        "hn" can be used as an alias for "humanize".

        +

        The humanize modifier only affects display styles (TEXT and HMTL). The "no‑humanize" option (See Section 3.4.6) will block the function of the humanize modifier.

        +

        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.

        +
             EXAMPLE:
                 xo_emit("{h:input/%u}, {h,hn-space:output/%u}, "
                     "{h,hn-decimal:errors/%u}, {h,hn-1000:capacity/%u}, "
        @@ -23523,19 +23555,19 @@ jQuery(function ($) {
                     input, output, errors, capacity, remaining);
             TEXT:
                 21, 57 K, 96M, 44M, 1.2G
        -	    

        In the HTML style, the original numeric value is rendered in the "data‑number" attribute on the <div> element:

        -
        +	    

        In the HTML style, the original numeric value is rendered in the "data‑number" attribute on the <div> element:

        +
             <div class="data" data-tag="errors"
                  data-number="100663296">96M</div>
         	    
        -

        +

        +2.2.2.7 

        The Key Modifier ({k:}) -

        The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data.

        -
        +

        The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data.

        +
             EXAMPLE:
                 xo_open_list("user");
                 for (i = 0; i < num_users; i++) {
        @@ -23545,16 +23577,16 @@ jQuery(function ($) {
                     xo_close_instance("user");
                 }
                 xo_close_list("user");
        -	    

        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.

        +

        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.

        -

        +

        +2.2.2.8 

        The Leaf-List Modifier ({l:}) -

        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.

        -
        +

        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.

        +
             EXAMPLE:
                 for (i = 0; i < num_users; i++) {
                     xo_emit("Member {l:user}\n", user[i].u_name);
        @@ -23564,16 +23596,16 @@ jQuery(function ($) {
                 <user>pallavi</user>
             JSON:
                 "user": [ "phil", "pallavi" ]
        -	    

        The name of the field must match the name of the leaf list.

        +

        The name of the field must match the name of the leaf list.

        -

        +

        +2.2.2.9 

        The No-Quotes Modifier ({n:}) -

        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.

        -
        +

        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.

        +
             EXAMPLE:
               const char *bool = is_true ? "true" : "false";
               xo_emit("{n:fancy/%s}", bool);
        @@ -23581,45 +23613,61 @@ jQuery(function ($) {
               "fancy": true
         	    
        -

        +

        +2.2.2.10 

        The Plural Modifier ({p:}) -

        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:

        -
        +

        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:

        +
             xo_emit("{:bytes} {Ngp:byte,bytes}\n", bytes);
        -	    

        The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. See Section 2.2.2.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.

        -

        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.

        +

        The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. See Section 2.2.2.5.

        +

        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.

        +

        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.

        -

        +

        +2.2.2.11 

        The Quotes Modifier ({q:}) -

        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.

        -
        +

        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.

        +
             EXAMPLE:
               xo_emit("{q:time/%d}", 2014);
             JSON:
               "year": "2014"
        +	    

        The heuristic is based on the format; if the format uses any of the following conversion specifiers, then no quotes are used:

        +
        +    d i o u x X D O U e E f F g G a A c C p
         	    
        -

        +

        +2.2.2.12 

        +The Trim Modifier ({t:}) + +

        The trim modifier removes any leading or trailing whitespace from the value.

        +
        +    EXAMPLE:
        +      xo_emit("{t:description}", "   some  input   ");
        +    JSON:
        +      "description": "some input"
        +	    
        +
        +

        + The White Space Modifier ({w:})

        -

        The white space modifier appends a single space to the data value:

        -
        +

        The white space modifier appends a single space to the data value:

        +
             EXAMPLE:
               xo_emit("{Lw:Name}{:name}\n", "phil");
             TEXT:
               Name phil
        -	    

        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.

        -

        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.

        +

        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.

        +

        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.

        @@ -23632,7 +23680,7 @@ jQuery(function ($) {

        If the format string is not provided for a value field, it defaults to "%s".

        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.

        The format string has the form:

        -
        +
           '%' format-modifier * format-character
         	    

        The format- modifier can be:

        @@ -23829,8 +23877,42 @@ jQuery(function ($) { UTF-8 and Locale Strings

        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".

        -

        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.

        -
        +

        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}",
        +           L"except for wide strings");
        +	    

        "%S" is equivalent to "%ls".

        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        FormatArgument TypeArgument Contents
        %sconst char *UTF-8 string
        %Sconst char *UTF-8 string (alias for '%s')
        %lsconst wchar_t *Wide character UNICODE string
        %hsconst char *locale-based string
        +

        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.

        +
             void print_order (const char *name, int size,
                               struct tm *timep) {
                 char buf[32];
        @@ -23849,10 +23931,10 @@ jQuery(function ($) {
                 xo_emit("It was ordered on {:order-time/%ls}.\n",
                         when);
             }
        -	    

        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.

        -

        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.

        -

        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.

        -
        +	    

        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.

        +

        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.

        +

        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.

        +
             xo_emit("{:name/%3.10.6s}", name);
         	    
        @@ -23862,7 +23944,7 @@ jQuery(function ($) { Characters Outside of Field Definitions

        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".

        -
        +
           EXAMPLE:
               xo_emit("The hat is {:size/%s}.\n", size_val);
           TEXT:
        @@ -23883,7 +23965,7 @@ jQuery(function ($) {
         "%m" Is Supported
         
         

        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).

        -
        +
             xo_emit("{:filename} cannot be opened: {:error/%m}", filename);
             xo_emit("{:filename} cannot be opened: {:error/%s}",
                     filename, strerror(errno));
        @@ -23930,7 +24012,7 @@ jQuery(function ($) {
         
      • distinct encoding formats, where "{:tag/#%s/%s}" means the display styles (text and HTML) will use "#%s" where other styles use "%s";

      If none of these features are in use by your code, then using the "_p" variants might be wise.

      -
      +
      @@ -23987,14 +24069,71 @@ jQuery(function ($) {

      +Retaining Parsed Format Information +

      +

      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.

      +
      +    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);
      +	    

      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):

      +
      Function printf-like Equivalent
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      FunctionFlags Equivalent
      xo_emit_hvxo_emit_hvf
      xo_emit_hxo_emit_hf
      xo_emitxo_emit_f
      xo_emit_hvpxo_emit_hvfp
      xo_emit_hpxo_emit_hfp
      xo_emit_pxo_emit_fp
      +

      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.

      +

      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.

      +
      +    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);
      +	    

      The retained information is kept as thread-specific data.

      + +
      +

      +
      +2.2.12 
      Example

      -

      In this example, the value for the number of items in stock is emitted:

      -
      +

      In this example, the value for the number of items in stock is emitted:

      +
               xo_emit("{P:   }{Lwc:In stock}{:in-stock/%u}\n",
                       instock);
      -	    

      This call will generate the following output:

      -
      +	    

      This call will generate the following output:

      +
         TEXT: 
              In stock: 144
         XML:
      @@ -24009,8 +24148,8 @@ jQuery(function ($) {
               <div class="padding"> </div>
               <div class="data" data-tag="in-stock">144</div>
             </div>
      -	    

      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:

      -
      +	    

      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:

      +
              <div class="data" data-tag="in-stock"
                 data-xpath="/top/data/item/in-stock"
                 data-type="number"
      @@ -24021,17 +24160,148 @@ jQuery(function ($) {
       

      2.3 
      +Representing Hierarchy +

      +

      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.

      +

      XML encodes lists as set of sequential elements:

      +
      +    <user>phil</user>
      +    <user>pallavi</user>
      +    <user>sjg</user>
      +	    

      JSON encodes lists using a single name and square brackets:

      +
      +    "user": [ "phil", "pallavi", "sjg" ]
      +	    

      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.

      +

      Section Contents:

      + +
      +

      +
      +2.3.1 
      +Containers +

      +

      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.

      +

      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.

      +
      +    int xo_open_container_h (xo_handle_t *xop, const char *name);
      +    int xo_open_container (const char *name);
      +	    

      To close a level, use the xo_close_container() or xo_close_container_h() functions:

      +
      +    int xo_close_container_h (xo_handle_t *xop, const char *name);
      +    int xo_close_container (const char *name);
      +	    

      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.

      +
      +    Example:
      +
      +        xo_open_container("top");
      +        xo_open_container("system");
      +        xo_emit("{:host-name/%s%s%s", hostname,
      +                domainname ? "." : "", domainname ?: "");
      +        xo_close_container("system");
      +        xo_close_container("top");
      +
      +    Sample Output:
      +      Text:
      +        my-host.example.org
      +      XML:
      +        <top>
      +          <system>
      +              <host-name>my-host.example.org</host-name>
      +          </system>
      +        </top>
      +      JSON:
      +        "top" : {
      +          "system" : {
      +              "host-name": "my-host.example.org"
      +          }
      +        }
      +      HTML:
      +        <div class="data"
      +             data-tag="host-name">my-host.example.org</div>
      +	    
      +
      +

      +
      +2.3.2 
      +Lists and Instances +

      +

      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:

      +
      +    xo_open_list("item");
      +
      +    for (ip = list; ip->i_title; ip++) {
      +        xo_open_instance("item");
      +        xo_emit("{L:Item} '{:name/%s}':\n", ip->i_title);
      +        xo_close_instance("item");
      +    }
      +
      +    xo_close_list("item");
      +	    

      Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.

      +
      +
      +

      +
      +2.3.3 
      +DTRT Mode +

      +

      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.

      +
      +    xo_set_flags(NULL, XOF_DTRT);
      +	    

      Each open and close function has a version with the suffix "_d", which will close the open container, list, or instance:

      +
      +    xo_open_container("top");
      +    ...
      +    xo_close_container_d();
      +	    

      This also works for lists and instances:

      +
      +    xo_open_list("item");
      +    for (...) {
      +        xo_open_instance("item");
      +        xo_emit(...);
      +        xo_close_instance_d();
      +    }
      +    xo_close_list_d();
      +	    

      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.

      +
      +
      +

      +
      +2.3.4 
      +Markers +

      +

      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.

      +

      Markers use names which are not user-visible, allowing the caller to choose appropriate internal names.

      +

      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.

      +
      +    for (i = 0; fish[i]; i++) {
      +        xo_open_instance("fish");
      +        xo_open_marker("fish-guts");
      +        dump_fish_details(i);
      +        xo_close_marker("fish-guts");
      +    }
      +	    
      +
      +
      +

      +
      +2.4 
      Command-line Arguments

      -

      libxo uses command line options to trigger rendering behavior. The following options are recognised:

      -

      +

      libxo uses command line options to trigger rendering behavior. The following options are recognised:

      +

      • --libxo <options>
      • --libxo=<options>
      • --libxo:<brief‑options>
      -

      Options is a comma-separated list of tokens that correspond to output styles, flags, or features:

      -
      +

      Programs using libxo are expecting to call the xo_parse_args function to parse these arguments. See Section 3.4.1 for details.

      +

      Options is a comma-separated list of tokens that correspond to output styles, flags, or features:

      +
      @@ -24082,6 +24352,10 @@ jQuery(function ($) { + + + + @@ -24094,6 +24368,10 @@ jQuery(function ($) { + + + + @@ -24123,165 +24401,7 @@ jQuery(function ($) {
      Token ActionDo not initialize the locale setting
      no-retainPrevent retaining formatting information
      no-top Do not emit a top set of braces (JSON)
      Emit pretty-printed output
      retainForce retaining formatting information
      text Emit TEXT output
      -

      The brief options are detailed in Section 3.4.6.

      -
      -
      -

      -
      -2.4 
      -Representing Hierarchy -

      -

      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.

      -

      XML encodes lists as set of sequential elements:

      -
      -    <user>phil</user>
      -    <user>pallavi</user>
      -    <user>sjg</user>
      -	    

      JSON encodes lists using a single name and square brackets:

      -
      -    "user": [ "phil", "pallavi", "sjg" ]
      -	    

      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.

      -

      Section Contents:

      - -
      -

      -
      -2.4.1 
      -Containers -

      -

      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.

      -

      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.

      -
      -    int xo_open_container_h (xo_handle_t *xop, const char *name);
      -    int xo_open_container (const char *name);
      -	    

      To close a level, use the xo_close_container() or xo_close_container_h() functions:

      -
      -    int xo_close_container_h (xo_handle_t *xop, const char *name);
      -    int xo_close_container (const char *name);
      -	    

      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.

      -
      -    Example:
      -
      -        xo_open_container("top");
      -        xo_open_container("system");
      -        xo_emit("{:host-name/%s%s%s", hostname,
      -                domainname ? "." : "", domainname ?: "");
      -        xo_close_container("system");
      -        xo_close_container("top");
      
      *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***