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

Function php_mask_spans

internal/cbm/doclink_php.c:234–267  ·  view source on GitHub ↗

Mark the bytes of a line that sit in a code span (backticks paired on the * line). */

Source from the content-addressed store, hash-verified

232/* Mark the bytes of a line that sit in a code span (backticks paired on the
233 * line). */
234static void php_mask_spans(const php_line_t *ln, bool *mask) {
235 size_t i = 0;
236 while (i < ln->n) {
237 if (ln->p[i] != '`') {
238 i++;
239 continue;
240 }
241 size_t run = 0;
242 while (i + run < ln->n && ln->p[i + run] == '`') {
243 run++;
244 }
245 size_t j = i + run;
246 size_t close = SIZE_MAX;
247 while (j < ln->n) {
248 size_t r = 0;
249 while (j + r < ln->n && ln->p[j + r] == '`') {
250 r++;
251 }
252 if (r == run) {
253 close = j;
254 break;
255 }
256 j += r ? r : SKIP_ONE;
257 }
258 if (close == SIZE_MAX) {
259 i += run;
260 continue;
261 }
262 for (size_t k = i; k < close + run; k++) {
263 mask[k] = true;
264 }
265 i = close + run;
266 }
267}
268
269/* The first position >= j of p[0, n) that is no white space. */
270static size_t php_skip_space(const char *p, size_t j, size_t n) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected