diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-22 00:16:37 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-22 00:16:37 +0000 |
commit | 85ad7222c5fd305322c7aa679840eedd807ef942 (patch) | |
tree | 2eefc978a7cccecf46cca22e3e6387891166e240 /eqn.c | |
parent | 4a9b3b91ed883201108726196caa6825d5df0914 (diff) | |
download | mandoc-85ad7222c5fd305322c7aa679840eedd807ef942.tar.gz |
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.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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) |