aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/eqn.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-22 00:16:37 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-22 00:16:37 +0000
commit4a2f730daa58794b6b003c016d48ca1406632f88 (patch)
treeba002fb7e4f299c27ab8e2f42611c01bec3f49b0 /eqn.c
parent4203843b4b3d7c453508e83eb6824fbd1b2f76bc (diff)
downloadmandoc-4a2f730daa58794b6b003c016d48ca1406632f88.tar.gz
mandoc-4a2f730daa58794b6b003c016d48ca1406632f88.tar.zst
mandoc-4a2f730daa58794b6b003c016d48ca1406632f88.zip
Accomodate for hard-spaces with tildes. For now, consider them regular
spaces. Also allow for tabs. Finally, have the parser correctly handle open and close brackets smooshed against other terms. All of these handle "details" noted in the CACM paper.
Diffstat (limited to 'eqn.c')
-rw-r--r--eqn.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/eqn.c b/eqn.c
index 41a5950e..66c55ff1 100644
--- a/eqn.c
+++ b/eqn.c
@@ -1,4 +1,4 @@
-/* $Id: eqn.c,v 1.21 2011/07/21 23:42:28 kristaps Exp $ */
+/* $Id: eqn.c,v 1.22 2011/07/22 00:16:37 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -453,11 +453,11 @@ eqn_next(struct eqn_node *ep, char quote, size_t *sz, int repl)
{
char *start, *next;
int q, diff, lim;
- size_t ssz;
+ size_t ssz, dummy;
struct eqn_def *def;
if (NULL == sz)
- sz = &ssz;
+ sz = &dummy;
lim = 0;
ep->rew = ep->cur;
@@ -482,14 +482,26 @@ again:
}
start = &ep->data[(int)ep->cur];
- next = q ? strchr(start, quote) : strchr(start, ' ');
+
+ if ( ! q) {
+ if ('{' == *start || '}' == *start)
+ ssz = 1;
+ else
+ ssz = strcspn(start + 1, " ~\"{}\t") + 1;
+ next = start + (int)ssz;
+ if ('\0' == *next)
+ next = NULL;
+ } else
+ next = strchr(start, quote);
if (NULL != next) {
*sz = (size_t)(next - start);
ep->cur += *sz;
if (q)
ep->cur++;
- while (' ' == ep->data[(int)ep->cur])
+ while (' ' == ep->data[(int)ep->cur] ||
+ '\t' == ep->data[(int)ep->cur] ||
+ '~' == ep->data[(int)ep->cur])
ep->cur++;
} else {
if (q)