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

Function find_arrows_and_strs

common/splice_script.c:551–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551static struct splice_script_error *find_arrows_and_strs(const tal_t *ctx,
552 struct token ***tokens_inout)
553{
554 struct token **input = *tokens_inout;
555 struct token **tokens = tal_arr(ctx, struct token *, tal_count(input));
556 struct token *token = NULL;
557 size_t n = 0;
558
559 for (size_t i = 0; i < tal_count(input); i++) {
560 switch(input[i]->type) {
561 case TOK_DELIMITER:
562 if (token)
563 tokens[n++] = token;
564 token = NULL;
565 tokens[n++] = tal_steal(tokens, input[i]);
566 break;
567 case TOK_CHAR:
568 if (!token) {
569 token = new_token(tokens, TOK_STR,
570 input[i]->script_index);
571 token->str = tal_strdup(token, "");
572 }
573 tal_append_fmt(&token->str, "%c", input[i]->c);
574
575 if (find_suffix(token->str, ARROW_SYMBOL)) {
576
577 /* Terminmate the string at the arrow */
578 *find_suffix(token->str, ARROW_SYMBOL) = 0;
579
580 if (*token->str)
581 tokens[n++] = token;
582 else
583 tal_free(token);
584 token = NULL;
585
586 tokens[n++] = new_token(tokens,
587 TOK_ARROW,
588 input[i]->script_index);
589 }
590 break;
591 case TOK_ARROW:
592 case TOK_STR:
593 case TOK_PIPE:
594 case TOK_ATSYM:
595 case TOK_PLUS:
596 case TOK_MINUS:
597 case TOK_COLON:
598 case TOK_SATS:
599 case TOK_PERCENT:
600 case TOK_QUESTION:
601 case TOK_WILDCARD:
602 case TOK_FEE:
603 case TOK_CHANID:
604 case TOK_WALLET:
605 case TOK_FEERATE:
606 case TOK_NODEID:
607 case TOK_BTCADDR:
608 case TOK_CHANQUERY:

Callers 1

parse_splice_scriptFunction · 0.85

Calls 5

new_tokenFunction · 0.85
tal_append_fmtFunction · 0.85
find_suffixFunction · 0.85
tal_freeFunction · 0.85
new_errorFunction · 0.85

Tested by

no test coverage detected