Return the Nth (0-based) def matching label + name, or NULL. */
| 71 | |
| 72 | /* Return the Nth (0-based) def matching label + name, or NULL. */ |
| 73 | static CBMDefinition *nth_def_named(CBMFileResult *r, const char *label, const char *name, int nth) { |
| 74 | int seen = 0; |
| 75 | for (int i = 0; i < r->defs.count; i++) { |
| 76 | CBMDefinition *d = &r->defs.items[i]; |
| 77 | if (label && (!d->label || strcmp(d->label, label) != 0)) |
| 78 | continue; |
| 79 | if (name && (!d->name || strcmp(d->name, name) != 0)) |
| 80 | continue; |
| 81 | if (seen == nth) |
| 82 | return d; |
| 83 | seen++; |
| 84 | } |
| 85 | return NULL; |
| 86 | } |
| 87 | |
| 88 | /* ── Test ─────────────────────────────────────────────────────────── */ |
| 89 |