-/* $Id: man.c,v 1.9 2009/03/26 09:55:39 kristaps Exp $ */
+/* $Id: man.c,v 1.10 2009/03/26 11:16:21 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
int
man_pmacro(struct man *m, int ln, char *buf)
{
- int i, j, c;
+ int i, j, c, ppos;
char mac[5];
/* Comments and empties are quickly ignored. */
return(1);
}
+ ppos = i;
+
if (buf[i] && '\\' == buf[i])
if (buf[i + 1] && '\"' == buf[i + 1])
return(1);
/* Copy the first word into a nil-terminated buffer. */
- for (j = 0; j < 4; j++) {
- if (0 == (mac[j] = buf[j + i]))
+ for (j = 0; j < 4; j++, i++) {
+ if (0 == (mac[j] = buf[i]))
break;
- else if (' ' == buf[j + i])
+ else if (' ' == buf[i])
break;
}
if (j == 4 || j < 1) {
if ( ! (MAN_IGN_MACRO & m->pflags)) {
- (void)man_verr(m, ln, i,
+ (void)man_verr(m, ln, ppos,
"ill-formed macro: %s", mac);
goto err;
}
- if ( ! man_vwarn(m, ln, 0, "ill-formed macro: %s", mac))
+ if ( ! man_vwarn(m, ln, ppos,
+ "ill-formed macro: %s", mac))
goto err;
return(1);
}
if (MAN_MAX == (c = man_hash_find(m->htab, mac))) {
if ( ! (MAN_IGN_MACRO & m->pflags)) {
- (void)man_verr(m, ln, i,
+ (void)man_verr(m, ln, ppos,
"unknown macro: %s", mac);
goto err;
}
- if ( ! man_vwarn(m, ln, i, "unknown macro: %s", mac))
+ if ( ! man_vwarn(m, ln, ppos,
+ "unknown macro: %s", mac))
goto err;
return(1);
}
/* Begin recursive parse sequence. */
- if ( ! man_macro(m, c, ln, 1, &i, buf))
+ if ( ! man_macro(m, c, ln, ppos, &i, buf))
goto err;
return(1);
-/* $Id: man_macro.c,v 1.7 2009/03/25 16:07:36 kristaps Exp $ */
+/* $Id: man_macro.c,v 1.8 2009/03/26 11:16:21 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
*
*/
#include <assert.h>
#include <ctype.h>
-#include <err.h> /* XXX */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* ARGSUSED */
static int
-man_args(struct man *man, int line,
+man_args(struct man *m, int line,
int *pos, char *buf, char **v)
{
if (buf[*pos])
return(1);
- warnx("tail whitespace");
- return(-1);
+ if ( ! man_vwarn(m, line, *pos, "trailing spaces"))
+ return(-1);
+
+ return(1);
}
/*
(*pos)++;
if (0 == buf[*pos]) {
- warnx("unterminated quotation");
- return(-1);
+ if ( ! man_vwarn(m, line, *pos, "unterminated quote"))
+ return(-1);
+ return(1);
}
buf[(*pos)++] = 0;
if (buf[*pos])
return(1);
- warnx("tail whitespace");
- return(-1);
+ if ( ! man_vwarn(m, line, *pos, "trailing spaces"))
+ return(-1);
+ return(1);
}