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

Function gi_normalize

src/discover/gitignore_guard.c:169–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169bool gi_normalize(const char *line, size_t length, gi_view_t *view, gi_guard_t *guard) {
170 *view = (gi_view_t){0};
171 if (!length || !gi_work(guard, 1) || line[0] == '#') {
172 return gi_active(guard);
173 }
174 if (!gi_trim(line, &length, guard) || !length) {
175 return gi_active(guard);
176 }
177 if (!gi_work(guard, 1)) {
178 return false;
179 }
180 if (*line == '!') {
181 view->negated = true;
182 line++;
183 length--;
184 }
185 if (!length || !gi_work(guard, 1)) {
186 return gi_active(guard);
187 }
188 if (line[length - 1] == '/') {
189 view->dir_only = true;
190 length--;
191 }
192 if (!length || !gi_work(guard, 1)) {
193 return gi_active(guard);
194 }
195 if (*line == '/') {
196 view->rooted = true;
197 line++;
198 length--;
199 }
200 for (size_t i = 0; !view->rooted && i < length; i++) {
201 if (!gi_work(guard, 1)) {
202 return false;
203 }
204 view->rooted = line[i] == '/';
205 }
206 view->text = line;
207 view->length = length;
208 return true;
209}

Callers 2

gi_lineFunction · 0.85
gi_add_patternFunction · 0.85

Calls 3

gi_workFunction · 0.85
gi_activeFunction · 0.85
gi_trimFunction · 0.85

Tested by

no test coverage detected