aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit1001fe029bca51173d79b3b314825dc33a40bb65 (patch)
tree7617e6bfaa4af6b729a1bd484233c036f4e5ef42
parent63715ce7fcf7bb1237ac456e45c0d5ecefda8e2c (diff)
downloadmandoc-1001fe029bca51173d79b3b314825dc33a40bb65.tar.gz
mandoc-1001fe029bca51173d79b3b314825dc33a40bb65.tar.zst
mandoc-1001fe029bca51173d79b3b314825dc33a40bb65.zip
basic support for tag priorities; written at YYC
-rw-r--r--mdoc_term.c6
-rw-r--r--tag.c10
-rw-r--r--tag.h6
3 files changed, 12 insertions, 10 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index d8a8ff3f..bed304c1 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.320 2015/07/17 22:38:29 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.321 2015/07/25 14:02:06 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -2268,7 +2268,7 @@ termp_tag_pre(DECL_ARGS)
(n->parent->tok == MDOC_Xo &&
n->parent->parent->prev == NULL &&
n->parent->parent->parent->tok == MDOC_It)) &&
- ! tag_get(n->child->string, 0))
- tag_put(n->child->string, 0, p->line);
+ ! tag_get(n->child->string, 0, 1))
+ tag_put(n->child->string, 0, 1, p->line);
return(1);
}
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 <schwarze@openbsd.org>
*
@@ -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;
}
/*
diff --git a/tag.h b/tag.h
index 3708e4e3..b6030bb4 100644
--- a/tag.h
+++ b/tag.h
@@ -1,4 +1,4 @@
-/* $Id: tag.h,v 1.2 2015/07/21 03:26:22 schwarze Exp $ */
+/* $Id: tag.h,v 1.3 2015/07/25 14:02:06 schwarze Exp $ */
/*
* Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -18,8 +18,8 @@
__BEGIN_DECLS
char *tag_init(void);
-size_t tag_get(const char *, size_t);
-void tag_put(const char *, size_t, size_t);
+size_t tag_get(const char *, size_t, int);
+void tag_put(const char *, size_t, int, size_t);
void tag_write(void);
void tag_unlink(void);