Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Fix wide build, test it, but don't turn it on yet.
details: https://anonhg.NetBSD.org/src/rev/2ba0e13ab72a
branches: trunk
changeset: 750424:2ba0e13ab72a
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 30 23:54:52 2009 +0000
description:
Fix wide build, test it, but don't turn it on yet.
diffstat:
lib/libedit/Makefile | 27 +++++++--------------------
lib/libedit/chartype.h | 7 ++++++-
lib/libedit/el.c | 5 +++--
lib/libedit/el.h | 3 ++-
lib/libedit/eln.c | 19 ++++++++++---------
lib/libedit/hist.c | 16 ++++++++++++++--
lib/libedit/hist.h | 15 +++++++++++++--
lib/libedit/histedit.h | 6 +++---
lib/libedit/history.c | 14 +++++++-------
lib/libedit/makelist | 11 ++++++-----
lib/libedit/readline.c | 12 ++++++------
lib/libedit/search.c | 6 +++---
lib/libedit/tokenizer.c | 10 +++++-----
13 files changed, 85 insertions(+), 66 deletions(-)
diffs (truncated from 523 to 300 lines):
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/Makefile
--- a/lib/libedit/Makefile Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/Makefile Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.38 2009/12/30 22:37:40 christos Exp $
+# $NetBSD: Makefile,v 1.39 2009/12/30 23:54:52 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@@ -26,17 +26,14 @@
editline.3 tok_line.3 editline.3 tok_str.3
# For speed and debugging
-SRCS= ${OSRCS} readline.c
+SRCS= ${OSRCS} readline.c tokenizer.c history.c
# For protection
-#SRCS= editline.c readline.c
+#SRCS= editline.c readline.c tokenizer.c history.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
+SRCS += tokenizern.c historyn.c eln.c
+CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
CPPFLAGS+=-DWIDECHAR
-.else
-SRCS += tokenizer.c history.c
.endif
LIBEDITDIR?=${.CURDIR}
@@ -106,22 +103,12 @@
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 && \
+ ${HOST_SH} ${LIBEDITDIR}/makelist -n tokenizer.c > ${.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 && \
+ ${HOST_SH} ${LIBEDITDIR}/makelist -n history.c > ${.TARGET}.tmp && \
mv ${.TARGET}.tmp ${.TARGET}
tc1.o: ${LIBEDITDIR}/TEST/tc1.c
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/chartype.h
--- a/lib/libedit/chartype.h Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/chartype.h Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.1 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: chartype.h,v 1.2 2009/12/30 23:54:52 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -185,14 +185,18 @@
protected void ct_conv_buff_resize(ct_buffer_t *, size_t, size_t);
protected ssize_t ct_encode_char(char *, size_t, Char);
+#define ct_free_argv(s) el_free(s)
+
#else
#define ct_encode_string(s, b) (s)
#define ct_decode_string(s, b) (s)
#define ct_decode_argv(l, s, b) (s)
#define ct_conv_buff_resize(b, os, ns)
#define ct_encode_char(d, l, s) (*d = s, 1)
+#define ct_free_argv(s)
#endif
+#ifndef NARROWCHAR
/* Encode a characted into the destination buffer, provided there is sufficent
* buffer space available. Returns the number of bytes used up (zero if the
* character cannot be encoded, -1 if there was not enough space available). */
@@ -232,6 +236,7 @@
#define CHTYPE_NONPRINT (-4)
/* classification of character c, as one of the above defines */
protected int ct_chr_class(Char c);
+#endif
#endif /* _chartype_f */
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/el.c
--- a/lib/libedit/el.c Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/el.c Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.56 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: el.c,v 1.57 2009/12/30 23:54:52 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.56 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.57 2009/12/30 23:54:52 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -266,6 +266,7 @@
ptr_t ptr = va_arg(ap, ptr_t);
rv = hist_set(el, func, ptr);
+ el->el_flags &= ~NARROW_HISTORY;
break;
}
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/el.h
--- a/lib/libedit/el.h Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/el.h Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: el.h,v 1.19 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: el.h,v 1.20 2009/12/30 23:54:52 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -59,6 +59,7 @@
#define UNBUFFERED 0x08
#define CHARSET_IS_UTF8 0x10
#define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */
+#define NARROW_HISTORY 0x40
typedef int bool_t; /* True or not */
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/eln.c
--- a/lib/libedit/eln.c Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/eln.c Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.1 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: eln.c,v 1.2 2009/12/30 23:54:52 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.1 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.2 2009/12/30 23:54:52 christos Exp $");
#endif /* not lint && not SCCSID */
#include "histedit.h"
@@ -42,6 +42,7 @@
#include "read.h"
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
public int
el_getc(EditLine *el, char *cp)
@@ -89,7 +90,7 @@
if (!wargv)
return -1;
ret = el_wparse(el, argc, wargv);
- free(wargv);
+ ct_free_argv(wargv);
return ret;
}
@@ -171,7 +172,7 @@
default:
ret = -1;
}
- free(wargv);
+ ct_free_argv(wargv);
break;
}
@@ -191,14 +192,14 @@
goto out;
}
ret = el_wset(el, op, wargv[0], wargv[1], func);
- free(wargv);
+ ct_free_argv(wargv);
break;
}
case EL_HIST: { /* hist_fun_t, const char * */
hist_fun_t fun = va_arg(ap, hist_fun_t);
ptr_t ptr = va_arg(ap, ptr_t);
- ret = hist_set(el, fun,
- ct_decode_string(ptr, &el->el_lgcyconv));
+ ret = hist_set(el, fun, ptr);
+ el->el_flags |= NARROW_HISTORY;
break;
}
/* XXX: do we need to change el_rfunc_t? */
@@ -247,7 +248,7 @@
case EL_PROMPT: /* el_pfunc_t * */
case EL_RPROMPT: {
el_pfunc_t *p = va_arg(ap, el_pfunc_t *);
- ret = prompt_get(el, p, 0, 0, op);
+ ret = prompt_get(el, p, 0, op);
break;
}
@@ -256,7 +257,7 @@
el_pfunc_t *p = va_arg(ap, el_pfunc_t *);
char *c = va_arg(ap, char *);
wchar_t wc;
- ret = prompt_get(el, p, 0, &wc, op);
+ ret = prompt_get(el, p, &wc, op);
*c = (unsigned char)wc;
break;
}
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/hist.c
--- a/lib/libedit/hist.c Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/hist.c Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.c,v 1.16 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: hist.c,v 1.17 2009/12/30 23:54:52 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: hist.c,v 1.16 2009/12/30 22:37:40 christos Exp $");
+__RCSID("$NetBSD: hist.c,v 1.17 2009/12/30 23:54:52 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -209,3 +209,15 @@
return 1;
}
+
+#ifdef WIDECHAR
+protected wchar_t *
+hist_convert(EditLine *el, int fn, ptr_t arg)
+{
+ HistEventW ev;
+ if ((*(el)->el_history.fun)((el)->el_history.ref, &ev, fn, arg) == -1)
+ return NULL;
+ return ct_decode_string((const char *)(const void *)ev.str,
+ &el->el_scratch);
+}
+#endif
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/hist.h
--- a/lib/libedit/hist.h Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/hist.h Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.h,v 1.11 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: hist.h,v 1.12 2009/12/30 23:54:52 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -54,9 +54,17 @@
TYPE(HistEvent) ev; /* Event cookie */
} el_history_t;
-#define HIST_FUN(el, fn, arg) \
+#define HIST_FUN_INTERNAL(el, fn, arg) \
((((*(el)->el_history.fun) ((el)->el_history.ref, &(el)->el_history.ev, \
fn, arg)) == -1) ? NULL : (el)->el_history.ev.str)
+#ifdef WIDECHAR
+#define HIST_FUN(el, fn, arg) \
+ (((el)->el_flags & NARROW_HISTORY) ? hist_convert(el, fn, arg) : \
+ HIST_FUN_INTERNAL(el, fn, arg))
+#else
+#define HIST_FUN(el, fn, arg) HIST_FUN_INTERNAL(el, fn, arg)
+#endif
+
#define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL)
#define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL)
@@ -72,5 +80,8 @@
protected int hist_set(EditLine *, hist_fun_t, ptr_t);
protected int hist_command(EditLine *, int, const Char **);
protected int hist_enlargebuf(EditLine *, size_t, size_t);
+#ifdef WIDECHAR
+protected wchar_t *hist_convert(EditLine *, int, ptr_t);
+#endif
#endif /* _h_el_hist */
diff -r e2098da0cc22 -r 2ba0e13ab72a lib/libedit/histedit.h
--- a/lib/libedit/histedit.h Wed Dec 30 23:54:30 2009 +0000
+++ b/lib/libedit/histedit.h Wed Dec 30 23:54:52 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.42 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: histedit.h,v 1.43 2009/12/30 23:54:52 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -287,8 +287,8 @@
typedef struct historyw HistoryW;
-HistoryW * historyw_init(void);
Home |
Main Index |
Thread Index |
Old Index