diff --git a/lib/filename.h b/lib/filename.h index bc401b17a88..e37a373eb41 100644 --- a/lib/filename.h +++ b/lib/filename.h @@ -49,7 +49,10 @@ extern "C" { any notion of "current directory". IS_RELATIVE_FILE_NAME(Filename) tests whether Filename may be concatenated - to a directory filename. + to a directory filename to yield the name + of a file relative to that directory. + Watch out: IS_RELATIVE_FILE_NAME ("") is 1 + even though "" is not a relative file name. Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a relative file name! IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device diff --git a/lib/stdio-consolesafe.c b/lib/stdio-consolesafe.c index c9486f1a32f..f634de13ef4 100644 --- a/lib/stdio-consolesafe.c +++ b/lib/stdio-consolesafe.c @@ -85,7 +85,7 @@ gl_consolesafe_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *fp) specifiers as the mingw *printf functions. */ static int -vasprintf (char **resultp, const char *format, va_list args) +local_vasprintf (char **resultp, const char *format, va_list args) { /* First try: Use a stack-allocated buffer. */ char buf[2048]; @@ -123,6 +123,9 @@ vasprintf (char **resultp, const char *format, va_list args) return nbytes; } +# undef vasprintf +# define vasprintf local_vasprintf + # endif /* Bypass the functions __mingw_[v][f]printf, that trigger a bug in msvcrt, diff --git a/m4/getdelim.m4 b/m4/getdelim.m4 index 8b6eff47aa2..736c4e8b2eb 100644 --- a/m4/getdelim.m4 +++ b/m4/getdelim.m4 @@ -1,5 +1,5 @@ # getdelim.m4 -# serial 21 +# serial 22 dnl Copyright (C) 2005-2007, 2009-2026 Free Software Foundation, Inc. dnl @@ -37,7 +37,6 @@ AC_DEFUN([gl_FUNC_GETDELIM], gl_cv_func_working_getdelim=no ;; *) echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data - touch conftest.empty AC_RUN_IFELSE([AC_LANG_SOURCE([[ # include # include @@ -68,36 +67,32 @@ AC_DEFUN([gl_FUNC_GETDELIM], free (line); } fclose (in); - { - /* Test that reading EOF as the first character sets the first byte - in the buffer to NUL. This fails on glibc 2.42 and earlier. */ - in = fopen ("./conftest.empty", "r"); - if (!in) - return 1; - char *line = malloc (1); - line[0] = 'A'; - size_t siz = 1; - if (getdelim (&line, &siz, '\n', in) != -1 || line[0] != '\0') - result |= 8; - free (line); - } - fclose (in); return result; } ]])], [gl_cv_func_working_getdelim=yes], [gl_cv_func_working_getdelim=no], - [case "$host_os" in - # Guess yes on musl. - *-musl* | midipix*) gl_cv_func_working_getdelim="guessing yes" ;; - # Guess no on glibc. - *-gnu* | gnu*) gl_cv_func_working_getdelim="guessing no" ;; - *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;; - esac + [dnl We're cross compiling. + dnl Guess it works on glibc2 systems and musl systems. + AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ >= 2) && !defined __UCLIBC__ + Lucky GNU user + #endif +#endif + ], + [gl_cv_func_working_getdelim="guessing yes"], + [case "$host_os" in + *-musl* | midipix*) gl_cv_func_working_getdelim="guessing yes" ;; + *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;; + esac + ]) ]) ;; esac - rm -f conftest.data conftest.empty + rm -f conftest.data ]) case "$gl_cv_func_working_getdelim" in *yes) ;; diff --git a/m4/getline.m4 b/m4/getline.m4 index ed32fa10bfb..25539dc20c3 100644 --- a/m4/getline.m4 +++ b/m4/getline.m4 @@ -1,5 +1,5 @@ # getline.m4 -# serial 35 +# serial 36 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2026 Free Software Foundation, dnl Inc. @@ -31,7 +31,6 @@ AC_DEFUN([gl_FUNC_GETLINE], AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline], [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data - touch conftest.empty AC_RUN_IFELSE([AC_LANG_SOURCE([[ # include # include @@ -62,34 +61,30 @@ AC_DEFUN([gl_FUNC_GETLINE], free (line); } fclose (in); - { - /* Test that reading EOF as the first character sets the first byte - in the buffer to NUL. This fails on glibc 2.42 and earlier. */ - in = fopen ("./conftest.empty", "r"); - if (!in) - return 1; - char *line = malloc (1); - line[0] = 'A'; - size_t siz = 1; - if (getline (&line, &siz, in) != -1 || line[0] != '\0') - result |= 8; - free (line); - } - fclose (in); return result; } ]])], [am_cv_func_working_getline=yes], [am_cv_func_working_getline=no], - [case "$host_os" in - # Guess yes on musl. - *-musl* | midipix*) am_cv_func_working_getline="guessing yes" ;; - # Guess no on glibc. - *-gnu* | gnu*) am_cv_func_working_getline="guessing no" ;; - *) am_cv_func_working_getline="$gl_cross_guess_normal" ;; - esac + [dnl We're cross compiling. + dnl Guess it works on glibc2 systems and musl systems. + AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ >= 2) && !defined __UCLIBC__ + Lucky GNU user + #endif +#endif + ], + [am_cv_func_working_getline="guessing yes"], + [case "$host_os" in + *-musl* | midipix*) am_cv_func_working_getline="guessing yes" ;; + *) am_cv_func_working_getline="$gl_cross_guess_normal" ;; + esac + ]) ]) - rm -f conftest.data conftest.empty + rm -f conftest.data ]) else am_cv_func_working_getline=no diff --git a/m4/selinux-selinux-h.m4 b/m4/selinux-selinux-h.m4 index b3fcd2102e2..c964ced0728 100644 --- a/m4/selinux-selinux-h.m4 +++ b/m4/selinux-selinux-h.m4 @@ -1,5 +1,5 @@ # selinux-selinux-h.m4 -# serial 10 -*- Autoconf -*- +# serial 12 -*- Autoconf -*- dnl Copyright (C) 2006-2007, 2009-2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -49,7 +49,7 @@ AC_DEFUN([gl_CHECK_HEADER_SELINUX_SELINUX_H], USE_SELINUX_SELINUX_H=0 fi - case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in + case "$ac_cv_search_getfilecon_raw:$ac_cv_header_selinux_selinux_h" in no:*) # already warned ;; *:no) @@ -79,15 +79,17 @@ AC_DEFUN([gl_LIBSELINUX], LIB_SELINUX= if test "$with_selinux" != no; then gl_saved_LIBS=$LIBS - AC_SEARCH_LIBS([setfilecon], [selinux], - [test "$ac_cv_search_setfilecon" = "none required" || - LIB_SELINUX=$ac_cv_search_setfilecon]) + dnl On Android, in Termux, prefer libandroid-selinux.so, because it + dnl defines many more API functions than /system/lib/libselinux.so. + AC_SEARCH_LIBS([getfilecon_raw], [android-selinux selinux], + [test "$ac_cv_search_getfilecon_raw" = "none required" || + LIB_SELINUX=$ac_cv_search_getfilecon_raw]) LIBS=$gl_saved_LIBS fi AC_SUBST([LIB_SELINUX]) # Warn if SELinux is found but libselinux is absent; - if test "$ac_cv_search_setfilecon" = no; then + if test "$ac_cv_search_getfilecon_raw" = no; then if test "$host" = "$build" \ && { test -d /sys/fs/selinux || test -d /selinux; }; then AC_MSG_WARN([This system supports SELinux but libselinux is missing.])