From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.rz.uni-karlsruhe.de (Debian-exim@smtp1.rz.uni-karlsruhe.de [129.13.185.217]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p0MLSG4B002006 for ; Sat, 22 Jan 2011 16:28:16 -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 1Pgl0J-0005fu-1b; Sat, 22 Jan 2011 22:28:15 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1Pgl0I-0001cs-W4 for tech@mdocml.bsd.lv; Sat, 22 Jan 2011 22:28:14 +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 1Pgl0I-000445-VG for tech@mdocml.bsd.lv; Sat, 22 Jan 2011 22:28:14 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1Pgl0I-0007lR-UP for tech@mdocml.bsd.lv; Sat, 22 Jan 2011 22:28:14 +0100 Date: Sat, 22 Jan 2011 22:28:14 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: line termination in manuals Message-ID: <20110122212814.GH12520@iris.usta.de> References: <20110122195656.GE12520@iris.usta.de> <20110122200516.GA26592@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: <20110122200516.GA26592@britannica.bec.de> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Joerg, Joerg Sonnenberger wrote on Sat, Jan 22, 2011 at 09:05:17PM +0100: > On Sat, Jan 22, 2011 at 08:56:56PM +0100, Ingo Schwarze wrote: >> deraadt@ pointed out that, if somebody would compile mandoc >> on Windows, the C library would take care of different >> conventions regarding line termination. > Actually, it wouldn't. We explicitly read the file as whole or mmap it > and separate it at \n. I don't see a good reason why we couldn't just > drop \r before \n and accept both silently. Good point. The following works for me. OK? 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 21:27:00 -0000 @@ -669,6 +669,8 @@ } while (i < (int)blk.sz && (start || '\0' != blk.buf[i])) { + if ('\r' == blk.buf[i] && '\n' == blk.buf[i+1]) + ++i; if ('\n' == blk.buf[i]) { ++i; ++lnn; @@ -705,6 +707,8 @@ /* Found escape & at least one other char. */ + if ('\r' == blk.buf[i+1] && '\n' == blk.buf[i+2]) + ++i; if ('\n' == blk.buf[i + 1]) { i += 2; /* Escaped newlines are skipped over */ -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv