From: Dave Hart Date: Sat, 18 Dec 2010 06:57:45 +0000 (+0000) Subject: [Bug 1458] Can not compile NTP on FreeBSD 4.7 X-Git-Tag: NTP_4_2_7P97~3^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4487099ed1c05175ed168051e0953cd433d5abeb;p=thirdparty%2Fntp.git [Bug 1458] Can not compile NTP on FreeBSD 4.7 bk: 4d0c5b69Wq20-FdSlYbQfTNqeQxg2w --- diff --git a/libntp/ntp_lineedit.c b/libntp/ntp_lineedit.c index 339de635d..55fdf0430 100644 --- a/libntp/ntp_lineedit.c +++ b/libntp/ntp_lineedit.c @@ -47,11 +47,14 @@ static char * lineedit_prompt; #ifdef LE_EDITLINE - static EditLine * ntp_el; - static History * ntp_hist; - static HistEvent hev; - - char * ntp_prompt_callback(EditLine *); +# ifndef H_SETSIZE +# define H_SETSIZE H_EVENT +# endif +static EditLine * ntp_el; +static History * ntp_hist; +static HistEvent hev; + +char * ntp_prompt_callback(EditLine *); #endif /* LE_EDITLINE */ @@ -76,7 +79,11 @@ ntp_readline_init( #ifdef LE_EDITLINE if (NULL == ntp_el) { +# if 4 == EL_INIT_ARGS ntp_el = el_init(progname, stdin, stdout, stderr); +# else + ntp_el = el_init(progname, stdin, stdout); +# endif if (ntp_el) { el_set(ntp_el, EL_PROMPT, ntp_prompt_callback); @@ -96,12 +103,12 @@ ntp_readline_init( success = 0; } else { - memset(&hev, 0, sizeof hev); - - history(ntp_hist, &hev, H_SETSIZE, 128); - - el_set(ntp_el, EL_HIST, history, ntp_hist); - + memset(&hev, 0, sizeof(hev)); +#ifdef H_SETSIZE + history(ntp_hist, &hev, H_SETSIZE, 128); +#endif + el_set(ntp_el, EL_HIST, history, + ntp_hist); /* use any .editrc */ el_source(ntp_el, NULL); } diff --git a/m4/ntp_lineeditlibs.m4 b/m4/ntp_lineeditlibs.m4 index 2a973e951..f86e617f4 100644 --- a/m4/ntp_lineeditlibs.m4 +++ b/m4/ntp_lineeditlibs.m4 @@ -86,6 +86,32 @@ AC_DEFUN([NTP_LINEEDITLIBS], [ *) AC_CHECK_HEADERS([readline.h readline/readline.h histedit.h]) AC_CHECK_HEADERS([history.h readline/history.h]) + + case "$ac_cv_header_histedit_h" in + yes) + AC_CACHE_CHECK( + [number of arguments to el_init()], + [ntp_cv_el_init_args], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include + #include + ]], + [[ + el_init("conftest", stdin, stdout, stderr); + ]] + )], + [ntp_cv_el_init_args=4], + [ntp_cv_el_init_args=3] + )] + ) + AC_DEFINE_UNQUOTED( + [EL_INIT_ARGS], + [$ntp_cv_el_init_args], + [number of args to el_init()] + ) + esac AC_MSG_CHECKING([whether readline supports history])