summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/man.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2010-08-18 01:17:44 +0000
committerschwarze <schwarze@openbsd.org>2010-08-18 01:17:44 +0000
commitcf51ef33bb47e42b7437acaa190ece79543df94d (patch)
tree724ce5a2e5dbb31e398e7e14e39322a4d5c3b03a /usr.bin/mandoc/man.c
parentUse isascii(3) to make sure we really throw away non-ASCII characters, (diff)
downloadwireguard-openbsd-cf51ef33bb47e42b7437acaa190ece79543df94d.tar.xz
wireguard-openbsd-cf51ef33bb47e42b7437acaa190ece79543df94d.zip
Simplify and sync the code and comments for copying the macro name
in man_pmacro() and mdoc_pmacro(). In particular, no need to use isgraph(3) here, that has already been done in main.c. Joint work by Kristaps and myself, ok kristaps@.
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r--usr.bin/mandoc/man.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 95b176237af..a6839fe32d0 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.38 2010/07/25 18:05:54 schwarze Exp $ */
+/* $Id: man.c,v 1.39 2010/08/18 01:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -17,7 +17,6 @@
#include <sys/types.h>
#include <assert.h>
-#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
@@ -477,23 +476,14 @@ man_pmacro(struct man *m, int ln, char *buf, int offs)
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) {