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

Function xo_do_emit

tools/libxo/libxo/libxo.c:6510–6552  ·  view source on GitHub ↗

* Parse and emit a set of fields */

Source from the content-addressed store, hash-verified

6508 * Parse and emit a set of fields
6509 */
6510static int
6511xo_do_emit (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt)
6512{
6513 xop->xo_columns = 0; /* Always reset it */
6514 xop->xo_errno = errno; /* Save for "%m" */
6515
6516 if (fmt == NULL)
6517 return 0;
6518
6519 unsigned max_fields;
6520 xo_field_info_t *fields = NULL;
6521
6522 /* Adjust XOEF_RETAIN based on global flags */
6523 if (XOF_ISSET(xop, XOF_RETAIN_ALL))
6524 flags |= XOEF_RETAIN;
6525 if (XOF_ISSET(xop, XOF_RETAIN_NONE))
6526 flags &= ~XOEF_RETAIN;
6527
6528 /*
6529 * Check for 'retain' flag, telling us to retain the field
6530 * information. If we've already saved it, then we can avoid
6531 * re-parsing the format string.
6532 */
6533 if (!(flags & XOEF_RETAIN)
6534 || xo_retain_find(fmt, &fields, &max_fields) != 0
6535 || fields == NULL) {
6536
6537 /* Nothing retained; parse the format string */
6538 max_fields = xo_count_fields(xop, fmt);
6539 fields = alloca(max_fields * sizeof(fields[0]));
6540 bzero(fields, max_fields * sizeof(fields[0]));
6541
6542 if (xo_parse_fields(xop, fields, max_fields, fmt))
6543 return -1; /* Warning already displayed */
6544
6545 if (flags & XOEF_RETAIN) {
6546 /* Retain the info */
6547 xo_retain_add(fmt, fields, max_fields);
6548 }
6549 }
6550
6551 return xo_do_emit_fields(xop, fields, max_fields, fmt);
6552}
6553
6554/*
6555 * Rebuild a format string in a gettext-friendly format. This function

Callers 6

xo_emit_hvFunction · 0.85
xo_emit_hFunction · 0.85
xo_emitFunction · 0.85
xo_emit_hvfFunction · 0.85
xo_emit_hfFunction · 0.85
xo_emit_fFunction · 0.85

Calls 6

xo_retain_findFunction · 0.85
xo_count_fieldsFunction · 0.85
bzeroFunction · 0.85
xo_parse_fieldsFunction · 0.85
xo_retain_addFunction · 0.85
xo_do_emit_fieldsFunction · 0.85

Tested by

no test coverage detected