Lines Matching full:roff
1 /* $OpenBSD: roff.c,v 1.276 2025/01/06 18:48:13 schwarze Exp $ */
18 * Implementation of the roff(7) parser for mandoc(1).
34 #include "roff.h"
100 struct roff {
142 #define ROFF_ARGS struct roff *r, /* parse ctx */ \
170 static int roffnode_cleanscope(struct roff *);
171 static int roffnode_pop(struct roff *);
172 static void roffnode_push(struct roff *, enum roff_tok,
182 static int roff_ccond(struct roff *, int, int);
191 static int roff_eqndelim(struct roff *, struct buf *, int);
192 static int roff_evalcond(struct roff *, int, char *, int *);
196 static int roff_expand(struct roff *, struct buf *,
200 static void roff_free1(struct roff *);
206 static int roff_getregn(struct roff *,
208 static int roff_getregro(const struct roff *,
210 static const char *roff_getstrn(struct roff *,
212 static int roff_hasregn(const struct roff *,
225 static enum roff_tok roff_parse(struct roff *, char *, int *,
227 static int roff_parse_comment(struct roff *, struct buf *,
229 static int roff_parsetext(struct roff *, struct buf *,
237 static void roff_setregn(struct roff *, const char *,
239 static void roff_setstr(struct roff *,
686 * Pop the current node off of the stack of roff instructions currently
690 roffnode_pop(struct roff *r)
705 * Push a roff node onto the instruction stack. This must later be
709 roffnode_push(struct roff *r, enum roff_tok tok, const char *name,
726 /* --- roff parser state data management ---------------------------------- */
729 roff_free1(struct roff *r)
766 roff_reset(struct roff *r)
780 roff_free(struct roff *r)
792 struct roff *
795 struct roff *r;
797 r = mandoc_calloc(1, sizeof(struct roff));
832 roff_setreg(man->roff, "nS", 0, '=');
861 roff_man_alloc(struct roff *roff, const char *os_s, int quick)
866 man->roff = roff;
870 roff->man = man;
964 n->string = roff_strdup(man->roff, word);
977 addstr = roff_strdup(man->roff, word);
1222 /* --- main functions of the roff parser ---------------------------------- */
1232 roff_parse_comment(struct roff *r, struct buf *buf, int ln, int pos, char ec)
1352 roff_expand(struct roff *r, struct buf *buf, int ln, int pos, char ec)
1610 * Parse a quoted or unquoted roff-style request or macro argument.
1619 roff_getarg(struct roff *r, char **cpp, int ln, int *pos)
1725 roff_parsetext(struct roff *r, struct buf *buf, int pos, int *offs)
1791 roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs, size_t len)
1926 * This is neither a roff request nor a user-defined macro.
1933 /* Execute a roff request or a user-defined macro. */
1939 * Internal interface function to tell the roff parser that execution
1944 roff_userret(struct roff *r)
1958 roff_endparse(struct roff *r)
1984 roff_parse(struct roff *r, char *buf, int *pos, int ln, int ppos)
2079 roffnode_cleanscope(struct roff *r)
2098 roff_ccond(struct roff *r, int ln, int ppos)
2546 roff_evalcond(struct roff *r, int ln, char *v, int *pos)
3002 roff_setreg(struct roff *r, const char *name, int val, char sign)
3008 roff_setregn(struct roff *r, const char *name, size_t len,
3048 roff_getregro(const struct roff *r, const char *name)
3074 roff_getreg(struct roff *r, const char *name)
3080 roff_getregn(struct roff *r, const char *name, size_t len, char sign)
3113 roff_hasregn(const struct roff *r, const char *name, size_t len)
3207 /* --- handler functions for roff requests -------------------------------- */
3323 roff_eqndelim(struct roff *r, struct buf *buf, int pos)
4024 * Measure the length in bytes of the roff identifier at *cpp
4098 roff_setstr(struct roff *r, const char *name, const char *string,
4165 * Rudimentary roff copy mode:
4182 roff_getstrn(struct roff *r, const char *name, size_t len,
4296 roff_strdup(const struct roff *r, const char *p)
4384 roff_getformat(const struct roff *r)
4401 roff_getcontrol(const struct roff *r, const char *cp, int *ppos)