Den 2010-08-18 13:35 skrev Paolo Bonzini:
> On 08/16/2010 08:14 PM, Peter Rosin wrote:
>> The logo of my version of MSVC is:
>>
>> ----8<----
>> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
>> 80x86
>> Copyright (C) Microsoft Corporation. All rights reserved.
>>
>> ----8<----
>>
>> Which I match with (in some quasi-regexp notation)
>>
>> ----8<----
>> Microsoft.*Optimizing Compiler.*
>> Copyright.*Microsoft Corporation.*
>> .\{0,1\}
>> ----8<----
>>
>> (but only if it matches the first three lines in stderr)
>>
>> I don't know why I have to have the ".\{0,1\}" part of the regexp,
>> but I suspect that it has something to do with newline conversion
>> in MSYS.
>
> Yes, it matches a CR.
Yes. I think it is weird that MSYS does not strip *all* CRs...
~$ uname -a
MINGW32_NT-5.1 PEDA-PC 1.0.15(0.47/3/2) 2010-08-010 22:33 i686 Msys
~$ sed --version
GNU sed version 3.02
Copyright (C) 1998 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
~$ sed -n -e 'l' testfile
foo$
bar$
$
~$ od -a testfile
0000000 f o o cr nl b a r cr nl cr nl
0000014
~$ sed -n -e '1N;2N;l' testfile
foo\nbar\r\n\r$
Compare with Cygwin (no text mode mounts anywhere)
~$ uname -a
CYGWIN_NT-5.1 peda-pc 1.7.1(0.218/5/3) 2009-12-07 11:48 i686 Cygwin
~$ sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
~$ sed -n -e 'l' testfile
foo$
bar$
$
~$ od -a testfile
0000000 f o o cr nl b a r cr nl cr nl
0000014
~$ sed -n -e '1N;2N;l' testfile
foo\nbar\n$
~$
And a Linux
~$ uname -a
Linux flingan 2.6.25.20-co-0.8.0 #3 PREEMPT Sun Nov 8 15:44:29 CET 2009 i686
GNU/Linux
~$ sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>
General help using GNU software: <http://www.gnu.org/gethelp/>
E-mail bug reports to: <[email protected]>
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
~$ sed -n -e 'l' testfile
foo\r$
bar\r$
\r$
~$ od -a testfile
0000000 f o o cr nl b a r cr nl cr nl
0000014
~$ sed -n -e '1N;2N;l' testfile
foo\r\nbar\r\n\r$
~$
The only one that behaves as I expected is Linux. I expected Cygwin to behave
as Linux behaves (i.e. preserving all CRs), and MSYS to behave as Cygwin
behaves (i.e. stripping all CRs).
Cheers,
Peter