Oops, this code does not compile on mingw:

> --- tests/test-link.c.orig    2009-01-20 01:17:22.000000000 +0100
> +++ tests/test-link.c 2009-01-20 01:13:52.000000000 +0100
> @@ -18,6 +18,7 @@
>  
>  #include <unistd.h>
>  
> +#include <errno.h>
>  #include <stdio.h>
>  #include <stdlib.h>
>  
> @@ -36,8 +37,20 @@
>  int
>  main (int argc, char **argv)
>  {
> +  int ret;
> +
>    ASSERT (argc == 3);
> -  ASSERT (link (argv[1], argv[2]) == 0);
> +
> +  ret = link (argv[1], argv[2]);
> +  if (ret < 0)
> +    {
> +      /* If the device does not support hard links, errno is
> +      EPERM on Linux, EOPNOTSUPP on FreeBSD.  */
> +      if (errno == EPERM || errno == EOPNOTSUPP)
> +     return 77;
> +      perror ("link");
> +      return 1;
> +    }

Fixing it like this:

2009-01-20  Bruno Haible  <br...@clisp.org>

        Fix compilation failure on mingw.
        * tests/test-link.c (main): Don't assume that EOPNOTSUPP exists.

*** tests/test-link.c.orig      2009-01-21 00:29:35.000000000 +0100
--- tests/test-link.c   2009-01-21 00:27:29.000000000 +0100
***************
*** 46,55 ****
      {
        /* If the device does not support hard links, errno is
         EPERM on Linux, EOPNOTSUPP on FreeBSD.  */
!       if (errno == EPERM || errno == EOPNOTSUPP)
!       return 77;
!       perror ("link");
!       return 1;
      }
  
    return 0;
--- 46,62 ----
      {
        /* If the device does not support hard links, errno is
         EPERM on Linux, EOPNOTSUPP on FreeBSD.  */
!       switch (errno)
!       {
!       case EPERM:
! #ifdef EOPNOTSUPP
!       case EOPNOTSUPP:
! #endif
!         return 77;
!       default:
!         perror ("link");
!         return 1;
!       }
      }
  
    return 0;


Reply via email to