This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Incorrect DOS line ending conversion for cygwin build of perl


I note that the cygwin build of perl does not correctly translate DOS \r\n
line endings into \n when opening files in text mode, this causes all sorts
of grief in perl scripts which search for things like fred$ in DOS text
files. 

After a bit of digging around in perl source it turns out that the problem
is in the function str_gets() in x2p/str.c, this code uses the FILE *fp->_p
variable to read directly from the FILE buffer, but alas cygwin only does
the \r\n -> \n conversion when serving up the contents of the _p buffer (
in fread, fgets, fgetc etc ), not before, so reading the _p buffer directly
circumvents the translation.

There is a perl variable USE_STDIO_PTR which can be undefined to stop perl
from using the FILE _p variable. I have built a cygwin version of perl with
this undefined and the line ending conversion now works fine. 

You might consider this to be a bug in the perl build system (USE_STDIO_PTR
should be undefined by default for cygwin builds), however at the very
least cygwin should ship a version of perl which has been built correctly.

Alternatively cygwin could be altered to do the line ending conversion
before putting data into FILE *fp->_p, I imagine this might cause slight
upheaval though.

Bertie


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]