-/* $Id: man.c,v 1.78 2010/06/26 16:07:08 kristaps Exp $ */
+/* $Id: man.c,v 1.86 2010/08/08 14:51:32 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#include <sys/types.h>
#include <assert.h>
-#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "mandoc.h"
-#include "regs.h"
#include "libman.h"
#include "libmandoc.h"
"nf", "fi", "r", "RE",
"RS", "DT", "UC", "PD",
"Sp", "Vb", "Ve", "AT",
+ "in"
};
const char * const *man_macronames = __man_macronames;
static void man_node_unlink(struct man *,
struct man_node *);
static int man_ptext(struct man *, int, char *, int);
-static int man_pmacro(struct man *,
- const struct regset *regs,
- int, char *, int);
+static int man_pmacro(struct man *, int, char *, int);
static void man_free1(struct man *);
static void man_alloc1(struct man *);
static int macrowarn(struct man *, int, const char *, int);
struct man *
-man_alloc(void *data, int pflags, mandocmsg msg)
+man_alloc(struct regset *regs, void *data,
+ int pflags, mandocmsg msg)
{
struct man *p;
p->data = data;
p->pflags = pflags;
p->msg = msg;
+ p->regs = regs;
man_alloc1(p);
return(p);
int
-man_parseln(struct man *m, const struct regset *regs,
- int ln, char *buf, int offs)
+man_parseln(struct man *m, int ln, char *buf, int offs)
{
if (MAN_HALT & m->flags)
return(0);
return(('.' == buf[offs] || '\'' == buf[offs]) ?
- man_pmacro(m, regs, ln, buf, offs) :
+ man_pmacro(m, ln, buf, offs) :
man_ptext(m, ln, buf, offs));
}
*/
assert(i);
- if (mandoc_eos(buf, (size_t)i))
+ if (mandoc_eos(buf, (size_t)i, 0))
m->last->flags |= MAN_EOS;
descope:
int
-man_pmacro(struct man *m, const struct regset *regs,
- int ln, char *buf, int offs)
+man_pmacro(struct man *m, int ln, char *buf, int offs)
{
int i, j, ppos;
enum mant tok;
ppos = i;
- /* Copy the first word into a nil-terminated buffer. */
-
- for (j = 0; j < 4; j++, i++) {
- if ('\0' == (mac[j] = buf[i]))
- break;
- else if (' ' == buf[i])
- break;
-
- /* Check for invalid characters. */
-
- if (isgraph((u_char)buf[i]))
- continue;
- if ( ! man_pmsg(m, ln, i, MANDOCERR_BADCHAR))
- return(0);
- i--;
- }
+ /*
+ * Copy the first word into a nil-terminated buffer.
+ * Stop copying when a tab, space, or eoln is encountered.
+ */
+ j = 0;
+ while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i])
+ mac[j++] = buf[i++];
mac[j] = '\0';
if (j == 4 || j < 1) {
/* Call to handler... */
assert(man_macros[tok].fp);
- if ( ! (*man_macros[tok].fp)(m, regs, tok, ln, ppos, &i, buf))
+ if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf))
goto err;
out: