diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-08-18 01:17:45 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-08-18 01:17:45 +0000 |
commit | 8b63efab0fb70f28ebb08ccfadeeee8be662c02b (patch) | |
tree | 78941a0451560d6ec98f767947833d7b66111b68 /usr.bin/mandoc/mdoc.c | |
parent | c9a52f5c514aad74ee46b6ee2953f5a4f6f443bb (diff) |
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/mdoc.c')
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index cfbdacd347d..3158ab3337d 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.63 2010/08/07 18:06:45 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.64 2010/08/18 01:17:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> @@ -18,7 +18,6 @@ #include <sys/types.h> #include <assert.h> -#include <ctype.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -773,26 +772,13 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) sv = i; /* - * Copy the first word into a nil-terminated buffer. Stop - * copying when a tab, space, or eoln is encountered. + * Copy the first word into a nil-terminated buffer. + * Stop copying when a tab, space, or eoln is encountered. */ - for (j = 0; j < 4; j++, i++) { - if ('\0' == (mac[j] = buf[i])) - break; - else if (' ' == buf[i] || '\t' == buf[i]) - break; - - /* Check for invalid characters. */ - /* TODO: remove me, already done in main.c. */ - - if (isgraph((u_char)buf[i])) - continue; - if ( ! mdoc_pmsg(m, ln, i, MANDOCERR_BADCHAR)) - return(0); - i--; - } - + j = 0; + while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i]) + mac[j++] = buf[i++]; mac[j] = '\0'; if (j == 4 || j < 2) { |