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

Function go_bracket

internal/cbm/doclink_go.c:1051–1081  ·  view source on GitHub ↗

One bracket pair text[open] .. text[close] of a paragraph; `first` is the * first opening bracket since the last closing one. */

Source from the content-addressed store, hash-verified

1049/* One bracket pair text[open] .. text[close] of a paragraph; `first` is the
1050 * first opening bracket since the last closing one. */
1051static void go_bracket(go_doc_t *d, const char *text, size_t len, size_t first, size_t open,
1052 size_t close, uint32_t line) {
1053 const char *inner = text + open + SKIP_ONE;
1054 size_t inner_len = close - open - SKIP_ONE;
1055 const go_linkdef_t *def = go_pair_linkdef(d, text, first, open, close);
1056 if (def) {
1057 /* a URL is external whatever it says: a long one is stored clipped */
1058 go_emit(d, def->url, go_clip(def->url, def->url_len, GO_URL_MAX), line, CBM_DOCLINK_HREF);
1059 return;
1060 }
1061 if (open > 0 && !go_border_ok(go_rune_before(text, open))) {
1062 return;
1063 }
1064 if (close + SKIP_ONE < len && !go_border_ok(go_rune_at(text, len, close + SKIP_ONE))) {
1065 return;
1066 }
1067 if (inner_len > GO_REF_MAX) {
1068 /* Not decided here, and never by its beginning: the resolver reports
1069 * the clipped text as unparseable. */
1070 if (go_long_ref_shaped(inner, inner_len)) {
1071 go_emit(d, inner, go_clip(inner, inner_len, (size_t)GO_REF_MAX + SKIP_ONE), line,
1072 CBM_DOCLINK_GO_DOC_LINK);
1073 }
1074 return;
1075 }
1076 CBMDocLinkGoRef ref;
1077 if (!cbm_doclink_go_parse_ref(inner, inner_len, &ref) || go_names_own_param(d, &ref)) {
1078 return;
1079 }
1080 go_emit(d, inner, inner_len, line, CBM_DOCLINK_GO_DOC_LINK);
1081}
1082
1083/* The paragraph's lines joined by newlines, scanned for bracket pairs: `[`
1084 * (re)starts a pair, the next `]` closes it. */

Callers 1

go_scan_paragraphFunction · 0.85

Calls 9

go_pair_linkdefFunction · 0.85
go_emitFunction · 0.85
go_clipFunction · 0.85
go_border_okFunction · 0.85
go_rune_beforeFunction · 0.85
go_rune_atFunction · 0.85
go_long_ref_shapedFunction · 0.85
cbm_doclink_go_parse_refFunction · 0.85
go_names_own_paramFunction · 0.85

Tested by

no test coverage detected