[PATCH 2/2] widl: open files to write in binary mode

Jacek Caban jacek at codeweavers.com
Wed Dec 16 09:41:51 CST 2020


On 16.12.2020 15:35, Steve Lhomme wrote:
> On 2020-12-16 15:18, Jacek Caban wrote:
>> Hi Steve,
>>
>> On 16.12.2020 10:14, Steve Lhomme wrote:
>>> When compiled with mingw64 the output files have Windows line 
>>> endings instead
>>> of UNIX ones.
>>> ---
>>>   tools/widl/header.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/widl/header.c b/tools/widl/header.c
>>> index 43be8d74cbe..5457185538e 100644
>>> --- a/tools/widl/header.c
>>> +++ b/tools/widl/header.c
>>> @@ -1893,7 +1893,7 @@ void write_header(const statement_list_t *stmts)
>>>     if (!do_header) return;
>>> -  if(!(header = fopen(header_name, "w"))) {
>>> +  if(!(header = fopen(header_name, "wb"))) {
>>
>>
>> There are more places that would need to be fixed for consistency. 
>> Maybe we could use _set_fmode(_O_BINARY) in main() instead?
>
> Is this a MS-only thing ? I don't mind having this patch only in 
> mingw-w64-tools (which also have some extra patch as well).


Yes, it would need an #ifdef.


> In general it may not be the proper way to handle this. For writing 
> all files widl generates, it should be fine. But for reading files the 
> "binary" mode is not currently used and it may break reading files 
> that used to be read properly on Windows ?


Which files do you mean? The only non-binary files that widl generates 
are headers and C files.


Generally speaking, widl output is cross platform, so it should generate 
the same output on regardless of host platform used. Windows line ending 
breaks that.


Jacek




More information about the wine-devel mailing list