]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1458] Can not compile NTP on FreeBSD 4.7
authorDave Hart <hart@ntp.org>
Sat, 18 Dec 2010 06:57:45 +0000 (06:57 +0000)
committerDave Hart <hart@ntp.org>
Sat, 18 Dec 2010 06:57:45 +0000 (06:57 +0000)
bk: 4d0c5b69Wq20-FdSlYbQfTNqeQxg2w

libntp/ntp_lineedit.c
m4/ntp_lineeditlibs.m4

index 339de635d33a8ca882cb057d48dee7eb3db1431a..55fdf0430ee82f5839af84acb9bb0317760fed21 100644 (file)
@@ -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);
                        }
index 2a973e951fa75e04a1013ed9ca58245b7a2ca735..f86e617f4b30fe3ff7df1d1005446030b21cda53 100644 (file)
@@ -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 <stdio.h>
+                           #include <histedit.h>
+                       ]],
+                       [[
+                           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])