[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Opening a can of worms: a readline gnulib module?
From: |
Simon Josefsson |
Subject: |
Re: Opening a can of worms: a readline gnulib module? |
Date: |
Thu, 11 Aug 2005 21:42:40 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> Simon Josefsson wrote:
>> So the entire M4 file read as below now. Correct?
>
> gl_cv_lib_readline vs. ac_cv_lib_readline_readline should be the same.
> HAVE_READLINE vs. HAVE_READLINE_READLINE_H should be the same.
I solved it slightly differently. I made these two tests orthogonal.
readline/readline.h is used by the header file if available.
-lreadline is used instead of the *.c file if available. The two
decisions don't depend on each other.
> After this, you can commit it if it works. Let's see whether it also needs
> mention of libncurses/libtermcap.
It builds on the following platforms:
i686-pc-linux-gnu
i686-pc-linux-gnu
alphaev67-unknown-linux-gnu
i386-unknown-netbsdelf2.0 spe143
alpha-unknown-freebsd5.4
ia64-unknown-freebsd5.4
alphaev68-dec-osf5.1b
alphaev68-dec-osf5.1b
alphaev7-dec-osf5.1b
ia64-unknown-linux-gnu
ia64-hp-hpux11.23
ia64-unknown-linux-gnu
i686-pc-linux-gnu
ia64-unknown-linux-gnu
alphaev67-dec-osf5.1b
alphaev67-unknown-linux-gnu
x86_64-unknown-linux-gnu
x86_64-unknown-linux-gnu
powerpc-apple-darwin5.5
powerpc-apple-darwin6.8
sparc-sun-solaris2.9
i386-pc-solaris2.9
I'll try to see if it fails to find the library because it need
termcap on any platform now...
> IMO, support for FreeBSD libedit [1] can be added at a later date. Not urgent.
Interesting. I wonder if the gnulib module really should have another
name. E.g., gl_prompt. It could use readline or libedit internally.
On the other hand, readline is a GNU interface, so perhaps we should
focus on that, and only provide the libedit implementation as a
courtesy.
I added a comment to readline.h, and fixed a problem with PROMPT=NULL
too, and fixed a few M4 typos.
Installed the patch below. That was the last local gnulib
modification I had right now...
Thanks!
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/ChangeLog,v
retrieving revision 1.323
diff -u -p -r1.323 ChangeLog
--- ChangeLog 11 Aug 2005 09:56:12 -0000 1.323
+++ ChangeLog 11 Aug 2005 19:31:08 -0000
@@ -1,5 +1,7 @@
2005-08-11 Simon Josefsson <address@hidden>
+ * modules/readline: New file.
+
* modules/strnlen (Files): Add strnlen.h.
2005-08-10 Simon Josefsson <address@hidden>
Index: lib/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.899
diff -u -p -r1.899 ChangeLog
--- lib/ChangeLog 11 Aug 2005 11:45:05 -0000 1.899
+++ lib/ChangeLog 11 Aug 2005 19:31:10 -0000
@@ -1,3 +1,7 @@
+2005-08-11 Simon Josefsson <address@hidden>
+
+ * readline.h, readline.c: New file.
+
2005-08-11 Bruno Haible <address@hidden>
* strnlen.h (strnlen): Change parameter name to match comment.
Index: lib/readline.c
===================================================================
RCS file: lib/readline.c
diff -N lib/readline.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/readline.c 11 Aug 2005 19:31:10 -0000
@@ -0,0 +1,51 @@
+/* readline.c --- Simple implementation of readline.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ Written by Simon Josefsson
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* This module is intended to be used when the application only need
+ the readline interface. If you need more functions from the
+ readline library, it is recommended to require the readline library
+ (or improve this module) rather than #if-protect part of your
+ application (doing so would add assumptions of this module into
+ your application). The application should use #include
+ "readline.h", that header file will include <readline/readline.h>
+ if the real library is present on the system. */
+
+/* Get specification. */
+#include "readline.h"
+
+#include <stdio.h>
+#include <getline.h>
+
+char *
+readline (const char *prompt)
+{
+ char *out = NULL;
+ size_t size = 0;
+
+ if (prompt)
+ fputs (prompt, stdout);
+
+ if (getline (&out, &size, stdin) < 0)
+ return NULL;
+
+ return out;
+}
Index: lib/readline.h
===================================================================
RCS file: lib/readline.h
diff -N lib/readline.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/readline.h 11 Aug 2005 19:31:10 -0000
@@ -0,0 +1,35 @@
+/* readline.h --- Simple implementation of readline.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+ Written by Simon Josefsson
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef GL_READLINE_H
+#define GL_READLINE_H
+
+#if HAVE_READLINE_READLINE_H
+/* <readline/readline.h> makes use of the FILE type without including
+ <stdio.h> itself. */
+# include <stdio.h>
+# include <readline/readline.h>
+#else
+/* Prints a prompt PROMPT and then reads and returns a single line of
+ text from the user. If PROMPT is NULL or the empty string, no
+ prompt is displayed. The returned line is allocated with malloc;
+ the caller should free the line when it has finished with it. */
+extern char *readline (const char *prompt);
+#endif
+
+#endif /* GL_READLINE_H */
Index: m4/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/ChangeLog,v
retrieving revision 1.683
diff -u -p -r1.683 ChangeLog
--- m4/ChangeLog 11 Aug 2005 09:56:12 -0000 1.683
+++ m4/ChangeLog 11 Aug 2005 19:31:10 -0000
@@ -1,3 +1,7 @@
+2005-08-11 Simon Josefsson <address@hidden>
+
+ * readline.m4: New file.
+
2005-08-10 Simon Josefsson <address@hidden>
* strnlen.m4: New file.
Index: m4/readline.m4
===================================================================
RCS file: m4/readline.m4
diff -N m4/readline.m4
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ m4/readline.m4 11 Aug 2005 19:31:10 -0000
@@ -0,0 +1,63 @@
+# readline.m4 serial 1
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_READLINE],
+[
+ AC_LIBSOURCES([readline.c, readline.h])
+
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and
+ dnl INCREADLINE accordingly.
+ AC_LIB_LINKFLAGS_BODY([readline])
+
+ dnl Add $INCREADLINE to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed libreadline and not disabled its use
+ dnl via --without-libreadline-prefix, he wants to use it. The AC_TRY_LINK
+ dnl will then succeed.
+ am_save_CPPFLAGS="$CPPFLAGS"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE])
+
+ AC_CACHE_CHECK(for readline, gl_cv_lib_readline, [
+ gl_cv_lib_readline=no
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBREADLINE"
+ AC_TRY_LINK([#include <stdio.h>
+#include <readline/readline.h>],
+ [readline((char*)0);],
+ gl_cv_lib_readline=yes)
+ LIBS="$am_save_LIBS"
+ ])
+ if test "$gl_cv_lib_readline" = yes; then
+ AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline() library.])
+ fi
+ if test "$gl_cv_lib_readline" = yes; then
+ AC_MSG_CHECKING([how to link with libreadline])
+ AC_MSG_RESULT([$LIBREADLINE])
+ else
+ dnl If $LIBREADLINE didn't lead to a usable library, we don't need
$INCREADLINE
+ dnl either.
+ CPPFLAGS="$am_save_CPPFLAGS"
+ LIBREADLINE=
+ LTLIBREADLINE=
+ fi
+ AC_SUBST(LIBREADLINE)
+ AC_SUBST(LTLIBREADLINE)
+
+ AC_CHECK_HEADERS(readline/readline.h)
+
+ if test $gl_cv_lib_readline = no; then
+ AC_LIBOBJ(readline)
+ gl_PREREQ_READLINE
+ fi
+])
+
+# Prerequisites of lib/readline.c.
+AC_DEFUN([gl_PREREQ_READLINE], [
+ :
+])
Index: modules/readline
===================================================================
RCS file: modules/readline
diff -N modules/readline
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/readline 11 Aug 2005 19:31:10 -0000
@@ -0,0 +1,25 @@
+Description:
+Simple implementation of readline.
+
+Files:
+lib/readline.h
+lib/readline.c
+m4/readline.m4
+m4/lib-link.m4
+
+Depends-on:
+getline
+
+configure.ac:
+gl_FUNC_READLINE
+
+Makefile.am:
+
+Include:
+"readline.h"
+
+License:
+GPL
+
+Maintainer:
+Simon Josefsson
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Bruno Haible, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Bruno Haible, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Bruno Haible, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?,
Simon Josefsson <=
- Re: Opening a can of worms: a readline gnulib module?, Oskar Liljeblad, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Oskar Liljeblad, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/11
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/12
- Re: Opening a can of worms: a readline gnulib module?, Bruno Haible, 2005/08/12
- Re: Opening a can of worms: a readline gnulib module?, Simon Josefsson, 2005/08/12
- Re: [bug-gnulib] Re: Opening a can of worms: a readline gnulib module?, Bruno Haible, 2005/08/12
- Re: [bug-gnulib] Re: Opening a can of worms: a readline gnulib module?, Oskar Liljeblad, 2005/08/12
- Re: [bug-gnulib] Re: Opening a can of worms: a readline gnulib module?, Bruno Haible, 2005/08/12