Re: [PATCH 2/2] Include unistd.h.

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

 



Hi,

mduft@xxxxxxxxxx wrote:

> --- a/compat/fnmatch/fnmatch.c
> +++ b/compat/fnmatch/fnmatch.c
> @@ -25,6 +25,7 @@
>  # define _GNU_SOURCE	1
>  #endif
>  
> +#include <unistd.h>
>  #include <errno.h>

Given that we are touching this file anyway, how about relying on
git-compat-util for this?

That way, there is no need to debug feature test macros, order of
#includes, etc.  Untested.

-- >8 --
Subject: compat/fnmatch: use git-compat-util.h for system headers

Finding the right feature test macros and ordering of #includes to
get the desired functionality from all operating systems can be a big
pain.  Take advantage of the debugging already done and avoid future
churn by using git's usual git-compat-util for this.

In particular, the current fnmatch.c doesn't #include anything that
ought to provide NULL unless HAVE_STRING_H is defined, and it fails to
compile on Interix because of this.  Other platforms must have been
getting the macro through another header.

To make this code easier to reuse and to simplify future automated
merges from upstream, still keep the old #includes, just disabled with
"#if 0".

Reported-by: Markus Duft <mduft@xxxxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
Maybe the old #includes after #include-ing git-compat-util should be
left uncommented because harmless.

 compat/fnmatch/fnmatch.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/compat/fnmatch/fnmatch.c b/compat/fnmatch/fnmatch.c
index 14feac7..4bf3b5c 100644
--- a/compat/fnmatch/fnmatch.c
+++ b/compat/fnmatch/fnmatch.c
@@ -16,6 +16,9 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include "git-compat-util.h"
+
+#if 0
 #if HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -46,6 +49,7 @@
 # include <wchar.h>
 # include <wctype.h>
 #endif
+#endif
 
 /* Comment out all this code if we are using the GNU C Library, and are not
    actually compiling the library itself.  This code is part of the GNU C
-- 
1.7.5.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]