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

Function find_bolt_ref

tools/check-bolt.c:96–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96static char *find_bolt_ref(const char *prefix, char **p, size_t *len)
97{
98 for (;;) {
99 char *bolt, *end;
100 size_t preflen;
101
102 /* Quote is of form 'BOLT #X:' */
103 *p = strchr(*p, '*');
104 if (!*p)
105 return NULL;
106 *p += 1;
107 while (cisspace(**p))
108 (*p)++;
109 if (strncmp(*p, prefix, strlen(prefix)) != 0)
110 continue;
111 *p += strlen(prefix);
112 while (cisspace(**p))
113 (*p)++;
114 if (**p != '#')
115 continue;
116 (*p)++;
117
118 preflen = strcspn(*p, " :");
119 bolt = tal_strndup(NULL, *p, preflen);
120
121 (*p) += preflen;
122 while (cisspace(**p))
123 (*p)++;
124 if (**p != ':')
125 continue;
126 (*p)++;
127
128 end = strstr(*p, "*/");
129 if (!end)
130 *len = strlen(*p);
131 else
132 *len = end - *p;
133 return bolt;
134 }
135}
136
137static char *code_to_regex(const char *code, size_t len, bool escape)
138{

Callers 1

mainFunction · 0.85

Calls 1

cisspaceFunction · 0.85

Tested by

no test coverage detected