Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit provide an el_init_fd function.
details: https://anonhg.NetBSD.org/src/rev/2658cebe3b27
branches: trunk
changeset: 784230:2658cebe3b27
user: christos <christos%NetBSD.org@localhost>
date: Tue Jan 22 20:23:21 2013 +0000
description:
provide an el_init_fd function.
diffstat:
lib/libedit/editline.3 | 20 +++++++++++++++++---
lib/libedit/el.c | 18 +++++++++++++-----
lib/libedit/histedit.h | 4 +++-
lib/libedit/shlib_version | 4 ++--
4 files changed, 35 insertions(+), 11 deletions(-)
diffs (139 lines):
diff -r 458645534011 -r 2658cebe3b27 lib/libedit/editline.3
--- a/lib/libedit/editline.3 Tue Jan 22 19:28:00 2013 +0000
+++ b/lib/libedit/editline.3 Tue Jan 22 20:23:21 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: editline.3,v 1.78 2013/01/10 16:03:06 wiz Exp $
+.\" $NetBSD: editline.3,v 1.79 2013/01/22 20:23:21 christos Exp $
.\"
.\" Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,12 +26,13 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 10, 2013
+.Dd January 22, 2013
.Dt EDITLINE 3
.Os
.Sh NAME
.Nm editline ,
.Nm el_init ,
+.Nm el_init_fd ,
.Nm el_end ,
.Nm el_reset ,
.Nm el_gets ,
@@ -77,6 +78,8 @@
.In histedit.h
.Ft EditLine *
.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
+.Ft EditLine *
+.Fn el_init_fd "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr" "int fdin" "int fdout" "int fderr"
.Ft void
.Fn el_end "EditLine *e"
.Ft void
@@ -170,6 +173,8 @@
.Fa EditLine ,
which is created by
.Fn el_init
+or
+.Fn el_init_fd
and freed by
.Fn el_end .
.Pp
@@ -193,11 +198,20 @@
In this documentation, references to
.Dq the tty
are actually to this input/output stream combination.
+.It Fn el_init_fd
+Like
+.Fn el_init
+but allows specifying file descriptors for the
+.Xr stdio 3
+corresponding streams, in case those were created with
+.Xr funopen 3 .
.It Fn el_end
Clean up and finish with
.Fa e ,
assumed to have been created with
-.Fn el_init .
+.Fn el_init
+or
+.Fn el_init_fd .
.It Fn el_reset
Reset the tty and the parser.
This should be called after an error which may have upset the tty's
diff -r 458645534011 -r 2658cebe3b27 lib/libedit/el.c
--- a/lib/libedit/el.c Tue Jan 22 19:28:00 2013 +0000
+++ b/lib/libedit/el.c Tue Jan 22 20:23:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.71 2012/09/11 11:58:53 christos Exp $ */
+/* $NetBSD: el.c,v 1.72 2013/01/22 20:23:21 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
-__RCSID("$NetBSD: el.c,v 1.71 2012/09/11 11:58:53 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.72 2013/01/22 20:23:21 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -60,6 +60,14 @@
public EditLine *
el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
{
+ return el_init_fd(prog, fin, fout, ferr, fileno(fin), fileno(fout),
+ fileno(ferr));
+}
+
+public EditLine *
+el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
+ int fdin, int fdout, int fderr)
+{
EditLine *el = el_malloc(sizeof(*el));
if (el == NULL)
@@ -71,9 +79,9 @@
el->el_outfile = fout;
el->el_errfile = ferr;
- el->el_infd = fileno(fin);
- el->el_outfd = fileno(fout);
- el->el_errfd = fileno(ferr);
+ el->el_infd = fdin;
+ el->el_outfd = fdout;
+ el->el_errfd = fderr;
el->el_prog = Strdup(ct_decode_string(prog, &el->el_scratch));
if (el->el_prog == NULL) {
diff -r 458645534011 -r 2658cebe3b27 lib/libedit/histedit.h
--- a/lib/libedit/histedit.h Tue Jan 22 19:28:00 2013 +0000
+++ b/lib/libedit/histedit.h Tue Jan 22 20:23:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.49 2012/05/31 13:16:39 christos Exp $ */
+/* $NetBSD: histedit.h,v 1.50 2013/01/22 20:23:21 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -84,6 +84,8 @@
* Initialization, cleanup, and resetting
*/
EditLine *el_init(const char *, FILE *, FILE *, FILE *);
+EditLine *el_init_fd(const char *, FILE *, FILE *, FILE *,
+ int, int, int);
void el_end(EditLine *);
void el_reset(EditLine *);
diff -r 458645534011 -r 2658cebe3b27 lib/libedit/shlib_version
--- a/lib/libedit/shlib_version Tue Jan 22 19:28:00 2013 +0000
+++ b/lib/libedit/shlib_version Tue Jan 22 20:23:21 2013 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.18 2009/01/11 03:07:48 christos Exp $
+# $NetBSD: shlib_version,v 1.19 2013/01/22 20:23:21 christos Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=3
-minor=0
+minor=1
Home |
Main Index |
Thread Index |
Old Index