From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id b708ed3c; for ; Sat, 25 Jul 2015 09:02:37 -0500 (EST) Date: Sat, 25 Jul 2015 09:02:37 -0500 (EST) Message-Id: <4449873231889931210.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: basic support for tag priorities; written at YYC X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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