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

Function cbm_source_line_count

internal/cbm/cbm.c:1748–1756  ·  view source on GitHub ↗

The ONE line counter for a source buffer (#1967). Every caller that asks * "how many lines does this file have" uses it, so the coverage report never * holds two answers for the same buffer. * * Convention: a '\n' TERMINATES a line; it does not open a new one. So the * count is the number of '\n' that have at least one byte after them, plus * one. "a\nb" and "a\nb\n" both have 2 lines (the t

Source from the content-addressed store, hash-verified

1746 * newline still counts its last line. An empty buffer counts as 1 line, because
1747 * tree-sitter still reports row 0 for it and 1-based line maps index line 1. */
1748uint32_t cbm_source_line_count(const char *src, int src_len) {
1749 uint32_t n = 1;
1750 for (int i = 0; i + 1 < src_len; i++) {
1751 if (src[i] == '\n') {
1752 n++;
1753 }
1754 }
1755 return n;
1756}
1757
1758/* Recovery subtraction (#963): tree-sitter error recovery plus the
1759 * ERROR-descending def walker often still extract constructs INSIDE a failed

Callers 3

cbm_line_offsetsFunction · 0.85
extract_file_ex_bodyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected