-/* $Id: demandoc.c,v 1.10 2014/03/19 22:20:43 schwarze Exp $ */
+/* $Id: demandoc.c,v 1.13 2015/01/15 04:26:39 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+
+#include <sys/types.h>
#include <assert.h>
#include <ctype.h>
main(int argc, char *argv[])
{
struct mparse *mp;
- int ch, i, list;
+ struct mchars *mchars;
+ int ch, fd, i, list;
extern int optind;
progname = strrchr(argv[0], '/');
argc -= optind;
argv += optind;
- mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_FATAL, NULL, NULL);
+ mchars = mchars_alloc();
+ mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_BADARG, NULL, mchars, NULL);
assert(mp);
if (0 == argc)
for (i = 0; i < argc; i++) {
mparse_reset(mp);
- pmandoc(mp, -1, argv[i], list);
+ if (mparse_open(mp, &fd, argv[i]) != MANDOCLEVEL_OK) {
+ perror(argv[i]);
+ continue;
+ }
+ pmandoc(mp, fd, argv[i], list);
}
mparse_free(mp);
+ mchars_free(mchars);
return((int)MANDOCLEVEL_OK);
}
struct man *man;
int line, col;
- if (mparse_readfd(mp, fd, fn) >= MANDOCLEVEL_FATAL) {
- fprintf(stderr, "%s: Parse failure\n", fn);
- return;
- }
-
+ mparse_readfd(mp, fd, fn);
mparse_result(mp, &mdoc, &man, NULL);
line = 1;
col = 0;