=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.156 retrieving revision 1.162 diff -u -p -r1.156 -r1.162 --- mandoc/mdoc.c 2010/07/02 12:54:33 1.156 +++ mandoc/mdoc.c 2010/08/08 14:51:32 1.162 @@ -1,6 +1,7 @@ -/* $Id: mdoc.c,v 1.156 2010/07/02 12:54:33 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.162 2010/08/08 14:51:32 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2010 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,7 +22,6 @@ #include #include -#include #include #include #include @@ -29,7 +29,6 @@ #include #include "mandoc.h" -#include "regs.h" #include "libmdoc.h" #include "libmandoc.h" @@ -721,7 +720,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int of assert(buf < end); - if (mandoc_eos(buf+offs, (size_t)(end-buf-offs))) + if (mandoc_eos(buf+offs, (size_t)(end-buf-offs), 0)) m->last->flags |= MDOC_EOS; return(1); @@ -764,11 +763,11 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off i = offs; - /* Accept whitespace after the initial control char. */ + /* Accept tabs/whitespace after the initial control char. */ - if (' ' == buf[i]) { + if (' ' == buf[i] || '\t' == buf[i]) { i++; - while (buf[i] && ' ' == buf[i]) + while (buf[i] && (' ' == buf[i] || '\t' == buf[i])) i++; if ('\0' == buf[i]) return(1); @@ -776,23 +775,14 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off sv = i; - /* Copy the first word into a nil-terminated buffer. */ + /* + * 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]) - break; - - /* Check for invalid characters. */ - - 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) { @@ -807,7 +797,12 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off return(1); } - /* The macro is sane. Jump to the next word. */ + /* Disregard the first trailing tab, if applicable. */ + + if ('\t' == buf[i]) + i++; + + /* Jump to the next non-whitespace word. */ while (buf[i] && ' ' == buf[i]) i++;