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

Function process_3rd_separators

common/splice_script.c:834–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834static struct splice_script_error *process_3rd_separators(const tal_t *ctx,
835 struct token ***tokens_inout)
836{
837 struct token **input = *tokens_inout;
838 struct token **tokens = tal_arr(ctx, struct token *,
839 tal_count(input) * 3);
840 char *split_point;
841 size_t script_index;
842 size_t n = 0;
843
844 for (size_t i = 0; i < tal_count(input); i++) {
845 switch(input[i]->type) {
846 case TOK_CHAR:
847 return new_error(ctx, INVALID_TOKEN, input[i],
848 "3rd_separators");
849 case TOK_DELIMITER:
850 case TOK_ARROW:
851 case TOK_PIPE:
852 case TOK_COLON:
853 case TOK_PLUS:
854 case TOK_MINUS:
855 tokens[n++] = tal_steal(tokens, input[i]);
856 break;
857 case TOK_STR:
858 if ((split_point = strchr(input[i]->str,
859 AT_SYMBOL))) {
860 if (split_point != strrchr(input[i]->str,
861 AT_SYMBOL))
862 return new_error_offset(ctx,
863 TOO_MANY_ATS,
864 input[i],
865 "3rd_separators",
866 split_point - input[i]->str);
867
868 *split_point = 0;
869 tokens[n++] = tal_steal(tokens, input[i]);
870
871 script_index = input[i]->script_index;
872 script_index += (split_point - input[i]->str);
873
874 tokens[n++] = new_token(tokens, TOK_ATSYM,
875 script_index);
876
877 script_index++;
878
879 tokens[n] = new_token(tokens, TOK_STR,
880 script_index);
881 tokens[n++]->str = split_point + 1;
882 } else {
883 tokens[n++] = tal_steal(tokens, input[i]);
884 }
885 break;
886 case TOK_ATSYM:
887 case TOK_SATS:
888 case TOK_PERCENT:
889 case TOK_QUESTION:
890 case TOK_WILDCARD:
891 case TOK_FEE:

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