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

Diff for /mandoc/tag.c between version 1.2 and 1.4

version 1.2, 2015/07/18 03:41:37 version 1.4, 2015/07/25 14:02:06
Line 34 
Line 34 
   
 struct tag_entry {  struct tag_entry {
         size_t   line;          size_t   line;
           int      prio;
         char     s[];          char     s[];
 };  };
   
Line 52  static int   tag_fd = -1;
Line 53  static int   tag_fd = -1;
  * where various marked-up terms are documented and create   * where various marked-up terms are documented and create
  * the temporary tags file, saving the name for the pager.   * the temporary tags file, saving the name for the pager.
  */   */
 void  char *
 tag_init(void)  tag_init(void)
 {  {
         struct ohash_info        tag_info;          struct ohash_info        tag_info;
Line 64  tag_init(void)
Line 65  tag_init(void)
         if ((tag_fd = mkstemp(tag_fn)) == -1) {          if ((tag_fd = mkstemp(tag_fn)) == -1) {
                 free(tag_fn);                  free(tag_fn);
                 tag_fn = NULL;                  tag_fn = NULL;
                 return;                  return(NULL);
         }          }
   
         tag_info.alloc = tag_alloc;          tag_info.alloc = tag_alloc;
Line 73  tag_init(void)
Line 74  tag_init(void)
         tag_info.key_offset = offsetof(struct tag_entry, s);          tag_info.key_offset = offsetof(struct tag_entry, s);
         tag_info.data = NULL;          tag_info.data = NULL;
         ohash_init(&tag_data, 4, &tag_info);          ohash_init(&tag_data, 4, &tag_info);
 }  
   
 char *  
 tag_filename(void)  
 {  
   
         return(tag_fn);          return(tag_fn);
 }  }
   
Line 87  tag_filename(void)
Line 82  tag_filename(void)
  * or 0 if the term is unknown.   * or 0 if the term is unknown.
  */   */
 size_t  size_t
 tag_get(const char *s, size_t len)  tag_get(const char *s, size_t len, int prio)
 {  {
         struct tag_entry        *entry;          struct tag_entry        *entry;
         const char              *end;          const char              *end;
Line 100  tag_get(const char *s, size_t len)
Line 95  tag_get(const char *s, size_t len)
         end = s + len;          end = s + len;
         slot = ohash_qlookupi(&tag_data, s, &end);          slot = ohash_qlookupi(&tag_data, s, &end);
         entry = ohash_find(&tag_data, slot);          entry = ohash_find(&tag_data, slot);
         return(entry == NULL ? 0 : entry->line);          return((entry == NULL || prio < entry->prio) ? 0 : entry->line);
 }  }
   
 /*  /*
  * Set the line number where a term is defined.   * Set the line number where a term is defined.
  */   */
 void  void
 tag_put(const char *s, size_t len, size_t line)  tag_put(const char *s, size_t len, int prio, size_t line)
 {  {
         struct tag_entry        *entry;          struct tag_entry        *entry;
         const char              *end;          const char              *end;
Line 127  tag_put(const char *s, size_t len, size_t line)
Line 122  tag_put(const char *s, size_t len, size_t line)
                 ohash_insert(&tag_data, slot, entry);                  ohash_insert(&tag_data, slot, entry);
         }          }
         entry->line = line;          entry->line = line;
           entry->prio = prio;
 }  }
   
 /*  /*

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

CVSweb