=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mandoc_xr.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/mandoc/mandoc_xr.c 2017/07/01 09:47:23 1.1 --- src/usr.bin/mandoc/mandoc_xr.c 2017/07/02 15:31:48 1.2 *************** *** 1,4 **** ! /* $OpenBSD: mandoc_xr.c,v 1.1 2017/07/01 09:47:23 schwarze Exp $ */ /* * Copyright (c) 2017 Ingo Schwarze * --- 1,4 ---- ! /* $OpenBSD: mandoc_xr.c,v 1.2 2017/07/02 15:31:48 schwarze Exp $ */ /* * Copyright (c) 2017 Ingo Schwarze * *************** *** 59,75 **** xr_first = xr_last = NULL; } ! void mandoc_xr_add(const char *sec, const char *name, int line, int pos) { ! struct mandoc_xr *xr; const char *pend; size_t ssz, nsz, tsz; unsigned int slot; uint32_t hv; if (xr_hash == NULL) ! return; ssz = strlen(sec) + 1; nsz = strlen(name) + 1; --- 59,76 ---- xr_first = xr_last = NULL; } ! int mandoc_xr_add(const char *sec, const char *name, int line, int pos) { ! struct mandoc_xr *xr, *oxr; const char *pend; size_t ssz, nsz, tsz; unsigned int slot; + int ret; uint32_t hv; if (xr_hash == NULL) ! return 0; ssz = strlen(sec) + 1; nsz = strlen(name) + 1; *************** *** 86,100 **** pend = xr->hashkey + tsz; hv = ohash_interval(xr->hashkey, &pend); slot = ohash_lookup_memory(xr_hash, xr->hashkey, tsz, hv); ! if (ohash_find(xr_hash, slot) == NULL) { ohash_insert(xr_hash, slot, xr); if (xr_first == NULL) xr_first = xr; else xr_last->next = xr; xr_last = xr; ! } else ! free(xr); } struct mandoc_xr * --- 87,107 ---- pend = xr->hashkey + tsz; hv = ohash_interval(xr->hashkey, &pend); slot = ohash_lookup_memory(xr_hash, xr->hashkey, tsz, hv); ! if ((oxr = ohash_find(xr_hash, slot)) == NULL) { ohash_insert(xr_hash, slot, xr); if (xr_first == NULL) xr_first = xr; else xr_last->next = xr; xr_last = xr; ! return 0; ! } ! ! ret = (oxr->line == -1) ^ (xr->line == -1); ! if (xr->line == -1) ! oxr->line = -1; ! free(xr); ! return ret; } struct mandoc_xr *