Hi Paul, * Paul Eggert wrote on Wed, Sep 14, 2005 at 01:21:18AM CEST: > Ralf Wildenhues <[EMAIL PROTECTED]> writes: > > > Would you accept a patch to change all of these to use > > #ifdef HAVE_CONFIG_H > > # include <config.h> > > #endif > > > > uniformly? > > That makes sense to me, yes. We should be consistent, and that's the > majority usage. > > Also, no .h file should include config.h. This is because config.h > must be included first, and it's the includer's responsibility to do > that. You might as well fix that inconsistency too, while you're at > it.
ACK. Several steps: 0) Find any .c files that include config.h bug not first -- I have not found any. :) For reference, this is how I searched: cd gnulib/lib for i in *.c; do if grep '^#.*include.*config\.h' $i > /dev/null; then if sed -n '/^#.*include/{p;q;}' $i | grep -v config\\.h; then echo $i fi fi done 1) Fix the files that forgot to guard inclusion by HAVE_CONFIG_H. This is the first patch. 2) Fix any header files not to include config.h, and their callers to include it if not already. This part may break third-party software, including possibly the upstream source, so pay attention to it! I have added a warning to the headers that config.h needs to be included beforehand. This is the second patch. 3) Make all remaining usage uniform as well. This is the third patch (gzip'ed because of the size). Notable exception to uniformity is argz.c where Libtool is upstream. I may look this eventually. :-) 4) Update gnulib documentation(?) about the preferred style. This would most likely fit into either gnulib.texi or standards.texi, I believe. I have not produced a patch for this, though. 5) Maybe even enforce the style by a check. Not done, either. Thinking out loud, `#if HAVE*' vs. `#ifdef HAVE*' also could be uniformized for other values of `*' .. not sure it's worth the effort. Do I have to contact each upstream source now? Cheers, Ralf * atexit.c, chdir-long.c chown.c, fchown-stub.c, getgroups.c, gettimeofday.c, lchown.c, lstat.c, mkdir.c, mkstemp.c, nanosleep.c, openat.c, raise.c, readtokens0.c, readutmp.c, unlinkdir.c: Guard inclusion of config.h with HAVE_CONFIG_H. * __fpending.h, argp-fmtstream.h, dirfd.h, getdate.h, human.h, inttostr.h: Removed inclusion of config.h from header files. * inttostr.c: Adjusted in-tree users. * __fpending.c, acl.c, argmatch.c, argp-eexst.c, argp-fmtstream.c, argp-fs-xinl.c, argp-help.c, argp-parse.c, argp-pvh.c, argp-xinl.c, backupfile.c, basename.c, c-stack.c, calloc.c, check-version.c, cloexec.c, closeout.c, copy-file.c, creat-safer.c, cycle-check.c, dirfd.c, dirname.c, dup-safer.c, dup2.c, euidaccess.c, exclude.c, exitfail.c, fatal-signal.c, fd-safer.c, file-type.c, fileblocks.c, filemode.c, filenamecat.c, findprog.c, fnmatch.c, fopen-safer.c, free.c, fsusage.c, ftruncate.c, full-write.c, fwriteerror.c, getaddrinfo.c, getcwd.c, getdelim.c, getline.c, getlogin_r.c, getndelim2.c, getnline.c, getopt1.c, getpass.c, group-member.c, hard-locale.c, hash-pjw.c, hash.c, human.c, idcache.c, inet_ntop.c, isdir.c, long-options.c, malloc.c, memcasecmp.c, memcmp.c, memcoll.c, memcpy.c, memmove.c, mkdir-p.c, mkdtemp.c, modechange.c, mountlist.c, open-safer.c, physmem.c, pipe-safer.c, pipe.c, poll.c, posixver.c, progname.c, progreloc.c, putenv.c, quote.c, quotearg.c, readline.c, readlink.c, realloc.c, regex.c, rename.c, rmdir.c, rpmatch.c, safe-read.c, same.c, save-cwd.c, savedir.c, setenv.c, sig2str.c, strcspn.c, strerror.c, stripslash.c, strncasecmp.c, strndup.c, strnlen.c, strnlen1.c, strsep.c, strstr.c, strtod.c, strtoimax.c, strtol.c, strverscmp.c, tempname.c, time_r.c, unsetenv.c, userspec.c, utimecmp.c, version-etc-fsf.c, version-etc.c, wait-process.c, xalloc-die.c, xgetcwd.c, xmalloc.c, xmemcoll.c, xnanosleep.c, xreadlink.c, xsetenv.c, xstrndup.c, xstrtoimax.c, xstrtol.c, xstrtoumax.c, yesno.c: Standardize inclusion of config.h.
* atexit.c, chdir-long.c chown.c, fchown-stub.c, getgroups.c, gettimeofday.c, lchown.c, lstat.c, mkdir.c, mkstemp.c, nanosleep.c, openat.c, raise.c, readtokens0.c, readutmp.c, unlinkdir.c: Guard inclusion of config.h with HAVE_CONFIG_H. Index: lib/atexit.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/atexit.c,v retrieving revision 1.3 diff -u -r1.3 atexit.c --- lib/atexit.c 8 Sep 2003 23:03:20 -0000 1.3 +++ lib/atexit.c 13 Sep 2005 15:13:10 -0000 @@ -1,7 +1,9 @@ /* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */ /* This function is in the public domain. --Mike Stump. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif int atexit (void (*f) (void)) Index: lib/chdir-long.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/chdir-long.c,v retrieving revision 1.5 diff -u -r1.5 chdir-long.c --- lib/chdir-long.c 14 May 2005 06:03:57 -0000 1.5 +++ lib/chdir-long.c 14 Sep 2005 12:30:17 -0000 @@ -17,7 +17,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include "chdir-long.h" Index: lib/chown.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/chown.c,v retrieving revision 1.14 diff -u -r1.14 chown.c --- lib/chown.c 2 Jul 2005 09:45:08 -0000 1.14 +++ lib/chown.c 13 Sep 2005 15:13:10 -0000 @@ -18,7 +18,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* Disable the definition of chown to rpl_chown (from config.h) in this file. Otherwise, we'd get conflicting prototypes for rpl_chown on Index: lib/fchown-stub.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/fchown-stub.c,v retrieving revision 1.1 diff -u -r1.1 fchown-stub.c --- lib/fchown-stub.c 10 Jul 2004 06:29:25 -0000 1.1 +++ lib/fchown-stub.c 13 Sep 2005 15:13:10 -0000 @@ -1,4 +1,6 @@ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include <sys/types.h> #include <errno.h> Index: lib/getgroups.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/getgroups.c,v retrieving revision 1.11 diff -u -r1.11 getgroups.c --- lib/getgroups.c 14 May 2005 06:03:58 -0000 1.11 +++ lib/getgroups.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include <stdio.h> #include <sys/types.h> #include <errno.h> Index: lib/gettimeofday.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gettimeofday.c,v retrieving revision 1.6 diff -u -r1.6 gettimeofday.c --- lib/gettimeofday.c 14 May 2005 06:03:58 -0000 1.6 +++ lib/gettimeofday.c 13 Sep 2005 15:13:10 -0000 @@ -20,7 +20,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* Disable the definitions of these functions (from config.h) so we can use the library versions here. */ Index: lib/lchown.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/lchown.c,v retrieving revision 1.15 diff -u -r1.15 lchown.c --- lib/lchown.c 14 May 2005 06:03:58 -0000 1.15 +++ lib/lchown.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include <sys/types.h> #include <sys/stat.h> Index: lib/lstat.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/lstat.c,v retrieving revision 1.8 diff -u -r1.8 lstat.c --- lib/lstat.c 24 Jun 2005 14:53:04 -0000 1.8 +++ lib/lstat.c 13 Sep 2005 15:13:10 -0000 @@ -19,7 +19,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* The specification of these functions is in sys_stat.h. But we cannot include this include file here, because on some systems, a Index: lib/mkdir.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/mkdir.c,v retrieving revision 1.18 diff -u -r1.18 mkdir.c --- lib/mkdir.c 14 May 2005 06:03:58 -0000 1.18 +++ lib/mkdir.c 13 Sep 2005 15:13:10 -0000 @@ -19,7 +19,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* Disable the definition of mkdir to rpl_mkdir (from config.h) in this file. Otherwise, we'd get conflicting prototypes for rpl_mkdir on Index: lib/mkstemp.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/mkstemp.c,v retrieving revision 1.5 diff -u -r1.5 mkstemp.c --- lib/mkstemp.c 2 Jun 2005 20:41:06 -0000 1.5 +++ lib/mkstemp.c 13 Sep 2005 15:13:10 -0000 @@ -15,7 +15,9 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* Disable the definition of mkstemp to rpl_mkstemp (from config.h) in this file. Otherwise, we'd get conflicting prototypes for rpl_mkstemp on Index: lib/nanosleep.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/nanosleep.c,v retrieving revision 1.15 diff -u -r1.15 nanosleep.c --- lib/nanosleep.c 14 May 2005 06:03:58 -0000 1.15 +++ lib/nanosleep.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* Undefine nanosleep here so any prototype is not redefined to be a prototype for rpl_nanosleep. (they'd conflict e.g., on alpha-dec-osf3.2) */ Index: lib/openat.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/openat.c,v retrieving revision 1.4 diff -u -r1.4 openat.c --- lib/openat.c 2 Jun 2005 20:41:06 -0000 1.4 +++ lib/openat.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include "openat.h" Index: lib/raise.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/raise.c,v retrieving revision 1.2 diff -u -r1.2 raise.c --- lib/raise.c 14 May 2005 06:03:58 -0000 1.2 +++ lib/raise.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ /* written by Jim Meyering */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include <sys/types.h> #include <signal.h> Index: lib/readtokens0.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/readtokens0.c,v retrieving revision 1.2 diff -u -r1.2 readtokens0.c --- lib/readtokens0.c 14 May 2005 06:03:58 -0000 1.2 +++ lib/readtokens0.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ Written by Jim Meyering. */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include <stdlib.h> #include "readtokens0.h" Index: lib/readutmp.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/readutmp.c,v retrieving revision 1.23 diff -u -r1.23 readutmp.c --- lib/readutmp.c 22 Jun 2005 18:27:44 -0000 1.23 +++ lib/readutmp.c 13 Sep 2005 15:13:10 -0000 @@ -17,7 +17,9 @@ /* Written by jla; revised by djm */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include "readutmp.h" Index: lib/unlinkdir.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/unlinkdir.c,v retrieving revision 1.1 diff -u -r1.1 unlinkdir.c --- lib/unlinkdir.c 15 May 2005 06:11:32 -0000 1.1 +++ lib/unlinkdir.c 13 Sep 2005 15:13:10 -0000 @@ -18,7 +18,9 @@ /* Written by Paul Eggert and Jim Meyering. */ -#include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif #include "unlinkdir.h"
* __fpending.h, argp-fmtstream.h, dirfd.h, getdate.h, human.h, inttostr.h: Removed inclusion of config.h from header files. * inttostr.c: Adjusted in-tree users. Index: lib/__fpending.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/__fpending.h,v retrieving revision 1.4 diff -u -r1.4 __fpending.h --- lib/__fpending.h 4 Jun 2003 19:22:29 -0000 1.4 +++ lib/__fpending.h 14 Sep 2005 12:44:58 -0000 @@ -1,6 +1,4 @@ -#if HAVE_CONFIG_H -# include <config.h> -#endif +/* You must include config.h before including this file. */ #include <stddef.h> #include <stdio.h> Index: lib/argp-fmtstream.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/argp-fmtstream.h,v retrieving revision 1.4 diff -u -r1.4 argp-fmtstream.h --- lib/argp-fmtstream.h 14 May 2005 06:03:57 -0000 1.4 +++ lib/argp-fmtstream.h 14 Sep 2005 12:44:58 -0000 @@ -25,9 +25,7 @@ #ifndef _ARGP_FMTSTREAM_H #define _ARGP_FMTSTREAM_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +/* You must include config.h before including this file. */ #include <stdio.h> #include <string.h> Index: lib/dirfd.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/dirfd.h,v retrieving revision 1.5 diff -u -r1.5 dirfd.h --- lib/dirfd.h 14 May 2005 06:03:58 -0000 1.5 +++ lib/dirfd.h 14 Sep 2005 12:44:59 -0000 @@ -17,9 +17,7 @@ Written by Jim Meyering. */ -#if HAVE_CONFIG_H -# include <config.h> -#endif +/* You must include config.h before including this file. */ #include <sys/types.h> Index: lib/getdate.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/getdate.h,v retrieving revision 1.12 diff -u -r1.12 getdate.h --- lib/getdate.h 14 May 2005 06:03:58 -0000 1.12 +++ lib/getdate.h 14 Sep 2005 12:44:59 -0000 @@ -16,9 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if HAVE_CONFIG_H -# include <config.h> -#endif +/* You must include config.h before including this file. */ #include <stdbool.h> #include "timespec.h" Index: lib/human.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/human.h,v retrieving revision 1.12 diff -u -r1.12 human.h --- lib/human.h 14 May 2005 06:03:58 -0000 1.12 +++ lib/human.h 14 Sep 2005 12:44:59 -0000 @@ -19,12 +19,10 @@ /* Written by Paul Eggert and Larry McVoy. */ +/* You must include config.h before including this file. */ + #ifndef HUMAN_H_ # define HUMAN_H_ 1 - -# if HAVE_CONFIG_H -# include <config.h> -# endif # include <limits.h> # include <stdbool.h> Index: lib/inttostr.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/inttostr.c,v retrieving revision 1.2 diff -u -r1.2 inttostr.c --- lib/inttostr.c 14 May 2005 06:03:58 -0000 1.2 +++ lib/inttostr.c 14 Sep 2005 12:44:59 -0000 @@ -18,6 +18,9 @@ /* Written by Paul Eggert */ +#ifdef HAVE_CONFIG_H +# inclued <config.h> +#endif #include "inttostr.h" /* Convert I to a printable string in BUF, which must be at least Index: lib/inttostr.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/inttostr.h,v retrieving revision 1.4 diff -u -r1.4 inttostr.h --- lib/inttostr.h 14 May 2005 06:03:58 -0000 1.4 +++ lib/inttostr.h 14 Sep 2005 12:44:59 -0000 @@ -18,9 +18,7 @@ /* Written by Paul Eggert */ -#if HAVE_CONFIG_H -# include <config.h> -#endif +/* You must include config.h before including this file. */ #if HAVE_INTTYPES_H # include <inttypes.h>
config-h-uniform.diff.gz
Description: GNU Zip compressed data
_______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib