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

Function skip_raw_string

internal/cbm/preprocessor.cpp:95–133  ·  view source on GitHub ↗

C++ raw string literals (R"delim(...)delim"). Returns the index one past the closing quote, or -1 when the form cannot be confidently recognized (unterminated, malformed delimiter) — the caller then STOPS collecting so the mis-modeled literal cannot poison the scan state of the rest of the file (#1989 review).

Source from the content-addressed store, hash-verified

93// the mis-modeled literal cannot poison the scan state of the rest of the
94// file (#1989 review).
95static int skip_raw_string(const char *source, int source_len, int quote) {
96 int j = quote + 1;
97 int delim_start = j;
98 while (j < source_len) {
99 char c = source[j];
100 if (c == '(') {
101 break;
102 }
103 // Delimiter chars: the standard d-char set excludes space, parens,
104 // backslash, and the line breaks — a double quote IS a legal d-char
105 // (R"""(...)""" compiles), so it must not end the delimiter (#1989
106 // review round 3).
107 if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == ')' || c == '\\' ||
108 j - delim_start >= 16) {
109 return -1;
110 }
111 j++;
112 }
113 if (j >= source_len || source[j] != '(') {
114 return -1;
115 }
116 int delim_len = j - delim_start;
117 j++; // past the opening "("
118 while (j < source_len) {
119 if (source[j] == ')') {
120 int k = j + 1;
121 int m = 0;
122 while (m < delim_len && k + m < source_len &&
123 source[k + m] == source[delim_start + m]) {
124 m++;
125 }
126 if (m == delim_len && k + m < source_len && source[k + m] == '"') {
127 return k + m + 1;
128 }
129 }
130 j++;
131 }
132 return -1; // unterminated raw string: uncertain
133}
134
135// If the identifier just scanned is a raw-string prefix (R, LR, uR, UR, u8R)
136// immediately followed by a quote, return skip_raw_string(...). Returns 0 for

Callers 1

raw_string_after_prefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected