[BACK]Return to mandoc_xr.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/mandoc_xr.c between version 1.1 and 1.3

version 1.1, 2017/07/01 09:47:30 version 1.3, 2017/07/02 21:18:29
Line 59  mandoc_xr_reset(void)
Line 59  mandoc_xr_reset(void)
         xr_first = xr_last = NULL;          xr_first = xr_last = NULL;
 }  }
   
 void  int
 mandoc_xr_add(const char *sec, const char *name, int line, int pos)  mandoc_xr_add(const char *sec, const char *name, int line, int pos)
 {  {
         struct mandoc_xr         *xr;          struct mandoc_xr         *xr, *oxr;
         const char               *pend;          const char               *pend;
         size_t                    ssz, nsz, tsz;          size_t                    ssz, nsz, tsz;
         unsigned int              slot;          unsigned int              slot;
           int                       ret;
         uint32_t                  hv;          uint32_t                  hv;
   
         if (xr_hash == NULL)          if (xr_hash == NULL)
                 return;                  return 0;
   
         ssz = strlen(sec) + 1;          ssz = strlen(sec) + 1;
         nsz = strlen(name) + 1;          nsz = strlen(name) + 1;
Line 80  mandoc_xr_add(const char *sec, const char *name, int l
Line 81  mandoc_xr_add(const char *sec, const char *name, int l
         xr->name = xr->hashkey + ssz;          xr->name = xr->hashkey + ssz;
         xr->line = line;          xr->line = line;
         xr->pos = pos;          xr->pos = pos;
           xr->count = 1;
         memcpy(xr->sec, sec, ssz);          memcpy(xr->sec, sec, ssz);
         memcpy(xr->name, name, nsz);          memcpy(xr->name, name, nsz);
   
         pend = xr->hashkey + tsz;          pend = xr->hashkey + tsz;
         hv = ohash_interval(xr->hashkey, &pend);          hv = ohash_interval(xr->hashkey, &pend);
         slot = ohash_lookup_memory(xr_hash, xr->hashkey, tsz, hv);          slot = ohash_lookup_memory(xr_hash, xr->hashkey, tsz, hv);
         if (ohash_find(xr_hash, slot) == NULL) {          if ((oxr = ohash_find(xr_hash, slot)) == NULL) {
                 ohash_insert(xr_hash, slot, xr);                  ohash_insert(xr_hash, slot, xr);
                 if (xr_first == NULL)                  if (xr_first == NULL)
                         xr_first = xr;                          xr_first = xr;
                 else                  else
                         xr_last->next = xr;                          xr_last->next = xr;
                 xr_last = xr;                  xr_last = xr;
         } else                  return 0;
                 free(xr);          }
   
           oxr->count++;
           ret = (oxr->line == -1) ^ (xr->line == -1);
           if (xr->line == -1)
                   oxr->line = -1;
           free(xr);
           return ret;
 }  }
   
 struct mandoc_xr *  struct mandoc_xr *

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

CVSweb