On Fri, Sep 7, 2012 at 10:37 AM, LRN wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 07.09.2012 17:18, Earnie Boyd wrote:
>> On Fri, Sep 7, 2012 at 9:10 AM, LRN wrote:
>>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>>>
>>> On 07.09.2012 15:59, Earnie Boyd wrote:
>>>> I assume you meant this for the mingw-dvlpr list.
>>> I did. Sorry.
>>>
>>>>> Since MSys tries to be POSIXly, why not run _set_fmode
>>>>> (_O_BINARY); when MSys core initializes?
>>>>>
>>>>
>>>> MSYS already does.
>>>>
>>>>> I've just been reviewing msys/cygwin patches to tar, and
>>>>> considerable portion of them is devoted to forcing tar to
>>>>> use binary mode when working with files. Would be good to
>>>>> just make it the default for MSys programs and libraries.
>>>>
>>>> There would be no reason to consider it for MSYS. All streams
>>>> are _O_BINARY and cannot be changed by the user.
>>>>
>>> I've grepped msysCORE-1.0.17 for "set_fmode" and found nothing.
>>> Should i assume that this change is not yet released?
>>
>> It's embedded in the bowels of the MSYS source in winsup/cygwin
>> directory. I forget exactly how it is implemented.
>>
> Did some tests on 1.0.17.
>
> 1) Yes, default mode for opened files is binary.
>
> 2) MSys programs CAN open files in text mode, written data will change
> accordingly (haven't tried to read though).
>
You can specify the 'wt' or _O_TEXT modes but they are ignored just
like in Linux.
> 3) Inherited streams retain their type: if Windows shell is used to
> pipe a program outputting data to a MSys program, and pipes MSys
> program's stdout and stderr into files, then MSys will write to
> stdout/stderr in text mode, but will read stdin in binary mode.
>
While "native" programs can open the files in text mode, MSYS is
reading/writing in binary mode. I.E. there is no special treatment
for the \r character and is passed through the pipe as read.
> 4) For any files (inherited streams or newly opened) MSys program can
> use setmode() to change them to binary. It will work as expected on
> files opened for writing and on inherited stdout/stderr, but will not
> work on stdin.
I assume here you mean pipes between native and MSYS. The setmode may
influence the native to be binary but MSYS end is binary regardless.
>
> Yes, it's setmode(), not set_fmode(); MSys never uses set_fmode(), and
> setmode() is its own function.
>
> (3) means that tar patches are partially justified, since in some
> places tar is made freopen(cygwin)/setmode(msys) standard streams to
> binary mode. The parts that force creat/open to use binary mode are
> redundant.
>
Redundant yes, it won't hurt MSYS either direction.
> When piping is done by Bash, pipe ends are probably in binary mode by
> default.
For MSYS yes, for Cygwin it depends on the configuration of the
mounted directory.
--
Earnie
-- https://sites.google.com/site/earnieboyd
|