MCPcopy Create free account
hub / github.com/ElementsProject/lightning / process_top_separators

Function process_top_separators

common/splice_script.c:627–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625}
626
627static struct splice_script_error *process_top_separators(const tal_t *ctx,
628 struct token ***tokens_inout)
629{
630 struct token **input = *tokens_inout;
631 struct token **tokens = tal_arr(ctx, struct token *,
632 tal_count(input) * 3);
633 char *split_point;
634 size_t script_index;
635 size_t n = 0;
636
637 for (size_t i = 0; i < tal_count(input); i++) {
638 switch(input[i]->type) {
639 case TOK_CHAR:
640 return new_error(ctx, INVALID_TOKEN, input[i],
641 "top_separators");
642 case TOK_DELIMITER:
643 case TOK_ARROW:
644 tokens[n++] = tal_steal(tokens, input[i]);
645 break;
646 case TOK_STR:
647 if ((split_point = strchr(input[i]->str,
648 PIPE_SYMBOL))) {
649 if (split_point != strrchr(input[i]->str,
650 PIPE_SYMBOL))
651 return new_error_offset(ctx,
652 TOO_MANY_PIPES,
653 input[i],
654 "top_separators",
655 split_point - input[i]->str);
656
657 *split_point = 0;
658 tokens[n++] = tal_steal(tokens, input[i]);
659
660 script_index = input[i]->script_index;
661 script_index += (split_point - input[i]->str);
662
663 tokens[n++] = new_token(tokens, TOK_PIPE,
664 script_index);
665
666 script_index++;
667
668 tokens[n] = new_token(tokens, TOK_STR,
669 script_index);
670 tokens[n++]->str = split_point + 1;
671
672 } else if ((split_point = strchr(input[i]->str,
673 COLON_SYMBOL))) {
674 if (split_point != strrchr(input[i]->str,
675 COLON_SYMBOL))
676 return new_error_offset(ctx,
677 TOO_MANY_COLONS,
678 input[i],
679 "top_separators",
680 split_point - input[i]->str);
681
682 *split_point = 0;
683 tokens[n++] = tal_steal(tokens, input[i]);
684

Callers 1

parse_splice_scriptFunction · 0.85

Calls 4

new_errorFunction · 0.85
new_error_offsetFunction · 0.85
new_tokenFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected