aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Shafer <phil@FreeBSD.org>2017-06-09 03:30:07 +0000
committerPhil Shafer <phil@FreeBSD.org>2017-06-09 03:30:07 +0000
commit4d0cf5aca3fe69e3abb9719b9dc74d3daf4643f8 (patch)
tree92eaf265c5a9319cbdc5a8c0b3d0432031587ad9
parentb51d07578967b942e94d6a59fdcabd8e6313713f (diff)
downloadsrc-4d0cf5aca3fe69e3abb9719b9dc74d3daf4643f8.tar.gz
src-4d0cf5aca3fe69e3abb9719b9dc74d3daf4643f8.zip
Import libxo 0.8.1vendor/Juniper/libxo/0.8.1
Notes
Notes: svn path=/vendor/Juniper/libxo/dist/; revision=319729 svn path=/vendor/Juniper/libxo/0.8.1/; revision=319730; tag=vendor/Juniper/libxo/0.8.1
-rw-r--r--configure.ac2
-rw-r--r--doc/libxo-manual.html2
-rw-r--r--libxo/libxo.c20
3 files changed, 18 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 3deb765f357f..1cf91469a025 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
-AC_INIT([libxo], [0.8.0], [phil@juniper.net])
+AC_INIT([libxo], [0.8.1], [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 e25445543ecb..c7577b922678 100644
--- a/doc/libxo-manual.html
+++ b/doc/libxo-manual.html
@@ -22011,7 +22011,7 @@ jQuery(function ($) {
</tr>
<tr>
<td class="header left"></td>
-<td class="header right">June 3, 2017</td>
+<td class="header right">June 8, 2017</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>
diff --git a/libxo/libxo.c b/libxo/libxo.c
index c6db0ed4fa7c..7f015b7b2dcf 100644
--- a/libxo/libxo.c
+++ b/libxo/libxo.c
@@ -239,7 +239,6 @@ typedef uint8_t xo_color_t;
#define XO_EFF_CLEAR_BITS XO_EFF_RESET /* Reset gets reset, surprisingly */
typedef uint8_t xo_effect_t;
-typedef uint8_t xo_color_t;
typedef struct xo_colors_s {
xo_effect_t xoc_effects; /* Current effect set */
xo_color_t xoc_col_fg; /* Foreground color */
@@ -685,6 +684,7 @@ xo_default_init (void)
#if !defined(NO_LIBXO_OPTIONS)
if (!XOF_ISSET(xop, XOF_NO_ENV)) {
char *env = getenv("LIBXO_OPTIONS");
+
if (env)
xo_set_options_simple(xop, env);
@@ -1158,7 +1158,7 @@ xo_utf8_emit_len (wchar_t wc)
}
/*
- * Emit a single wide character into the given buffer
+ * Emit one wide character into the given buffer
*/
static void
xo_utf8_emit_char (char *buf, ssize_t len, wchar_t wc)
@@ -1170,7 +1170,7 @@ xo_utf8_emit_char (char *buf, ssize_t len, wchar_t wc)
return;
}
- /* Start with the low bits and insert them, six bits as a time */
+ /* Start with the low bits and insert them, six bits at a time */
for (i = len - 1; i >= 0; i--) {
buf[i] = 0x80 | (wc & 0x3f);
wc >>= 6; /* Drop the low six bits */
@@ -1178,7 +1178,7 @@ xo_utf8_emit_char (char *buf, ssize_t len, wchar_t wc)
/* Finish off the first byte with the length bits */
buf[0] &= xo_utf8_data_bits[len]; /* Clear out the length bits */
- buf[0] |= xo_utf8_len_bits[len]; /* Drop in new length bits */
+ buf[0] |= xo_utf8_len_bits[len]; /* Drop in new length bits */
}
/*
@@ -1518,6 +1518,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
newfmt[plen++] = ':';
newfmt[plen++] = ' ';
}
+
memcpy(newfmt + plen, fmt, len);
newfmt[len + plen] = '\0';
@@ -1537,6 +1538,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
ssize_t rc = vsnprintf(xbp->xb_curp, left, newfmt, vap);
+
if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
va_end(va_local);
@@ -1549,6 +1551,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
rc = vsnprintf(xbp->xb_curp, left, fmt, vap);
}
+
va_end(va_local);
rc = xo_escape_xml(xbp, rc, 1);
@@ -1559,6 +1562,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
if (code >= 0) {
const char *msg = strerror(code);
+
if (msg) {
xo_buf_append(xbp, ": ", 2);
xo_buf_append(xbp, msg, strlen(msg));
@@ -1572,6 +1576,7 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
vfprintf(stderr, newfmt, vap);
if (code >= 0) {
const char *msg = strerror(code);
+
if (msg)
fprintf(stderr, ": %s", msg);
}
@@ -1688,6 +1693,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
va_copy(va_local, vap);
ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+
rc = vsnprintf(xbp->xb_curp, left, fmt, vap);
if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
@@ -1701,6 +1707,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
rc = vsnprintf(xbp->xb_curp, left, fmt, vap);
}
+
va_end(va_local);
rc = xo_escape_xml(xbp, rc, 0);
@@ -1708,6 +1715,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
if (need_nl && code > 0) {
const char *msg = strerror(code);
+
if (msg) {
xo_buf_append(xbp, ": ", 2);
xo_buf_append(xbp, msg, strlen(msg));
@@ -1741,6 +1749,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
va_copy(va_local, vap);
rc = vsnprintf(bp, bufsiz, fmt, va_local);
}
+
va_end(va_local);
cp = bp + rc;
@@ -1776,6 +1785,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
if (need_nl && code > 0) {
const char *msg = strerror(code);
+
if (msg) {
xo_printf(xop, ": %s", msg);
}
@@ -1790,6 +1800,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
case XO_STYLE_HTML:
if (XOIF_ISSET(xop, XOIF_DIV_OPEN)) {
static char div_close[] = "</div>";
+
XOIF_CLEAR(xop, XOIF_DIV_OPEN);
xo_data_append(xop, div_close, sizeof(div_close) - 1);
@@ -2158,6 +2169,7 @@ xo_set_style_name (xo_handle_t *xop, const char *name)
return -1;
int style = xo_name_to_style(name);
+
if (style < 0)
return -1;