Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Wide character support (UTF-8) from Johny Mattss...
details: https://anonhg.NetBSD.org/src/rev/ad7c3fc4ba4b
branches: trunk
changeset: 750418:ad7c3fc4ba4b
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 30 22:37:40 2009 +0000
description:
Wide character support (UTF-8) from Johny Mattsson; currently disabled.
diffstat:
lib/libedit/Makefile | 44 ++++-
lib/libedit/chared.c | 154 ++++++++++--------
lib/libedit/chared.h | 43 ++--
lib/libedit/chartype.c | 361 +++++++++++++++++++++++++++++++++++++++++++++
lib/libedit/chartype.h | 237 +++++++++++++++++++++++++++++
lib/libedit/common.c | 116 +++++++-------
lib/libedit/el.c | 120 +++++++-------
lib/libedit/el.h | 30 ++-
lib/libedit/eln.c | 340 ++++++++++++++++++++++++++++++++++++++++++
lib/libedit/emacs.c | 82 +++++-----
lib/libedit/filecomplete.c | 40 ++--
lib/libedit/filecomplete.h | 4 +-
lib/libedit/hist.c | 35 ++--
lib/libedit/hist.h | 12 +-
lib/libedit/histedit.h | 137 +++++++++++++---
lib/libedit/history.c | 246 +++++++++++++++--------------
lib/libedit/key.c | 170 +++++++-------------
lib/libedit/key.h | 23 +-
lib/libedit/makelist | 24 +-
lib/libedit/map.c | 71 ++++----
lib/libedit/map.h | 16 +-
lib/libedit/parse.c | 92 +++++++----
lib/libedit/parse.h | 10 +-
lib/libedit/prompt.c | 41 ++--
lib/libedit/prompt.h | 11 +-
lib/libedit/read.c | 89 ++++++++--
lib/libedit/read.h | 4 +-
lib/libedit/readline.c | 168 +++++++++++---------
lib/libedit/refresh.c | 215 +++++++++++++++-----------
lib/libedit/refresh.h | 4 +-
lib/libedit/search.c | 81 +++++----
lib/libedit/search.h | 14 +-
lib/libedit/sys.h | 6 +-
lib/libedit/term.c | 277 +++++++++++++++++++--------------
lib/libedit/term.h | 24 +-
lib/libedit/tokenizer.c | 87 +++++-----
lib/libedit/tty.c | 49 +++--
lib/libedit/tty.h | 5 +-
lib/libedit/vi.c | 194 +++++++++++++----------
39 files changed, 2466 insertions(+), 1210 deletions(-)
diffs (truncated from 8321 to 300 lines):
diff -r 6646ddbc0784 -r ad7c3fc4ba4b lib/libedit/Makefile
--- a/lib/libedit/Makefile Wed Dec 30 22:12:12 2009 +0000
+++ b/lib/libedit/Makefile Wed Dec 30 22:37:40 2009 +0000
@@ -1,15 +1,16 @@
-# $NetBSD: Makefile,v 1.37 2009/01/18 12:17:49 lukem Exp $
+# $NetBSD: Makefile,v 1.38 2009/12/30 22:37:40 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
+WIDECHAR ?= no
WARNS= 4
LIB= edit
LIBDPLIBS+= termcap ${.CURDIR}/../libterm
-OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c hist.c \
- key.c map.c \
+OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
+ hist.c key.c map.c chartype.c \
parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c
MAN= editline.3 editrc.5
@@ -25,9 +26,18 @@
editline.3 tok_line.3 editline.3 tok_str.3
# For speed and debugging
-#SRCS= ${OSRCS} tokenizer.c history.c readline.c
+SRCS= ${OSRCS} readline.c
# For protection
-SRCS= editline.c tokenizer.c history.c readline.c
+#SRCS= editline.c readline.c
+
+.if ${WIDECHAR} == "yes"
+SRCS += tokenizern.c tokenizerw.c historyn.c historyw.c eln.c
+CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
+CLEANFILES+=historyn.c.tmp historyn.c historyw.c.tmp historyw.c
+CPPFLAGS+=-DWIDECHAR
+.else
+SRCS += tokenizer.c history.c
+.endif
LIBEDITDIR?=${.CURDIR}
@@ -36,8 +46,8 @@
CLEANFILES+=editline.c
CLEANFILES+=common.h.tmp editline.c.tmp emacs.h.tmp fcns.c.tmp fcns.h.tmp
-CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp
-CLEANFILES+=tc1.o tc1
+CLEANFILES+=help.c.tmp help.h.tmp vi.h.tmp tc1.o tc1
+CLEANFILES+=tokenizern.c.tmp tokenizern.c tokenizerw.c.tmp tokenizerw.c
CPPFLAGS+=-I. -I${LIBEDITDIR}
CPPFLAGS+=-I. -I${.CURDIR}
CPPFLAGS+=#-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
@@ -94,6 +104,26 @@
${HOST_SH} ${LIBEDITDIR}/makelist -e ${OSRCS:T} > ${.TARGET}.tmp && \
mv ${.TARGET}.tmp ${.TARGET}
+tokenizern.c: makelist Makefile
+ ${_MKTARGET_CREATE}
+ ${HOST_SH} ${LIBEDITDIR}/makelist -t NARROW tokenizer > ${.TARGET}.tmp && \
+ mv ${.TARGET}.tmp ${.TARGET}
+
+tokenizerw.c: makelist Makefile
+ ${_MKTARGET_CREATE}
+ ${HOST_SH} ${LIBEDITDIR}/makelist -t WIDE tokenizer > ${.TARGET}.tmp && \
+ mv ${.TARGET}.tmp ${.TARGET}
+
+historyn.c: makelist Makefile
+ ${_MKTARGET_CREATE}
+ ${HOST_SH} ${LIBEDITDIR}/makelist -t NARROW history > ${.TARGET}.tmp && \
+ mv ${.TARGET}.tmp ${.TARGET}
+
+historyw.c: makelist Makefile
+ ${_MKTARGET_CREATE}
+ ${HOST_SH} ${LIBEDITDIR}/makelist -t WIDE history > ${.TARGET}.tmp && \
+ mv ${.TARGET}.tmp ${.TARGET}
+
tc1.o: ${LIBEDITDIR}/TEST/tc1.c
tc1: libedit.a tc1.o
diff -r 6646ddbc0784 -r ad7c3fc4ba4b lib/libedit/chared.c
--- a/lib/libedit/chared.c Wed Dec 30 22:12:12 2009 +0000
+++ b/lib/libedit/chared.c Wed Dec 30 22:37:40 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.27 2009/02/15 21:55:23 christos Exp $ */
+/* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: chared.c,v 1.27 2009/02/15 21:55:23 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -66,7 +66,7 @@
size = el->el_line.lastchar - el->el_line.buffer;
vu->len = size;
vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer);
- memcpy(vu->buf, el->el_line.buffer, size);
+ (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf));
/* save command info for redo */
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
@@ -80,11 +80,11 @@
* Save yank/delete data for paste
*/
protected void
-cv_yank(EditLine *el, const char *ptr, int size)
+cv_yank(EditLine *el, const Char *ptr, int size)
{
c_kill_t *k = &el->el_chared.c_kill;
- memcpy(k->buf, ptr, (size_t)size);
+ (void)memcpy(k->buf, ptr, size * sizeof(*k->buf));
k->last = k->buf + size;
}
@@ -95,7 +95,7 @@
protected void
c_insert(EditLine *el, int num)
{
- char *cp;
+ Char *cp;
if (el->el_line.lastchar + num >= el->el_line.limit) {
if (!ch_enlargebufs(el, (size_t)num))
@@ -127,7 +127,7 @@
}
if (num > 0) {
- char *cp;
+ Char *cp;
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
*cp = cp[num];
@@ -143,7 +143,7 @@
protected void
c_delafter1(EditLine *el)
{
- char *cp;
+ Char *cp;
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
*cp = cp[1];
@@ -168,7 +168,7 @@
}
if (num > 0) {
- char *cp;
+ Char *cp;
for (cp = el->el_line.cursor - num;
cp <= el->el_line.lastchar;
@@ -186,7 +186,7 @@
protected void
c_delbefore1(EditLine *el)
{
- char *cp;
+ Char *cp;
for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
*cp = cp[1];
@@ -199,9 +199,9 @@
* Return if p is part of a word according to emacs
*/
protected int
-ce__isword(int p)
+ce__isword(Int p)
{
- return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
+ return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL);
}
@@ -209,11 +209,11 @@
* Return if p is part of a word according to vi
*/
protected int
-cv__isword(int p)
+cv__isword(Int p)
{
- if (isalnum(p) || p == '_')
+ if (Isalnum(p) || p == '_')
return 1;
- if (isgraph(p))
+ if (Isgraph(p))
return 2;
return 0;
}
@@ -223,24 +223,24 @@
* Return if p is part of a big word according to vi
*/
protected int
-cv__isWord(int p)
+cv__isWord(Int p)
{
- return (!isspace(p));
+ return (!Isspace(p));
}
/* c__prev_word():
* Find the previous word
*/
-protected char *
-c__prev_word(char *p, char *low, int n, int (*wtest)(int))
+protected Char *
+c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
{
p--;
while (n--) {
- while ((p >= low) && !(*wtest)((unsigned char) *p))
+ while ((p >= low) && !(*wtest)(*p))
p--;
- while ((p >= low) && (*wtest)((unsigned char) *p))
+ while ((p >= low) && (*wtest)(*p))
p--;
}
@@ -256,13 +256,13 @@
/* c__next_word():
* Find the next word
*/
-protected char *
-c__next_word(char *p, char *high, int n, int (*wtest)(int))
+protected Char *
+c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
{
while (n--) {
- while ((p < high) && !(*wtest)((unsigned char) *p))
+ while ((p < high) && !(*wtest)(*p))
p++;
- while ((p < high) && (*wtest)((unsigned char) *p))
+ while ((p < high) && (*wtest)(*p))
p++;
}
if (p > high)
@@ -274,21 +274,21 @@
/* cv_next_word():
* Find the next word vi style
*/
-protected char *
-cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
+protected Char *
+cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
{
int test;
while (n--) {
- test = (*wtest)((unsigned char) *p);
- while ((p < high) && (*wtest)((unsigned char) *p) == test)
+ test = (*wtest)(*p);
+ while ((p < high) && (*wtest)(*p) == test)
p++;
/*
* vi historically deletes with cw only the word preserving the
* trailing whitespace! This is not what 'w' does..
*/
if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
- while ((p < high) && isspace((unsigned char) *p))
+ while ((p < high) && Isspace(*p))
p++;
}
@@ -303,17 +303,17 @@
/* cv_prev_word():
* Find the previous word vi style
*/
-protected char *
-cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
+protected Char *
+cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
{
int test;
p--;
while (n--) {
- while ((p > low) && isspace((unsigned char) *p))
+ while ((p > low) && Isspace(*p))
p--;
- test = (*wtest)((unsigned char) *p);
- while ((p >= low) && (*wtest)((unsigned char) *p) == test)
+ test = (*wtest)(*p);
+ while ((p >= low) && (*wtest)(*p) == test)
p--;
}
p++;
@@ -332,9 +332,9 @@
* A '$' by itself means a big number; "$-" is for negative; '^' means 1.
* Return p pointing to last char used.
*/
-protected char *
+protected Char *
Home |
Main Index |
Thread Index |
Old Index