From 1001fe029bca51173d79b3b314825dc33a40bb65 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 25 Jul 2015 14:02:06 +0000 Subject: basic support for tag priorities; written at YYC --- tag.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tag.c') diff --git a/tag.c b/tag.c index fd91e4a4..8ce576f4 100644 --- a/tag.c +++ b/tag.c @@ -1,4 +1,4 @@ -/* $Id: tag.c,v 1.3 2015/07/21 03:26:22 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[]; }; @@ -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; } /* -- cgit v1.2.3-56-ge451