Module Name: src
Committed By: christos
Date: Thu Dec 31 15:58:26 UTC 2009
Modified Files:
src/lib/libedit: Makefile editline.3 el.c el.h eln.c histedit.h
prompt.c read.c
Log Message:
- Document and enable wide character support.
- Fix read function compatibility.
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/libedit/Makefile
cvs rdiff -u -r1.70 -r1.71 src/lib/libedit/editline.3
cvs rdiff -u -r1.57 -r1.58 src/lib/libedit/el.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libedit/el.h
cvs rdiff -u -r1.2 -r1.3 src/lib/libedit/eln.c
cvs rdiff -u -r1.43 -r1.44 src/lib/libedit/histedit.h
cvs rdiff -u -r1.17 -r1.18 src/lib/libedit/prompt.c
cvs rdiff -u -r1.53 -r1.54 src/lib/libedit/read.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/Makefile
diff -u src/lib/libedit/Makefile:1.39 src/lib/libedit/Makefile:1.40
--- src/lib/libedit/Makefile:1.39 Wed Dec 30 18:54:52 2009
+++ src/lib/libedit/Makefile Thu Dec 31 10:58:26 2009
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.39 2009/12/30 23:54:52 christos Exp $
+# $NetBSD: Makefile,v 1.40 2009/12/31 15:58:26 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
-WIDECHAR ?= no
+WIDECHAR ?= yes
WARNS= 4
LIB= edit
@@ -26,12 +26,13 @@
editline.3 tok_line.3 editline.3 tok_str.3
# For speed and debugging
-SRCS= ${OSRCS} readline.c tokenizer.c history.c
+#SRCS= ${OSRCS} readline.c tokenizer.c history.c
# For protection
-#SRCS= editline.c readline.c tokenizer.c history.c
+SRCS= editline.c readline.c tokenizer.c history.c
.if ${WIDECHAR} == "yes"
-SRCS += tokenizern.c historyn.c eln.c
+OSRCS += eln.c
+SRCS += tokenizern.c historyn.c
CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
CPPFLAGS+=-DWIDECHAR
.endif
Index: src/lib/libedit/editline.3
diff -u src/lib/libedit/editline.3:1.70 src/lib/libedit/editline.3:1.71
--- src/lib/libedit/editline.3:1.70 Sun Jul 5 17:55:24 2009
+++ src/lib/libedit/editline.3 Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-.\" $NetBSD: editline.3,v 1.70 2009/07/05 21:55:24 perry Exp $
+.\" $NetBSD: editline.3,v 1.71 2009/12/31 15:58:26 christos Exp $
.\"
.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd July 5, 2009
+.Dd December 31, 2009
.Dt EDITLINE 3
.Os
.Sh NAME
@@ -35,24 +35,41 @@
.Nm el_end ,
.Nm el_reset ,
.Nm el_gets ,
+.Nm el_wgets ,
.Nm el_getc ,
+.Nm el_wgetc ,
.Nm el_push ,
+.Nm el_wpush ,
.Nm el_parse ,
+.Nm el_wparse ,
.Nm el_set ,
+.Nm el_wset ,
.Nm el_get ,
+.Nm el_wget ,
.Nm el_source ,
.Nm el_resize ,
.Nm el_line ,
+.Nm el_wline ,
.Nm el_insertstr ,
+.Nm el_winsertstr ,
.Nm el_deletestr ,
+.Nm el_wdeletestr ,
.Nm history_init ,
+.Nm history_winit ,
.Nm history_end ,
+.Nm history_wend ,
.Nm history ,
+.Nm historyw ,
.Nm tok_init ,
+.Nm tok_winit ,
.Nm tok_end ,
+.Nm tok_wend ,
.Nm tok_reset ,
+.Nm tok_wreset ,
.Nm tok_line ,
+.Nm tok_wline ,
.Nm tok_str
+.Nm tok_wstr
.Nd line editor, history and tokenization functions
.Sh LIBRARY
.Lb libedit
@@ -66,17 +83,29 @@
.Fn el_reset "EditLine *e"
.Ft const char *
.Fn el_gets "EditLine *e" "int *count"
+.Ft const wchar_t *
+.Fn el_wgets "EditLine *e" "int *count"
.Ft int
.Fn el_getc "EditLine *e" "char *ch"
+.Ft int
+.Fn el_wgetc "EditLine *e" "wchar_t *ch"
.Ft void
.Fn el_push "EditLine *e" "const char *str"
+.Ft void
+.Fn el_wpush "EditLine *e" "const wchar_t *str"
.Ft int
.Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
.Ft int
+.Fn el_wparse "EditLine *e" "int argc" "const wchar_t *argv[]"
+.Ft int
.Fn el_set "EditLine *e" "int op" "..."
.Ft int
+.Fn el_wset "EditLine *e" "int op" "..."
+.Ft int
.Fn el_get "EditLine *e" "int op" "..."
.Ft int
+.Fn el_wget "EditLine *e" "int op" "..."
+.Ft int
.Fn el_source "EditLine *e" "const char *file"
.Ft void
.Fn el_resize "EditLine *e"
@@ -84,24 +113,44 @@
.Fn el_line "EditLine *e"
.Ft int
.Fn el_insertstr "EditLine *e" "const char *str"
+.Ft int
+.Fn el_winsertstr "EditLine *e" "const wchar_t *str"
.Ft void
.Fn el_deletestr "EditLine *e" "int count"
+.Ft void
+.Fn el_wdeletestr "EditLine *e" "int count"
.Ft History *
.Fn history_init
+.Ft HistoryW *
+.Fn history_winit
.Ft void
.Fn history_end "History *h"
+.Ft void
+.Fn history_wend "HistoryW *h"
.Ft int
.Fn history "History *h" "HistEvent *ev" "int op" "..."
+.Ft int
+.Fn historyw "HistoryW *h" "HistEventW *ev" "int op" "..."
.Ft Tokenizer *
.Fn tok_init "const char *IFS"
+.Ft TokenizerW *
+.Fn tok_winit "const wchar_t *IFS"
.Ft void
.Fn tok_end "Tokenizer *t"
.Ft void
+.Fn tok_wend "TokenizerW *t"
+.Ft void
.Fn tok_reset "Tokenizer *t"
+.Ft void
+.Fn tok_wreset "TokenizerW *t"
.Ft int
.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char **argv[]" "int *cursorc" "int *cursoro"
.Ft int
+.Fn tok_wline "TokenizerW *t" "const LineInfoW *li" "int *argc" "const wchar_t **argv[]" "int *cursorc" "int *cursoro"
+.Ft int
.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]"
+.Ft int
+.Fn tok_wstr "TokenizerW *t" "const wchar_t *str" "int *argc" "const wchar_t **argv[]"
.Sh DESCRIPTION
The
.Nm
@@ -124,6 +173,9 @@
and freed by
.Fn el_end .
.Pp
+The wide character functions behave the same way as their narrow
+counterparts.
+.Pp
The following functions are available:
.Bl -tag -width 4n
.It Fn el_init
@@ -809,6 +861,7 @@
and
.Dv EL_RPROMPT .
Jaromir Dolecek implemented the readline emulation.
+Johny Mattsson implemented wide character support.
.Sh BUGS
At this time, it is the responsibility of the caller to
check the result of the
Index: src/lib/libedit/el.c
diff -u src/lib/libedit/el.c:1.57 src/lib/libedit/el.c:1.58
--- src/lib/libedit/el.c:1.57 Wed Dec 30 18:54:52 2009
+++ src/lib/libedit/el.c Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.57 2009/12/30 23:54:52 christos Exp $ */
+/* $NetBSD: el.c,v 1.58 2009/12/31 15:58:26 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.57 2009/12/30 23:54:52 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.58 2009/12/31 15:58:26 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -282,6 +282,7 @@
{
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
rv = el_read_setfn(el, rc);
+ el->el_flags &= ~NARROW_READ;
break;
}
Index: src/lib/libedit/el.h
diff -u src/lib/libedit/el.h:1.20 src/lib/libedit/el.h:1.21
--- src/lib/libedit/el.h:1.20 Wed Dec 30 18:54:52 2009
+++ src/lib/libedit/el.h Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: el.h,v 1.20 2009/12/30 23:54:52 christos Exp $ */
+/* $NetBSD: el.h,v 1.21 2009/12/31 15:58:26 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -60,6 +60,7 @@
#define CHARSET_IS_UTF8 0x10
#define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */
#define NARROW_HISTORY 0x40
+#define NARROW_READ 0x80
typedef int bool_t; /* True or not */
Index: src/lib/libedit/eln.c
diff -u src/lib/libedit/eln.c:1.2 src/lib/libedit/eln.c:1.3
--- src/lib/libedit/eln.c:1.2 Wed Dec 30 18:54:52 2009
+++ src/lib/libedit/eln.c Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.2 2009/12/30 23:54:52 christos Exp $ */
+/* $NetBSD: eln.c,v 1.3 2009/12/31 15:58:26 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.2 2009/12/30 23:54:52 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.3 2009/12/31 15:58:26 christos Exp $");
#endif /* not lint && not SCCSID */
#include "histedit.h"
@@ -205,6 +205,7 @@
/* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */
ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
+ el->el_flags |= NARROW_READ;
break;
case EL_CLIENTDATA: /* void * */
ret = el_wset(el, op, va_arg(ap, void *));
Index: src/lib/libedit/histedit.h
diff -u src/lib/libedit/histedit.h:1.43 src/lib/libedit/histedit.h:1.44
--- src/lib/libedit/histedit.h:1.43 Wed Dec 30 18:54:52 2009
+++ src/lib/libedit/histedit.h Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.43 2009/12/30 23:54:52 christos Exp $ */
+/* $NetBSD: histedit.h,v 1.44 2009/12/31 15:58:26 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -141,7 +141,7 @@
/* , el_func_t); */
#define EL_HIST 10 /* , hist_fun_t, const ptr_t); set */
#define EL_EDITMODE 11 /* , int); set/get */
-#define EL_RPROMPT 12 /* , promt_func); set/get */
+#define EL_RPROMPT 12 /* , prompt_func); set/get */
#define EL_GETCFN 13 /* , el_rfunc_t); set/get */
#define EL_CLIENTDATA 14 /* , void *); set/get */
#define EL_UNBUFFERED 15 /* , int); set/get */
@@ -150,8 +150,8 @@
#define EL_GETFP 18 /* , int, FILE **); get */
#define EL_SETFP 19 /* , int, FILE *); set */
#define EL_REFRESH 20 /* , void); set */
-#define EL_PROMPT_ESC 21 /* , promt_func, wchar_t); set/get */
-#define EL_RPROMPT_ESC 22 /* , promt_func, wchar_t); set/get */
+#define EL_PROMPT_ESC 21 /* , prompt_func, wchar_t); set/get */
+#define EL_RPROMPT_ESC 22 /* , prompt_func, wchar_t); set/get */
#define EL_BUILTIN_GETCFN (NULL)
Index: src/lib/libedit/prompt.c
diff -u src/lib/libedit/prompt.c:1.17 src/lib/libedit/prompt.c:1.18
--- src/lib/libedit/prompt.c:1.17 Wed Dec 30 17:37:40 2009
+++ src/lib/libedit/prompt.c Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: prompt.c,v 1.17 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: prompt.c,v 1.18 2009/12/31 15:58:26 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: prompt.c,v 1.17 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: prompt.c,v 1.18 2009/12/31 15:58:26 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -94,7 +94,7 @@
if (elp->p_wide)
p = (*elp->p_func)(el);
else
- p = ct_decode_string((char *)(*elp->p_func)(el),
+ p = ct_decode_string((char *)(void *)(*elp->p_func)(el),
&el->el_scratch);
for (; *p; p++) {
Index: src/lib/libedit/read.c
diff -u src/lib/libedit/read.c:1.53 src/lib/libedit/read.c:1.54
--- src/lib/libedit/read.c:1.53 Wed Dec 30 17:37:40 2009
+++ src/lib/libedit/read.c Thu Dec 31 10:58:26 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.53 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: read.c,v 1.54 2009/12/31 15:58:26 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.53 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.54 2009/12/31 15:58:26 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -418,6 +418,10 @@
(void) fprintf(el->el_errfile, "Reading a character\n");
#endif /* DEBUG_READ */
num_read = (*el->el_read.read_char)(el, cp);
+#ifdef WIDECHAR
+ if (el->el_flags & NARROW_READ)
+ *cp = *(char *)(void *)cp;
+#endif
#ifdef DEBUG_READ
(void) fprintf(el->el_errfile, "Got it %c\n", *cp);
#endif /* DEBUG_READ */