Skip to content

Commit 801787d

Browse files
authored
Simplify strcasestr check in fileinfo (#13365)
The strcasestr is not present on Windows and on Solaris 10 until Solaris 11 implementation in string.h. At this point strcasestr is not used in the bundled libmagic (file) library due to patch removing the strcasestr usage in file.c, however future libmagic version bump might need it again. This simplifies the strcasestr check if available on the system without running the test code and avoiding the unknown issue when cross-compiling. If found, the HAVE_STRCASESTR is defined, otherwise the strcasestr.c is added to the build sources.
1 parent 5e7783e commit 801787d

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

ext/fileinfo/config.m4

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,10 @@ if test "$PHP_FILEINFO" != "no"; then
1414
libmagic/readcdf.c libmagic/softmagic.c libmagic/der.c \
1515
libmagic/buffer.c libmagic/is_csv.c"
1616

17-
AC_MSG_CHECKING([for strcasestr])
18-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
19-
#include <string.h>
20-
#include <strings.h>
21-
#include <stdlib.h>
22-
23-
int main(void)
24-
{
25-
char *s0, *s1, *ret;
26-
27-
s0 = (char *) malloc(42);
28-
s1 = (char *) malloc(8);
29-
30-
memset(s0, 'X', 42);
31-
s0[24] = 'Y';
32-
s0[26] = 'Z';
33-
s0[41] = '\0';
34-
memset(s1, 'x', 8);
35-
s1[0] = 'y';
36-
s1[2] = 'Z';
37-
s1[7] = '\0';
38-
39-
ret = strcasestr(s0, s1);
40-
41-
return !(NULL != ret);
42-
}
43-
]])],[
44-
dnl using the platform implementation
45-
AC_MSG_RESULT(yes)
46-
],[
47-
AC_MSG_RESULT(no)
17+
AC_CHECK_FUNCS([strcasestr],,[
4818
AC_MSG_NOTICE(using libmagic strcasestr implementation)
4919
libmagic_sources="$libmagic_sources libmagic/strcasestr.c"
50-
],[AC_MSG_RESULT([skipped, cross-compiling])])
20+
])
5121

5222
PHP_NEW_EXTENSION(fileinfo, fileinfo.c php_libmagic.c $libmagic_sources, $ext_shared,,-I@ext_srcdir@/libmagic)
5323
PHP_ADD_BUILD_DIR($ext_builddir/libmagic)

0 commit comments

Comments
 (0)