diff options
Diffstat (limited to 'libxo')
-rw-r--r-- | libxo/libxo.3 | 10 | ||||
-rw-r--r-- | libxo/libxo.c | 64 | ||||
-rw-r--r-- | libxo/xo_attr.3 | 10 | ||||
-rw-r--r-- | libxo/xo_create.3 | 10 | ||||
-rw-r--r-- | libxo/xo_emit.3 | 10 | ||||
-rw-r--r-- | libxo/xo_emit_err.3 | 10 | ||||
-rw-r--r-- | libxo/xo_emit_f.3 | 10 | ||||
-rw-r--r-- | libxo/xo_err.3 | 10 | ||||
-rw-r--r-- | libxo/xo_error.3 | 10 | ||||
-rw-r--r-- | libxo/xo_finish.3 | 10 | ||||
-rw-r--r-- | libxo/xo_flush.3 | 10 | ||||
-rw-r--r-- | libxo/xo_format.5 | 10 | ||||
-rw-r--r-- | libxo/xo_message.3 | 10 | ||||
-rw-r--r-- | libxo/xo_no_setlocale.3 | 10 | ||||
-rw-r--r-- | libxo/xo_open_container.3 | 10 | ||||
-rw-r--r-- | libxo/xo_open_list.3 | 10 | ||||
-rw-r--r-- | libxo/xo_open_marker.3 | 10 | ||||
-rw-r--r-- | libxo/xo_options.7 | 9 | ||||
-rw-r--r-- | libxo/xo_parse_args.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_allocator.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_flags.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_info.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_options.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_style.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_syslog_enterprise_id.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_version.3 | 10 | ||||
-rw-r--r-- | libxo/xo_set_writer.3 | 10 | ||||
-rw-r--r-- | libxo/xo_syslog.3 | 10 |
28 files changed, 320 insertions, 13 deletions
diff --git a/libxo/libxo.3 b/libxo/libxo.3 index 4e2488cd5f57..f07962036e07 100644 --- a/libxo/libxo.3 +++ b/libxo/libxo.3 @@ -311,3 +311,13 @@ to use an alternative set of low-level output functions. .Xr xo_set_style 3 , .Xr xo_set_writer 3 , .Xr xo_format 5 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/libxo.c b/libxo/libxo.c index 2b8ba68bd25e..84e9c01a428f 100644 --- a/libxo/libxo.c +++ b/libxo/libxo.c @@ -137,7 +137,7 @@ static const char xo_default_format[] = "%s"; #define XO_INDENT_BY 2 /* Amount to indent when pretty printing */ #define XO_DEPTH 128 /* Default stack depth */ -#define XO_MAX_ANCHOR_WIDTH (8*1024) /* Anything wider is just sillyb */ +#define XO_MAX_ANCHOR_WIDTH (8*1024) /* Anything wider is just silly */ #define XO_FAILURE_NAME "failure" @@ -5071,16 +5071,60 @@ xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip, bp[vlen] = '\0'; width = strtol(bp, &cp, 0); - if (width == LONG_MIN || width == LONG_MAX - || bp == cp || *cp != '\0' ) { + if (width == LONG_MIN || width == LONG_MAX || bp == cp || *cp != '\0') { width = 0; xo_failure(xop, "invalid width for anchor: '%s'", bp); } } else if (flen) { - if (flen != 2 || strncmp("%d", fmt, flen) != 0) - xo_failure(xop, "invalid width format: '%*.*s'", flen, flen, fmt); - if (!XOF_ISSET(xop, XOF_NO_VA_ARG)) - width = va_arg(xop->xo_vap, int); + /* + * We really expect the format for width to be "{:/%d}" or + * "{:/%u}", so if that's the case, we just grab our width off + * the argument list. But we need to avoid optimized logic if + * there's a custom formatter. + */ + if (xop->xo_formatter == NULL && flen == 2 + && strncmp("%d", fmt, flen) == 0) { + if (!XOF_ISSET(xop, XOF_NO_VA_ARG)) + width = va_arg(xop->xo_vap, int); + } else if (xop->xo_formatter == NULL && flen == 2 + && strncmp("%u", fmt, flen) == 0) { + if (!XOF_ISSET(xop, XOF_NO_VA_ARG)) + width = va_arg(xop->xo_vap, unsigned); + } else { + /* + * So we have a format and it's not a simple one like + * "{:/%d}". That means we need to format the field, + * extract the value from the formatted output, and then + * discard that output. + */ + int anchor_was_set = FALSE; + xo_buffer_t *xbp = &xop->xo_data; + ssize_t start_offset = xo_buf_offset(xbp); + bp = xo_buf_cur(xbp); /* Save start of the string */ + cp = NULL; + + if (XOIF_ISSET(xop, XOIF_ANCHOR)) { + XOIF_CLEAR(xop, XOIF_ANCHOR); + anchor_was_set = TRUE; + } + + ssize_t rc = xo_do_format_field(xop, xbp, fmt, flen, 0); + if (rc >= 0) { + xo_buf_append(xbp, "", 1); /* Append a NUL */ + + width = strtol(bp, &cp, 0); + if (width == LONG_MIN || width == LONG_MAX + || bp == cp || *cp != '\0') { + width = 0; + xo_failure(xop, "invalid width for anchor: '%s'", bp); + } + } + + /* Reset the cur pointer to where we found it */ + xbp->xb_curp = xbp->xb_bufp + start_offset; + if (anchor_was_set) + XOIF_SET(xop, XOIF_ANCHOR); + } } return width; @@ -5107,9 +5151,6 @@ static void xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip, const char *value, ssize_t vlen) { - if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML) - return; - if (XOIF_ISSET(xop, XOIF_ANCHOR)) xo_failure(xop, "the anchor already recording is discarded"); @@ -5129,9 +5170,6 @@ static void xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip, const char *value, ssize_t vlen) { - if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML) - return; - if (!XOIF_ISSET(xop, XOIF_ANCHOR)) { xo_failure(xop, "no start anchor"); return; diff --git a/libxo/xo_attr.3 b/libxo/xo_attr.3 index c71377fd17eb..9e61acd3656c 100644 --- a/libxo/xo_attr.3 +++ b/libxo/xo_attr.3 @@ -58,3 +58,13 @@ already emitted in other form. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_create.3 b/libxo/xo_create.3 index bfbadc4e6ed6..03d51764b8ae 100644 --- a/libxo/xo_create.3 +++ b/libxo/xo_create.3 @@ -65,3 +65,13 @@ resources associated with the default handle. .Xr xo_emit 3 , .Xr xo_set_options 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_emit.3 b/libxo/xo_emit.3 index 155ea75d1fdf..eceb38e0aa83 100644 --- a/libxo/xo_emit.3 +++ b/libxo/xo_emit.3 @@ -102,3 +102,13 @@ then the number of display columns consumed by the output will be returned. .Xr xo_open_list 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_emit_err.3 b/libxo/xo_emit_err.3 index bb1ca640c6e7..eae44b746c28 100644 --- a/libxo/xo_emit_err.3 +++ b/libxo/xo_emit_err.3 @@ -70,3 +70,13 @@ parameter. .Xr xo_format 5 , .Xr xo_err 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_emit_f.3 b/libxo/xo_emit_f.3 index 087954631516..2edfa79ac9c0 100644 --- a/libxo/xo_emit_f.3 +++ b/libxo/xo_emit_f.3 @@ -109,3 +109,13 @@ for details. .Xr xo_open_list 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_err.3 b/libxo/xo_err.3 index 532899ab85ff..87cf2010a8a1 100644 --- a/libxo/xo_err.3 +++ b/libxo/xo_err.3 @@ -72,3 +72,13 @@ parameter. .Xr xo_emit 3 , .Xr xo_emit_err 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_error.3 b/libxo/xo_error.3 index e5c99e9dd923..0330af4142da 100644 --- a/libxo/xo_error.3 +++ b/libxo/xo_error.3 @@ -39,3 +39,13 @@ calls. .Xr printf 3 , .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_finish.3 b/libxo/xo_finish.3 index 221b1c1779b4..f9c6b3de62e2 100644 --- a/libxo/xo_finish.3 +++ b/libxo/xo_finish.3 @@ -37,3 +37,13 @@ especially for the non-TEXT output styles. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_flush.3 b/libxo/xo_flush.3 index e43bae0057e7..a785c68f12ec 100644 --- a/libxo/xo_flush.3 +++ b/libxo/xo_flush.3 @@ -33,3 +33,13 @@ function is used for this. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_format.5 b/libxo/xo_format.5 index b1829c8941dc..5265359866bb 100644 --- a/libxo/xo_format.5 +++ b/libxo/xo_format.5 @@ -965,3 +965,13 @@ names to make that difference more obvious. .Xr libxo 3 , .Xr xolint 1 , .Xr xo_emit 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_message.3 b/libxo/xo_message.3 index 36f014884999..ce979a51dc95 100644 --- a/libxo/xo_message.3 +++ b/libxo/xo_message.3 @@ -66,3 +66,13 @@ and .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_no_setlocale.3 b/libxo/xo_no_setlocale.3 index f91abc005107..da3e8a343fab 100644 --- a/libxo/xo_no_setlocale.3 +++ b/libxo/xo_no_setlocale.3 @@ -41,3 +41,13 @@ function. .Xr xo_open_list 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_open_container.3 b/libxo/xo_open_container.3 index e765089a7f69..16cd9c999a17 100644 --- a/libxo/xo_open_container.3 +++ b/libxo/xo_open_container.3 @@ -186,3 +186,13 @@ and the name recorded do not match. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_open_list.3 b/libxo/xo_open_list.3 index 6d65b8f15afc..e4d3080eeb63 100644 --- a/libxo/xo_open_list.3 +++ b/libxo/xo_open_list.3 @@ -156,3 +156,13 @@ are rendered as multiple leaf elements. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_open_marker.3 b/libxo/xo_open_marker.3 index e7356ba6e6f6..2df3bff1535f 100644 --- a/libxo/xo_open_marker.3 +++ b/libxo/xo_open_marker.3 @@ -103,3 +103,13 @@ properly. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_options.7 b/libxo/xo_options.7 index 5e86668d009f..297dcba92a41 100644 --- a/libxo/xo_options.7 +++ b/libxo/xo_options.7 @@ -145,3 +145,12 @@ The following are three example invocations of .Sh SEE ALSO .Xr libxo 3 , .Xr xo_format 5 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . diff --git a/libxo/xo_parse_args.3 b/libxo/xo_parse_args.3 index 487b50bafb9b..b014e608a0d3 100644 --- a/libxo/xo_parse_args.3 +++ b/libxo/xo_parse_args.3 @@ -150,3 +150,13 @@ must be maintained by the caller. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_allocator.3 b/libxo/xo_set_allocator.3 index c20a0f5230e5..c0e731ec2131 100644 --- a/libxo/xo_set_allocator.3 +++ b/libxo/xo_set_allocator.3 @@ -52,3 +52,13 @@ functions are used. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_flags.3 b/libxo/xo_set_flags.3 index 52997c5ec1c1..a4c5754656cb 100644 --- a/libxo/xo_set_flags.3 +++ b/libxo/xo_set_flags.3 @@ -137,3 +137,13 @@ handle. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_info.3 b/libxo/xo_set_info.3 index 8ea06570a68e..c9c653f7597b 100644 --- a/libxo/xo_set_info.3 +++ b/libxo/xo_set_info.3 @@ -100,3 +100,13 @@ and "data-help" attributes: .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_options.3 b/libxo/xo_set_options.3 index 5b7c8eda72a5..bb44c9ca8207 100644 --- a/libxo/xo_set_options.3 +++ b/libxo/xo_set_options.3 @@ -29,3 +29,13 @@ The options are identical to those listed in .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_style.3 b/libxo/xo_set_style.3 index 8e34033a5953..6cac9cdc5319 100644 --- a/libxo/xo_set_style.3 +++ b/libxo/xo_set_style.3 @@ -51,3 +51,13 @@ The name can be any of the styles: "text", "xml", "json", or "html". .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_syslog_enterprise_id.3 b/libxo/xo_set_syslog_enterprise_id.3 index da2eed73a939..79eda02dd568 100644 --- a/libxo/xo_set_syslog_enterprise_id.3 +++ b/libxo/xo_set_syslog_enterprise_id.3 @@ -34,3 +34,13 @@ https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers .Sh SEE ALSO .Xr xo_syslog 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_version.3 b/libxo/xo_set_version.3 index 5f9394d5c6d6..271d2357a200 100644 --- a/libxo/xo_set_version.3 +++ b/libxo/xo_set_version.3 @@ -32,3 +32,13 @@ is in use. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_set_writer.3 b/libxo/xo_set_writer.3 index 2f93bd94a44f..22c8ee91083b 100644 --- a/libxo/xo_set_writer.3 +++ b/libxo/xo_set_writer.3 @@ -54,3 +54,13 @@ flush any pending data associated with the opaque pointer. .Sh SEE ALSO .Xr xo_emit 3 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + diff --git a/libxo/xo_syslog.3 b/libxo/xo_syslog.3 index db92d3693c53..c56c1dcc64c8 100644 --- a/libxo/xo_syslog.3 +++ b/libxo/xo_syslog.3 @@ -77,3 +77,13 @@ function names. .Xr xo_set_syslog_enterprise_id 3 , .Xr xo_format 5 , .Xr libxo 3 +.Sh HISTORY +The +.Nm libxo +library first appeared in +.Fx 11.0 . +.Sh AUTHORS +.Nm libxo +was written by +.An Phil Shafer Aq Mt phil@freebsd.org . + |