MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / go_parse_linkdef

Function go_parse_linkdef

internal/cbm/doclink_go.c:884–906  ·  view source on GitHub ↗

go/doc/comment parseLink: `[text]: url` with a known scheme. */

Source from the content-addressed store, hash-verified

882
883/* go/doc/comment parseLink: `[text]: url` with a known scheme. */
884static bool go_parse_linkdef(const go_line_t *l, go_linkdef_t *out) {
885 const char *s = l->s;
886 size_t n = l->len;
887 if (n == 0 || s[0] != '[') {
888 return false;
889 }
890 size_t close = go_find2(s, n, ']', ':');
891 if (close + GO_LINKDEF_TAIL >= n || !go_blank_or_tab(s[close + PAIR_LEN])) {
892 return false;
893 }
894 const char *url = s + close + GO_LINKDEF_TAIL;
895 size_t url_len = n - close - GO_LINKDEF_TAIL;
896 go_trim(&url, &url_len);
897 size_t colon = go_find2(url, url_len, ':', '/');
898 if (colon + PAIR_LEN >= url_len || url[colon + PAIR_LEN] != '/' || !go_is_scheme(url, colon)) {
899 return false;
900 }
901 out->text = s + SKIP_ONE;
902 out->text_len = close - SKIP_ONE;
903 out->url = url;
904 out->url_len = url_len;
905 return true;
906}
907
908/* A paragraph whose every line is a link definition defines links and is no
909 * text. */

Callers 2

go_para_is_linkdefsFunction · 0.85
go_collect_linkdefsFunction · 0.85

Calls 4

go_find2Function · 0.85
go_blank_or_tabFunction · 0.85
go_trimFunction · 0.85
go_is_schemeFunction · 0.85

Tested by

no test coverage detected