Skip to content

Commit 3bc1f9e

Browse files
sgngitster
authored andcommitted
compat/regex: move stdlib.h up in inclusion chain
In Linux with musl libc, we have this inclusion chain: compat/regex/regex.c:69 `-> compat/regex/regex_internal.h `-> /usr/include/stdlib.h `-> /usr/include/features.h `-> /usr/include/alloca.h In that inclusion chain, `<features.h>` claims it's _BSD_SOURCE compatible when it's NOT asked to be either {_POSIX,_GNU,_XOPEN,_BSD}_SOURCE, or __STRICT_ANSI__. And, `<stdlib.h>` will include `<alloca.h>` to be compatible with software written for GNU and BSD. Thus, redefine `alloca` macro, which was defined before at compat/regex/regex.c:66. Considering this is only compat code, we've taken from other project, it's not our business to decide which source should we adhere to. Include `<stdlib.h>` early to prevent the redefinition of alloca. This also remove a potential warning about alloca not defined on: #undef alloca Helped-by: Ramsay Jones <[email protected]> Signed-off-by: Đoàn Trần Công Danh <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1437ebf commit 3bc1f9e

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

compat/regex/regex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#undefs RE_DUP_MAX and sets it to the right value. */
6161
#include <limits.h>
6262
#include <stdint.h>
63+
#include <stdlib.h>
6364

6465
#ifdef GAWK
6566
#undef alloca

compat/regex/regex_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <assert.h>
2424
#include <ctype.h>
2525
#include <stdio.h>
26-
#include <stdlib.h>
2726
#include <string.h>
2827

2928
#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC

0 commit comments

Comments
 (0)