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, 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[] = "
";
/* 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);
}
@@ -3861,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;
}
@@ -3972,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) {
/*
@@ -4023,14 +4063,14 @@ xo_format_text (xo_handle_t *xop, const char *str, ssize_t 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, ssize_t len)
+ const char *value, ssize_t vlen)
{
const char *fmt = xfip->xfi_format;
ssize_t flen = xfip->xfi_flen;
@@ -4054,8 +4094,7 @@ 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;
}
@@ -4074,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);
@@ -4166,8 +4205,9 @@ xo_arg (xo_handle_t *xop)
static void
xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen,
- const char *format, ssize_t flen,
- const char *encoding, ssize_t elen, xo_xff_flags_t flags)
+ 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;
@@ -4253,7 +4293,7 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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);
@@ -4263,8 +4303,8 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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:
@@ -4273,25 +4313,24 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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;
}
@@ -4327,7 +4366,9 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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);
@@ -4337,20 +4378,19 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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)
@@ -4362,18 +4402,20 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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("diouDOUeEfFgG", 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;
}
@@ -4407,7 +4449,7 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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);
@@ -4415,39 +4457,39 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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;
}
@@ -4457,27 +4499,27 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t 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;
}
@@ -4487,7 +4529,9 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen,
xo_data_append(xop, "", 1);
ssize_t value_offset = xo_buf_offset(&xop->xo_data);
- xo_do_format_field(xop, NULL, format, flen, flags);
+
+ 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,
@@ -4536,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, ssize_t len, const char *fmt, ssize_t 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 {
@@ -4574,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;
}
}
@@ -4898,7 +4928,7 @@ 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, ssize_t len)
+ const char *value, ssize_t vlen)
{
const char *fmt = xfip->xfi_format;
ssize_t flen = xfip->xfi_flen;
@@ -4906,13 +4936,13 @@ xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip,
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
@@ -4972,7 +5002,7 @@ 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, ssize_t len)
+ const char *value, ssize_t vlen)
{
const char *fmt = xfip->xfi_format;
ssize_t flen = xfip->xfi_flen;
@@ -4982,7 +5012,7 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
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;
}
@@ -4997,8 +5027,8 @@ 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);
@@ -5026,7 +5056,7 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
static ssize_t
xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, ssize_t len)
+ const char *value, ssize_t vlen)
{
const char *fmt = xfip->xfi_format;
ssize_t flen = xfip->xfi_flen;
@@ -5035,10 +5065,10 @@ xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip,
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
@@ -5075,7 +5105,7 @@ xo_anchor_clear (xo_handle_t *xop)
*/
static void
xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, ssize_t len)
+ const char *value, ssize_t vlen)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -5092,12 +5122,12 @@ 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, ssize_t len)
+ const char *value, ssize_t vlen)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -5109,7 +5139,7 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
XOIF_CLEAR(xop, XOIF_UNITS_PENDING);
- ssize_t 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;
@@ -6213,12 +6243,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 == '[')
@@ -7899,7 +7929,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);
@@ -7915,7 +7946,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);
@@ -8132,7 +8164,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);
diff --git a/tests/core/saved/test_01.E.out b/tests/core/saved/test_01.E.out
index 407d3f4a5567..40d9ec67f5eb 100644
--- a/tests/core/saved/test_01.E.out
+++ b/tests/core/saved/test_01.E.out
@@ -1,5 +1,6 @@
op create: [] [] [0]
op open_container: [top] [] [0x810]
+op content: [used-percent] [12] [0]
op content: [kve_start] [0xdeadbeef] [0x8]
op content: [kve_end] [0xcabb1e] [0x8]
op string: [host] [my-box] [0x200000]
@@ -129,6 +130,9 @@ 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]
diff --git a/tests/core/saved/test_01.H.out b/tests/core/saved/test_01.H.out
index 7c0b3de061a6..7622c97a31ff 100644
--- a/tests/core/saved/test_01.H.out
+++ b/tests/core/saved/test_01.H.out
@@ -1,2 +1,2 @@
-
testing argument modifier
my-box
.
example.com
...
testing argument modifier with encoding to
.
example.com
...
very
42
42
-
Connecting to
my-box
.
example.com
...
Item
Total Sold
In Stock
On Order
SKU
gum
1412
54
10
GRO-000-415
bolt
4123
144
42
HRD-000-632
water
17
14
2
GRO-000-2331
\ No newline at end of file
+
testing argument modifier
my-box
.
example.com
...
testing argument modifier with encoding to
.
example.com
...
very
42
42
+
Connecting to
my-box
.
example.com
...
Item
Total Sold
In Stock
On Order
SKU
gum
1412
54
10
GRO-000-415
bolt
4123
144
42
HRD-000-632
water
17
14
2
GRO-000-2331
\ No newline at end of file
diff --git a/tests/core/saved/test_01.HIPx.out b/tests/core/saved/test_01.HIPx.out
index f6c7290366fb..94c387ea8d08 100644
--- a/tests/core/saved/test_01.HIPx.out
+++ b/tests/core/saved/test_01.HIPx.out
@@ -1,3 +1,8 @@
+
testing argument modifier
my-box
@@ -332,6 +337,10 @@
group
+
/some/file
diff --git a/tests/core/saved/test_01.HP.out b/tests/core/saved/test_01.HP.out
index 0fdcbd18005b..044bd4430496 100644
--- a/tests/core/saved/test_01.HP.out
+++ b/tests/core/saved/test_01.HP.out
@@ -1,3 +1,8 @@
+
testing argument modifier
my-box
@@ -332,6 +337,10 @@
group
+
/some/file
diff --git a/tests/core/saved/test_01.J.out b/tests/core/saved/test_01.J.out
index 1577ce0c0410..897a7d28958e 100644
--- a/tests/core/saved/test_01.J.out
+++ b/tests/core/saved/test_01.J.out
@@ -1,2 +1,2 @@
-{"top": {"kve_start":"0xdeadbeef","kve_end":"0xcabb1e","host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
+{"top": {"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/tests/core/saved/test_01.JP.out b/tests/core/saved/test_01.JP.out
index d24abbc0254f..885f30e59f99 100644
--- a/tests/core/saved/test_01.JP.out
+++ b/tests/core/saved/test_01.JP.out
@@ -1,5 +1,6 @@
{
"top": {
+ "used-percent": 12,
"kve_start": "0xdeadbeef",
"kve_end": "0xcabb1e",
"host": "my-box",
@@ -117,6 +118,9 @@
"links": "links",
"user": "user",
"group": "group",
+ "pre": "that",
+ "links": 3,
+ "post": "this",
"mode": "/some/file",
"mode_octal": 640,
"links": 1,
diff --git a/tests/core/saved/test_01.T.out b/tests/core/saved/test_01.T.out
index 71cd130ab350..5a4673f7d8bc 100644
--- a/tests/core/saved/test_01.T.out
+++ b/tests/core/saved/test_01.T.out
@@ -1,3 +1,4 @@
+df 12%
testing argument modifier my-box.example.com...
testing argument modifier with encoding to .example.com...
Label text value
@@ -50,4 +51,5 @@ XXXXXXXX
X XCost: 425
X XCost: 455
links user group
+3 this
/some/file 1 user group
diff --git a/tests/core/saved/test_01.X.out b/tests/core/saved/test_01.X.out
index a243ce7c79f1..6c5afaca81ae 100644
--- a/tests/core/saved/test_01.X.out
+++ b/tests/core/saved/test_01.X.out
@@ -1 +1 @@
-
0xdeadbeef 0xcabb1e my-box example.com my-box example.com value very 42 [42] my-box example.com GRO-000-415 gum 1412 54 10 HRD-000-212 rope 85 4 2 HRD-000-517 ladder 0 2 1 HRD-000-632 bolt 4123 144 42 GRO-000-2331 water 17 14 2 GRO-000-415 gum 1412.0 54 10 HRD-000-212 rope 85.0 4 2 HRD-000-517 ladder 0 2 1 HRD-000-632 bolt 4123.0 144 42 GRO-000-2331 water 17.0 14 2 GRO-000-533 fish 1321.0 45 1 - gum
- rope
- ladder
- bolt
- water
425 455 mode octal links user group /some/file 640 1 user group
\ No newline at end of file
+
12 0xdeadbeef 0xcabb1e my-box example.com my-box example.com value very 42 [42] my-box example.com GRO-000-415 gum 1412 54 10 HRD-000-212 rope 85 4 2 HRD-000-517 ladder 0 2 1 HRD-000-632 bolt 4123 144 42 GRO-000-2331 water 17 14 2 GRO-000-415 gum 1412.0 54 10 HRD-000-212 rope 85.0 4 2 HRD-000-517 ladder 0 2 1 HRD-000-632 bolt 4123.0 144 42 GRO-000-2331 water 17.0 14 2 GRO-000-533 fish 1321.0 45 1 - gum
- rope
- ladder
- bolt
- water
425 455 mode octal links user group that 3 this /some/file 640 1 user group
\ No newline at end of file
diff --git a/tests/core/saved/test_01.XP.out b/tests/core/saved/test_01.XP.out
index 98dc13b68f29..2aa52ace6e65 100644
--- a/tests/core/saved/test_01.XP.out
+++ b/tests/core/saved/test_01.XP.out
@@ -1,4 +1,5 @@
+ 12
0xdeadbeef
0xcabb1e
my-box
@@ -108,6 +109,9 @@
links
user
group
+ that
+ 3
+ this
/some/file
640
1
diff --git a/tests/core/saved/test_02.J.out b/tests/core/saved/test_02.J.out
index 5578389aa479..2cb2abcb8726 100644
--- a/tests/core/saved/test_02.J.out
+++ b/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":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"}}}
}
diff --git a/tests/core/saved/test_02.JP.out b/tests/core/saved/test_02.JP.out
index fd910aa6e808..930d8876fba3 100644
--- a/tests/core/saved/test_02.JP.out
+++ b/tests/core/saved/test_02.JP.out
@@ -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/tests/core/test_01.c b/tests/core/test_01.c
index a3a6a4be3e29..26c272492ecb 100644
--- a/tests/core/test_01.c
+++ b/tests/core/test_01.c
@@ -80,6 +80,8 @@ main (int argc, char **argv)
xo_open_container_h(NULL, "top");
+ 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);
@@ -190,6 +192,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/xohtml/xohtml.css b/xohtml/xohtml.css
index fc9ea066860e..67c3bff1b18a 100644
--- a/xohtml/xohtml.css
+++ b/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/xohtml/xohtml.sh.in b/xohtml/xohtml.sh.in
index a15d82e3276a..f6c2fdbc99ff 100644
--- a/xohtml/xohtml.sh.in
+++ b/xohtml/xohtml.sh.in
@@ -57,7 +57,8 @@ if [ "$CMD" = "cat" -a -t 0 ]; then
do_help
fi
-echo "\n\n"
+echo ''
+echo ''
echo ' '
echo ' '
echo ' '
@@ -66,10 +67,12 @@ echo ''
echo ''
-echo "\n\n"
+echo ''
+echo ''
$CMD
-echo "\n\n"
+echo ''
+echo ''
exit 0