diff options
-rw-r--r-- | usr.bin/mandoc/man.c | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 26 |
2 files changed, 14 insertions, 38 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) { 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) { |