* mdocml: basic support for tag priorities; written at YYC
@ 2015-07-25 14:02 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-07-25 14:02 UTC (permalink / raw)
To: source
Log Message:
-----------
basic support for tag priorities; written at YYC
Modified Files:
--------------
mdocml:
mdoc_term.c
tag.c
tag.h
Revision Data
-------------
Index: tag.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tag.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ltag.h -Ltag.h -u -p -r1.2 -r1.3
--- tag.h
+++ tag.h
@@ -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);
Index: tag.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tag.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Ltag.c -Ltag.c -u -p -r1.3 -r1.4
--- tag.c
+++ 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_
ohash_insert(&tag_data, slot, entry);
}
entry->line = line;
+ entry->prio = prio;
}
/*
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.320
retrieving revision 1.321
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.320 -r1.321
--- mdoc_term.c
+++ mdoc_term.c
@@ -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);
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-25 14:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-25 14:02 mdocml: basic support for tag priorities; written at YYC schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).