A message line `A->>+B: text`: its arrow; false when it has none. */
| 647 | |
| 648 | /* A message line `A->>+B: text`: its arrow; false when it has none. */ |
| 649 | static bool dg_sequence_message(dg_t *dg, dg_str_t ln, uint32_t line) { |
| 650 | static const char *const arrows[] = {"<<-->>", "<<->>", "-->>", "->>", "--x", "-x", |
| 651 | "--)", "-)", "-->", "->", NULL}; |
| 652 | const char *colon = memchr(ln.p, ':', ln.n); |
| 653 | dg_str_t head = colon ? dg_s(ln.p, (size_t)(colon - ln.p)) : ln; |
| 654 | for (int k = 0; arrows[k]; k++) { |
| 655 | size_t al = strlen(arrows[k]); |
| 656 | for (size_t i = 0; i + al <= head.n; i++) { |
| 657 | if (memcmp(head.p + i, arrows[k], al) != 0) { |
| 658 | continue; |
| 659 | } |
| 660 | dg_str_t to = dg_trim(dg_s(head.p + i + al, head.n - i - al)); |
| 661 | while (to.n && (to.p[0] == '+' || to.p[0] == '-')) { |
| 662 | to.p++; |
| 663 | to.n--; |
| 664 | } |
| 665 | dg_str_t label = colon |
| 666 | ? dg_s(colon + SKIP_ONE, (size_t)(ln.p + ln.n - colon) - SKIP_ONE) |
| 667 | : dg_s(NULL, 0); |
| 668 | bool reply = arrows[k][0] == '-' && arrows[k][SKIP_ONE] == '-'; |
| 669 | dg_arrow(dg, dg_s(head.p, i), to, label, reply ? "reply" : "message", line); |
| 670 | return true; |
| 671 | } |
| 672 | } |
| 673 | return false; |
| 674 | } |
| 675 | |
| 676 | static void dg_sequence(dg_t *dg, dg_lines_t *it) { |
| 677 | static const char participant[] = "participant "; |
no test coverage detected