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

Function process_2nd_separators

common/splice_script.c:731–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731static struct splice_script_error *process_2nd_separators(const tal_t *ctx,
732 struct token ***tokens_inout)
733{
734 struct token **input = *tokens_inout;
735 struct token **tokens = tal_arr(ctx, struct token *,
736 tal_count(input) * 3);
737 char *split_point;
738 size_t script_index;
739 size_t n = 0;
740
741 for (size_t i = 0; i < tal_count(input); i++) {
742 switch(input[i]->type) {
743 case TOK_CHAR:
744 return new_error(ctx, INVALID_TOKEN, input[i],
745 "2nd_separators");
746 case TOK_DELIMITER:
747 case TOK_ARROW:
748 case TOK_PIPE:
749 case TOK_COLON:
750 tokens[n++] = tal_steal(tokens, input[i]);
751 break;
752 case TOK_STR:
753 if ((split_point = strchr(input[i]->str,
754 PLUS_SYMBOL))) {
755 if (split_point != strrchr(input[i]->str,
756 PLUS_SYMBOL))
757 return new_error_offset(ctx,
758 TOO_MANY_PLUS,
759 input[i],
760 "2nd_separators",
761 split_point - input[i]->str);
762
763 *split_point = 0;
764 tokens[n++] = tal_steal(tokens, input[i]);
765
766 script_index = input[i]->script_index;
767 script_index += (split_point - input[i]->str);
768
769 tokens[n++] = new_token(tokens, TOK_PLUS,
770 script_index);
771
772 script_index++;
773
774 tokens[n] = new_token(tokens, TOK_STR,
775 script_index);
776 tokens[n++]->str = split_point + 1;
777 } else if ((split_point = strchr(input[i]->str,
778 MINUS_SYMBOL))) {
779 if (split_point != strrchr(input[i]->str,
780 MINUS_SYMBOL))
781 return new_error_offset(ctx,
782 TOO_MANY_MINUS,
783 input[i],
784 "2nd_separators",
785 split_point - input[i]->str);
786
787 *split_point = 0;
788 tokens[n++] = tal_steal(tokens, input[i]);

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