diff --git a/Makefile b/Makefile
index 30f3812..87ad4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -517,6 +517,8 @@ LIB_H += compat/bswap.h
LIB_H += compat/cygwin.h
LIB_H += compat/mingw.h
LIB_H += compat/obstack.h
+LIB_H += compat/exitfail.h
+LIB_H += compat/exit.h
LIB_H += compat/win32/pthread.h
LIB_H += compat/win32/syslog.h
LIB_H += compat/win32/sys/poll.h
@@ -599,6 +601,7 @@ LIB_OBJS += cache-tree.o
LIB_OBJS += color.o
LIB_OBJS += combine-diff.o
LIB_OBJS += commit.o
+LIB_OBJS += compat/exitfail.o
LIB_OBJS += compat/obstack.o
LIB_OBJS += config.o
LIB_OBJS += connect.o
@@ -872,6 +875,8 @@ ifeq ($(uname_S),Darwin)
NEEDS_CRYPTO_WITH_SSL = YesPlease
NEEDS_SSL_WITH_CRYPTO = YesPlease
NEEDS_LIBICONV = YesPlease
+ NEEDS_OBSTACK = YesPlease
+ NEEDS_EXITFAIL = YesPlease
ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
OLD_ICONV = UnfortunatelyYes
endif
@@ -1416,6 +1421,12 @@ endif
ifdef NEEDS_RESOLV
EXTLIBS += -lresolv
endif
+ifdef NEEDS_OBSTACK
+ BASIC_CFLAGS += -DNEEDS_OBSTACK
+endif
+ifdef NEEDS_EXITFAIL
+ BASIC_CFLAGS += -DNEEDS_EXITFAIL
+endif
ifdef NO_D_TYPE_IN_DIRENT
BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
endif
diff --git a/compat/exit.h b/compat/exit.h
new file mode 100644
index 0000000..9dbfb7c
--- /dev/null
+++ b/compat/exit.h
@@ -0,0 +1,32 @@
+/* exit() function.
+ Copyright (C) 1995, 2001 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef _EXIT_H
+#define _EXIT_H
+
+/* Get exit() declaration. */
+#include <stdlib.h>
+
+/* Some systems do not define EXIT_*, even with STDC_HEADERS. */
+#ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+#endif /* _EXIT_H */
diff --git a/compat/exitfail.c b/compat/exitfail.c
new file mode 100644
index 0000000..a2dd5dd
--- /dev/null
+++ b/compat/exitfail.c
@@ -0,0 +1,24 @@
+/* Failure exit status
+
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#ifdef NEEDS_EXITFAIL
+#include "exitfail.h"
+#include "exit.h"
+
+int volatile exit_failure = EXIT_FAILURE;
+#endif
diff --git a/compat/exitfail.h b/compat/exitfail.h
new file mode 100644
index 0000000..e46cf9c
--- /dev/null
+++ b/compat/exitfail.h
@@ -0,0 +1,20 @@
+/* Failure exit status
+
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING.
+ If not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+extern int volatile exit_failure;
diff --git a/compat/obstack.c b/compat/obstack.c
index 75440d9..825658c 100644
--- a/compat/obstack.c
+++ b/compat/obstack.c
@@ -18,15 +18,12 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#ifdef _LIBC
# include <obstack.h>
# include <shlib-compat.h>
#else
+# include <gettext.h>
+# include "git-compat-util.h"
# include "obstack.h"
#endif
@@ -54,7 +51,7 @@
#include <stddef.h>
-#ifndef ELIDE_CODE
+#if !defined ELIDE_CODE || defined NEEDS_OBSTACK
# if HAVE_INTTYPES_H
@@ -400,16 +397,6 @@ _obstack_memory_used (struct obstack *h)
return nbytes;
}
-/* Define the error handler. */
-# ifdef _LIBC
-# include <libintl.h>
-# else
-# include "gettext.h"
-# endif
-# ifndef _
-# define _(msgid) gettext (msgid)
-# endif
-
# ifdef _LIBC
# include <libio/iolibio.h>
# endif
diff --git a/compat/obstack.h b/compat/obstack.h
index 449070e..5636b91 100644
--- a/compat/obstack.h
+++ b/compat/obstack.h
@@ -187,7 +187,7 @@ extern int _obstack_begin_1 (struct obstack *, int, int,
void (*) (void *, void *), void *);
extern int _obstack_memory_used (struct obstack *);
-void obstack_free (struct obstack *__obstack, void *__block);
+void obstack_free (struct obstack *__obstack, void *__blk);
/* Error handler called when `obstack_chunk_alloc' failed to allocate
diff --git a/kwset.c b/kwset.c
index fd4515a..d01c562 100644
--- a/kwset.c
+++ b/kwset.c
@@ -37,7 +37,8 @@
#include "cache.h"
#include "kwset.h"
-#include "obstack.h"
+#include "git-compat-util.h"
+#include "compat/obstack.h"
#define NCHAR (UCHAR_MAX + 1)
#define obstack_chunk_alloc xmalloc
--
1.7.6.476.g57292