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: Bruno Haible
Subject: Re: [PATCH 15/21] freopen: workaround freopen() on OS/2 kLIBC
Date: Mon, 01 Dec 2014 01:01:24 +0100
User-agent: KMail/4.8.5 (Linux/3.2.0-64-generic; KDE/4.8.5; x86_64; ; )

> +#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?

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.

Bruno




reply via email to

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