* The field format is: * '{' modifiers ':' content [ '/' print-fmt [ '/' encode-fmt ]] '}' * Roles are optional and include the following field types: * 'D': decoration; something non-text and non-data (colons, commmas) * 'E': error message * 'G': gettext() the entire string; optional domainname as content * 'L': label; text preceding data * 'N': note; text following data * 'P
| 5463 | * If the print-fmt is not provided, it defaults to 's'. |
| 5464 | */ |
| 5465 | static const char * |
| 5466 | xo_parse_roles (xo_handle_t *xop, const char *fmt, |
| 5467 | const char *basep, xo_field_info_t *xfip) |
| 5468 | { |
| 5469 | const char *sp; |
| 5470 | unsigned ftype = 0; |
| 5471 | xo_xff_flags_t flags = 0; |
| 5472 | uint8_t fnum = 0; |
| 5473 | |
| 5474 | for (sp = basep; sp && *sp; sp++) { |
| 5475 | if (*sp == ':' || *sp == '/' || *sp == '}') |
| 5476 | break; |
| 5477 | |
| 5478 | if (*sp == '\\') { |
| 5479 | if (sp[1] == '\0') { |
| 5480 | xo_failure(xop, "backslash at the end of string"); |
| 5481 | return NULL; |
| 5482 | } |
| 5483 | |
| 5484 | /* Anything backslashed is ignored */ |
| 5485 | sp += 1; |
| 5486 | continue; |
| 5487 | } |
| 5488 | |
| 5489 | if (*sp == ',') { |
| 5490 | const char *np; |
| 5491 | for (np = ++sp; *np; np++) |
| 5492 | if (*np == ':' || *np == '/' || *np == '}' || *np == ',') |
| 5493 | break; |
| 5494 | |
| 5495 | ssize_t slen = np - sp; |
| 5496 | if (slen > 0) { |
| 5497 | xo_xff_flags_t value; |
| 5498 | |
| 5499 | value = xo_name_lookup(xo_role_names, sp, slen); |
| 5500 | if (value) |
| 5501 | ftype = value; |
| 5502 | else { |
| 5503 | value = xo_name_lookup(xo_modifier_names, sp, slen); |
| 5504 | if (value) |
| 5505 | flags |= value; |
| 5506 | else |
| 5507 | xo_failure(xop, "unknown keyword ignored: '%.*s'", |
| 5508 | slen, sp); |
| 5509 | } |
| 5510 | } |
| 5511 | |
| 5512 | sp = np - 1; |
| 5513 | continue; |
| 5514 | } |
| 5515 | |
| 5516 | switch (*sp) { |
| 5517 | case 'C': |
| 5518 | case 'D': |
| 5519 | case 'E': |
| 5520 | case 'G': |
| 5521 | case 'L': |
| 5522 | case 'N': |
no test coverage detected