summaryrefslogtreecommitdiffstats
path: root/tag.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-07-25 14:02:06 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-07-25 14:02:06 +0000
commit8ecd58a3e222c5d6df72c264a6aad988c28321a4 (patch)
treeb9e03a585ffa25006118286ff62be9f72972a303 /tag.c
parentbb2b6d70625fb83d3ac31a1015588226c42b8457 (diff)
downloadmandoc-8ecd58a3e222c5d6df72c264a6aad988c28321a4.tar.gz
basic support for tag priorities; written at YYC
Diffstat (limited to 'tag.c')
-rw-r--r--tag.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tag.c b/tag.c
index b2326bb6..1b141e42 100644
--- a/tag.c
+++ b/tag.c
@@ -34,6 +34,7 @@
struct tag_entry {
size_t line;
+ int prio;
char s[];
};
@@ -81,7 +82,7 @@ tag_init(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;
@@ -94,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;
@@ -121,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;
}
/*