* mdocml: Carefully let mandoc_getcontrol() handle libroff's detection of
@ 2011-03-29 9:00 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-03-29 9:00 UTC (permalink / raw)
To: source
Log Message:
-----------
Carefully let mandoc_getcontrol() handle libroff's detection of a macro
line. Note that we now properly ignore \.", which earlier would have
been pushed through macro detection. This required attention to all
entries of roff_parse().
This removes a TODO by schwarze@ to the effect that \. can be a control
character, which is now handled in mandoc_getcontrol().
Modified Files:
--------------
mdocml:
TODO
roff.c
Revision Data
-------------
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.96
retrieving revision 1.97
diff -LTODO -LTODO -u -p -r1.96 -r1.97
--- TODO
+++ TODO
@@ -16,11 +16,6 @@
.br \}
reported by ulrich spoerlein Tue, 19 Oct 2010 20:39:50 +0200
-- \. at the start of the line does *not* prevent interpretation
- of the following word as a macro.
- Werner LEMBERG on bug-groff@ Tue, 22 Mar 2011 14:21:28 +0100
- http://lists.gnu.org/archive/html/bug-groff/2011-03/msg00011.html
-
************************************************************************
* formatter bugs
************************************************************************
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -Lroff.c -Lroff.c -u -p -r1.129 -r1.130
--- roff.c
+++ roff.c
@@ -33,9 +33,6 @@
#define RSTACK_MAX 128
-#define ROFF_CTL(c) \
- ('.' == (c) || '\'' == (c))
-
enum rofft {
ROFF_ad,
ROFF_am,
@@ -476,7 +473,7 @@ roff_parseln(struct roff *r, int ln, cha
{
enum rofft t;
enum rofferr e;
- int ppos;
+ int ppos, ctl;
/*
* Run the reserved-word filter only if we have some reserved
@@ -486,6 +483,9 @@ roff_parseln(struct roff *r, int ln, cha
if (r->first_string && ! roff_res(r, bufp, szp, pos))
return(ROFF_REPARSE);
+ ppos = pos;
+ ctl = mandoc_getcontrol(*bufp, &pos);
+
/*
* First, if a scope is open and we're not a macro, pass the
* text through the macro's filter. If a scope isn't open and
@@ -494,7 +494,7 @@ roff_parseln(struct roff *r, int ln, cha
* no matter our state.
*/
- if (r->last && ! ROFF_CTL((*bufp)[pos])) {
+ if (r->last && ! ctl) {
t = r->last->tok;
assert(roffs[t].text);
e = (*roffs[t].text)
@@ -503,18 +503,18 @@ roff_parseln(struct roff *r, int ln, cha
if (ROFF_CONT != e)
return(e);
if (r->eqn)
- return(eqn_read(&r->eqn, ln, *bufp, *offs));
+ return(eqn_read(&r->eqn, ln, *bufp, pos));
if (r->tbl)
- return(tbl_read(r->tbl, ln, *bufp, *offs));
+ return(tbl_read(r->tbl, ln, *bufp, pos));
return(ROFF_CONT);
- } else if ( ! ROFF_CTL((*bufp)[pos])) {
+ } else if ( ! ctl) {
if (r->eqn)
- return(eqn_read(&r->eqn, ln, *bufp, *offs));
+ return(eqn_read(&r->eqn, ln, *bufp, pos));
if (r->tbl)
- return(tbl_read(r->tbl, ln, *bufp, *offs));
+ return(tbl_read(r->tbl, ln, *bufp, pos));
return(ROFF_CONT);
} else if (r->eqn)
- return(eqn_read(&r->eqn, ln, *bufp, *offs));
+ return(eqn_read(&r->eqn, ln, *bufp, ppos));
/*
* If a scope is open, go to the child handler for that macro,
@@ -527,7 +527,7 @@ roff_parseln(struct roff *r, int ln, cha
assert(roffs[t].sub);
return((*roffs[t].sub)
(r, t, bufp, szp,
- ln, pos, pos, offs));
+ ln, ppos, pos, offs));
}
/*
@@ -536,7 +536,6 @@ roff_parseln(struct roff *r, int ln, cha
* the compilers handle it.
*/
- ppos = pos;
if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos)))
return(ROFF_CONT);
@@ -570,7 +569,6 @@ roff_endparse(struct roff *r)
}
}
-
/*
* Parse a roff node's type from the input buffer. This must be in the
* form of ".foo xxx" in the usual way.
@@ -582,13 +580,7 @@ roff_parse(struct roff *r, const char *b
size_t maclen;
enum rofft t;
- assert(ROFF_CTL(buf[*pos]));
- (*pos)++;
-
- while (' ' == buf[*pos] || '\t' == buf[*pos])
- (*pos)++;
-
- if ('\0' == buf[*pos])
+ if ('\0' == buf[*pos] || '"' == buf[*pos])
return(ROFF_MAX);
mac = buf + *pos;
@@ -598,6 +590,7 @@ roff_parse(struct roff *r, const char *b
? ROFF_USERDEF : roff_hash_find(mac, maclen);
*pos += (int)maclen;
+
while (buf[*pos] && ' ' == buf[*pos])
(*pos)++;
@@ -816,11 +809,7 @@ roff_block_sub(ROFF_ARGS)
*/
if (r->last->end) {
- i = pos + 1;
- while (' ' == (*bufp)[i] || '\t' == (*bufp)[i])
- i++;
-
- for (j = 0; r->last->end[j]; j++, i++)
+ for (i = pos, j = 0; r->last->end[j]; j++, i++)
if ((*bufp)[i] != r->last->end[j])
break;
@@ -831,6 +820,10 @@ roff_block_sub(ROFF_ARGS)
roffnode_pop(r);
roffnode_cleanscope(r);
+ while (' ' == (*bufp)[i] || '\t' == (*bufp)[i])
+ i++;
+
+ pos = i;
if (ROFF_MAX != roff_parse(r, *bufp, &pos))
return(ROFF_RERUN);
return(ROFF_IGN);
@@ -842,8 +835,8 @@ roff_block_sub(ROFF_ARGS)
* pulling it out of the hashtable.
*/
- ppos = pos;
- t = roff_parse(r, *bufp, &pos);
+ if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos)))
+ return(ROFF_IGN);
/*
* Macros other than block-end are only significant
@@ -880,7 +873,6 @@ roff_cond_sub(ROFF_ARGS)
enum rofft t;
enum roffrule rr;
- ppos = pos;
rr = r->last->rule;
/*
--
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:[~2011-03-29 9:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-29 9:00 mdocml: Carefully let mandoc_getcontrol() handle libroff's detection of kristaps
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).