=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.134 retrieving revision 1.140 diff -u -p -r1.134 -r1.140 --- mandoc/main.c 2011/01/04 12:06:21 1.134 +++ mandoc/main.c 2011/01/24 23:41:55 1.140 @@ -1,7 +1,7 @@ -/* $Id: main.c,v 1.134 2011/01/04 12:06:21 kristaps Exp $ */ +/* $Id: main.c,v 1.140 2011/01/24 23:41:55 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010 Ingo Schwarze + * Copyright (c) 2010, 2011 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 @@ -158,6 +158,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "list type must come first", "tag lists require a width argument", "missing font type", + "skipping end of block that is not open", /* related to bad macro arguments */ "skipping argument", @@ -178,9 +179,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "unknown escape sequence", "unterminated quoted string", - /* related to tables */ - "extra data cells", - "generic error", /* related to tables */ @@ -190,12 +188,15 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "no table layout cells specified", "no table data cells specified", "ignore data in cell", + "data block still open", + "ignoring extra data cells", "input stack limit exceeded, infinite loop?", "skipping bad character", + "escaped character not allowed in a name", "skipping text before the first section header", "skipping unknown macro", - "NOT IMPLEMENTED: skipping request", + "NOT IMPLEMENTED, please use groff: skipping request", "line scope broken", "argument count wrong", "skipping end of block that is not open", @@ -683,6 +684,16 @@ parsebuf(struct curparse *curp, struct buf blk, int st } while (i < (int)blk.sz && (start || '\0' != blk.buf[i])) { + + /* + * When finding an unescaped newline character, + * leave the character loop to process the line. + * Skip a preceding carriage return, if any. + */ + + if ('\r' == blk.buf[i] && i + 1 < (int)blk.sz && + '\n' == blk.buf[i + 1]) + ++i; if ('\n' == blk.buf[i]) { ++i; ++lnn; @@ -717,11 +728,18 @@ parsebuf(struct curparse *curp, struct buf blk, int st continue; } - /* Found escape & at least one other char. */ + /* + * Found escape and at least one other character. + * When it's a newline character, skip it. + * When there is a carriage return in between, + * skip that one as well. + */ + if ('\r' == blk.buf[i + 1] && i + 2 < (int)blk.sz && + '\n' == blk.buf[i + 2]) + ++i; if ('\n' == blk.buf[i + 1]) { i += 2; - /* Escaped newlines are skipped over */ ++lnn; continue; }