aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--TODO9
-rw-r--r--configh.in3
-rwxr-xr-xconfigure44
-rw-r--r--debug.c15
-rw-r--r--m4/ChangeLog8
-rw-r--r--m4/readline.m46
7 files changed, 78 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 2732bfbb..b7beff3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-08-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * debug.c (HAVE_HISTORY_LIST): Move checks and defines to the top.
+ (do_save, serialize): Adjust #if checks to depend on having both
+ readline and the history functions. Needed for Mac OS X whose
+ native readline is a very old version. Sigh.
+ * configh.in, configure: Regenerated due to change in m4/readline.m4.
+ Issue reported by Hermann Peifer and Larry Baker.
+
2013-08-26 Arnold D. Robbins <arnold@skeeve.com>
* regcomp.c (parse_dup_op): Remove RE_TOKEN_INIT_BUG code (change of
diff --git a/TODO b/TODO
index f08d82d7..3df94646 100644
--- a/TODO
+++ b/TODO
@@ -15,15 +15,6 @@ TODO
Minor Cleanups and Code Improvements
------------------------------------
- Put FAKE_FD_VALUE into a head included from awk.h and extension/
- dirfd.h.
-
- Mac OS X readline doesn't have history_list which is used from debug.c
- functions do_save and serialize.
- See http://ftp.samba.org/pub/unpacked/samba_3_current/source4/lib/smbreadline/readline.m4
- for some help. Reported by Larry Baker, larry.baker@stanfordalumni.org
-
-
API:
??? #if !defined(GAWK) && !defined(GAWK_OMIT_CONVENIENCE_MACROS)
diff --git a/configh.in b/configh.in
index f6540a45..a535fd4b 100644
--- a/configh.in
+++ b/configh.in
@@ -66,6 +66,9 @@
/* Define to 1 if you have the `grantpt' function. */
#undef HAVE_GRANTPT
+/* Do we have history_list? */
+#undef HAVE_HISTORY_LIST
+
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV
diff --git a/configure b/configure
index 0e5a9303..03e0838f 100755
--- a/configure
+++ b/configure
@@ -10462,6 +10462,50 @@ $as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h
LIBREADLINE=$_combo
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for history_list in -lreadline" >&5
+$as_echo_n "checking for history_list in -lreadline... " >&6; }
+if ${ac_cv_lib_readline_history_list+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline $_combo $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char history_list ();
+int
+main ()
+{
+return history_list ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_readline_history_list=yes
+else
+ ac_cv_lib_readline_history_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_history_list" >&5
+$as_echo "$ac_cv_lib_readline_history_list" >&6; }
+if test "x$ac_cv_lib_readline_history_list" = xyes; then :
+
+$as_echo "#define HAVE_HISTORY_LIST 1" >>confdefs.h
+
+fi
+
+
break
fi
done
diff --git a/debug.c b/debug.c
index 29500f29..949ebb49 100644
--- a/debug.c
+++ b/debug.c
@@ -108,6 +108,12 @@ static BREAKPOINT breakpoints = { &breakpoints, &breakpoints, 0 };
static int sess_history_base = 0;
#endif
+#ifndef HAVE_HISTORY_LIST
+#define HIST_ENTRY void
+#define history_list() NULL
+#endif
+
+
/* 'list' command */
static int last_printed_line = 0;
static int last_print_count; /* # of lines printed */
@@ -4058,7 +4064,7 @@ do_dump_instructions(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
int
do_save(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
{
-#ifdef HAVE_LIBREADLINE
+#if defined(HAVE_LIBREADLINE) && defined(HAVE_HISTORY_LIST)
FILE *fp;
HIST_ENTRY **hist_list;
int i;
@@ -4282,11 +4288,6 @@ serialize_subscript(char *buf, int buflen, struct list_item *item)
static void
serialize(int type)
{
-#ifndef HAVE_LIBREADLINE
-#define HIST_ENTRY void
-#define history_list() NULL
-#endif
-
static char *buf = NULL;
static int buflen = 0;
int bl;
@@ -4400,7 +4401,7 @@ enlarge_buffer:
cndn = &wd->cndn;
break;
case HISTORY:
-#ifdef HAVE_LIBREADLINE
+#if defined(HAVE_LIBREADLINE) && defined(HAVE_HISTORY_LIST)
h = (HIST_ENTRY *) ptr;
nchar = strlen(h->line);
if (nchar >= buflen - bl)
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 59ddc228..3996eb53 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,11 @@
+2013-08-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * readline.m4: Add additional code to check for history_list()
+ function. Patterned after checks in:
+ http://ftp.samba.org/pub/unpacked/samba_3_current/source4/lib/smbreadline/readline.m4
+ Thanks to Larry Baker (larry.baker@stanfordalumni.org) for the
+ pointer.
+
2013-05-09 Arnold D. Robbins <arnold@skeeve.com>
* 4.1.0: Release tar ball made.
diff --git a/m4/readline.m4 b/m4/readline.m4
index 76605af8..f24e95bf 100644
--- a/m4/readline.m4
+++ b/m4/readline.m4
@@ -72,6 +72,12 @@ dnl action if cross compiling:
AC_DEFINE(HAVE_LIBREADLINE,1,
[Define to 1 if you have a fully functional readline library.])
AC_SUBST(LIBREADLINE,$_combo)
+
+ AC_CHECK_LIB(readline, history_list,
+ [AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
+ [],
+ [$_combo])
+
break
fi
done