aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Shafer <phil@FreeBSD.org>2016-05-29 01:40:19 +0000
committerPhil Shafer <phil@FreeBSD.org>2016-05-29 01:40:19 +0000
commit302133f1d4a519b98134674e4d3086c0f77a07eb (patch)
tree0cab17fa056b6a5213477ab91e8059d0a0acd7bf
parente6f3e75ca44f549e316983e52c8f7697f4751fce (diff)
downloadsrc-302133f1d4a519b98134674e4d3086c0f77a07eb.tar.gz
src-302133f1d4a519b98134674e4d3086c0f77a07eb.zip
Import libxo 0.6.2vendor/Juniper/libxo/0.6.2
Notes
Notes: svn path=/vendor/Juniper/libxo/dist/; revision=300923 svn path=/vendor/Juniper/libxo/0.6.2/; revision=300924; tag=vendor/Juniper/libxo/0.6.2
-rw-r--r--configure.ac2
-rw-r--r--doc/libxo-manual.html12
-rw-r--r--doc/libxo.txt10
-rw-r--r--libxo/libxo.c30
-rw-r--r--libxo/xo_buf.h4
-rw-r--r--libxo/xo_encoder.c2
-rw-r--r--libxo/xo_format.54
-rw-r--r--tests/core/saved/test_03.E.out12
-rw-r--r--tests/core/saved/test_03.H.out2
-rw-r--r--tests/core/saved/test_03.HIPx.out34
-rw-r--r--tests/core/saved/test_03.HP.out34
-rw-r--r--tests/core/saved/test_03.J.out2
-rw-r--r--tests/core/saved/test_03.JP.out12
-rw-r--r--tests/core/saved/test_03.T.out4
-rw-r--r--tests/core/saved/test_03.X.out2
-rw-r--r--tests/core/saved/test_03.XP.out8
-rw-r--r--tests/core/test_03.c59
17 files changed, 195 insertions, 38 deletions
diff --git a/configure.ac b/configure.ac
index d1db4386ce4b..0ff0a6477a22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
-AC_INIT([libxo], [0.6.1], [phil@juniper.net])
+AC_INIT([libxo], [0.6.2], [phil@juniper.net])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
# Support silent build rules. Requires at least automake-1.11.
diff --git a/doc/libxo-manual.html b/doc/libxo-manual.html
index 4db374b394f5..0c042a47a418 100644
--- a/doc/libxo-manual.html
+++ b/doc/libxo-manual.html
@@ -515,7 +515,7 @@ li.indline1 {
}
@top-right {
- content: "April 2016";
+ content: "May 2016";
}
@top-center {
@@ -22009,7 +22009,7 @@ jQuery(function ($) {
</tr>
<tr>
<td class="header left"></td>
-<td class="header right">April 15, 2016</td>
+<td class="header right">May 28, 2016</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>
@@ -22739,7 +22739,7 @@ jQuery(function ($) {
make
make test
sudo make install
- </pre> <p id="doc_section_1_1_2_p_4">The following sections will walk thru each of these steps with additional details and options, but the above directions should be all that's needed.</p>
+ </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>
<ul>
<li><a href="#setting-up-the-build" title="Setting up the build">Section 1.1.2.1</a></li>
@@ -23087,7 +23087,7 @@ jQuery(function ($) {
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 preceeded by a comma:</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>
EXAMPLE:
xo_emit("{,label:Free}{,decoration::}{,padding: }"
@@ -23444,7 +23444,7 @@ 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 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.</p>
+<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>
<ul>
<li><a href="#the-argument-modifier-a" title="The Argument Modifier ({a:})">Section 2.2.2.1</a></li>
@@ -23688,7 +23688,7 @@ jQuery(function ($) {
<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 ('&#8209;'), indicating the output value should be padded on the right instead of the left.</li>
<li>a leading zero ('0') indicating the output value should be padded on the left with zeroes instead of spaces (' ').</li>
-<li>one or more digits ('0' - '9') indicating the minimum width of the argument. If the width in columns of the output value is less that the minumum width, the value will be padded to reach the minimum.</li>
+<li>one or more digits ('0' - '9') indicating the minimum width of the argument. If the width in columns of the output value is less than the minimum width, the value will be padded to reach the minimum.</li>
<li>a period followed by one or more digits indicating the maximum number of bytes which will be examined for a string argument, or the maximum width for a non-string argument. When handling ASCII strings this functions as the field width but for multi-byte characters, a single character may be composed of multiple bytes. xo_emit will never dereference memory beyond the given number of bytes.</li>
<li>a second period followed by one or more digits indicating the maximum width for a string argument. This modifier cannot be given for non-string arguments.</li>
<li>one or more 'h' characters, indicating shorter input data.</li>
diff --git a/doc/libxo.txt b/doc/libxo.txt
index ba63702920c5..4cd51cca5d57 100644
--- a/doc/libxo.txt
+++ b/doc/libxo.txt
@@ -155,7 +155,7 @@ explained in detail in the rest of this section.
make test
sudo make install
-The following sections will walk thru each of these steps with
+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.
@@ -469,7 +469,7 @@ content. The roles are listed below; only one role is permitted:
When a role is not provided, the "value" role is used as the default.
-Roles and modifiers can also use more verbose names, when preceeded by
+Roles and modifiers can also use more verbose names, when preceded by
a comma:
EXAMPLE:
@@ -720,7 +720,7 @@ particular output styles:
| w | white | A blank (" ") is appended after the label |
|---+---------------+--------------------------------------------------|
-Roles and modifiers can also use more verbose names, when preceeded by
+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
@@ -986,8 +986,8 @@ the right instead of the left.
- a leading zero ('0') indicating the output value should be padded on the
left with zeroes instead of spaces (' ').
- one or more digits ('0' - '9') indicating the minimum width of the
-argument. If the width in columns of the output value is less that
-the minumum width, the value will be padded to reach the minimum.
+argument. If the width in columns of the output value is less than
+the minimum width, the value will be padded to reach the minimum.
- a period followed by one or more digits indicating the maximum
number of bytes which will be examined for a string argument, or the maximum
width for a non-string argument. When handling ASCII strings this
diff --git a/libxo/libxo.c b/libxo/libxo.c
index 194a0962b428..7a714b1573d1 100644
--- a/libxo/libxo.c
+++ b/libxo/libxo.c
@@ -56,7 +56,7 @@
* (end of word, middle of word, etc) and many that affect characters
* previously emitted. Without content, it can't hope to tell us.
* But it's the only standard tool we've got, so we use it. We would
- * use wcswidth() but it typically just loops thru adding the results
+ * use wcswidth() but it typically just loops through adding the results
* of wcwidth() calls in an entirely unhelpful way.
*
* Even then, there are many poor implementations (macosx), so we have
@@ -97,7 +97,7 @@
/*
* Three styles of specifying thread-local variables are supported.
- * configure.ac has the brains to run each possibility thru the
+ * configure.ac has the brains to run each possibility through the
* compiler and see what works; we are left to define the THREAD_LOCAL
* macro to the right value. Most toolchains (clang, gcc) use
* "before", but some (borland) use "after" and I've heard of some
@@ -988,7 +988,7 @@ xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
}
/*
- * Print some data thru the handle.
+ * Print some data through the handle.
*/
static int
xo_printf_v (xo_handle_t *xop, const char *fmt, va_list vap)
@@ -1251,7 +1251,7 @@ xo_buf_append_locale (xo_handle_t *xop, xo_buffer_t *xbp,
cols += xo_buf_append_locale_from_utf8(xop, xbp, cp, slen);
- /* Next time thru, we'll start at the next character */
+ /* Next time through, we'll start at the next character */
cp += slen - 1;
sp = cp + 1;
}
@@ -2816,7 +2816,7 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
* but if we did the work ourselves, then we need to do it.
*/
int delta = xfp->xf_width[XF_WIDTH_MIN] - cols;
- if (!xo_buf_has_room(xbp, delta))
+ if (!xo_buf_has_room(xbp, xfp->xf_width[XF_WIDTH_MIN]))
goto bail;
/*
@@ -3328,7 +3328,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
case XO_STYLE_XML:
if (flags & XFF_TRIM_WS)
columns = rc = xo_trim_ws(xbp, rc);
- /* fall thru */
+ /* FALLTHRU */
case XO_STYLE_HTML:
rc = xo_escape_xml(xbp, rc, (flags & XFF_ATTR));
break;
@@ -3687,7 +3687,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
if (flags & XFF_ENCODE_ONLY) {
/*
- * Even if this is encode-only, we need to go thru the
+ * 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.
*/
@@ -5342,7 +5342,7 @@ xo_gettext_finish_numbering_fields (xo_handle_t *xop UNUSED,
}
/*
- * The format string uses field numbers, so we need to whiffle thru it
+ * The format string uses field numbers, so we need to whiffle through it
* and make sure everything's sane and lovely.
*/
static int
@@ -6128,6 +6128,12 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
XOIF_CLEAR(xop, XOIF_REORDER);
+ /*
+ * If we've got enough data, flush it.
+ */
+ if (xo_buf_offset(&xop->xo_data) > XO_BUF_HIGH_WATER)
+ flush = 1;
+
/* If we don't have an anchor, write the text out */
if (flush && !XOIF_ISSET(xop, XOIF_ANCHOR)) {
if (xo_write(xop) < 0)
@@ -6988,7 +6994,7 @@ xo_do_close_leaf_list (xo_handle_t *xop, const char *name)
case XO_STYLE_ENCODER:
rc = xo_encoder_handle(xop, XO_OP_CLOSE_LEAF_LIST, name, NULL);
- /*fallthru*/
+ /* FALLTHRU */
default:
xo_depth_change(xop, name, -1, 0, XSS_CLOSE_LEAF_LIST, XSF_LIST);
@@ -7780,9 +7786,9 @@ xo_parse_args (int argc, char **argv)
}
cp = argv[i] + sizeof(libxo_opt) - 1;
- if (*cp == 0) {
+ if (*cp == '\0') {
cp = argv[++i];
- if (cp == 0) {
+ if (cp == NULL) {
xo_warnx("missing libxo option");
return -1;
}
@@ -7879,7 +7885,7 @@ xo_set_version_h (xo_handle_t *xop, const char *version)
}
/*
- * Set the version number for the API content being carried thru
+ * Set the version number for the API content being carried through
* the xo handle.
*/
void
diff --git a/libxo/xo_buf.h b/libxo/xo_buf.h
index 349e9adefcc5..01eb397d37c4 100644
--- a/libxo/xo_buf.h
+++ b/libxo/xo_buf.h
@@ -19,8 +19,8 @@
#ifndef XO_BUF_H
#define XO_BUF_H
-#define XO_BUFSIZ (8*1024) /* Initial buffer size */
-
+#define XO_BUFSIZ (8*1024) /* Initial buffer size */
+#define XO_BUF_HIGH_WATER (XO_BUFSIZ - 512) /* When to auto-flush */
/*
* xo_buffer_t: a memory buffer that can be grown as needed. We
* use them for building format strings and output data.
diff --git a/libxo/xo_encoder.c b/libxo/xo_encoder.c
index 70195ecaa32e..eb2960bf7d9f 100644
--- a/libxo/xo_encoder.c
+++ b/libxo/xo_encoder.c
@@ -313,7 +313,7 @@ xo_encoder_init (xo_handle_t *xop, const char *name)
/*
* A couple of function varieties here, to allow for multiple
- * use cases. This varient is for when the main program knows
+ * use cases. This variant is for when the main program knows
* its own encoder needs.
*/
xo_handle_t *
diff --git a/libxo/xo_format.5 b/libxo/xo_format.5
index d0e6a33abbda..abd1b6f65c5f 100644
--- a/libxo/xo_format.5
+++ b/libxo/xo_format.5
@@ -116,7 +116,7 @@ The roles are listed below; only one role is permitted:
.Pp
When a role is not provided, the "value" role is used as the default.
.Pp
-Roles and modifiers can also use more verbose names, when preceeded by
+Roles and modifiers can also use more verbose names, when preceded by
a comma:
.Bd -literal -offset indent
EXAMPLE:
@@ -380,7 +380,7 @@ The modifier string "Vkq" means the
field has a value role, that it is a key for the current instance, and
that the value should be quoted when encoded for JSON.
.Pp
-Roles and modifiers can also use more verbose names, when preceeded by
+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)
diff --git a/tests/core/saved/test_03.E.out b/tests/core/saved/test_03.E.out
index 39657834bd23..c68081fb5e16 100644
--- a/tests/core/saved/test_03.E.out
+++ b/tests/core/saved/test_03.E.out
@@ -1,6 +1,18 @@
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]
diff --git a/tests/core/saved/test_03.H.out b/tests/core/saved/test_03.H.out
index 6b9ccc435b80..ff618972a3ef 100644
--- a/tests/core/saved/test_03.H.out
+++ b/tests/core/saved/test_03.H.out
@@ -1 +1 @@
-<div class="line"><div class="data" data-tag="first-name">Terry</div><div class="text"> </div><div class="data" data-tag="last-name">Jones</div><div class="text"> works in dept #</div><div class="data" data-tag="department">660</div></div><div class="line"><div class="data" data-tag="first-name">Leslie</div><div class="text"> </div><div class="data" data-tag="last-name">Patterson</div><div class="text"> works in dept #</div><div class="data" data-tag="department">341</div></div><div class="line"><div class="data" data-tag="first-name">Ashley</div><div class="text"> </div><div class="data" data-tag="last-name">Smith</div><div class="text"> works in dept #</div><div class="data" data-tag="department">1440</div></div> \ No newline at end of file
+<div class="line"><div class="text">[</div><div class="data" data-tag="extra"></div><div class="text">]</div></div><div class="line"><div class="title"> Type</div><div class="text"> </div><div class="title">InUse</div><div class="text"> </div><div class="title">MemUse</div><div class="text"> </div><div class="title">HighUse</div><div class="text"> </div><div class="title">Requests</div><div class="text"> </div><div class="title">Size(s)</div></div><div class="line"><div class="data" data-tag="type"> name</div><div class="text"> </div><div class="data" data-tag="in-use">12345</div><div class="text"> </div><div class="data" data-tag="memory-use">54321</div><div class="units">K</div><div class="text"> </div><div class="data" data-tag="high-use"> -</div><div class="text"> </div><div class="data" data-tag="requests"> 32145</div><div class="text"> </div></div><div class="line"><div class="data" data-tag="first-name">Terry</div><div class="text"> </div><div class="data" data-tag="last-name">Jones</div><div class="text"> works in dept #</div><div class="data" data-tag="department">660</div></div><div class="line"><div class="data" data-tag="first-name">Leslie</div><div class="text"> </div><div class="data" data-tag="last-name">Patterson</div><div class="text"> works in dept #</div><div class="data" data-tag="department">341</div></div><div class="line"><div class="data" data-tag="first-name">Ashley</div><div class="text"> </div><div class="data" data-tag="last-name">Smith</div><div class="text"> works in dept #</div><div class="data" data-tag="department">1440</div></div><div class="line"><div class="text">done</div></div> \ No newline at end of file
diff --git a/tests/core/saved/test_03.HIPx.out b/tests/core/saved/test_03.HIPx.out
index bfae221c7483..aaf867b6e87e 100644
--- a/tests/core/saved/test_03.HIPx.out
+++ b/tests/core/saved/test_03.HIPx.out
@@ -1,4 +1,35 @@
<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="extra" data-xpath="/employees/extra"></div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title"> Type</div>
+ <div class="text"> </div>
+ <div class="title">InUse</div>
+ <div class="text"> </div>
+ <div class="title">MemUse</div>
+ <div class="text"> </div>
+ <div class="title">HighUse</div>
+ <div class="text"> </div>
+ <div class="title">Requests</div>
+ <div class="text"> </div>
+ <div class="title">Size(s)</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="type" data-xpath="/employees/memory/type"> name</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="in-use" data-xpath="/employees/memory[type = 'name']/in-use">12345</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="memory-use" data-xpath="/employees/memory[type = 'name']/memory-use">54321</div>
+ <div class="units">K</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="high-use" data-xpath="/employees/memory[type = 'name']/high-use"> -</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="requests" data-xpath="/employees/memory[type = 'name']/requests"> 32145</div>
+ <div class="text"> </div>
+</div>
+<div class="line">
<div class="data" data-tag="first-name" data-xpath="/employees/employee/first-name" data-type="string" data-help="First name of employee">Terry</div>
<div class="text"> </div>
<div class="data" data-tag="last-name" data-xpath="/employees/employee/last-name" data-type="string" data-help="Last name of employee">Jones</div>
@@ -19,3 +50,6 @@
<div class="text"> works in dept #</div>
<div class="data" data-tag="department" data-xpath="/employees/employee/department">1440</div>
</div>
+<div class="line">
+ <div class="text">done</div>
+</div>
diff --git a/tests/core/saved/test_03.HP.out b/tests/core/saved/test_03.HP.out
index f8b072a3c24b..2e476fbb78ee 100644
--- a/tests/core/saved/test_03.HP.out
+++ b/tests/core/saved/test_03.HP.out
@@ -1,4 +1,35 @@
<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="extra"></div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title"> Type</div>
+ <div class="text"> </div>
+ <div class="title">InUse</div>
+ <div class="text"> </div>
+ <div class="title">MemUse</div>
+ <div class="text"> </div>
+ <div class="title">HighUse</div>
+ <div class="text"> </div>
+ <div class="title">Requests</div>
+ <div class="text"> </div>
+ <div class="title">Size(s)</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="type"> name</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="in-use">12345</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="memory-use">54321</div>
+ <div class="units">K</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="high-use"> -</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="requests"> 32145</div>
+ <div class="text"> </div>
+</div>
+<div class="line">
<div class="data" data-tag="first-name">Terry</div>
<div class="text"> </div>
<div class="data" data-tag="last-name">Jones</div>
@@ -19,3 +50,6 @@
<div class="text"> works in dept #</div>
<div class="data" data-tag="department">1440</div>
</div>
+<div class="line">
+ <div class="text">done</div>
+</div>
diff --git a/tests/core/saved/test_03.J.out b/tests/core/saved/test_03.J.out
index 4ba1fb1772d8..00a53016dc86 100644
--- a/tests/core/saved/test_03.J.out
+++ b/tests/core/saved/test_03.J.out
@@ -1,2 +1,2 @@
-{"employees": {"employee": [{"first-name":"Terry","last-name":"Jones","department":660}, {"first-name":"Leslie","last-name":"Patterson","department":341}, {"first-name":"Ashley","last-name":"Smith","department":1440}]}
+{"employees": {"employee": [],"extra":"", "memory": [{"type":"name","in-use":12345,"memory-use":54321,"high-use":"-","requests":32145}], "employee": [{"first-name":"Terry","last-name":"Jones","department":660}, {"first-name":"Leslie","last-name":"Patterson","department":341}, {"first-name":"Ashley","last-name":"Smith","department":1440}]}
}
diff --git a/tests/core/saved/test_03.JP.out b/tests/core/saved/test_03.JP.out
index ff2d5b033dda..a62f47ecde34 100644
--- a/tests/core/saved/test_03.JP.out
+++ b/tests/core/saved/test_03.JP.out
@@ -1,6 +1,18 @@
{
"employees": {
"employee": [
+ ],
+ "extra": "",
+ "memory": [
+ {
+ "type": "name",
+ "in-use": 12345,
+ "memory-use": 54321,
+ "high-use": "-",
+ "requests": 32145
+ }
+ ],
+ "employee": [
{
"first-name": "Terry",
"last-name": "Jones",
diff --git a/tests/core/saved/test_03.T.out b/tests/core/saved/test_03.T.out
index da60fb7c9ab3..90486fb3c3d2 100644
--- a/tests/core/saved/test_03.T.out
+++ b/tests/core/saved/test_03.T.out
@@ -1,3 +1,7 @@
+[]
+ Type InUse MemUse HighUse Requests Size(s)
+ name 12345 54321K - 32145
Terry Jones works in dept #660
Leslie Patterson works in dept #341
Ashley Smith works in dept #1440
+done
diff --git a/tests/core/saved/test_03.X.out b/tests/core/saved/test_03.X.out
index a626fb6679d9..279e359d5f60 100644
--- a/tests/core/saved/test_03.X.out
+++ b/tests/core/saved/test_03.X.out
@@ -1 +1 @@
-<employees><employee><first-name>Terry</first-name><last-name>Jones</last-name><department>660</department></employee><employee><first-name>Leslie</first-name><last-name>Patterson</last-name><department>341</department></employee><employee><first-name>Ashley</first-name><last-name>Smith</last-name><department>1440</department></employee></employees> \ No newline at end of file
+<employees><extra></extra><memory><type>name</type><in-use>12345</in-use><memory-use>54321</memory-use><high-use>-</high-use><requests>32145</requests></memory><employee><first-name>Terry</first-name><last-name>Jones</last-name><department>660</department></employee><employee><first-name>Leslie</first-name><last-name>Patterson</last-name><department>341</department></employee><employee><first-name>Ashley</first-name><last-name>Smith</last-name><department>1440</department></employee></employees> \ No newline at end of file
diff --git a/tests/core/saved/test_03.XP.out b/tests/core/saved/test_03.XP.out
index b6e764180dad..751bbfcd9eb3 100644
--- a/tests/core/saved/test_03.XP.out
+++ b/tests/core/saved/test_03.XP.out
@@ -1,4 +1,12 @@
<employees>
+ <extra></extra>
+ <memory>
+ <type>name</type>
+ <in-use>12345</in-use>
+ <memory-use>54321</memory-use>
+ <high-use>-</high-use>
+ <requests>32145</requests>
+ </memory>
<employee>
<first-name>Terry</first-name>
<last-name>Jones</last-name>
diff --git a/tests/core/test_03.c b/tests/core/test_03.c
index 0ab96994fd14..af65ddd98d8c 100644
--- a/tests/core/test_03.c
+++ b/tests/core/test_03.c
@@ -25,6 +25,9 @@ int info_count = (sizeof(info) / sizeof(info[0]));
int
main (int argc, char **argv)
{
+ unsigned opt_count = 1;
+ unsigned opt_extra = 0;
+
struct employee {
const char *e_first;
const char *e_last;
@@ -34,24 +37,68 @@ main (int argc, char **argv)
{ "Leslie", "Patterson", 341 },
{ "Ashley", "Smith", 1440 },
{ NULL, NULL }
- }, *ep = employees;
+ }, *ep;
argc = xo_parse_args(argc, argv);
if (argc < 0)
return 1;
+ for (argc = 1; argv[argc]; argc++) {
+ if (strcmp(argv[argc], "count") == 0) {
+ if (argv[argc + 1])
+ opt_count = atoi(argv[++argc]);
+ } else if (strcmp(argv[argc], "extra") == 0) {
+ if (argv[argc + 1])
+ opt_extra = atoi(argv[++argc]);
+ }
+ }
+
xo_set_info(NULL, info, info_count);
xo_open_container("employees");
xo_open_list("employee");
- for ( ; ep->e_first; ep++) {
- xo_open_instance("employee");
- xo_emit("{:first-name} {:last-name} works in dept #{:department/%u}\n",
- ep->e_first, ep->e_last, ep->e_dept);
- xo_close_instance("employee");
+ xo_emit("[{:extra/%*s}]\n", opt_extra, "");
+
+ xo_emit("{T:/%13s} {T:/%5s} {T:/%6s} {T:/%7s} {T:/%8s} {T:Size(s)}\n",
+ "Type", "InUse", "MemUse", "HighUse", "Requests");
+ xo_open_list("memory");
+ xo_open_instance("memory");
+
+#define PRIu64 "llu"
+#define TO_ULL(_x) ((unsigned long long) _x)
+ xo_emit("{k:type/%13s} {:in-use/%5" PRIu64 "} "
+ "{:memory-use/%5" PRIu64 "}{U:K} {:high-use/%7s} "
+ "{:requests/%8" PRIu64 "} ",
+ "name", TO_ULL(12345), TO_ULL(54321), "-", TO_ULL(32145));
+
+ int first = 1, i;
+#if 0
+ xo_open_list("size");
+ for (i = 0; i < 32; i++) {
+ if (!first)
+ xo_emit(",");
+ xo_emit("{l:size/%d}", 1 << (i + 4));
+ first = 0;
+ }
+ xo_close_list("size");
+#endif
+ xo_close_instance("memory");
+ xo_emit("\n");
+ xo_close_list("memory");
+
+ while (opt_count-- != 0) {
+ for (ep = employees; ep->e_first; ep++) {
+ xo_open_instance("employee");
+ xo_emit("{:first-name} {:last-name} works in "
+ "dept #{:department/%u}\n",
+ ep->e_first, ep->e_last, ep->e_dept);
+ xo_close_instance("employee");
+ }
}
+ xo_emit("done\n");
+
xo_close_list("employee");
xo_close_container("employees");