version 1.40, 2014/01/02 16:29:55 |
version 1.44, 2014/03/19 21:51:20 |
|
|
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> |
|
* Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
enum mandoclevel file_status; /* status of current parse */ |
enum mandoclevel file_status; /* status of current parse */ |
enum mandoclevel wlevel; /* ignore messages below this */ |
enum mandoclevel wlevel; /* ignore messages below this */ |
int line; /* line number in the file */ |
int line; /* line number in the file */ |
enum mparset inttype; /* which parser to use */ |
int options; /* parser options */ |
struct man *pman; /* persistent man parser */ |
struct man *pman; /* persistent man parser */ |
struct mdoc *pmdoc; /* persistent mdoc parser */ |
struct mdoc *pmdoc; /* persistent mdoc parser */ |
struct man *man; /* man parser */ |
struct man *man; /* man parser */ |
|
|
struct roff *roff; /* roff parser (!NULL) */ |
struct roff *roff; /* roff parser (!NULL) */ |
int reparse_count; /* finite interp. stack */ |
int reparse_count; /* finite interp. stack */ |
mandocmsg mmsg; /* warning/error message handler */ |
mandocmsg mmsg; /* warning/error message handler */ |
void *arg; /* argument to mmsg */ |
|
const char *file; |
const char *file; |
struct buf *secondary; |
struct buf *secondary; |
char *defos; /* default operating system */ |
char *defos; /* default operating system */ |
Line 254 pset(const char *buf, int pos, struct mparse *curp) |
|
Line 254 pset(const char *buf, int pos, struct mparse *curp) |
|
return; |
return; |
} |
} |
|
|
switch (curp->inttype) { |
if (MPARSE_MDOC & curp->options) { |
case (MPARSE_MDOC): |
|
if (NULL == curp->pmdoc) |
if (NULL == curp->pmdoc) |
curp->pmdoc = mdoc_alloc(curp->roff, curp, |
curp->pmdoc = mdoc_alloc( |
curp->defos); |
curp->roff, curp, curp->defos, |
|
MPARSE_QUICK & curp->options ? 1 : 0); |
assert(curp->pmdoc); |
assert(curp->pmdoc); |
curp->mdoc = curp->pmdoc; |
curp->mdoc = curp->pmdoc; |
return; |
return; |
case (MPARSE_MAN): |
} else if (MPARSE_MAN & curp->options) { |
if (NULL == curp->pman) |
if (NULL == curp->pman) |
curp->pman = man_alloc(curp->roff, curp); |
curp->pman = man_alloc(curp->roff, curp, |
|
MPARSE_QUICK & curp->options ? 1 : 0); |
assert(curp->pman); |
assert(curp->pman); |
curp->man = curp->pman; |
curp->man = curp->pman; |
return; |
return; |
default: |
|
break; |
|
} |
} |
|
|
if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) { |
if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) { |
if (NULL == curp->pmdoc) |
if (NULL == curp->pmdoc) |
curp->pmdoc = mdoc_alloc(curp->roff, curp, |
curp->pmdoc = mdoc_alloc( |
curp->defos); |
curp->roff, curp, curp->defos, |
|
MPARSE_QUICK & curp->options ? 1 : 0); |
assert(curp->pmdoc); |
assert(curp->pmdoc); |
curp->mdoc = curp->pmdoc; |
curp->mdoc = curp->pmdoc; |
return; |
return; |
} |
} |
|
|
if (NULL == curp->pman) |
if (NULL == curp->pman) |
curp->pman = man_alloc(curp->roff, curp); |
curp->pman = man_alloc(curp->roff, curp, |
|
MPARSE_QUICK & curp->options ? 1 : 0); |
assert(curp->pman); |
assert(curp->pman); |
curp->man = curp->pman; |
curp->man = curp->pman; |
} |
} |
|
|
if (0 == rc) { |
if (0 == rc) { |
assert(MANDOCLEVEL_FATAL <= curp->file_status); |
assert(MANDOCLEVEL_FATAL <= curp->file_status); |
break; |
break; |
} |
} else if (2 == rc) |
|
break; |
|
|
/* Temporary buffers typically are not full. */ |
/* Temporary buffers typically are not full. */ |
|
|
|
|
} |
} |
|
|
struct mparse * |
struct mparse * |
mparse_alloc(enum mparset inttype, enum mandoclevel wlevel, |
mparse_alloc(int options, enum mandoclevel wlevel, |
mandocmsg mmsg, void *arg, char *defos) |
mandocmsg mmsg, char *defos) |
{ |
{ |
struct mparse *curp; |
struct mparse *curp; |
|
|
Line 771 mparse_alloc(enum mparset inttype, enum mandoclevel wl |
|
Line 773 mparse_alloc(enum mparset inttype, enum mandoclevel wl |
|
|
|
curp = mandoc_calloc(1, sizeof(struct mparse)); |
curp = mandoc_calloc(1, sizeof(struct mparse)); |
|
|
|
curp->options = options; |
curp->wlevel = wlevel; |
curp->wlevel = wlevel; |
curp->mmsg = mmsg; |
curp->mmsg = mmsg; |
curp->arg = arg; |
|
curp->inttype = inttype; |
|
curp->defos = defos; |
curp->defos = defos; |
|
|
curp->roff = roff_alloc(inttype, curp); |
curp->roff = roff_alloc(curp, options); |
return(curp); |
return(curp); |
} |
} |
|
|