From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.rz.uni-karlsruhe.de (smtp1.rz.uni-karlsruhe.de [129.13.185.217]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p0MMJ5mw009547 for ; Sat, 22 Jan 2011 17:20:12 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by smtp1.rz.uni-karlsruhe.de with esmtp (Exim 4.63 #1) id 1Pgln2-0006Ek-6A; Sat, 22 Jan 2011 23:18:36 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1Pgln2-0001XP-4T for tech@mdocml.bsd.lv; Sat, 22 Jan 2011 23:18:36 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1Pgln2-000525-3T for tech@mdocml.bsd.lv; Sat, 22 Jan 2011 23:18:36 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1Pgln2-00033t-2O for tech@mdocml.bsd.lv; Sat, 22 Jan 2011 23:18:36 +0100 Date: Sat, 22 Jan 2011 23:18:36 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: line termination in manuals Message-ID: <20110122221836.GJ12520@iris.usta.de> References: <20110122195656.GE12520@iris.usta.de> <20110122200516.GA26592@britannica.bec.de> <20110122212814.GH12520@iris.usta.de> <20110122213510.GA29547@britannica.bec.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110122213510.GA29547@britannica.bec.de> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Joerg, Joerg Sonnenberger wrote on Sat, Jan 22, 2011 at 10:35:10PM +0100: > On Sat, Jan 22, 2011 at 10:28:14PM +0100, Ingo Schwarze wrote: > At least add a comment that this falls through to the next statement > for handling. Otherwise it looks fine. Gah, writing comments is good. It makes you think again about the code, so you find bugs. When the last character in blk.buf is '\r' (without a newline at the end of the file), my first attempt would have overrun the buffer by one byte. Thus, i'm committing the following shortly. Yours, Ingo Index: main.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/main.c,v retrieving revision 1.69 diff -u -r1.69 main.c --- main.c 20 Jan 2011 21:33:11 -0000 1.69 +++ main.c 22 Jan 2011 22:12:58 -0000 @@ -669,6 +669,15 @@ } 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] && '\n' == blk.buf[i+1]) + ++i; if ('\n' == blk.buf[i]) { ++i; ++lnn; @@ -703,11 +712,18 @@ 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 + 1 < (int)blk.sz && + '\n' == blk.buf[i + 2]) + ++i; if ('\n' == blk.buf[i + 1]) { i += 2; - /* Escaped newlines are skipped over */ ++lnn; continue; } -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv