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

Function xo_gettext_rewrite_fields

tools/libxo/libxo/libxo.c:6006–6038  ·  view source on GitHub ↗

* At this point, we need to consider if the fields have been reordered, * such as "The {:adjective} {:noun}" to "La {:noun} {:adjective}". * * We need to rewrite the new_fields using the old fields order, * so that we can render the message using the arguments as they * appear on the stack. It's a lot of work, but we don't really * want to (eventually) fall into the standard printf code whi

Source from the content-addressed store, hash-verified

6004 * varargs we were originally passed.
6005 */
6006static void
6007xo_gettext_rewrite_fields (xo_handle_t *xop UNUSED,
6008 xo_field_info_t *fields, unsigned max_fields)
6009{
6010 xo_field_info_t tmp[max_fields];
6011 bzero(tmp, max_fields * sizeof(tmp[0]));
6012
6013 unsigned fnum = 0;
6014 xo_field_info_t *newp, *outp, *zp;
6015 for (newp = fields, outp = tmp; newp->xfi_ftype; newp++, outp++) {
6016 switch (newp->xfi_ftype) {
6017 case XO_ROLE_NEWLINE: /* Don't get numbered */
6018 case XO_ROLE_TEXT:
6019 case XO_ROLE_EBRACE:
6020 case 'G':
6021 *outp = *newp;
6022 outp->xfi_renum = 0;
6023 continue;
6024 }
6025
6026 zp = xo_gettext_find_field(fields, ++fnum);
6027 if (zp == NULL) { /* Should not occur */
6028 *outp = *newp;
6029 outp->xfi_renum = 0;
6030 continue;
6031 }
6032
6033 *outp = *zp;
6034 outp->xfi_renum = newp->xfi_fnum;
6035 }
6036
6037 memcpy(fields, tmp, max_fields * sizeof(tmp[0]));
6038}
6039
6040/*
6041 * We've got two lists of fields, the old list from the original

Callers 1

Calls 3

bzeroFunction · 0.85
xo_gettext_find_fieldFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected