bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: diffutils 2.8.1 ISO C90 compliance patch


From: Paul Eggert
Subject: Re: diffutils 2.8.1 ISO C90 compliance patch
Date: Tue, 14 Nov 2006 12:23:28 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

"Paul Edwards" <address@hidden> writes:

> Because you can't portably do a pipe, I
> added 2 extra positional parameters to diff3 so that you
> have to do the individual diffs outside of diff3 and pass
> the results in as parameters.

I'm afraid that part of the change is pretty much a nonstarter; users
of diff3 wouldn't put up with that.  We'd need a better solution, if
you really want to run diff3 on your platform.

> + #if HAVE_SYS_TYPES_H
>   #include <sys/types.h>
> + #endif

For this sort of thing, I suggest you create an empty file lib/sys/types.h.
That way, you don't have to modify the source code.

>   #ifndef __attribute__
>   /* This feature is available in gcc versions 2.5 and later.  */
> ! # if 1 || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
>   #  define __attribute__(Spec) /* empty */
>   # endif

I don't understand why this change was needed.  I assume __attribute__
was not defined but __GNUC__ was defined?  If so, why redefine __attribute__
to nothing?  GCC supports __attribute__.

> + #ifdef SIGPIPE
>          SIGPIPE
> + #endif

It's a bit more complicated than that, since it'd mean a comma just
before the } and some compilers don't like that.  A better fix is below.

>   # define sigprocmask(how, n, o) \
> !     /*((how) == SIG_BLOCK ? *(o) = sigblock (*(n)) : sigsetmask (*(n)))*/
>   #endif

This fails on BSD hosts that have sigblock and sigsetmask but not
sigprocmask.  But we can add a test for that, as shown below.

Your remaining library code looks OK, I guess.  Perhaps you can make
it part of your build process, for every program?

Anyway, I installed this.  Thanks.

2006-11-14  Paul Eggert  <address@hidden>

        Don't assume SIGPIPE exists, and that sigblock and sigsetmask
        exist if sigprocmask does not.  Problem reported by Paul Edwards
        for MVS 3.8.
        * configure.ac (sigblock): Check whether this function is
        available, if sigprocmask is not.
        * src/sdiff.c (sigs): Omit SIGPIPE if it's not defined.
        Put SIGINT last; all uses changed.
        (handler_index_of_SIGPIPE): Omit if SIGPIPE is not defined.
        (sigblock, sigsetmask) [!HAVE_SIGBLOCK]: New macros.

--- configure.ac        5 Sep 2006 22:57:29 -0000       1.36
+++ configure.ac        14 Nov 2006 20:20:13 -0000
@@ -54,6 +54,9 @@ AC_HEADER_SYS_WAIT
 AC_TYPE_PID_T
 
 AC_CHECK_FUNCS_ONCE([sigaction sigprocmask strcasecoll stricoll])
+if test $ac_cv_func_sigprocmask = no; then
+  AC_CHECK_FUNCS([sigblock])
+fi
 AC_FUNC_CLOSEDIR_VOID
 AC_FUNC_FORK
 
--- src/sdiff.c 5 Nov 2006 00:57:34 -0000       1.44
+++ src/sdiff.c 14 Nov 2006 20:20:13 -0000
@@ -81,11 +81,13 @@ static int const sigs[] = {
 #ifdef SIGXFSZ
        SIGXFSZ,
 #endif
-       SIGINT,
-       SIGPIPE
+#ifdef SIGPIPE
+       SIGPIPE,
+# define handler_index_of_SIGPIPE (NUM_SIGS - 2)
+#endif
+       SIGINT
+#define handler_index_of_SIGINT (NUM_SIGS - 1)
 };
-#define handler_index_of_SIGINT (NUM_SIGS - 2)
-#define handler_index_of_SIGPIPE (NUM_SIGS - 1)
 
 #if HAVE_SIGACTION
   /* Prefer `sigaction' if available, since `signal' can lose signals.  */
@@ -111,6 +113,10 @@ static int const sigs[] = {
 # ifndef SIG_SETMASK
 #  define SIG_SETMASK (! SIG_BLOCK)
 # endif
+# if ! HAVE_SIGBLOCK
+#  define sigblock(mask) (mask)
+#  define sigsetmask(mask) (mask)
+# endif
 # define sigprocmask(how, n, o) \
     ((how) == SIG_BLOCK \
      ? *(sigset_t *) (o) = sigblock (*(n)) \




reply via email to

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