bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 15/21] freopen: workaround freopen() on OS/2 kLIBC


From: KO Myung-Hun
Subject: Re: [PATCH 15/21] freopen: workaround freopen() on OS/2 kLIBC
Date: Tue, 02 Dec 2014 15:56:11 +0900
User-agent: Mozilla/5.0 (OS/2; Warp 4.5; rv:10.0.6esrpre) Gecko/20120715 Firefox/10.0.6esrpre SeaMonkey/2.7.2

Hi/2.

Bruno Haible wrote:
>> +#ifdef __KLIBC__
>> +  FILE *result = freopen (filename, mode, stream);
>> +
>> +  /* On OS/2 kLIBC, freopen() returns NULL even if it is successful
>> +     if filename is NULL. */
>> +  if (!result && !errno)
>> +    result = stream;
> 
> 1) In the comment you say 'if filename is NULL' but in the code you use
> the (hacky) workaround code also if filename != NULL. Why?
> 

If filename != NULL, it is not possible that result is NULL and errno is
0. Anyway fixed.


> 2) When freopen returns NULL for success, does it set errno = 0, or does
> it leave errno untouched? Can you find out, please, by using a test program
> like
> 
>   errno = 42;
>   FILE *result = freopen (NULL, mode, stream);
>   printf ("errno = %d\n", errno);
> 
> If it's the latter case (it leaves errno untouched), you need to add an
> 'errno = 0;' statement before the freopen call.
> 

I thought testing this. But it was wrong. Thanks for pointing this.

Fixed.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

Attachment: 0001-freopen-workaround-freopen-on-OS-2-kLIBC.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]