git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 26, 2011, 02:20 UTC
Message-ID
<20110526022045.GA8172@elie>
In-Reply-To
<1306332924-28587-3-git-send-email-mduft@gentoo.org>
Hi,
mduft@gentoo.org wrote:
Show 8 quoted lines
> --- 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@gentoo.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
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
Previous: Erik Faye-LundNext: Junio C Hamano
Message 11 of 18 in “Interix catch-ups for recent changes/releases.”
  1. Interix catch-ups for recent changes/releases.mduft@gentoo.org, May 25, 2011
  2. 1/2 Add additional build options for Interix, and remove obsolete ones.mduft@gentoo.org, May 25, 2011
  3. Junio C HamanoMay 25, 2011
  4. Markus DuftMay 26, 2011
  5. Junio C HamanoMay 26, 2011
  6. 2/2 Include unistd.h.mduft@gentoo.org, May 25, 2011
  7. Junio C HamanoMay 25, 2011
  8. Tor ArntsenMay 25, 2011
  9. Junio C HamanoMay 25, 2011
  10. Erik Faye-LundMay 25, 2011
  11. Jonathan NiederMay 26, 2011
  12. Junio C HamanoMay 26, 2011
  13. Jonathan NiederMay 26, 2011
  14. Markus DuftMay 30, 2011
  15. Markus DuftJun 15, 2011
  16. Jonathan NiederJun 15, 2011
  17. Update the Interix default build configuration.mduft@gentoo.org, Jun 15, 2011
  18. Markus DuftMay 27, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.