| 326 | */ |
| 327 | |
| 328 | static void extended_entry_extract(struct tree_desc_x *t, |
| 329 | struct name_entry *a, |
| 330 | const char *first, |
| 331 | int first_len) |
| 332 | { |
| 333 | const char *path; |
| 334 | int len; |
| 335 | struct tree_desc probe; |
| 336 | struct tree_desc_skip *skip; |
| 337 | |
| 338 | /* |
| 339 | * Extract the first entry from the tree_desc, but skip the |
| 340 | * ones that we already returned in earlier rounds. |
| 341 | */ |
| 342 | while (1) { |
| 343 | if (!t->d.size) { |
| 344 | entry_clear(a); |
| 345 | break; /* not found */ |
| 346 | } |
| 347 | entry_extract(&t->d, a); |
| 348 | for (skip = t->skip; skip; skip = skip->prev) |
| 349 | if (a->path == skip->ptr) |
| 350 | break; /* found */ |
| 351 | if (!skip) |
| 352 | break; |
| 353 | /* We have processed this entry already. */ |
| 354 | update_tree_entry(&t->d); |
| 355 | } |
| 356 | |
| 357 | if (!first || !a->path) |
| 358 | return; |
| 359 | |
| 360 | /* |
| 361 | * The caller wants "first" from this tree, or nothing. |
| 362 | */ |
| 363 | path = a->path; |
| 364 | len = tree_entry_len(a); |
| 365 | switch (check_entry_match(first, first_len, path, len)) { |
| 366 | case -1: |
| 367 | entry_clear(a); |
| 368 | case 0: |
| 369 | return; |
| 370 | default: |
| 371 | break; |
| 372 | } |
| 373 | |
| 374 | /* |
| 375 | * We need to look-ahead -- we suspect that a subtree whose |
| 376 | * name is "first" may be hiding behind the current entry "path". |
| 377 | */ |
| 378 | probe = t->d; |
| 379 | while (probe.size) { |
| 380 | entry_extract(&probe, a); |
| 381 | path = a->path; |
| 382 | len = tree_entry_len(a); |
| 383 | switch (check_entry_match(first, first_len, path, len)) { |
| 384 | case -1: |
| 385 | entry_clear(a); |
no test coverage detected