int man_parseln(struct man *man, int ln, char *buf, int offs) { man->flags |= MAN_NEWLINE; return (roff_getcontrol(man->roff, buf, &offs) ? man_pmacro(man, ln, buf, offs) : man_ptext(man, ln, buf, offs)); }
int man_parseln(struct roff_man *man, int ln, char *buf, int offs) { if (man->last->type != ROFFT_EQN || ln > man->last->line) man->flags |= MAN_NEWLINE; return roff_getcontrol(man->roff, buf, &offs) ? man_pmacro(man, ln, buf, offs) : man_ptext(man, ln, buf, offs); }
/* * Main parse routine. Parses a single line -- really just hands off to * the macro (mdoc_pmacro()) or text parser (mdoc_ptext()). */ int mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs) { if (mdoc->last->type != MDOC_EQN || ln > mdoc->last->line) mdoc->flags |= MDOC_NEWLINE; /* * Let the roff nS register switch SYNOPSIS mode early, * such that the parser knows at all times * whether this mode is on or off. * Note that this mode is also switched by the Sh macro. */ if (roff_getreg(mdoc->roff, "nS")) mdoc->flags |= MDOC_SYNOPSIS; else mdoc->flags &= ~MDOC_SYNOPSIS; return(roff_getcontrol(mdoc->roff, buf, &offs) ? mdoc_pmacro(mdoc, ln, buf, offs) : mdoc_ptext(mdoc, ln, buf, offs)); }
enum rofferr roff_parseln(struct roff *r, int ln, char **bufp, size_t *szp, int pos, int *offs) { enum rofft t; enum rofferr e; int ppos, ctl; /* * Run the reserved-word filter only if we have some reserved * words to fill in. */ e = roff_res(r, bufp, szp, ln, pos); if (ROFF_IGN == e) return(e); assert(ROFF_CONT == e); ppos = pos; ctl = roff_getcontrol(r, *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 * we're not a macro, just let it through. * Finally, if there's an equation scope open, divert it into it * no matter our state. */ if (r->last && ! ctl) { t = r->last->tok; assert(roffs[t].text); e = (*roffs[t].text) (r, t, bufp, szp, ln, pos, pos, offs); assert(ROFF_IGN == e || ROFF_CONT == e); if (ROFF_CONT != e) return(e); if (r->eqn) return(eqn_read(&r->eqn, ln, *bufp, pos, offs)); if (r->tbl) return(tbl_read(r->tbl, ln, *bufp, pos)); return(roff_parsetext(*bufp + pos)); } else if ( ! ctl) { if (r->eqn) return(eqn_read(&r->eqn, ln, *bufp, pos, offs)); if (r->tbl) return(tbl_read(r->tbl, ln, *bufp, pos)); return(roff_parsetext(*bufp + pos)); } else if (r->eqn) return(eqn_read(&r->eqn, ln, *bufp, ppos, offs)); /* * If a scope is open, go to the child handler for that macro, * as it may want to preprocess before doing anything with it. * Don't do so if an equation is open. */ if (r->last) { t = r->last->tok; assert(roffs[t].sub); return((*roffs[t].sub) (r, t, bufp, szp, ln, ppos, pos, offs)); } /* * Lastly, as we've no scope open, try to look up and execute * the new macro. If no macro is found, simply return and let * the compilers handle it. */ if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos))) return(ROFF_CONT); assert(roffs[t].proc); return((*roffs[t].proc) (r, t, bufp, szp, ln, ppos, pos, offs)); }