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

Function path_body

internal/cbm/doc_pdf.c:414–456  ·  view source on GitHub ↗

PATH_RE's body after the optional prefix: (?:[seg]+/)+[tail]*[end] */

Source from the content-addressed store, hash-verified

412
413/* PATH_RE's body after the optional prefix: (?:[seg]+/)+[tail]*[end] */
414static int path_body(const uint32_t *t, int n, int q) {
415 int p = q;
416 int last_ts = -1;
417 for (;;) {
418 int r = p;
419 while (r < n && path_seg(t[r])) {
420 r++;
421 }
422 if (r > p && r < n && t[r] == '/') {
423 last_ts = r + 1;
424 p = r + 1;
425 continue;
426 }
427 break;
428 }
429 if (last_ts < 0) {
430 return -1;
431 }
432 /* tail starts, from the last segment back to the first */
433 int ts = last_ts;
434 for (;;) {
435 int r = ts;
436 int last_e = -1;
437 while (r < n && path_tail(t[r])) {
438 if (path_end(t[r])) {
439 last_e = r;
440 }
441 r++;
442 }
443 if (last_e >= 0) {
444 return last_e + 1;
445 }
446 /* give back one segment: the previous '/' before ts-1 */
447 int s = ts - 2;
448 while (s >= q && t[s] != '/') {
449 s--;
450 }
451 if (s < q) {
452 return -1;
453 }
454 ts = s + 1;
455 }
456}
457
458static int path_at(const uint32_t *t, int n, int p) {
459 if (p > 0) {

Callers 1

path_atFunction · 0.85

Calls 3

path_segFunction · 0.85
path_tailFunction · 0.85
path_endFunction · 0.85

Tested by

no test coverage detected