version 1.209, 2018/12/30 00:49:55 |
version 1.213, 2019/06/03 19:58:02 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* 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-2018 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2019 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.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 |
Line 157 mparse_buf_r(struct mparse *curp, struct buf blk, size |
|
Line 157 mparse_buf_r(struct mparse *curp, struct buf blk, size |
|
ln.sz = 256; |
ln.sz = 256; |
ln.buf = mandoc_malloc(ln.sz); |
ln.buf = mandoc_malloc(ln.sz); |
ln.next = NULL; |
ln.next = NULL; |
firstln = loop = NULL; |
firstln = lastln = loop = NULL; |
lnn = curp->line; |
lnn = curp->line; |
pos = 0; |
pos = 0; |
inloop = 0; |
inloop = 0; |
Line 255 mparse_buf_r(struct mparse *curp, struct buf blk, size |
|
Line 255 mparse_buf_r(struct mparse *curp, struct buf blk, size |
|
/* XXX Ugly hack to mark the end of the input. */ |
/* XXX Ugly hack to mark the end of the input. */ |
|
|
if (i == blk.sz || blk.buf[i] == '\0') { |
if (i == blk.sz || blk.buf[i] == '\0') { |
|
if (pos + 2 > ln.sz) |
|
resize_buf(&ln, 256); |
ln.buf[pos++] = '\n'; |
ln.buf[pos++] = '\n'; |
ln.buf[pos] = '\0'; |
ln.buf[pos] = '\0'; |
} |
} |
|
|
mparse_open(struct mparse *curp, const char *file) |
mparse_open(struct mparse *curp, const char *file) |
{ |
{ |
char *cp; |
char *cp; |
int fd; |
int fd, save_errno; |
|
|
cp = strrchr(file, '.'); |
cp = strrchr(file, '.'); |
curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz")); |
curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz")); |
Line 623 mparse_open(struct mparse *curp, const char *file) |
|
Line 625 mparse_open(struct mparse *curp, const char *file) |
|
*/ |
*/ |
|
|
if ( ! curp->gzip) { |
if ( ! curp->gzip) { |
|
save_errno = errno; |
mandoc_asprintf(&cp, "%s.gz", file); |
mandoc_asprintf(&cp, "%s.gz", file); |
fd = open(cp, O_RDONLY); |
fd = open(cp, O_RDONLY); |
free(cp); |
free(cp); |
|
errno = save_errno; |
if (fd != -1) { |
if (fd != -1) { |
curp->gzip = 1; |
curp->gzip = 1; |
return fd; |
return fd; |
Line 688 mparse_free(struct mparse *curp) |
|
Line 692 mparse_free(struct mparse *curp) |
|
struct roff_meta * |
struct roff_meta * |
mparse_result(struct mparse *curp) |
mparse_result(struct mparse *curp) |
{ |
{ |
|
roff_state_reset(curp->man); |
if (curp->options & MPARSE_VALIDATE) { |
if (curp->options & MPARSE_VALIDATE) { |
if (curp->man->meta.macroset == MACROSET_MDOC) |
if (curp->man->meta.macroset == MACROSET_MDOC) |
mdoc_validate(curp->man); |
mdoc_validate(curp->man); |