Re: open MinGW failure

2010-01-12 Thread Simon Josefsson
Bruno Haible br...@clisp.org writes:

 Removing the mingw* case in the 'case' statement is wrong, because the * case
 executes an AC_CACHE_CHECK which would yield 'no' when cross-compiling to 
 mingw
 or natively compiling to mingw via wine but yield 'yes' when natively 
 compiling
 to mingw via Cygwin. In other words: The AC_CACHE_CHECK test would yield
 different results depending on the compilation environment, therefore it
 must be bypassed through a 'mingw*' case clause.

 pw* should be treated like mingw*, because there's no difference regarding
 target executable format. Both can be executed under Wine.

Thanks -- here is an improved patch I will be using in my projects while
we wait for Wine bugfixing.  It may not be perfect, but it works for me.

/Simon

diff --git a/m4/open.m4 b/m4/open.m4
index d705b3a..63ab918 100644
--- a/m4/open.m4
+++ b/m4/open.m4
@@ -9,7 +9,9 @@ AC_DEFUN([gl_FUNC_OPEN],
   AC_REQUIRE([AC_CANONICAL_HOST])
   case $host_os in
 mingw* | pw*)
-  gl_REPLACE_OPEN
+  # The misbehaviour is only under Wine, see
+  # http://bugs.winehq.org/show_bug.cgi?id=21292
+  gl_cv_func_open_slash=no
   ;;
 *)
   dnl open(foo/) should not create a file when the file name has a
@@ -46,13 +48,13 @@ changequote([,])dnl
 ])
   rm -f conftest.sl conftest.tmp conftest.lnk
 ])
-  case $gl_cv_func_open_slash in
-*no)
-  AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
-[Define to 1 if open() fails to recognize a trailing slash.])
-  gl_REPLACE_OPEN
-  ;;
-  esac
+  ;;
+  esac
+  case $gl_cv_func_open_slash in
+*no)
+  AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
+[Define to 1 if open() fails to recognize a trailing slash.])
+  gl_REPLACE_OPEN
   ;;
   esac
 ])




Re: open MinGW failure

2010-01-11 Thread Simon Josefsson
Bruno Haible br...@clisp.org writes:

 The relevant code is:
 
   /* Cannot create directory.  */
   errno = 0;
   ASSERT (func (nonexist.ent/, O_CREAT | O_RDONLY, 0600) == -1);
 
 Open returns 3 for me, and it has created a file 'nonexist.ent'.

 This must be a bug in Wine, then. Please report it.

Yes, already done see my followup post and
http://bugs.winehq.org/show_bug.cgi?id=21292 in particular.

 I see there is some code for this in lib/open.c, however it is not used
 because:
 
 /* Define to 1 if open() fails to recognize a trailing slash. */
 /* #undef OPEN_TRAILING_SLASH_BUG */
 
 Defining it makes the self-test work, which argues there is a bug in the
 open.m4 detection code, indeed it is not run at all for MinGW:
 
   case $host_os in
 mingw* | pw*)
   gl_REPLACE_OPEN
   ;;
 *)
 
 A simple fix to the problem is attached.

 Hmm, you and Paolo explained to me on 2009-08-21 that Wine should be
 considered as a platform of its own. But I still don't fully agree. Can
 you first report the bug to the Wine people and come back to patching
 gnulib only if they are not fixing it within two months?

We'll see what happens.  For a rationale for supporting Wine as a
separate platform, see my other post in this thread.

 I wonder if the code is correct for the 'pw*' system though, it will not
 trigger the trailing slash test on it.  I don't know what pw* is, and
 can't test it, so I'll leave that to others.

 'pw32' is Paul Sokolovsky's POSIX over Win32 package [1], which was
 developed in 2000-2001 and appears to be abandoned now [2].

Thanks for pointers.

/Simon




Re: open MinGW failure

2010-01-11 Thread Simon Josefsson
Paolo Bonzini bonz...@gnu.org writes:

 On 01/09/2010 12:33 PM, Bruno Haible wrote:
 Hmm, you and Paolo explained to me on 2009-08-21 that Wine should be
 considered as a platform of its own. But I still don't fully agree. Can
 you first report the bug to the Wine people and come back to patching
 gnulib only if they are not fixing it within two months?

 I agree with this.  Alternatively we could just make sure that code
 paths in configure that differ for Wine and Windows do all tests using
 cache variables, so that these can be tweaked with config.site when
 people use Wine.

Yes, that would help (but a bit time consuming).

 If we don't do that, we should anyway use no mercy for old versions
 and un-patch it as soon as it is fixed in Wine.

That's fine with me.  The bug is present in the latest stable Wine
release though.

/Simon




Re: open MinGW failure

2010-01-09 Thread Simon Josefsson
This problem was also caused by Wine, and not visible under Windows XP.
See http://bugs.winehq.org/show_bug.cgi?id=21292

My old patch fixes the problem under Wine, but this updated patch adds a
comment explaining.

Ok to push?

/Simon

diff --git a/m4/open.m4 b/m4/open.m4
index d705b3a..bc04613 100644
--- a/m4/open.m4
+++ b/m4/open.m4
@@ -8,7 +8,7 @@ AC_DEFUN([gl_FUNC_OPEN],
 [
   AC_REQUIRE([AC_CANONICAL_HOST])
   case $host_os in
-mingw* | pw*)
+pw*)
   gl_REPLACE_OPEN
   ;;
 *)
@@ -40,6 +40,9 @@ changequote(,)dnl
freebsd*)gl_cv_func_open_slash=guessing no ;;
solaris2.[0-9]*) gl_cv_func_open_slash=guessing no ;;
hpux*)   gl_cv_func_open_slash=guessing no ;;
+  # The misbehaviour is only under Wine, see
+  # http://bugs.winehq.org/show_bug.cgi?id=21292
+  mingw*)  gl_cv_func_open_slash=guessing no ;;
*)   gl_cv_func_open_slash=guessing yes ;;
  esac
 changequote([,])dnl




Re: open MinGW failure

2010-01-09 Thread Bruno Haible
Hi Simon,

Simon Josefsson wrote:
 I got this when cross-compiling to MinGW with Wine:
 
 test-open.h:34: assertion failed
 FAIL: test-open.exe

Whereas on a real Windows XP SP3, I get:

  skipping test: symlinks not supported on this file system
  SKIP: test-open.exe

(which is a bit misleading: only part of the test was skipped).

 The relevant code is:
 
   /* Cannot create directory.  */
   errno = 0;
   ASSERT (func (nonexist.ent/, O_CREAT | O_RDONLY, 0600) == -1);
 
 Open returns 3 for me, and it has created a file 'nonexist.ent'.

This must be a bug in Wine, then. Please report it. This test program

===
#include errno.h
#include fcntl.h
#include stdio.h
int main ()
{
  int ret = open (nonexist.ent/, O_CREAT | O_RDONLY, 0600);
  printf (ret=%d errno=%d\n, ret, errno);
  return 0;
}
===

when run on Windows (via Cygwin 1.5.x), yields:

$ gcc -mno-cygwin foo.c
$ ./a.exe 
ret=-1 errno=22

 I see there is some code for this in lib/open.c, however it is not used
 because:
 
 /* Define to 1 if open() fails to recognize a trailing slash. */
 /* #undef OPEN_TRAILING_SLASH_BUG */
 
 Defining it makes the self-test work, which argues there is a bug in the
 open.m4 detection code, indeed it is not run at all for MinGW:
 
   case $host_os in
 mingw* | pw*)
   gl_REPLACE_OPEN
   ;;
 *)
 
 A simple fix to the problem is attached.

Hmm, you and Paolo explained to me on 2009-08-21 that Wine should be
considered as a platform of its own. But I still don't fully agree. Can
you first report the bug to the Wine people and come back to patching
gnulib only if they are not fixing it within two months?

 I wonder if the code is correct for the 'pw*' system though, it will not
 trigger the trailing slash test on it.  I don't know what pw* is, and
 can't test it, so I'll leave that to others.

'pw32' is Paul Sokolovsky's POSIX over Win32 package [1], which was
developed in 2000-2001 and appears to be abandoned now [2].

Bruno

[1] http://pw32.sourceforge.net/manual/main.html
[2] http://gcc.gnu.org/ml/gcc-patches/2008-06/msg00120.html




Re: open MinGW failure

2010-01-09 Thread Bruno Haible
Simon Josefsson wrote:
 diff --git a/m4/open.m4 b/m4/open.m4
 index d705b3a..bc04613 100644
 --- a/m4/open.m4
 +++ b/m4/open.m4
 @@ -8,7 +8,7 @@ AC_DEFUN([gl_FUNC_OPEN],
  [
AC_REQUIRE([AC_CANONICAL_HOST])
case $host_os in
 -mingw* | pw*)
 +pw*)
gl_REPLACE_OPEN
;;
  *)
 @@ -40,6 +40,9 @@ changequote(,)dnl
 freebsd*)gl_cv_func_open_slash=guessing no ;;
 solaris2.[0-9]*) gl_cv_func_open_slash=guessing no ;;
 hpux*)   gl_cv_func_open_slash=guessing no ;;
 +# The misbehaviour is only under Wine, see
 +# http://bugs.winehq.org/show_bug.cgi?id=21292
 +mingw*)  gl_cv_func_open_slash=guessing no ;;
 *)   gl_cv_func_open_slash=guessing yes ;;
   esac
  changequote([,])dnl

We have switched from tabs to spaces for indentation.

Removing the mingw* case in the 'case' statement is wrong, because the * case
executes an AC_CACHE_CHECK which would yield 'no' when cross-compiling to mingw
or natively compiling to mingw via wine but yield 'yes' when natively compiling
to mingw via Cygwin. In other words: The AC_CACHE_CHECK test would yield
different results depending on the compilation environment, therefore it
must be bypassed through a 'mingw*' case clause.

pw* should be treated like mingw*, because there's no difference regarding
target executable format. Both can be executed under Wine.

Bruno




Re: open MinGW failure

2010-01-09 Thread Paolo Bonzini

On 01/09/2010 12:33 PM, Bruno Haible wrote:

Hmm, you and Paolo explained to me on 2009-08-21 that Wine should be
considered as a platform of its own. But I still don't fully agree. Can
you first report the bug to the Wine people and come back to patching
gnulib only if they are not fixing it within two months?


I agree with this.  Alternatively we could just make sure that code 
paths in configure that differ for Wine and Windows do all tests using 
cache variables, so that these can be tweaked with config.site when 
people use Wine.


If we don't do that, we should anyway use no mercy for old versions and 
un-patch it as soon as it is fixed in Wine.


Paolo




open MinGW failure

2010-01-08 Thread Simon Josefsson
I got this when cross-compiling to MinGW with Wine:

test-open.h:34: assertion failed
FAIL: test-open.exe

The relevant code is:

  /* Cannot create directory.  */
  errno = 0;
  ASSERT (func (nonexist.ent/, O_CREAT | O_RDONLY, 0600) == -1);

Open returns 3 for me, and it has created a file 'nonexist.ent'.

I see there is some code for this in lib/open.c, however it is not used
because:

/* Define to 1 if open() fails to recognize a trailing slash. */
/* #undef OPEN_TRAILING_SLASH_BUG */

Defining it makes the self-test work, which argues there is a bug in the
open.m4 detection code, indeed it is not run at all for MinGW:

  case $host_os in
mingw* | pw*)
  gl_REPLACE_OPEN
  ;;
*)

A simple fix to the problem is attached.

I wonder if the code is correct for the 'pw*' system though, it will not
trigger the trailing slash test on it.  I don't know what pw* is, and
can't test it, so I'll leave that to others.

Thoughts?

/Simon

diff --git a/m4/open.m4 b/m4/open.m4
index d705b3a..823d548 100644
--- a/m4/open.m4
+++ b/m4/open.m4
@@ -8,7 +8,7 @@ AC_DEFUN([gl_FUNC_OPEN],
 [
   AC_REQUIRE([AC_CANONICAL_HOST])
   case $host_os in
-mingw* | pw*)
+pw*)
   gl_REPLACE_OPEN
   ;;
 *)
@@ -40,6 +40,7 @@ changequote(,)dnl
freebsd*)gl_cv_func_open_slash=guessing no ;;
solaris2.[0-9]*) gl_cv_func_open_slash=guessing no ;;
hpux*)   gl_cv_func_open_slash=guessing no ;;
+   mingw*)  gl_cv_func_open_slash=guessing no ;;
*)   gl_cv_func_open_slash=guessing yes ;;
  esac
 changequote([,])dnl