bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] Suggestion: new module link


From: Bruno Haible
Subject: Re: [PATCH] Suggestion: new module link
Date: Wed, 21 Jan 2009 00:30:17 +0100
User-agent: KMail/1.9.9

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  <address@hidden>

        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

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