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
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);