Skip to content

Commit

Permalink
compat/fnmatch/fnmatch.c: give a fall-back definition for NULL
Browse files Browse the repository at this point in the history
Somebody tried to compile fnmatch.c compatibility file on Interix and got
an error because no header included in the file on that platform defined
NULL.  It usually comes from stddef.h and indirectly from other headers
like string.h, unistd.h, stdio.h, stdlib.h, etc., but with the way we
compile this file from our Makefile, inclusion of the header files that
are expected to define NULL in fnmatch.c do not happen because they are
protected with "#ifdef STDC_HEADERS", etc. which we do not pass.

As the least-impact workaround, give a fall-back definition when none of
the headers define NULL.

Noticed-by: Markus Duft <mduft@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed May 26, 2011
1 parent 5cfe425 commit a02cf90
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compat/fnmatch/fnmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ extern char *getenv ();
extern int errno;
# endif

# ifndef NULL
# define NULL 0
# endif

/* This function doesn't exist on most systems. */

# if !defined HAVE___STRCHRNUL && !defined _LIBC
Expand Down

0 comments on commit a02cf90

Please sign in to comment.