Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit - Document and enable wide character support.



details:   https://anonhg.NetBSD.org/src/rev/7cf368f0816f
branches:  trunk
changeset: 750434:7cf368f0816f
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Dec 31 15:58:26 2009 +0000

description:
- Document and enable wide character support.
- Fix read function compatibility.

diffstat:

 lib/libedit/Makefile   |  11 +++++----
 lib/libedit/editline.3 |  57 ++++++++++++++++++++++++++++++++++++++++++++++++-
 lib/libedit/el.c       |   5 ++-
 lib/libedit/el.h       |   3 +-
 lib/libedit/eln.c      |   5 ++-
 lib/libedit/histedit.h |   8 +++---
 lib/libedit/prompt.c   |   6 ++--
 lib/libedit/read.c     |   8 +++++-
 8 files changed, 82 insertions(+), 21 deletions(-)

diffs (truncated from 339 to 300 lines):

diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/Makefile
--- a/lib/libedit/Makefile      Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/Makefile      Thu Dec 31 15:58:26 2009 +0000
@@ -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
diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/editline.3
--- a/lib/libedit/editline.3    Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/editline.3    Thu Dec 31 15:58:26 2009 +0000
@@ -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
diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/el.c
--- a/lib/libedit/el.c  Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/el.c  Thu Dec 31 15:58:26 2009 +0000
@@ -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;
        }
 
diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/el.h
--- a/lib/libedit/el.h  Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/el.h  Thu Dec 31 15:58:26 2009 +0000
@@ -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                  */
 
diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/eln.c
--- a/lib/libedit/eln.c Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/eln.c Thu Dec 31 15:58:26 2009 +0000
@@ -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 *));
diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/histedit.h
--- a/lib/libedit/histedit.h    Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/histedit.h    Thu Dec 31 15:58:26 2009 +0000
@@ -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)
 
diff -r 5920cd0c8a82 -r 7cf368f0816f lib/libedit/prompt.c
--- a/lib/libedit/prompt.c      Thu Dec 31 15:42:46 2009 +0000
+++ b/lib/libedit/prompt.c      Thu Dec 31 15:58:26 2009 +0000
@@ -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 */



Home | Main Index | Thread Index | Old Index