From 1e95a1a7946ca6a2e648b37d64e479165b07c6f5 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sat, 10 Jun 2017 17:12:00 -0400 Subject: [PATCH 01/20] rename "format" to "fmt" for consistency --- libxo/libxo.c | 77 ++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/libxo/libxo.c b/libxo/libxo.c index 7f015b7b..575d41a9 100644 --- a/libxo/libxo.c +++ b/libxo/libxo.c @@ -3644,6 +3644,10 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp, return 0; } +/* + * Remove any numeric precision/width format from the format string by + * inserting the "%" after the [0-9]+, returning the substring. + */ static char * xo_fix_encoding (xo_handle_t *xop UNUSED, char *encoding) { @@ -3657,8 +3661,7 @@ xo_fix_encoding (xo_handle_t *xop UNUSED, char *encoding) break; } - cp -= 1; - *cp = '%'; + *--cp = '%'; /* Back off and insert the '%' */ return cp; } @@ -4166,7 +4169,7 @@ 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 *fmt, ssize_t flen, const char *encoding, ssize_t elen, xo_xff_flags_t flags) { int pretty = XOF_ISSET(xop, XOF_PRETTY); @@ -4253,7 +4256,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_do_format_field(xop, NULL, fmt, flen, flags); if (flags & XFF_HUMANIZE) xo_format_humanize(xop, xbp, &save, flags); @@ -4264,7 +4267,7 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, flags |= XFF_NO_OUTPUT; xo_buf_append_div(xop, "data", flags, name, nlen, - format, flen, encoding, elen); + fmt, flen, encoding, elen); break; case XO_STYLE_XML: @@ -4274,24 +4277,24 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, */ if (flags & XFF_DISPLAY_ONLY) { flags |= XFF_NO_OUTPUT; - xo_do_format_field(xop, NULL, format, flen, flags); + xo_do_format_field(xop, NULL, 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 +4330,7 @@ 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_do_format_field(xop, NULL, fmt, flen, flags); xo_data_append(xop, "", 1); @@ -4338,19 +4341,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_do_format_field(xop, NULL, 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) @@ -4364,16 +4367,16 @@ 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("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 +4410,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_do_format_field(xop, NULL, fmt, flen, flags); if (quote) xo_data_append(xop, "\"", 1); @@ -4416,38 +4419,38 @@ 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_do_format_field(xop, NULL, 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_do_format_field(xop, NULL, 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_do_format_field(xop, NULL, fmt, flen, flags); break; } @@ -4457,27 +4460,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 +4490,7 @@ 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_do_format_field(xop, NULL, fmt, flen, flags); xo_data_append(xop, "", 1); xo_encoder_handle(xop, quote ? XO_OP_STRING : XO_OP_CONTENT, From 728a35a0f7d10965dd174b1b443a2c95e594c934 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:36:43 -0400 Subject: [PATCH 02/20] Don't treat values as format strings; they are not --- libxo/libxo.c | 123 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 44 deletions(-) diff --git a/libxo/libxo.c b/libxo/libxo.c index 575d41a9..4705999a 100644 --- a/libxo/libxo.c +++ b/libxo/libxo.c @@ -473,6 +473,7 @@ 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 void @@ -1761,7 +1762,8 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) rc += rc2; } - xo_buf_append_div(xop, "message", 0, NULL, 0, bp, rc, NULL, 0); + xo_buf_append_div(xop, "message", 0, NULL, 0, bp, rc, + NULL, 0, NULL, 0); } break; @@ -3780,10 +3782,15 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp, } } +/* + * Html mode: append a
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[] = "
xo_columns; save.xhs_anchor_columns = xop->xo_anchor_columns; - xo_do_format_field(xop, NULL, value, vlen, flags); + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); + else + xo_do_format_field(xop, NULL, fmt, flen, flags); if (flags & XFF_HUMANIZE) { /* @@ -4026,7 +4038,7 @@ 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; } } @@ -4169,8 +4181,9 @@ xo_arg (xo_handle_t *xop) static void xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, - const char *fmt, 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; @@ -4256,7 +4269,10 @@ 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, fmt, flen, flags); + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); + else + xo_do_format_field(xop, NULL, fmt, flen, flags); if (flags & XFF_HUMANIZE) xo_format_humanize(xop, xbp, &save, flags); @@ -4266,7 +4282,7 @@ 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, + xo_buf_append_div(xop, "data", flags, name, nlen, value, vlen, fmt, flen, encoding, elen); break; @@ -4277,7 +4293,8 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, */ if (flags & XFF_DISPLAY_ONLY) { flags |= XFF_NO_OUTPUT; - xo_do_format_field(xop, NULL, fmt, flen, flags); + if (vlen == 0) + xo_do_format_field(xop, NULL, fmt, flen, flags); break; } @@ -4330,7 +4347,12 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, } xo_data_append(xop, ">", 1); - xo_do_format_field(xop, NULL, fmt, flen, flags); + + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); + else + xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_data_append(xop, "", 1); @@ -4341,7 +4363,8 @@ 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, fmt, flen, flags); + if (vlen == 0) + xo_do_format_field(xop, NULL, fmt, flen, flags); break; } @@ -4365,6 +4388,8 @@ 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; fmt = "true"; /* JSON encodes empty tags as a boolean true */ @@ -4410,7 +4435,10 @@ 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, fmt, flen, flags); + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); + else + xo_do_format_field(xop, NULL, fmt, flen, flags); if (quote) xo_data_append(xop, "\"", 1); @@ -4419,7 +4447,8 @@ 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, fmt, flen, flags); + if (vlen == 0) + xo_do_format_field(xop, NULL, fmt, flen, flags); break; } @@ -4443,14 +4472,20 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, xo_data_escape(xop, name, nlen); xo_data_append(xop, "=\"", 2); - xo_do_format_field(xop, NULL, fmt, flen, flags); + + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); + else + xo_do_format_field(xop, NULL, 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, fmt, flen, flags); + if (vlen == 0) + xo_do_format_field(xop, NULL, fmt, flen, flags); break; } @@ -4490,7 +4525,12 @@ 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, fmt, flen, flags); + + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); + else + xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_data_append(xop, "", 1); xo_encoder_handle(xop, quote ? XO_OP_STRING : XO_OP_CONTENT, @@ -4539,37 +4579,30 @@ 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); + if (vlen != 0) + xo_data_append_content(xop, value, vlen, flags); else xo_do_format_field(xop, NULL, 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 { @@ -4577,14 +4610,14 @@ 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) + if (vlen == 0) xo_do_format_field(xop, NULL, fmt, flen, flags | XFF_NO_OUTPUT); } break; case XO_STYLE_ENCODER: - if (len == 0) + if (vlen == 0) xo_do_format_field(xop, NULL, fmt, flen, flags | XFF_NO_OUTPUT); break; @@ -6216,12 +6249,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 == '[') @@ -7902,7 +7935,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); @@ -7918,7 +7952,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); @@ -8135,7 +8170,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); From 6c180a96714f62d5db851c4e424aef10963cffde Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:09 -0400 Subject: [PATCH 03/20] add test case for {U:%%} (from df.c) --- tests/core/test_01.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/test_01.c b/tests/core/test_01.c index a3a6a4be..26c27249 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, From 8e4a5f48eb641fbd30a03627565a2fd6bfa5c1b7 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:50 -0400 Subject: [PATCH 04/20] update test cases --- tests/core/saved/test_01.E.out | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/saved/test_01.E.out b/tests/core/saved/test_01.E.out index 407d3f4a..40d9ec67 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] From 72a8cdae3cbbeb6638e6bd9fdd6dc82bda8f08f9 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:52 -0400 Subject: [PATCH 05/20] update test cases --- tests/core/saved/test_01.H.out | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/core/saved/test_01.H.out b/tests/core/saved/test_01.H.out index 7c0b3de0..7622c97a 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
...
Label text
value
very
42
42 -
Connecting to
my-box
.
example.com
...
Item
Total Sold
In Stock
On Order
SKU
gum
1412
54
10
GRO-000-415
rope
85
4
2
HRD-000-212
ladder
0
2
1
HRD-000-517
bolt
4123
144
42
HRD-000-632
water
17
14
2
GRO-000-2331
Item
'
gum
':
Total sold
:
1412.0
In stock
:
54
On order
:
10
SKU
:
GRO-000-415
Item
'
rope
':
Total sold
:
85.0
In stock
:
4
On order
:
2
SKU
:
HRD-000-212
Item
'
ladder
':
Total sold
:
0
In stock
:
2
On order
:
1
SKU
:
HRD-000-517
Item
'
bolt
':
Total sold
:
4123.0
In stock
:
144
On order
:
42
SKU
:
HRD-000-632
Item
'
water
':
Total sold
:
17.0
In stock
:
14
On order
:
2
SKU
:
GRO-000-2331
Item
'
fish
':
Total sold
:
1321.0
In stock
:
45
On order
:
1
SKU
:
GRO-000-533
Item
:
gum
Item
:
rope
Item
:
ladder
Item
:
bolt
Item
:
water
X
X
X
X
X
X
X
X
X
X
Cost
:
425
X
X
Cost
:
455
links
user
group
/some/file
1
user
group
\ No newline at end of file +
df
12
%
testing argument modifier
my-box
.
example.com
...
testing argument modifier with encoding to
.
example.com
...
Label text
value
very
42
42 +
Connecting to
my-box
.
example.com
...
Item
Total Sold
In Stock
On Order
SKU
gum
1412
54
10
GRO-000-415
rope
85
4
2
HRD-000-212
ladder
0
2
1
HRD-000-517
bolt
4123
144
42
HRD-000-632
water
17
14
2
GRO-000-2331
Item
'
gum
':
Total sold
:
1412.0
In stock
:
54
On order
:
10
SKU
:
GRO-000-415
Item
'
rope
':
Total sold
:
85.0
In stock
:
4
On order
:
2
SKU
:
HRD-000-212
Item
'
ladder
':
Total sold
:
0
In stock
:
2
On order
:
1
SKU
:
HRD-000-517
Item
'
bolt
':
Total sold
:
4123.0
In stock
:
144
On order
:
42
SKU
:
HRD-000-632
Item
'
water
':
Total sold
:
17.0
In stock
:
14
On order
:
2
SKU
:
GRO-000-2331
Item
'
fish
':
Total sold
:
1321.0
In stock
:
45
On order
:
1
SKU
:
GRO-000-533
Item
:
gum
Item
:
rope
Item
:
ladder
Item
:
bolt
Item
:
water
X
X
X
X
X
X
X
X
X
X
Cost
:
425
X
X
Cost
:
455
links
user
group
3
this
/some/file
1
user
group
\ No newline at end of file From 5805cc3427f9a0eb661cce170a4447fd8d7832bb Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:53 -0400 Subject: [PATCH 06/20] update test cases --- tests/core/saved/test_01.HIPx.out | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/core/saved/test_01.HIPx.out b/tests/core/saved/test_01.HIPx.out index f6c72903..94c387ea 100644 --- a/tests/core/saved/test_01.HIPx.out +++ b/tests/core/saved/test_01.HIPx.out @@ -1,3 +1,8 @@ +
+
df
+
12
+
%
+
testing argument modifier
my-box
@@ -332,6 +337,10 @@
group
+
+
3
+
this
+
/some/file
From 06a568765acc2dbb2aa77fbe406a0de1204069e3 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:54 -0400 Subject: [PATCH 07/20] update test cases --- tests/core/saved/test_01.HP.out | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/core/saved/test_01.HP.out b/tests/core/saved/test_01.HP.out index 0fdcbd18..044bd443 100644 --- a/tests/core/saved/test_01.HP.out +++ b/tests/core/saved/test_01.HP.out @@ -1,3 +1,8 @@ +
+
df
+
12
+
%
+
testing argument modifier
my-box
@@ -332,6 +337,10 @@
group
+
+
3
+
this
+
/some/file
From be3050da102d4c969d339a5311c13bd9d301451e Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:55 -0400 Subject: [PATCH 08/20] update test cases --- tests/core/saved/test_01.J.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/saved/test_01.J.out b/tests/core/saved/test_01.J.out index 1577ce0c..897a7d28 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"} } From 234e11832c4838792b4254993a9d1fcf1feb652d Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:56 -0400 Subject: [PATCH 09/20] update test cases --- tests/core/saved/test_01.JP.out | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/saved/test_01.JP.out b/tests/core/saved/test_01.JP.out index d24abbc0..885f30e5 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, From 43b8e7c00778faa050bbde7f6a3de148833a26a7 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:58 -0400 Subject: [PATCH 10/20] update test cases --- tests/core/saved/test_01.T.out | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/core/saved/test_01.T.out b/tests/core/saved/test_01.T.out index 71cd130a..5a4673f7 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 From 43f65e2f364703e23a2219bd2b348f47cffcbcfb Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:38:59 -0400 Subject: [PATCH 11/20] update test cases --- tests/core/saved/test_01.X.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/saved/test_01.X.out b/tests/core/saved/test_01.X.out index a243ce7c..6c5afaca 100644 --- a/tests/core/saved/test_01.X.out +++ b/tests/core/saved/test_01.X.out @@ -1 +1 @@ -0xdeadbeef0xcabb1emy-boxexample.commy-boxexample.comvery42[42]my-boxexample.comGRO-000-415gum14125410HRD-000-212rope8542HRD-000-517ladder021HRD-000-632bolt412314442GRO-000-2331water17142GRO-000-415gum1412.05410HRD-000-212rope85.042HRD-000-517ladder021HRD-000-632bolt4123.014442GRO-000-2331water17.0142GRO-000-533fish1321.0451gumropeladderboltwater425455modeoctallinksusergroup/some/file6401usergroup \ No newline at end of file +120xdeadbeef0xcabb1emy-boxexample.commy-boxexample.comvery42[42]my-boxexample.comGRO-000-415gum14125410HRD-000-212rope8542HRD-000-517ladder021HRD-000-632bolt412314442GRO-000-2331water17142GRO-000-415gum1412.05410HRD-000-212rope85.042HRD-000-517ladder021HRD-000-632bolt4123.014442GRO-000-2331water17.0142GRO-000-533fish1321.0451gumropeladderboltwater425455modeoctallinksusergroup
that
3this/some/file6401usergroup
\ No newline at end of file From 33e7746ac49553863b121821780f8cafae2a98ea Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:39:01 -0400 Subject: [PATCH 12/20] update test cases --- tests/core/saved/test_01.XP.out | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/saved/test_01.XP.out b/tests/core/saved/test_01.XP.out index 98dc13b6..2aa52ace 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 From d4485420d42a6a98d249ab1b0020fcda43938ba5 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:39:02 -0400 Subject: [PATCH 13/20] update test cases --- tests/core/saved/test_02.J.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/saved/test_02.J.out b/tests/core/saved/test_02.J.out index 5578389a..2cb2abcb 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"}}} } From 15d8d75cbbebdc1cfa5975e5849202e36d4d4202 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:39:03 -0400 Subject: [PATCH 14/20] update test cases --- tests/core/saved/test_02.JP.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/saved/test_02.JP.out b/tests/core/saved/test_02.JP.out index fd910aa6..930d8876 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" From 2a40ee0f43bcd56c1018371e14bfe6cbb1300a4c Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Sun, 11 Jun 2017 03:40:11 -0400 Subject: [PATCH 15/20] add --install --- bin/Zaliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/Zaliases b/bin/Zaliases index 04cdec77..df7e8977 100644 --- a/bin/Zaliases +++ b/bin/Zaliases @@ -1,5 +1,5 @@ set top_src=`pwd` -alias Zautoreconf "(cd $top_src ; autoreconf)" +alias Zautoreconf "(cd $top_src ; autoreconf --install)" set opts=' \ --with-libslax-prefix=/Users/phil/work/root \ From 073597d09b3951a34bafd9f449cc790cd93ee84f Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Tue, 13 Jun 2017 01:43:31 -0400 Subject: [PATCH 16/20] detect end-of-string in '%' and '' escaping --- libxo/libxo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libxo/libxo.c b/libxo/libxo.c index 4705999a..d74c80eb 100644 --- a/libxo/libxo.c +++ b/libxo/libxo.c @@ -2705,6 +2705,8 @@ xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp, if ((flags & XFF_UNESCAPE) && (*cp == '\\' || *cp == '%')) { cp += 1; len -= 1; + if (len == 0 || *cp == '\0') + break; } } From 0f03f148a37b844ce3b908c4ca065925d556f000 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Tue, 13 Jun 2017 01:44:19 -0400 Subject: [PATCH 17/20] Add div.units as standard CSS text --- xohtml/xohtml.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xohtml/xohtml.css b/xohtml/xohtml.css index fc9ea066..67c3bff1 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; From 21a803c9de7b149be4257d125c24e3502d411a89 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Tue, 13 Jun 2017 01:44:51 -0400 Subject: [PATCH 18/20] nuke "n" in "echo" commands --- xohtml/xohtml.sh.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xohtml/xohtml.sh.in b/xohtml/xohtml.sh.in index a15d82e3..f6c2fdbc 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 From eccb66ec74b982fec4cdf3e46ac56f3009f6ec34 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Wed, 14 Jun 2017 01:54:17 -0400 Subject: [PATCH 19/20] make xo_simple_field, for common simple cases --- libxo/libxo.c | 140 ++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 74 deletions(-) diff --git a/libxo/libxo.c b/libxo/libxo.c index d74c80eb..2b8ba68b 100644 --- a/libxo/libxo.c +++ b/libxo/libxo.c @@ -95,6 +95,14 @@ #include #endif /* HAVE_GETTEXT */ +/* Rather lame that we can't count on these... */ +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + /* * Three styles of specifying thread-local variables are supported. * configure.ac has the brains to run each possibility through the @@ -3784,6 +3792,26 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp, } } +/* + * Convenience function that either append a fixed value (if one is + * given) or formats a field using a format string. If it's + * encode_only, then we can't skip formatting the field, since it may + * be pulling arguments off the stack. + */ +static inline void +xo_simple_field (xo_handle_t *xop, unsigned encode_only, + const char *value, ssize_t vlen, + const char *fmt, ssize_t flen, xo_xff_flags_t flags) +{ + if (encode_only) + flags |= XFF_NO_OUTPUT; + + if (vlen == 0) + xo_do_format_field(xop, NULL, fmt, flen, flags); + else if (!encode_only) + xo_data_append_content(xop, value, vlen, flags); +} + /* * Html mode: append a
to the output buffer contain a field * along with all the supporting information indicated by the flags. @@ -3876,9 +3904,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags, * from xo_vap. This is not true when vlen is zero, since * that means our "value" isn't on the stack. */ - if (vlen == 0) - xo_do_format_field(xop, NULL, encoding, elen, - flags | XFF_NO_OUTPUT); + xo_simple_field(xop, TRUE, NULL, 0, encoding, elen, flags); return; } @@ -3986,10 +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; - if (vlen != 0) - xo_data_append_content(xop, value, vlen, flags); - else - xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); if (flags & XFF_HUMANIZE) { /* @@ -4047,7 +4070,7 @@ xo_format_text (xo_handle_t *xop, const char *str, ssize_t len) 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; @@ -4071,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; } @@ -4091,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); @@ -4271,10 +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; - if (vlen != 0) - xo_data_append_content(xop, value, vlen, flags); - else - xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); if (flags & XFF_HUMANIZE) xo_format_humanize(xop, xbp, &save, flags); @@ -4294,9 +4313,7 @@ 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; - if (vlen == 0) - xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } @@ -4350,10 +4367,7 @@ xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen, xo_data_append(xop, ">", 1); - if (vlen != 0) - xo_data_append_content(xop, value, vlen, flags); - else - xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); xo_data_append(xop, "xo_data); - if (vlen != 0) - xo_data_append_content(xop, value, vlen, flags); - else - xo_do_format_field(xop, NULL, fmt, flen, flags); + xo_simple_field(xop, FALSE, value, vlen, fmt, flen, flags); xo_data_append(xop, "", 1); @@ -4587,10 +4586,7 @@ xo_format_content (xo_handle_t *xop, const char *class_name, { switch (xo_style(xop)) { case XO_STYLE_TEXT: - if (vlen != 0) - xo_data_append_content(xop, value, vlen, 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: @@ -4612,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 (vlen == 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 (vlen == 0) - xo_do_format_field(xop, NULL, fmt, flen, - flags | XFF_NO_OUTPUT); + xo_simple_field(xop, TRUE, value, vlen, fmt, flen, flags); break; } } @@ -4936,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; @@ -4944,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 @@ -5010,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; @@ -5020,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; } @@ -5035,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); @@ -5064,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; @@ -5073,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 @@ -5113,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; @@ -5130,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; @@ -5147,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; From 5e95ace7395736e2abcaa43ab3ca198ffc8bb9b4 Mon Sep 17 00:00:00 2001 From: Phil Shafer Date: Wed, 14 Jun 2017 13:18:17 -0400 Subject: [PATCH 20/20] add "-p" to "mkdir -p build" in setup.sh --- bin/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/setup.sh b/bin/setup.sh index f49dd48d..9111921f 100644 --- a/bin/setup.sh +++ b/bin/setup.sh @@ -22,7 +22,7 @@ if [ ! -f configure ]; then fi echo "Creating build directory ..." -mkdir build +mkdir -p build echo "Setup is complete. To build libslax:"