From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Add support for EQNPOS_SUBSUP and a doubly-linked eqn_box list.
Date: Sun, 28 Sep 2014 07:32:08 -0400 (EDT) [thread overview]
Message-ID: <201409281132.s8SBW8Li015863@krisdoz.my.domain> (raw)
Log Message:
-----------
Add support for EQNPOS_SUBSUP and a doubly-linked eqn_box list.
Modified Files:
--------------
mdocml:
mandoc.h
eqn.c
Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/eqn.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -Leqn.c -Leqn.c -u -p -r1.45 -r1.46
--- eqn.c
+++ eqn.c
@@ -198,6 +198,7 @@ static const struct eqnstr eqnposs[EQNPO
{ "", 0 }, /* EQNPOS_NONE */
{ "over", 4 }, /* EQNPOS_OVER */
{ "sup", 3 }, /* EQNPOS_SUP */
+ { NULL, 0 }, /* EQNPOS_SUPSUB */
{ "sub", 3 }, /* EQNPOS_SUB */
{ "to", 2 }, /* EQNPOS_TO */
{ "from", 4 }, /* EQNPOS_FROM */
@@ -569,14 +570,30 @@ eqn_box(struct eqn_node *ep, struct eqn_
return(EQN_OK);
}
+ /*
+ * Positional elements (e.g., over, sub, sup, ...).
+ */
for (i = 0; i < (int)EQNPOS__MAX; i++) {
- if ( ! EQNSTREQ(&eqnposs[i], start, sz))
+ /* Some elements don't have names (are virtual). */
+ if (NULL == eqnposs[i].name)
+ continue;
+ else if ( ! EQNSTREQ(&eqnposs[i], start, sz))
continue;
if (NULL == last->last) {
EQN_MSG(MANDOCERR_EQNSYNT, ep);
return(EQN_ERR);
}
- last->last->pos = (enum eqn_post)i;
+ /*
+ * If we encounter x sub y sup z, then according to the
+ * eqn manual, we regard this as x subsup y z.
+ */
+ if (EQNPOS_SUP == i &&
+ NULL != last->last->prev &&
+ EQNPOS_SUB == last->last->prev->pos)
+ last->last->prev->pos = EQNPOS_SUBSUP;
+ else
+ last->last->pos = (enum eqn_post)i;
+
if (EQN_EOF == (c = eqn_box(ep, last))) {
EQN_MSG(MANDOCERR_EQNEOF, ep);
return(EQN_ERR);
@@ -665,10 +682,11 @@ eqn_box_alloc(struct eqn_node *ep, struc
bp->parent = parent;
bp->size = ep->gsize;
- if (NULL == parent->first)
- parent->first = bp;
- else
+ if (NULL != parent->first) {
parent->last->next = bp;
+ bp->prev = parent->last;
+ } else
+ parent->first = bp;
parent->last = bp;
return(bp);
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.156
retrieving revision 1.157
diff -Lmandoc.h -Lmandoc.h -u -p -r1.156 -r1.157
--- mandoc.h
+++ mandoc.h
@@ -336,6 +336,7 @@ enum eqn_post {
EQNPOS_NONE = 0,
EQNPOS_OVER,
EQNPOS_SUP,
+ EQNPOS_SUBSUP,
EQNPOS_SUB,
EQNPOS_TO,
EQNPOS_FROM,
@@ -366,6 +367,7 @@ struct eqn_box {
struct eqn_box *first; /* first child node */
struct eqn_box *last; /* last child node */
struct eqn_box *next; /* node sibling */
+ struct eqn_box *prev; /* node sibling */
struct eqn_box *parent; /* node sibling */
char *text; /* text (or NULL) */
char *left;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-09-28 11:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201409281132.s8SBW8Li015863@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).