On 2023/03/28 22:25:42 +0200, Theo Buehler <t...@theobuehler.org> wrote: > Contrary to what I convinced op@ to be the case, duplicate tags may exist > in legitimate tags files. So we should ignore duplicates rather than > erroring on them. This fixes parsing the /var/db/libc.tags file. > > $ grep -wc ^memcpy /var/db/libc.tags > 2
oh... good to know that there may be duplicates. it would be nice to have mg record all of the tags (dups included) and allow the user to choose where to jump when there are multiple location. Overkill for now however. OK for me, thanks! > Index: tags.c > =================================================================== > RCS file: /cvs/src/usr.bin/mg/tags.c,v > retrieving revision 1.23 > diff -u -p -r1.23 tags.c > --- tags.c 22 Mar 2023 22:09:37 -0000 1.23 > +++ tags.c 28 Mar 2023 19:55:17 -0000 > @@ -388,8 +388,10 @@ addctag(char *s) > if (*l == '\0') > goto cleanup; > t->pat = strip(l, strlen(l)); > - if (RB_INSERT(tagtree, &tags, t) != NULL) > - goto cleanup; > + if (RB_INSERT(tagtree, &tags, t) != NULL) { > + free(t); > + free(s); > + } > return (TRUE); > cleanup: > free(t);