GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-07 Thread Conrad T. Pino
 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Jim,

The CVS project compiles the Windows CVS binary with Microsoft Visual
Studio 6.0 which doesn't have a "fchdir" implementation which is used
in "save-cwd.c" module.  The comments say:

   Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
   SCO Xenix.  Also, SunOS 4 and Irix 5.3 provide the function, yet it
   doesn't work for partitions on which auditing is enabled.  If
   you're still using an obsolete system with these problems, please
   send email to the maintainer of this code.

Function "fchdir" is also used in "chdir-long.c" and "openat.c" modules
which may not be used in Windows build.

What would you suggest for this issue?

Best regards,

Conrad T. Pino

The "grep fchdir ..." and build error outputs follow:

File lib\chdir-long.c:
56  cdb_fchdir (struct cd_buf const *cdb)
58return fchdir (cdb->fd);
200 if (cdb_fchdir (&cdb) != 0)

File lib\openat.c:
39 Simulate it by doing save_cwd/fchdir/open/restore_cwd.
72if (fchdir (fd) != 0)
95 Simulate it by doing save_cwd/fchdir/opendir(".")/restore_cwd.
114   if (fchdir (fd) != 0)
137Simulate it by doing save_cwd/fchdir/(stat|lstat)/restore_cwd.
158   if (fchdir (fd) != 0)

File lib\save-cwd.c:
58 So, we prefer to use the open/fchdir approach, but fall back on
61 Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
87 Upon failure, return -1 (errno is set by chdir or fchdir).
94  return fchdir (cwd->desc);

- Configuration: cvsnt - Win32 Debug
Linking...
libdiff.lib(save-cwd.obj) : error LNK2001: unresolved external symbol _fchdir
.\WinDebug\cvs.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

cvs.exe - 2 error(s), 0 warning(s)

-BEGIN PGP SIGNATURE-
Version: PGP 7.0.4

iQA/AwUBQi1FBbNM28ubzTo9EQLO3QCg15DJbXoDCR7MkuO9QaHHJ0WR0IsAoOce
YbYCRgf5hlXqTTwOnw5E4RXR
=F+Nb
-END PGP SIGNATURE-



___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Jim Meyering
"Conrad T. Pino" <[EMAIL PROTECTED]> wrote:
> The CVS project compiles the Windows CVS binary with Microsoft Visual
> Studio 6.0 which doesn't have a "fchdir" implementation which is used
> in "save-cwd.c" module.  The comments say:
>
>Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
>SCO Xenix.  Also, SunOS 4 and Irix 5.3 provide the function, yet it
>doesn't work for partitions on which auditing is enabled.  If
>you're still using an obsolete system with these problems, please
>send email to the maintainer of this code.
>
> Function "fchdir" is also used in "chdir-long.c" and "openat.c" modules
> which may not be used in Windows build.
>
> What would you suggest for this issue?

Hi Conrad,

Is it an option to use a more modern/POSIX-compliant development
environment on Windows?  I know that Cygwin now has fchdir and it looks
like MKS has support for it, too.  POSIX has required fchdir for a
long time, now, and having fchdir lets programs do things like save and
restore the working directory much more efficiently and robustly than
the alternative getcwd-based implementation would.  For example, if you
`return' to a saved working directory using chdir, you have to wonder
if maybe you've been tricked into changing to some other directory --
or incur the cost of getting/saving/comparing before and after device
and inode numbers.  If you opt to continue using Visual Studio 6 in
spite of this, it must have some important redeeming features.

The Unix systems that lack support for fchdir stopped being reasonable
porting targets a couple of years ago.  And since Cygwin has had fchdir
support for over three years, I thought we'd be safe on the WOE side, too.
So about a month ago we removed from the save-cwd module support for
systems with missing or flaky fchdir support.  Although that module
could work around the lack of a working fchdir function, the openat
module cannot.  And since the chdir-long module also uses openat, its
use of fchdir is moot.

If you have no alternative, it wouldn't be hard to revert the last
change to the save-cwd module, but it'd feel like a step backwards.

Jim


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


RE: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Jim.Hyslop
Jim Meyering wrote:
> Is it an option to use a more modern/POSIX-compliant development
> environment on Windows?  I know that Cygwin now has fchdir 
> and it looks
> like MKS has support for it, too.

> If you opt to continue using Visual Studio 6 in
> spite of this, it must have some important redeeming features.

The problem with the cygwin build is that it requires Cygwin.dll as well.
The MSVC build stands alone, not requiring any external DLLs.

I don't think it is reasonable to require all Windows users to download and
install Cygwin just to run CVS.

-- 
Jim Hyslop
Senior Software Designer
Leitch Technology International Inc. ( http://www.leitch.com )
Columnist, C/C++ Users Journal ( http://www.cuj.com/experts )


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Derek Price
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Jim.Hyslop wrote:
| Jim Meyering wrote:
|
|> Is it an option to use a more modern/POSIX-compliant development
|> environment on Windows?  I know that Cygwin now has fchdir and it
|> looks like MKS has support for it, too.
|
|
|> If you opt to continue using Visual Studio 6 in spite of this, it
|> must have some important redeeming features.
|
|
| The problem with the cygwin build is that it requires Cygwin.dll as
| well. The MSVC build stands alone, not requiring any external DLLs.
|
|
| I don't think it is reasonable to require all Windows users to
| download and install Cygwin just to run CVS.
I'm afraid I have to agree with Jim Hyslop.  Whatever Microsoft's
flaws, I still believe that some of our mutual user base is at least
relatively innocent and should still be catered to.
Regards,
Derek
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCLcarLD1OTBfyMaQRAu5RAJ9NJMTJgEZkPrSjdOGLZBYHaIH6KQCg/RnD
un34isGInces/lodh1MM4NQ=
=emIY
-END PGP SIGNATURE-

___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


RE: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Jim.Hyslop
[CVS support for MSVC]

By the way, I just had a quick look at Visual Studio .NET 2003, and it does
not appear to have POSIX support. At least, there's not fchdir function,
which is what triggered this whole discussion ;=)

-- 
Jim Hyslop
Senior Software Designer
Leitch Technology International Inc. ( http://www.leitch.com )
Columnist, C/C++ Users Journal ( http://www.cuj.com/experts )


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Frank Hemer
On Tuesday 08 March 2005 16:37, Derek Price wrote:
> Jim.Hyslop wrote:
> | Jim Meyering wrote:
> |> Is it an option to use a more modern/POSIX-compliant development
> |> environment on Windows?  I know that Cygwin now has fchdir and it
> |> looks like MKS has support for it, too.
> |>
> |>
> |> If you opt to continue using Visual Studio 6 in spite of this, it
> |> must have some important redeeming features.
> |
> | The problem with the cygwin build is that it requires Cygwin.dll as
> | well. The MSVC build stands alone, not requiring any external DLLs.
> |
> |
> | I don't think it is reasonable to require all Windows users to
> | download and install Cygwin just to run CVS.
>
> I'm afraid I have to agree with Jim Hyslop.  Whatever Microsoft's
> flaws, I still believe that some of our mutual user base is at least
> relatively innocent and should still be catered to.

I agree with this.
Even though I'm not an ms disciple, I know quite some users that would be 
affected ...
-- 
- The LinCVS Team -
http://www.lincvs.com



___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Jim Meyering
Derek Price <[EMAIL PROTECTED]> wrote:
> I'm afraid I have to agree with Jim Hyslop.  Whatever Microsoft's
> flaws, I still believe that some of our mutual user base is at least
> relatively innocent and should still be catered to.

This is not about Microsoft per se, but simply about
the lack of fchdir (or POSIX support in general) in WOE.

I suppose it's a long shot, but...
is there a way, in WOE/MSVC, to emulate fchdir's behavior?
I.e., given a file descriptor that is the result of opening a
directory, can you obtain an absolute path name of that directory?

BTW if we end up reverting the changes to save-cwd.c,
we'll also have to do something about its use of chdir_long,
which won't work on systems lacking fchdir:

#if !HAVE_FCHDIR
# undef chdir_long
# define chdir_long(d) chdir (d)
#endif


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-08 Thread Derek Price
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Jim Meyering wrote:
| Derek Price <[EMAIL PROTECTED]> wrote:
|
|> I'm afraid I have to agree with Jim Hyslop.  Whatever Microsoft's
|>  flaws, I still believe that some of our mutual user base is at
|> least relatively innocent and should still be catered to.
|
|
| This is not about Microsoft per se, but simply about the lack of
| fchdir (or POSIX support in general) in WOE.
I'm very, very reluctant to introduce a dependency on Cygwin for a
single function...
| I suppose it's a long shot, but... is there a way, in WOE/MSVC, to
| emulate fchdir's behavior? I.e., given a file descriptor that is
| the result of opening a directory, can you obtain an absolute path
| name of that directory?
Glancing at the sources for cygwin, it looks like they decided to save
the file name via their open() function and look up the stored value
in their fchdir(), then call chdir() on it.
Regards,
Derek
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCLdnTLD1OTBfyMaQRAgH3AKCV4TwsCiIK2V1M3Ub4zKzeiKyZDgCg0zOZ
N0MOMsKS+B3K5zqbg2uzaTY=
=qePb
-END PGP SIGNATURE-

___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-09 Thread Jim Meyering
Here's a patch that should restore the ability of save-cwd to
work on systems without the fchdir function.

Would you please see if this is sufficient?
If so, I'll check it in to gnulib (with an AC_CHECK_FUNCS(fchdir)
in save-cwd.m4).

Index: save-cwd.c
===
RCS file: /fetish/cu/lib/save-cwd.c,v
retrieving revision 1.24
diff -u -p -r1.24 save-cwd.c
--- save-cwd.c  20 Jan 2005 22:17:26 -  1.24
+++ save-cwd.c  9 Mar 2005 07:49:19 -
@@ -44,6 +44,18 @@
 #include "chdir-long.h"
 #include "xgetcwd.h"
 
+/* On systems without the fchdir function (WOE), pretend that open
+   always returns -1 so that save_cwd resorts to using xgetcwd.
+   Since chdir_long requires fchdir, use chdir instead.  */
+#if !HAVE_FCHDIR
+# undef open
+# define open(File, Flags) -1
+# undef fchdir
+# define fchdir(Fd) abort ()
+# undef chdir_long
+# define chdir_long(Dir) chdir (Dir)
+#endif
+
 /* Record the location of the current working directory in CWD so that
the program may change to other directories and later use restore_cwd
to return to the recorded location.  This function may allocate


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


RE: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-09 Thread Conrad T. Pino
 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Jim,

> From: Jim Meyering [mailto:[EMAIL PROTECTED]
> 
> This is not about Microsoft per se, but simply about
> the lack of fchdir (or POSIX support in general) in WOE.

I agree let's not enumerate Microsoft's flaws as we would never
finish. :)

> I suppose it's a long shot, but...
> is there a way, in WOE/MSVC, to emulate fchdir's behavior?

I think not.  My research on http://msdn.microsoft.com site came
up with no hint of a method to translate an open file / directory
handle into a path name.

> I.e., given a file descriptor that is the result of opening a
> directory, can you obtain an absolute path name of that directory?

Worse, if "C:\work" is a directory attempts to use the Visual C 6.0
"open" function with "_O_RDONLY" argument to open "." or "C:\work"
will both return -1 value i.e. error.  Sample program follows.

Conrad

#include 
#include 
#include 

static int opendir( char *name )
{
int fd;

fd = open( name,  _O_RDONLY );
printf( "open %s = %d\n", name, fd );

close( fd );

return fd;
}

int main(int argc, char* argv[])
{
int fd;

printf("Hello World!\n");

fd = opendir( "test.txt" );
fd = opendir( "." );
fd = opendir( "C:\\work" );

return 0;
}

-BEGIN PGP SIGNATURE-
Version: PGP 7.0.4

iQA/AwUBQi8GwLNM28ubzTo9EQJxHwCg4H3VBV4ftjY6Jau9DuleH/0mvykAoLee
EKxRsykxCHYpu0r1VRvKe6aq
=RI6I
-END PGP SIGNATURE-



___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


RE: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-09 Thread Conrad T. Pino
 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Jim,

> From: Jim Meyering [mailto:[EMAIL PROTECTED]
> 
> Here's a patch that should restore the ability of save-cwd to
> work on systems without the fchdir function.
> 
> Would you please see if this is sufficient?
> If so, I'll check it in to gnulib (with an AC_CHECK_FUNCS(fchdir)
> in save-cwd.m4).

The patch as submitted does not compile.  This line fails:

return fchdir (cwd->desc);

The patch at message end does compile and the build completes.

Conrad

Index: save-cwd.c
===
RCS file: /cvs/ccvs/lib/save-cwd.c,v
retrieving revision 1.6
diff -u -p -r1.6 save-cwd.c
- --- save-cwd.c  1 Mar 2005 18:15:42 -   1.6
+++ save-cwd.c  9 Mar 2005 14:50:43 -
@@ -44,6 +44,18 @@
 #include "chdir-long.h"
 #include "xgetcwd.h"

+/* On systems without the fchdir function (WOE), pretend that open
+   always returns -1 so that save_cwd resorts to using xgetcwd.
+   Since chdir_long requires fchdir, use chdir instead.  */
+#if !HAVE_FCHDIR
+# undef open
+# define open(File, Flags) -1
+# undef fchdir
+# define fchdir(Fd) ( abort (), -1 )
+# undef chdir_long
+# define chdir_long(Dir) chdir (Dir)
+#endif
+
 /* Record the location of the current working directory in CWD so that
the program may change to other directories and later use restore_cwd
to return to the recorded location.  This function may allocate

-BEGIN PGP SIGNATURE-
Version: PGP 7.0.4

iQA/AwUBQi8OqrNM28ubzTo9EQKCQACglWgegbLzUqZdLaxd+HC+ls9Jv7oAn1J5
0z2tXUL54UlQZECFNzsG4PuC
=7E/O
-END PGP SIGNATURE-



___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-09 Thread Jim Meyering
"Conrad T. Pino" <[EMAIL PROTECTED]> wrote:
...
>> Would you please see if this is sufficient?
>> If so, I'll check it in to gnulib (with an AC_CHECK_FUNCS(fchdir)
>> in save-cwd.m4).
>
> The patch as submitted does not compile.  This line fails:
>
> return fchdir (cwd->desc);
>
> The patch at message end does compile and the build completes.

Thanks.
I've checked that in.


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


RE: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-09 Thread Conrad T. Pino
 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Jim,

> From: Jim Meyering [mailto:[EMAIL PROTECTED]
> 
> "Conrad T. Pino" <[EMAIL PROTECTED]> wrote:
> ...
> >> Would you please see if this is sufficient?
> >> If so, I'll check it in to gnulib (with an AC_CHECK_FUNCS(fchdir)
> >> in save-cwd.m4).
> >
> > The patch as submitted does not compile.  This line fails:
> >
> > return fchdir (cwd->desc);
> >
> > The patch at message end does compile and the build completes.
> 
> Thanks.
> I've checked that in.

I've seen the "lib/save-cwd.c" change in GULLib CVS on Savannah but
I didn't see the "AC_CHECK_FUNCS(fchdir) in save-cwd.m4" change.

Conrad

-BEGIN PGP SIGNATURE-
Version: PGP 7.0.4

iQA/AwUBQi+5KrNM28ubzTo9EQLWKwCgp1C8kpucYC92QRaGblHAp5+z0xIAniOF
WX8BVodiTSIchNoDxIi4ZwT9
=Nwqu
-END PGP SIGNATURE-



___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-10 Thread Jim Meyering
"Conrad T. Pino" <[EMAIL PROTECTED]> wrote:
...
>> I've checked that in.
>
> I've seen the "lib/save-cwd.c" change in GULLib CVS on Savannah but
> I didn't see the "AC_CHECK_FUNCS(fchdir) in save-cwd.m4" change.

It was too late :)
I've just done it.

Index: m4/save-cwd.m4
===
RCS file: /cvsroot/gnulib/gnulib/m4/save-cwd.m4,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -u -r1.4 -r1.5
--- m4/save-cwd.m4  20 Jan 2005 22:21:01 -  1.4
+++ m4/save-cwd.m4  10 Mar 2005 08:55:38 -  1.5
@@ -1,4 +1,4 @@
-# save-cwd.m4 serial 4
+#serial 5
 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,5 +9,6 @@ AC_DEFUN([gl_SAVE_CWD],
   AC_LIBSOURCES([save-cwd.c, save-cwd.h])
   AC_LIBOBJ([save-cwd])
   dnl Prerequisites for lib/save-cwd.c.
+  AC_CHECK_FUNCS_ONCE(fchdir)
   AC_CHECK_HEADERS_ONCE(fcntl.h unistd.h)
 ])


___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs


Re: [bug-gnulib] RE: GNULib save-cwd.c on Windows & Visual Studio 6.0

2005-03-10 Thread James Youngman
On Tue, Mar 08, 2005 at 09:26:47AM -0500, Jim.Hyslop wrote:
> The MSVC build stands alone, not requiring any external DLLs.
> 
> I don't think it is reasonable to require all Windows users to download and
> install Cygwin just to run CVS.

So how does Tony Hoyle's CVSNT deal with this issue?

> 
> -- 
> Jim Hyslop
> Senior Software Designer
> Leitch Technology International Inc. ( http://www.leitch.com )
> Columnist, C/C++ Users Journal ( http://www.cuj.com/experts )



___
Bug-cvs mailing list
Bug-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-cvs