MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_simplify_format

Function xo_simplify_format

tools/libxo/libxo/libxo.c:6558–6585  ·  view source on GitHub ↗

* Rebuild a format string in a gettext-friendly format. This function * is exposed to tools can perform this function. See xo(1). */

Source from the content-addressed store, hash-verified

6556 * is exposed to tools can perform this function. See xo(1).
6557 */
6558char *
6559xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
6560 xo_simplify_field_func_t field_cb)
6561{
6562 xop = xo_default(xop);
6563
6564 xop->xo_columns = 0; /* Always reset it */
6565 xop->xo_errno = errno; /* Save for "%m" */
6566
6567 unsigned max_fields = xo_count_fields(xop, fmt);
6568 xo_field_info_t fields[max_fields];
6569
6570 bzero(fields, max_fields * sizeof(fields[0]));
6571
6572 if (xo_parse_fields(xop, fields, max_fields, fmt))
6573 return NULL; /* Warning already displayed */
6574
6575 xo_buffer_t xb;
6576 xo_buf_init(&xb);
6577
6578 if (with_numbers)
6579 xo_gettext_finish_numbering_fields(xop, fmt, fields);
6580
6581 if (xo_gettext_simplify_format(xop, &xb, fields, -1, fmt, field_cb))
6582 return NULL;
6583
6584 return xb.xb_bufp;
6585}
6586
6587xo_ssize_t
6588xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap)

Callers 1

mainFunction · 0.85

Calls 7

xo_defaultFunction · 0.85
xo_count_fieldsFunction · 0.85
bzeroFunction · 0.85
xo_parse_fieldsFunction · 0.85
xo_buf_initFunction · 0.85

Tested by

no test coverage detected