Skip to content

Commit e74cbac

Browse files
committed
Declare getdelim(3) if it exists in libc but is not prototyped in stdio.h.
This can happen on systems with a gcc packages that was built on and older versions of the OS where getdelim(3) was not present. --HG-- branch : 1.8
1 parent dd80b8f commit e74cbac

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@
9898
*/
9999
#undef HAVE_DECL_ERRNO
100100

101+
/* Define to 1 if you have the declaration of `getdelim', and to 0 if you
102+
don't. */
103+
#undef HAVE_DECL_GETDELIM
104+
101105
/* Define to 1 if you have the declaration of `getdomainname', and to 0 if you
102106
don't. */
103107
#undef HAVE_DECL_GETDOMAINNAME

configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19380,6 +19380,19 @@ if test "x$ac_cv_func_getdelim" = xyes; then :
1938019380
#define HAVE_GETDELIM 1
1938119381
_ACEOF
1938219382

19383+
# Out of date gcc fixed includes may result in missing getdelim() prototype
19384+
ac_fn_c_check_decl "$LINENO" "getdelim" "ac_cv_have_decl_getdelim" "$ac_includes_default"
19385+
if test "x$ac_cv_have_decl_getdelim" = xyes; then :
19386+
ac_have_decl=1
19387+
else
19388+
ac_have_decl=0
19389+
fi
19390+
19391+
cat >>confdefs.h <<_ACEOF
19392+
#define HAVE_DECL_GETDELIM $ac_have_decl
19393+
_ACEOF
19394+
19395+
1938319396
else
1938419397

1938519398
case " $LIBOBJS " in

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2560,7 +2560,10 @@ AC_CHECK_FUNCS([getgrouplist], [], [
25602560
esac
25612561
SUDO_APPEND_COMPAT_EXP(sudo_getgrouplist)
25622562
])
2563-
AC_CHECK_FUNCS([getdelim], [], [
2563+
AC_CHECK_FUNCS([getdelim], [
2564+
# Out of date gcc fixed includes may result in missing getdelim() prototype
2565+
AC_CHECK_DECLS([getdelim])
2566+
], [
25642567
AC_LIBOBJ(getdelim)
25652568
SUDO_APPEND_COMPAT_EXP(sudo_getdelim)
25662569
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }getdelim_test"

include/sudo_compat.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,13 @@ __dso_public int sudo_getgrouplist(const char *name, GETGROUPS_T basegid, GETGRO
408408
# undef getgrouplist
409409
# define getgrouplist(_a, _b, _c, _d) sudo_getgrouplist((_a), (_b), (_c), (_d))
410410
#endif /* GETGROUPLIST */
411-
#ifndef HAVE_GETDELIM
411+
#if !defined(HAVE_GETDELIM)
412412
__dso_public ssize_t sudo_getdelim(char **bufp, size_t *bufsizep, int delim, FILE *fp);
413413
# undef getdelim
414414
# define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d))
415+
#elif defined(HAVE_DECL_GETDELIM) && !HAVE_DECL_GETDELIM
416+
/* getdelim present in libc but missing prototype (old gcc fixed includes?) */
417+
ssize_t getdelim(char **bufp, size_t *bufsizep, int delim, FILE *fp);
415418
#endif /* HAVE_GETDELIM */
416419
#ifndef HAVE_GETUSERSHELL
417420
__dso_public char *sudo_getusershell(void);

0 commit comments

Comments
 (0)