Skip to content

Commit d190a08

Browse files
frekuigitster
authored andcommitted
obstack: Fix portability issues
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1, SunOS 5.10, and possibly others do not have exit.h and exitfail.h. Remove the use of these in obstack.c. The __block variable was renamed to block to avoid a gcc error: compat/obstack.h:190: error: __block attribute can be specified on variables only Initial-patch-by: David Aguilar <[email protected]> Reported-by: Brian Gernhardt <[email protected]> Signed-off-by: Fredrik Kuivinen <[email protected]> Acked-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9ecedde commit d190a08

File tree

3 files changed

+6
-36
lines changed

3 files changed

+6
-36
lines changed

compat/obstack.c

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@
1818
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
1919
Boston, MA 02110-1301, USA. */
2020

21-
22-
#ifdef HAVE_CONFIG_H
23-
# include <config.h>
24-
#endif
25-
26-
#ifdef _LIBC
27-
# include <obstack.h>
28-
# include <shlib-compat.h>
29-
#else
30-
# include "obstack.h"
31-
#endif
21+
#include "git-compat-util.h"
22+
#include <gettext.h>
23+
#include "obstack.h"
3224

3325
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
3426
incremented whenever callers compiled using an old obstack.h can no
@@ -103,15 +95,6 @@ enum
10395
static void print_and_abort (void);
10496
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
10597

106-
/* Exit value used when `print_and_abort' is used. */
107-
# include <stdlib.h>
108-
# ifdef _LIBC
109-
int obstack_exit_failure = EXIT_FAILURE;
110-
# else
111-
# include "exitfail.h"
112-
# define obstack_exit_failure exit_failure
113-
# endif
114-
11598
# ifdef _LIBC
11699
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
117100
/* A looong time ago (before 1994, anyway; we're not sure) this global variable
@@ -400,16 +383,6 @@ _obstack_memory_used (struct obstack *h)
400383
return nbytes;
401384
}
402385

403-
/* Define the error handler. */
404-
# ifdef _LIBC
405-
# include <libintl.h>
406-
# else
407-
# include "gettext.h"
408-
# endif
409-
# ifndef _
410-
# define _(msgid) gettext (msgid)
411-
# endif
412-
413386
# ifdef _LIBC
414387
# include <libio/iolibio.h>
415388
# endif
@@ -435,7 +408,7 @@ print_and_abort (void)
435408
# else
436409
fprintf (stderr, "%s\n", _("memory exhausted"));
437410
# endif
438-
exit (obstack_exit_failure);
411+
exit (1);
439412
}
440413

441414
#endif /* !ELIDE_CODE */

compat/obstack.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,14 @@ extern int _obstack_begin_1 (struct obstack *, int, int,
187187
void (*) (void *, void *), void *);
188188
extern int _obstack_memory_used (struct obstack *);
189189

190-
void obstack_free (struct obstack *__obstack, void *__block);
190+
void obstack_free (struct obstack *, void *);
191191

192192

193193
/* Error handler called when `obstack_chunk_alloc' failed to allocate
194194
more memory. This can be set to a user defined function which
195195
should either abort gracefully or use longjump - but shouldn't
196196
return. The default action is to print a message and abort. */
197197
extern void (*obstack_alloc_failed_handler) (void);
198-
199-
/* Exit value used when `print_and_abort' is used. */
200-
extern int obstack_exit_failure;
201198

202199
/* Pointer to beginning of object being allocated or to be allocated next.
203200
Note that this might not be the final address of the object

kwset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "cache.h"
3838

3939
#include "kwset.h"
40-
#include "obstack.h"
40+
#include "compat/obstack.h"
4141

4242
#define NCHAR (UCHAR_MAX + 1)
4343
#define obstack_chunk_alloc xmalloc

0 commit comments

Comments
 (0)