=================================================================== RCS file: /cvs/mandoc/tag.c,v retrieving revision 1.2 retrieving revision 1.4 diff -u -p -r1.2 -r1.4 --- mandoc/tag.c 2015/07/18 03:41:37 1.2 +++ mandoc/tag.c 2015/07/25 14:02:06 1.4 @@ -1,4 +1,4 @@ -/* $Id: tag.c,v 1.2 2015/07/18 03:41:37 schwarze Exp $ */ +/* $Id: tag.c,v 1.4 2015/07/25 14:02:06 schwarze Exp $ */ /* * Copyright (c) 2015 Ingo Schwarze * @@ -34,6 +34,7 @@ struct tag_entry { size_t line; + int prio; char s[]; }; @@ -52,7 +53,7 @@ static int tag_fd = -1; * where various marked-up terms are documented and create * the temporary tags file, saving the name for the pager. */ -void +char * tag_init(void) { struct ohash_info tag_info; @@ -64,7 +65,7 @@ tag_init(void) if ((tag_fd = mkstemp(tag_fn)) == -1) { free(tag_fn); tag_fn = NULL; - return; + return(NULL); } tag_info.alloc = tag_alloc; @@ -73,12 +74,6 @@ tag_init(void) tag_info.key_offset = offsetof(struct tag_entry, s); tag_info.data = NULL; ohash_init(&tag_data, 4, &tag_info); -} - -char * -tag_filename(void) -{ - return(tag_fn); } @@ -87,7 +82,7 @@ tag_filename(void) * or 0 if the term is unknown. */ size_t -tag_get(const char *s, size_t len) +tag_get(const char *s, size_t len, int prio) { struct tag_entry *entry; const char *end; @@ -100,14 +95,14 @@ tag_get(const char *s, size_t len) end = s + len; slot = ohash_qlookupi(&tag_data, s, &end); 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. */ 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; const char *end; @@ -127,6 +122,7 @@ tag_put(const char *s, size_t len, size_t line) ohash_insert(&tag_data, slot, entry); } entry->line = line; + entry->prio = prio; } /*