Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1876 05/04/05 19:43:56 jimw@stripped +40 -0
Update bundled libedit to latest version from OpenBSD CVS
with one change to revert to using strvis() instead of
the less widely available strnvis(). This also fixes
Bug #9568 (warning with gcc compile).
cmd-line-utils/libedit/vi.c
1.4 05/04/05 19:43:53 jimw@stripped +71 -62
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/tty.h
1.3 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/tty.c
1.5 05/04/05 19:43:53 jimw@stripped +136 -14
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/tokenizer.h
1.3 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/tokenizer.c
1.4 05/04/05 19:43:53 jimw@stripped +6 -8
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/term.c
1.7 05/04/05 19:43:53 jimw@stripped +63 -60
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/sys.h
1.3 05/04/05 19:43:53 jimw@stripped +7 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/sig.h
1.4 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/sig.c
1.5 05/04/05 19:43:53 jimw@stripped +4 -7
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/search.h
1.3 05/04/05 19:43:53 jimw@stripped +4 -7
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/search.c
1.5 05/04/05 19:43:53 jimw@stripped +44 -33
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/refresh.h
1.2 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/refresh.c
1.6 05/04/05 19:43:53 jimw@stripped +10 -13
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/readline/readline.h
1.4 05/04/05 19:43:53 jimw@stripped +76 -3
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/readline.c
1.7 05/04/05 19:43:53 jimw@stripped +763 -414
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/read.h
1.2 05/04/05 19:43:53 jimw@stripped +4 -1
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/read.c
1.6 05/04/05 19:43:53 jimw@stripped +78 -52
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/prompt.h
1.2 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/prompt.c
1.4 05/04/05 19:43:53 jimw@stripped +7 -10
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/parse.h
1.2 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/parse.c
1.5 05/04/05 19:43:53 jimw@stripped +15 -10
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/map.h
1.3 05/04/05 19:43:53 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/map.c
1.7 05/04/05 19:43:53 jimw@stripped +23 -27
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/libedit_term.h
1.3 05/04/05 19:43:53 jimw@stripped +6 -7
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/key.h
1.5 05/04/05 19:43:53 jimw@stripped +19 -19
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/key.c
1.5 05/04/05 19:43:53 jimw@stripped +23 -25
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/history.c
1.8 05/04/05 19:43:52 jimw@stripped +35 -22
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/histedit.h
1.3 05/04/05 19:43:52 jimw@stripped +6 -7
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/hist.h
1.3 05/04/05 19:43:52 jimw@stripped +3 -6
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/hist.c
1.4 05/04/05 19:43:52 jimw@stripped +9 -13
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/emacs.c
1.4 05/04/05 19:43:52 jimw@stripped +26 -31
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/el.h
1.5 05/04/05 19:43:52 jimw@stripped +8 -9
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/el.c
1.6 05/04/05 19:43:52 jimw@stripped +56 -20
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/editrc.5
1.2 05/04/05 19:43:52 jimw@stripped +50 -33
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/editline.3
1.2 05/04/05 19:43:52 jimw@stripped +78 -21
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/common.c
1.4 05/04/05 19:43:52 jimw@stripped +43 -47
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/chared.h
1.3 05/04/05 19:43:52 jimw@stripped +4 -7
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/chared.c
1.5 05/04/05 19:43:52 jimw@stripped +8 -11
Update to latest OpenBSD CVS version
cmd-line-utils/libedit/TEST/test.c
1.2 05/04/05 19:43:52 jimw@stripped +15 -19
Update to latest OpenBSD CVS version
client/mysql.cc
1.162 05/04/05 19:43:52 jimw@stripped +1 -1
Update to latest libedit API
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jimw
# Host: rama.(none)
# Root: /home/jimw/my/mysql-5.0-libedit
--- 1.161/client/mysql.cc 2005-03-25 10:51:07 -08:00
+++ 1.162/client/mysql.cc 2005-04-05 19:43:52 -07:00
@@ -1323,7 +1323,7 @@
setlocale(LC_ALL,""); /* so as libedit use isprint */
#endif
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
- rl_completion_entry_function= (CPFunction*)&no_completion;
+ rl_completion_entry_function= (Function*)&no_completion;
#else
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= (Function*)&no_completion;
--- 1.1/cmd-line-utils/libedit/TEST/test.c 2003-01-18 08:28:15 -08:00
+++ 1.2/cmd-line-utils/libedit/TEST/test.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $ */
+/* $OpenBSD: test.c,v 1.6 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: test.c,v 1.13 2003/08/07 16:44:35 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -36,25 +33,23 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#include "compat.h"
+#include "config.h"
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+//__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
+// The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: test.c,v 1.9 2000/09/04 23:36:41 lukem Exp $");
+static const char *rcsid = "$OpenBSD: test.c,v 1.6 2003/10/31 08:42:24 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
/*
* test.c: A little test program
*/
-#include "sys.h"
#include <stdio.h>
#include <string.h>
#include <signal.h>
@@ -130,7 +125,10 @@
int num;
const char *buf;
Tokenizer *tok;
- int lastevent = 0, ncontinuation;
+#if 0
+ int lastevent = 0;
+#endif
+ int ncontinuation;
History *hist;
HistEvent ev;
@@ -175,16 +173,14 @@
while ((buf = el_gets(el, &num)) != NULL && num != 0) {
int ac;
- char **av;
+ const char **av;
#ifdef DEBUG
(void) fprintf(stderr, "got %d %s", num, buf);
#endif
if (!continuation && num == 1)
continue;
- if (tok_line(tok, buf, &ac, &av) > 0)
- ncontinuation = 1;
-
+ ncontinuation = tok_line(tok, buf, &ac, &av) > 0;
#if 0
if (continuation) {
/*
@@ -192,7 +188,7 @@
* moved around in history.
*/
if (history(hist, &ev, H_SET, lastevent) == -1)
- err(1, "%d: %s\n", lastevent, ev.str);
+ err(1, "%d: %s", lastevent, ev.str);
history(hist, &ev, H_ADD , buf);
} else {
history(hist, &ev, H_ENTER, buf);
@@ -240,7 +236,7 @@
} else if (el_parse(el, ac, av) == -1) {
switch (fork()) {
case 0:
- execvp(av[0], av);
+ execvp(av[0], (char *const *)av);
perror(av[0]);
_exit(1);
/*NOTREACHED*/
--- 1.4/cmd-line-utils/libedit/chared.c 2004-08-31 05:50:59 -07:00
+++ 1.5/cmd-line-utils/libedit/chared.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: chared.c,v 1.18 2002/11/20 16:50:08 christos Exp $ */
+/* $OpenBSD: chared.c,v 1.8 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: chared.c,v 1.21 2003/11/02 20:08:41 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: chared.c,v 1.18 2002/11/20 16:50:08 christos Exp $");
+static const char rcsid[] = "$OpenBSD: chared.c,v 1.8 2003/11/25 20:12:38 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -62,13 +59,13 @@
{
c_undo_t *vu = &el->el_chared.c_undo;
c_redo_t *r = &el->el_chared.c_redo;
- int size;
+ uint size;
/* Save entire line for undo */
size = el->el_line.lastchar - el->el_line.buffer;
vu->len = size;
vu->cursor = el->el_line.cursor - el->el_line.buffer;
- memcpy(vu->buf, el->el_line.buffer, (size_t)size);
+ memcpy(vu->buf, el->el_line.buffer, size);
/* save command info for redo */
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
@@ -460,8 +457,8 @@
el->el_state.argument = 1;
el->el_state.lastcmd = ED_UNASSIGNED;
- el->el_chared.c_macro.nline = NULL;
el->el_chared.c_macro.level = -1;
+ el->el_chared.c_macro.offset = 0;
el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
sizeof(char *));
if (el->el_chared.c_macro.macro == NULL)
@@ -582,7 +579,7 @@
return 0;
/* Safe to set enlarged buffer size */
- el->el_line.limit = &newbuffer[newsz - EL_LEAVE];
+ el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
return 1;
}
--- 1.2/cmd-line-utils/libedit/chared.h 2004-08-24 08:41:36 -07:00
+++ 1.3/cmd-line-utils/libedit/chared.h 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: chared.h,v 1.11 2002/11/20 16:50:08 christos Exp $ */
+/* $OpenBSD: chared.h,v 1.8 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: chared.h,v 1.13 2003/10/18 23:48:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -66,8 +63,8 @@
typedef struct c_macro_t {
int level;
+ int offset;
char **macro;
- char *nline;
} c_macro_t;
/*
--- 1.3/cmd-line-utils/libedit/common.c 2004-08-24 08:41:36 -07:00
+++ 1.4/cmd-line-utils/libedit/common.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: common.c,v 1.14 2002/11/20 16:50:08 christos Exp $ */
+/* $OpenBSD: common.c,v 1.6 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: common.c,v 1.14 2002/11/20 16:50:08 christos Exp $");
+static const char rcsid[] = "$OpenBSD: common.c,v 1.6 2003/10/31 08:42:24 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -56,7 +53,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_end_of_file(EditLine *el, int c __attribute__((unused)))
+ed_end_of_file(EditLine *el, int c __attribute__((__unused__)))
{
re_goto_bottom(el);
@@ -113,7 +110,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_word(EditLine *el, int c __attribute__((unused)))
+ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *p, *kp;
@@ -141,7 +138,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_next_char(EditLine *el, int c __attribute__((unused)))
+ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
{
#ifdef notdef /* XXX */
#define EL el->el_line
@@ -192,7 +189,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_kill_line(EditLine *el, int c __attribute__((unused)))
+ed_kill_line(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -213,7 +210,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_end(EditLine *el, int c __attribute__((unused)))
+ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.lastchar;
@@ -236,7 +233,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_beg(EditLine *el, int c __attribute__((unused)))
+ed_move_to_beg(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -285,7 +282,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_char(EditLine *el, int c __attribute__((unused)))
+ed_next_char(EditLine *el, int c __attribute__((__unused__)))
{
char *lim = el->el_line.lastchar;
@@ -314,7 +311,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_word(EditLine *el, int c __attribute__((unused)))
+ed_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
@@ -340,7 +337,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_char(EditLine *el, int c __attribute__((unused)))
+ed_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor > el->el_line.buffer) {
@@ -437,8 +434,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_unassigned(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_unassigned(EditLine *el, int c __attribute__((__unused__)))
{
return (CC_ERROR);
@@ -455,8 +451,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigint(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_sigint(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -469,8 +465,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_dsusp(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -483,8 +479,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_flush_output(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -497,8 +493,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigquit(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -511,8 +507,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigtstp(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -525,8 +521,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_stop_output(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -539,8 +535,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_start_output(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_tty_start_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -553,7 +549,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_newline(EditLine *el, int c __attribute__((unused)))
+ed_newline(EditLine *el, int c __attribute__((__unused__)))
{
re_goto_bottom(el);
@@ -569,7 +565,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_char(EditLine *el, int c __attribute__((unused)))
+ed_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor <= el->el_line.buffer)
@@ -589,7 +585,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_clear_screen(EditLine *el, int c __attribute__((unused)))
+ed_clear_screen(EditLine *el, int c __attribute__((__unused__)))
{
term_clear_screen(el); /* clear the whole real screen */
@@ -604,8 +600,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_redisplay(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_redisplay(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_REDISPLAY);
@@ -618,7 +614,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_start_over(EditLine *el, int c __attribute__((unused)))
+ed_start_over(EditLine *el, int c __attribute__((__unused__)))
{
ch_reset(el);
@@ -632,8 +628,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_sequence_lead_in(EditLine *el __attribute__((unused)),
- int c __attribute__((unused)))
+ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -646,7 +642,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_history(EditLine *el, int c __attribute__((unused)))
+ed_prev_history(EditLine *el, int c __attribute__((__unused__)))
{
char beep = 0;
int sv_event = el->el_history.eventno;
@@ -684,7 +680,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_history(EditLine *el, int c __attribute__((unused)))
+ed_next_history(EditLine *el, int c __attribute__((__unused__)))
{
el_action_t beep = CC_REFRESH, rval;
@@ -711,7 +707,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_prev_history(EditLine *el, int c __attribute__((unused)))
+ed_search_prev_history(EditLine *el, int c __attribute__((__unused__)))
{
const char *hp;
int h;
@@ -779,7 +775,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_next_history(EditLine *el, int c __attribute__((unused)))
+ed_search_next_history(EditLine *el, int c __attribute__((__unused__)))
{
const char *hp;
int h;
@@ -833,7 +829,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_line(EditLine *el, int c __attribute__((unused)))
+ed_prev_line(EditLine *el, int c __attribute__((__unused__)))
{
char *ptr;
int nchars = c_hpos(el);
@@ -876,7 +872,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_line(EditLine *el, int c __attribute__((unused)))
+ed_next_line(EditLine *el, int c __attribute__((__unused__)))
{
char *ptr;
int nchars = c_hpos(el);
@@ -910,7 +906,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_command(EditLine *el, int c __attribute__((unused)))
+ed_command(EditLine *el, int c __attribute__((__unused__)))
{
char tmpbuf[EL_BUFSIZ];
int tmplen;
--- 1.1/cmd-line-utils/libedit/editline.3 2003-01-18 08:28:15 -08:00
+++ 1.2/cmd-line-utils/libedit/editline.3 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-.\" $NetBSD: editline.3,v 1.21 2001/04/02 18:29:49 wiz Exp $
+.\" $OpenBSD: editline.3,v 1.20 2004/04/14 22:00:35 jfb Exp $
+.\" $NetBSD: editline.3,v 1.42 2003/11/04 13:22:19 christos Exp $
.\"
.\" Copyright (c) 1997-1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -33,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 12, 1999
+.Dd October 17, 2003
.Os
.Dt EDITLINE 3
.Sh NAME
@@ -55,8 +56,6 @@
.Nm history_end ,
.Nm history
.Nd line editor and history functions
-.Sh LIBRARY
-.Lb libedit
.Sh SYNOPSIS
.Fd #include <histedit.h>
.Ft EditLine *
@@ -72,7 +71,7 @@
.Ft void
.Fn el_push "EditLine *e" "const char *str"
.Ft int
-.Fn el_parse "EditLine *e" "int argc" "char *argv[]"
+.Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
.Ft int
.Fn el_set "EditLine *e" "int op" "..."
.Ft int
@@ -103,10 +102,10 @@
These functions are available in the
.Nm libedit
library (which needs the
-.Nm libtermcap
+.Nm libcurses
library).
Programs should be linked with
-.Fl ledit ltermcap .
+.Fl ledit lcurses .
.Sh LINE EDITING FUNCTIONS
The line editing functions use a common data structure,
.Fa EditLine ,
@@ -152,7 +151,7 @@
Read a character from the tty.
.Fa ch
is modified to contain the character read.
-Returns the number of characters read if successful, -1 otherwise.
+Returns the number of characters read if successful, \-1 otherwise.
.It Fn el_push
Pushes
.Fa str
@@ -174,7 +173,7 @@
.Nm
commands.
If the command is prefixed with
-.Dq prog:
+.Dq prog :
then
.Fn el_parse
will only execute the command if
@@ -184,7 +183,7 @@
argument supplied to
.Fn el_init .
The return value is
--1 if the command is unknown,
+\-1 if the command is unknown,
0 if there was no error or
.Dq prog
didn't match, or
@@ -303,7 +302,7 @@
.It Dv EL_ADDFN , Xo
.Fa "const char *name" ,
.Fa "const char *help" ,
-.Fa "unsigned char (*func)(EditLine *e, int ch)
+.Fa "unsigned char (*func)(EditLine *e, int ch)"
.Xc
Add a user defined function,
.Fn func ,
@@ -336,7 +335,7 @@
Refresh display, and beep.
.It Dv CC_CURSOR
Cursor moved, so update and perform
-.Dv CC_REFRESH.
+.Dv CC_REFRESH .
.It Dv CC_REDISPLAY
Redisplay entire input line.
This is useful if a key binding outputs extra information.
@@ -362,12 +361,30 @@
editing is enabled (the default).
Note that this is only an indication, and does not
affect the operation of
-.Nm "" .
+.Nm .
At this time, it is the caller's responsibility to
check this
(using
.Fn el_get )
to determine if editing should be enabled or not.
+.It Dv EL_GETCFN , Fa "int (*f)(EditLine *, char *c)"
+Define the character reading function as
+.Fa f ,
+which is to return the number of characters read and store them in
+.Fa c .
+This function is called internally by
+.Fn el_gets
+and
+.Fn el_getc .
+The builtin function can be set or restored with the special function
+name ``EL_BUILTIN_GETCFN''.
+.It Dv EL_CLIENTDATA , Fa "void *data"
+Register
+.Fa data
+to be associated with this EditLine structure.
+It can be retrieved with the corresponding
+.Fn el_get
+call.
.El
.It Fn el_get
Get
@@ -376,6 +393,7 @@
.Fa op
determines which parameter to retrieve into
.Fa result .
+Returns 0 if successful, \-1 otherwise.
.Pp
The following values for
.Fa op
@@ -399,6 +417,22 @@
above).
.It Dv EL_EDITMODE, Fa "int *"
Return non-zero if editing is enabled.
+.It Dv EL_GETCFN, Fa "int (**f)(EditLine *, char *)"
+Return a pointer to the function that read characters, which is equal to
+``EL_BUILTIN_GETCFN'' in the case of the default builtin function.
+.It Dv EL_CLIENTDATA , Fa "void **data"
+Retrieve
+.Fa data
+previously registered with the corresponding
+.Fn el_set
+call.
+.It Dv EL_UNBUFFERED, Fa "int"
+Sets or clears unbuffered mode.
+In this mode,
+.Fn el_gets
+will return immediately after processing a single character.
+.It Dv EL_PREP_TERM, Fa "int"
+Sets or clears terminal editing mode.
.El
.It Fn el_source
Initialise
@@ -445,7 +479,7 @@
Insert
.Fa str
into the line at the cursor.
-Returns -1 if
+Returns \-1 if
.Fa str
is empty or won't fit, and 0 otherwise.
.It Fn el_deletestr
@@ -525,7 +559,11 @@
.It Dv H_ADD , Fa "const char *str"
Append
.Fa str
-to the current element of the history, or create an element with
+to the current element of the history, or perform the
+.Dv H_ENTER
+operation with argument
+.Fa str
+if there is no current element.
.It Dv H_APPEND , Fa "const char *str"
Append
.Fa str
@@ -535,6 +573,17 @@
.Fa str
as a new element to the history, and, if necessary,
removing the oldest entry to keep the list to the created size.
+If
+.Dv H_SETUNIQUE
+has been called with a non-zero argument, the element
+will not be entered into the history if its contents match
+the ones of the current history element.
+If the element is entered
+.Fn history
+returns 1; if it is ignored as a duplicate returns 0.
+Finally
+.Fn history
+returns \-1 if an error occurred.
.It Dv H_PREV_STR , Fa "const char *str"
Return the closest previous event that starts with
.Fa str .
@@ -553,22 +602,30 @@
.It Dv H_SAVE , Fa "const char *file"
Save the history list to
.Fa file .
+.It Dv H_SETUNIQUE , Fa "int unique"
+Set if the adjacent identical event strings should not be entered into
+the history.
+.It Dv H_GETUNIQUE
+Retrieve the current setting if if adjacent elements should be entered into
+the history.
.El
.Pp
.Fn history
-returns 0 if the operation
+returns \*(Ge 0 if the operation
.Fa op
-succeeds. Otherwise, -1 is returned and
+succeeds.
+Otherwise, \-1 is returned and
.Fa ev
is updated to contain more details about the error.
.El
.\"XXX.Sh EXAMPLES
.\"XXX: provide some examples
.Sh SEE ALSO
-.Xr editrc 5 ,
.Xr sh 1 ,
+.Xr curses 3 ,
.Xr signal 3 ,
-.Xr termcap 3
+.Xr termcap 3 ,
+.Xr editrc 5
.Sh HISTORY
The
.Nm
@@ -596,8 +653,8 @@
.Dv EL_RPROMPT .
Jaromir Dolecek implemented the readline emulation.
.Sh BUGS
-The tokenization functions are not publically defined in
-.Fd <histedit.h>.
+The tokenization functions are not publicly defined in
+.Aq Pa histedit.h .
.Pp
At this time, it is the responsibility of the caller to
check the result of the
--- 1.1/cmd-line-utils/libedit/editrc.5 2003-01-18 08:28:15 -08:00
+++ 1.2/cmd-line-utils/libedit/editrc.5 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-.\" $NetBSD: editrc.5,v 1.11 2001/06/19 13:42:09 wiz Exp $
+.\" $OpenBSD: editrc.5,v 1.19 2003/11/25 20:12:38 otto Exp $
+.\" $NetBSD: editrc.5,v 1.19 2003/11/01 23:35:33 christos Exp $
.\"
.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -33,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 8, 2000
+.Dd October 18, 2003
.Os
.Dt EDITRC 5
.Sh NAME
@@ -49,6 +50,7 @@
library.
.Pp
The format of each line is:
+.Pp
.Dl [prog:]command [arg [...]]
.Pp
.Ar command
@@ -62,7 +64,7 @@
.Ar prog
is the program name string that a program defines when it calls
.Xr el_init 3
-to setup
+to set up
.Xr editline 3 ,
which is usually
.Va argv[0] .
@@ -89,19 +91,13 @@
library has some builtin commands, which affect the way
that the line editing and history functions operate.
These are based on similar named builtins present in the
-.Xr tcsh 1
+.Xr tcsh
shell.
.Pp
The following builtin commands are available:
.Bl -tag -width 4n
.It Ic bind Xo
-.Op Fl a
-.Op Fl e
-.Op Fl k
-.Op Fl l
-.Op Fl r
-.Op Fl s
-.Op Fl v
+.Op Fl aeklrsv
.Op Ar key Op Ar command
.Xc
Without options, list all bound keys, and the editor command to which
@@ -118,16 +114,12 @@
.Ar key .
Options include:
.Bl -tag -width 4n
-.It Fl e
-Bind all keys to the standard GNU Emacs-like bindings.
-.It Fl v
-Bind all keys to the standard
-.Xr vi 1 -like
-bindings.
.It Fl a
List or change key bindings in the
.Xr vi 1
mode alternate (command mode) key map.
+.It Fl e
+Bind all keys to the standard GNU Emacs-like bindings.
.It Fl k
.Ar key
is interpreted as a symbolic arrow key name, which may be one of
@@ -149,6 +141,10 @@
.Ar command
are themselves reinterpreted, and this continues for ten levels of
interpretation.
+.It Fl v
+Bind all keys to the standard
+.Xr vi 1 Ns -like
+bindings.
.El
.Pp
.Ar command
@@ -164,7 +160,7 @@
.Sq No ^ Ar character
.Sm on
.Po
-e.g.
+e.g.\&
.Sq ^A
.Pc ,
and the following backslashed escape sequences:
@@ -213,7 +209,8 @@
.Sq cols ,
.Sq lines ,
.Sq rows ,
-.Sq meta or
+.Sq meta
+or
.Sq tabs ,
the value of that capability is printed, with
.Dq yes
@@ -222,7 +219,7 @@
indicating that the terminal does or does not have that capability.
.Pp
.Fl s
-returns an emptry string for non-existent capabilities, rather than
+returns an empty string for non-existent capabilities, rather than
causing an error.
.Fl v
causes messages to be verbose.
@@ -232,9 +229,6 @@
functionality in a program.
.It Ic history
List the history.
-.It Ic telltc
-List the values of all the terminal capabilities (see
-.Xr termcap 5 ).
.It Ic settc Ar cap Ar val
Set the terminal capability
.Ar cap
@@ -244,13 +238,11 @@
.Xr termcap 5 .
No sanity checking is done.
.It Ic setty Xo
-.Op Fl a
-.Op Fl d
-.Op Fl q
-.Op Fl x
+.Op Fl adqx
.Op Ar +mode
.Op Ar -mode
.Op Ar mode
+.Op Ar char=c
.Xc
Control which tty modes that
.Nm
@@ -291,6 +283,9 @@
on or off or removes control of
.Ar mode
in the chosen set.
+.It Ic telltc
+List the values of all the terminal capabilities (see
+.Xr termcap 5 ) .
.El
.Sh EDITOR COMMANDS
The following editor commands are available for use in key bindings:
@@ -300,11 +295,11 @@
Vi paste previous deletion to the right of the cursor.
.It Ic vi-paste-prev
Vi paste previous deletion to the left of the cursor.
-.It Ic vi-prev-space-word
+.It Ic vi-prev-big-word
Vi move to the previous space delimited word.
.It Ic vi-prev-word
Vi move to the previous word.
-.It Ic vi-next-space-word
+.It Ic vi-next-big-word
Vi move to the next space delimited word.
.It Ic vi-next-word
Vi move to the next word.
@@ -332,9 +327,9 @@
Vi enter insert mode at end of line.
.It Ic vi-delete-meta
Vi delete prefix command.
-.It Ic vi-end-word
+.It Ic vi-end-big-word
Vi move to the end of the current space delimited word.
-.It Ic vi-to-end-word
+.It Ic vi-end-word
Vi move to the end of the current word.
.It Ic vi-undo
Vi undo last change.
@@ -368,6 +363,28 @@
Vi repeat current character search in the same search direction.
.It Ic vi-repeat-prev-char
Vi repeat current character search in the opposite search direction.
+.It Ic vi-match
+Vi go to matching () {} or [].
+.It Ic vi-undo-line
+Vi undo all changes to line.
+.It Ic vi-to-column
+Vi go to specified column.
+.It Ic vi-yank-end
+Vi yank to end of line.
+.It Ic vi-yank
+Vi yank.
+.It Ic vi-comment-out
+Vi comment out current command.
+.It Ic vi-alias
+Vi include shell alias.
+.It Ic vi-to-history-line
+Vi go to specified history file line..
+.It Ic vi-histedit
+Vi edit history line with vi.
+.It Ic vi-history-word
+Vi append word from previous input line.
+.It Ic vi-redo
+Vi redo last non-motion command.
.It Ic em-delete-or-list
Delete character under cursor or list completions if at end of line.
.It Ic em-delete-next-word
@@ -380,7 +397,7 @@
Cut area between mark and cursor and save in cut buffer.
.It Ic em-copy-region
Copy area between mark and cursor to cut buffer.
-.It Ic em-gosmacs-traspose
+.It Ic em-gosmacs-transpose
Exchange the two characters before the cursor.
.It Ic em-next-word
Move next to end of current word.
@@ -488,4 +505,4 @@
library was written by Christos Zoulas,
and this manual was written by Luke Mewburn,
with some sections inspired by
-.Xr tcsh 1 .
+.Xr tcsh .
--- 1.5/cmd-line-utils/libedit/el.c 2004-09-03 05:47:32 -07:00
+++ 1.6/cmd-line-utils/libedit/el.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: el.c,v 1.30 2002/11/12 00:00:23 thorpej Exp $ */
+/* $OpenBSD: el.c,v 1.14 2004/08/23 18:31:25 otto Exp $ */
+/* $NetBSD: el.c,v 1.36 2003/10/18 23:48:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
-__RCSID("$NetBSD: el.c,v 1.30 2002/11/12 00:00:23 thorpej Exp $");
+static const char rcsid[] = "$OpenBSD: el.c,v 1.14 2004/08/23 18:31:25 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -72,7 +69,10 @@
el->el_infd = fileno(fin);
el->el_outfile = fout;
el->el_errfile = ferr;
- el->el_prog = strdup(prog);
+ if ((el->el_prog = el_strdup(prog)) == NULL) {
+ el_free(el);
+ return NULL;
+ }
/*
* Initialize all the modules. Order is important!!!
@@ -80,11 +80,11 @@
el->el_flags = 0;
if (term_init(el) == -1) {
- free(el->el_prog);
+ el_free(el->el_prog);
el_free(el);
return NULL;
}
- (void) el_key_init(el);
+ (void) key_init(el);
(void) map_init(el);
if (tty_init(el) == -1)
el->el_flags |= NO_TTY;
@@ -112,7 +112,7 @@
el_reset(el);
term_end(el);
- el_key_end(el);
+ key_end(el);
map_end(el);
tty_end(el);
ch_end(el);
@@ -257,6 +257,27 @@
el->el_data = va_arg(va, void *);
break;
+ case EL_UNBUFFERED:
+ rv = va_arg(va, int);
+ if (rv && !(el->el_flags & UNBUFFERED)) {
+ el->el_flags |= UNBUFFERED;
+ read_prepare(el);
+ } else if (!rv && (el->el_flags & UNBUFFERED)) {
+ el->el_flags &= ~UNBUFFERED;
+ read_finish(el);
+ }
+ rv = 0;
+ break;
+
+ case EL_PREP_TERM:
+ rv = va_arg(va, int);
+ if (rv)
+ read_prepare(el);
+ else
+ read_finish(el);
+ rv = 0;
+ break;
+
default:
rv = -1;
break;
@@ -297,21 +318,22 @@
rv = 0;
break;
-#if 0 /* XXX */
case EL_TERMINAL:
- rv = term_get(el, (const char *) &ret);
+ term_get(el, (const char **)ret);
+ rv = 0;
break;
+#if 0 /* XXX */
case EL_BIND:
case EL_TELLTC:
case EL_SETTC:
case EL_ECHOTC:
case EL_SETTY:
{
- char *argv[20];
+ const char *argv[20];
int i;
- for (i = 1; i < 20; i++)
+ for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
if ((argv[i] = va_arg(va, char *)) == NULL)
break;
@@ -378,6 +400,11 @@
rv = 0;
break;
+ case EL_UNBUFFERED:
+ *((int *) ret) = (!(el->el_flags & UNBUFFERED));
+ rv = 0;
+ break;
+
default:
rv = -1;
}
@@ -405,7 +432,7 @@
{
FILE *fp;
size_t len;
- char *ptr;
+ char *ptr, *lptr = NULL;
fp = NULL;
if (fname == NULL) {
@@ -437,15 +464,24 @@
return (-1);
while ((ptr = fgetln(fp, &len)) != NULL) {
- if (len > 0 && ptr[len - 1] == '\n')
- --len;
- ptr[len] = '\0';
+ if (ptr[len - 1] == '\n')
+ ptr[len - 1] = '\0';
+ else {
+ if ((lptr = (char *)malloc(len + 1)) == NULL) {
+ (void) fclose(fp);
+ return (-1);
+ }
+ memcpy(lptr, ptr, len);
+ lptr[len] = '\0';
+ ptr = lptr;
+ }
if (parse_line(el, ptr) == -1) {
+ free(lptr);
(void) fclose(fp);
return (-1);
}
}
-
+ free(lptr);
(void) fclose(fp);
return (0);
}
--- 1.4/cmd-line-utils/libedit/el.h 2004-09-03 05:47:32 -07:00
+++ 1.5/cmd-line-utils/libedit/el.h 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: el.h,v 1.13 2002/11/15 14:32:33 christos Exp $ */
+/* $OpenBSD: el.h,v 1.6 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -55,9 +52,10 @@
#define EL_BUFSIZ 1024 /* Maximum line size */
-#define HANDLE_SIGNALS 1<<0
-#define NO_TTY 1<<1
-#define EDIT_DISABLED 1<<2
+#define HANDLE_SIGNALS 0x01
+#define NO_TTY 0x02
+#define EDIT_DISABLED 0x04
+#define UNBUFFERED 0x08
typedef int bool_t; /* True or not */
@@ -91,6 +89,7 @@
/*
* Until we come up with something better...
*/
+#define el_strdup(a) strdup(a)
#define el_malloc(a) malloc(a)
#define el_realloc(a,b) realloc(a, b)
#define el_free(a) free(a)
--- 1.3/cmd-line-utils/libedit/emacs.c 2004-08-24 08:41:37 -07:00
+++ 1.4/cmd-line-utils/libedit/emacs.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: emacs.c,v 1.12 2002/11/15 14:32:33 christos Exp $ */
+/* $OpenBSD: emacs.c,v 1.7 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: emacs.c,v 1.16 2003/11/02 20:07:58 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: emacs.c,v 1.12 2002/11/15 14:32:33 christos Exp $");
+static const char rcsid[] = "$OpenBSD: emacs.c,v 1.7 2003/11/25 20:12:38 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -56,7 +53,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_or_list(EditLine *el, int c __attribute__((unused)))
+em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar) {
@@ -90,7 +87,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_next_word(EditLine *el, int c __attribute__((unused)))
+em_delete_next_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *p, *kp;
@@ -119,14 +116,12 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_yank(EditLine *el, int c __attribute__((unused)))
+em_yank(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
- if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) {
- if (!ch_enlargebufs(el, 1))
- return (CC_ERROR);
- }
+ if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
+ return (CC_NORM);
if (el->el_line.lastchar +
(el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
@@ -156,7 +151,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_line(EditLine *el, int c __attribute__((unused)))
+em_kill_line(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -178,7 +173,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_region(EditLine *el, int c __attribute__((unused)))
+em_kill_region(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -211,7 +206,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_region(EditLine *el, int c __attribute__((unused)))
+em_copy_region(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -235,12 +230,12 @@
}
-/* em_gosmacs_traspose():
+/* em_gosmacs_transpose():
* Exchange the two characters before the cursor
* Gosling emacs transpose chars [^T]
*/
protected el_action_t
-em_gosmacs_traspose(EditLine *el, int c)
+em_gosmacs_transpose(EditLine *el, int c)
{
if (el->el_line.cursor > &el->el_line.buffer[1]) {
@@ -260,7 +255,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_next_word(EditLine *el, int c __attribute__((unused)))
+em_next_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar)
return (CC_ERROR);
@@ -285,7 +280,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_upper_case(EditLine *el, int c __attribute__((unused)))
+em_upper_case(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *ep;
@@ -309,7 +304,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_capitol_case(EditLine *el, int c __attribute__((unused)))
+em_capitol_case(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *ep;
@@ -341,7 +336,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_lower_case(EditLine *el, int c __attribute__((unused)))
+em_lower_case(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *ep;
@@ -365,7 +360,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_set_mark(EditLine *el, int c __attribute__((unused)))
+em_set_mark(EditLine *el, int c __attribute__((__unused__)))
{
el->el_chared.c_kill.mark = el->el_line.cursor;
@@ -379,7 +374,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_exchange_mark(EditLine *el, int c __attribute__((unused)))
+em_exchange_mark(EditLine *el, int c __attribute__((__unused__)))
{
char *cp;
@@ -396,7 +391,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_universal_argument(EditLine *el, int c __attribute__((unused)))
+em_universal_argument(EditLine *el, int c __attribute__((__unused__)))
{ /* multiply current argument by 4 */
if (el->el_state.argument > 1000000)
@@ -413,7 +408,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_meta_next(EditLine *el, int c __attribute__((unused)))
+em_meta_next(EditLine *el, int c __attribute__((__unused__)))
{
el->el_state.metanext = 1;
@@ -426,7 +421,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_toggle_overwrite(EditLine *el, int c __attribute__((unused)))
+em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__)))
{
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
@@ -440,7 +435,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_prev_word(EditLine *el, int c __attribute__((unused)))
+em_copy_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *oldc, *dp;
@@ -467,7 +462,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_next(EditLine *el, int c __attribute__((unused)))
+em_inc_search_next(EditLine *el, int c __attribute__((__unused__)))
{
el->el_search.patlen = 0;
@@ -480,7 +475,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_prev(EditLine *el, int c __attribute__((unused)))
+em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
{
el->el_search.patlen = 0;
--- 1.3/cmd-line-utils/libedit/hist.c 2004-08-24 08:41:37 -07:00
+++ 1.4/cmd-line-utils/libedit/hist.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: hist.c,v 1.12 2003/01/21 18:40:23 christos Exp $ */
+/* $OpenBSD: hist.c,v 1.7 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: hist.c,v 1.12 2003/01/21 18:40:23 christos Exp $");
+static const char rcsid[] = "$OpenBSD: hist.c,v 1.7 2003/11/25 20:12:38 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -157,7 +154,6 @@
* process a history command
*/
protected int
-/*ARGSUSED*/
hist_command(EditLine *el, int argc, const char **argv)
{
const char *str;
@@ -167,7 +163,7 @@
if (el->el_history.ref == NULL)
return (-1);
- if (argc == 0 || strcmp(argv[0], "list") == 1) {
+ if (argc == 1 || strcmp(argv[1], "list") == 0) {
/* List history entries */
for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
@@ -176,15 +172,15 @@
return (0);
}
- if (argc != 2)
+ if (argc != 3)
return (-1);
- num = (int)strtol(argv[1], NULL, 0);
+ num = (int)strtol(argv[2], NULL, 0);
- if (strcmp(argv[0], "size") == 0)
+ if (strcmp(argv[1], "size") == 0)
return history(el->el_history.ref, &ev, H_SETSIZE, num);
- if (strcmp(argv[0], "unique") == 0)
+ if (strcmp(argv[1], "unique") == 0)
return history(el->el_history.ref, &ev, H_SETUNIQUE, num);
return -1;
--- 1.2/cmd-line-utils/libedit/hist.h 2004-08-24 08:41:37 -07:00
+++ 1.3/cmd-line-utils/libedit/hist.h 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: hist.h,v 1.9 2003/01/21 18:40:23 christos Exp $ */
+/* $OpenBSD: hist.h,v 1.7 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: hist.h,v 1.10 2003/08/07 16:44:31 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
--- 1.2/cmd-line-utils/libedit/histedit.h 2004-08-24 08:41:37 -07:00
+++ 1.3/cmd-line-utils/libedit/histedit.h 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: histedit.h,v 1.21 2003/01/21 18:40:24 christos Exp $ */
+/* $OpenBSD: histedit.h,v 1.9 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: histedit.h,v 1.24 2003/10/16 22:26:32 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -45,7 +42,7 @@
#define _HISTEDIT_H_
#define LIBEDIT_MAJOR 2
-#define LIBEDIT_MINOR 6
+#define LIBEDIT_MINOR 8
#include <sys/types.h>
#include <stdio.h>
@@ -131,6 +128,8 @@
#define EL_RPROMPT 12 /* , el_pfunc_t); */
#define EL_GETCFN 13 /* , el_rfunc_t); */
#define EL_CLIENTDATA 14 /* , void *); */
+#define EL_UNBUFFERED 15 /* , int); */
+#define EL_PREP_TERM 16 /* , int); */
#define EL_BUILTIN_GETCFN (NULL)
--- 1.7/cmd-line-utils/libedit/history.c 2004-08-27 08:32:23 -07:00
+++ 1.8/cmd-line-utils/libedit/history.c 2005-04-05 19:43:52 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: history.c,v 1.22 2003/01/21 18:40:24 christos Exp $ */
+/* $OpenBSD: history.c,v 1.13 2004/08/23 18:31:25 otto Exp $ */
+/* $NetBSD: history.c,v 1.25 2003/10/18 23:48:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: history.c,v 1.22 2003/01/21 18:40:24 christos Exp $");
+static const char rcsid[] = "$OpenBSD: history.c,v 1.13 2004/08/23 18:31:25 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -91,6 +88,7 @@
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
+#define h_strdup(a) strdup(a)
#define h_malloc(a) malloc(a)
#define h_realloc(a, b) realloc((a), (b))
#define h_free(a) free(a)
@@ -374,7 +372,8 @@
*/
/* ARGSUSED */
private void
-history_def_delete(history_t *h, HistEvent *ev __attribute__((unused)), hentry_t *hp)
+history_def_delete(history_t *h,
+ HistEvent *ev __attribute__((__unused__)), hentry_t *hp)
{
HistEventPrivate *evp = (void *)&hp->ev;
if (hp == &h->list)
@@ -397,7 +396,7 @@
h->cursor = (hentry_t *) h_malloc(sizeof(hentry_t));
if (h->cursor == NULL)
goto oomem;
- if ((h->cursor->ev.str = strdup(str)) == NULL) {
+ if ((h->cursor->ev.str = h_strdup(str)) == NULL) {
h_free((ptr_t)h->cursor);
goto oomem;
}
@@ -447,7 +446,7 @@
*/
/* ARGSUSED */
private int
-history_def_init(ptr_t *p, HistEvent *ev __attribute__((unused)), int n)
+history_def_init(ptr_t *p, HistEvent *ev __attribute__((__unused__)), int n)
{
history_t *h = (history_t *) h_malloc(sizeof(history_t));
if (h == NULL)
@@ -652,27 +651,39 @@
history_load(History *h, const char *fname)
{
FILE *fp;
- char *line;
+ char *line, *lbuf;
size_t sz, max_size;
char *ptr;
int i = -1;
HistEvent ev;
+ lbuf = NULL;
if ((fp = fopen(fname, "r")) == NULL)
return (i);
+ if ((line = fgetln(fp, &sz)) == NULL)
+ goto done;
+
+ if (strncmp(line, hist_cookie, sz) != 0)
+ goto done;
+
ptr = h_malloc(max_size = 1024);
if (ptr == NULL)
goto done;
for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
- char c = line[sz];
-
- if (sz != 0 && line[sz - 1] == '\n')
- line[--sz] = '\0';
- else
- line[sz] = '\0';
-
- if (max_size < sz) {
+ if (line[sz - 1] == '\n')
+ line[sz - 1] = '\0';
+ else {
+ lbuf = malloc(sz + 1);
+ if (lbuf == NULL) {
+ i = -1;
+ goto oomem;
+ }
+ memcpy(lbuf, line, sz);
+ lbuf[sz++] = '\0';
+ line = lbuf;
+ }
+ if (sz > max_size) {
char *nptr;
max_size = (sz + 1023) & ~1023;
nptr = h_realloc(ptr, max_size);
@@ -683,7 +694,6 @@
ptr = nptr;
}
(void) strunvis(ptr, line);
- line[sz] = c;
if (HENTER(h, &ev, ptr) == -1) {
h_free((ptr_t)ptr);
return -1;
@@ -692,6 +702,7 @@
oomem:
h_free((ptr_t)ptr);
done:
+ h_free(lbuf);
(void) fclose(fp);
return (i);
}
@@ -714,6 +725,8 @@
if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
goto done;
+ if (fputs(hist_cookie, fp) == EOF)
+ goto done;
ptr = h_malloc(max_size = 1024);
if (ptr == NULL)
goto done;
@@ -721,7 +734,7 @@
retval != -1;
retval = HPREV(h, &ev), i++) {
len = strlen(ev.str) * 4 + 1;
- if (len >= max_size) {
+ if (len > max_size) {
char *nptr;
max_size = (len + 1023) & ~1023;
nptr = h_realloc(ptr, max_size);
@@ -732,7 +745,7 @@
ptr = nptr;
}
(void) strvis(ptr, ev.str, VIS_WHITE);
- (void) fprintf(fp, "%s\n", ev.str);
+ (void) fprintf(fp, "%s\n", ptr);
}
oomem:
h_free((ptr_t)ptr);
--- 1.4/cmd-line-utils/libedit/key.c 2004-09-03 05:47:32 -07:00
+++ 1.5/cmd-line-utils/libedit/key.c 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: key.c,v 1.13 2002/03/18 16:00:55 christos Exp $ */
+/* $OpenBSD: key.c,v 1.9 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: key.c,v 1.13 2002/03/18 16:00:55 christos Exp $");
+static const char rcsid[] = "$OpenBSD: key.c,v 1.9 2003/11/25 20:12:38 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -103,14 +100,14 @@
* Initialize the key maps
*/
protected int
-el_key_init(EditLine *el)
+key_init(EditLine *el)
{
el->el_key.buf = (char *) el_malloc(KEY_BUFSIZ);
if (el->el_key.buf == NULL)
return (-1);
el->el_key.map = NULL;
- el_key_reset(el);
+ key_reset(el);
return (0);
}
@@ -119,7 +116,7 @@
* Free the key maps
*/
protected void
-el_key_end(EditLine *el)
+key_end(EditLine *el)
{
el_free((ptr_t) el->el_key.buf);
@@ -133,7 +130,7 @@
* Associate cmd with a key value
*/
protected key_value_t *
-el_key_map_cmd(EditLine *el, int cmd)
+key_map_cmd(EditLine *el, int cmd)
{
el->el_key.val.cmd = (el_action_t) cmd;
@@ -145,7 +142,7 @@
* Associate str with a key value
*/
protected key_value_t *
-el_key_map_str(EditLine *el, char *str)
+key_map_str(EditLine *el, char *str)
{
el->el_key.val.str = str;
@@ -159,7 +156,7 @@
* [Always bind the ansi arrow keys?]
*/
protected void
-el_key_reset(EditLine *el)
+key_reset(EditLine *el)
{
node__put(el, el->el_key.map);
@@ -177,7 +174,7 @@
* The last character read is returned in *ch.
*/
protected int
-el_key_get(EditLine *el, char *ch, key_value_t *val)
+key_get(EditLine *el, char *ch, key_value_t *val)
{
return (node_trav(el, el->el_key.map, ch, val));
@@ -191,7 +188,7 @@
* out str or a unix command.
*/
protected void
-el_key_add(EditLine *el, const char *key, key_value_t *val, int ntype)
+key_add(EditLine *el, const char *key, key_value_t *val, int ntype)
{
if (key[0] == '\0') {
@@ -219,7 +216,7 @@
*
*/
protected void
-el_key_clear(EditLine *el, el_action_t *map, const char *in)
+key_clear(EditLine *el, el_action_t *map, const char *in)
{
if ((map[(unsigned char)*in] == ED_SEQUENCE_LEAD_IN) &&
@@ -227,7 +224,7 @@
el->el_map.alt[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN) ||
(map == el->el_map.alt &&
el->el_map.key[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN)))
- (void) el_key_delete(el, in);
+ (void) key_delete(el, in);
}
@@ -236,7 +233,7 @@
* they exists.
*/
protected int
-el_key_delete(EditLine *el, const char *key)
+key_delete(EditLine *el, const char *key)
{
if (key[0] == '\0') {
@@ -257,7 +254,7 @@
* Print entire el->el_key.map if null
*/
protected void
-el_key_print(EditLine *el, const char *key)
+key_print(EditLine *el, const char *key)
{
/* do nothing if el->el_key.map is empty and null key specified */
@@ -356,7 +353,8 @@
break;
case XK_STR:
case XK_EXE:
- ptr->val.str = strdup(val->str);
+ if ((ptr->val.str = el_strdup(val->str)) == NULL)
+ return -1;
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
@@ -504,7 +502,7 @@
if (str[1] == 0) {
el->el_key.buf[ncnt + 1] = '"';
el->el_key.buf[ncnt + 2] = '\0';
- el_key_kprint(el, el->el_key.buf,
+ key_kprint(el, el->el_key.buf,
&ptr->val, ptr->type);
return (0);
} else
@@ -552,7 +550,7 @@
/* print this key and function */
el->el_key.buf[ncnt + 1] = '"';
el->el_key.buf[ncnt + 2] = '\0';
- el_key_kprint(el, el->el_key.buf, &ptr->val, ptr->type);
+ key_kprint(el, el->el_key.buf, &ptr->val, ptr->type);
} else
(void) node_enum(el, ptr->next, ncnt + 1);
@@ -568,7 +566,7 @@
* function specified by val
*/
protected void
-el_key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
+key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
{
el_bindings_t *fp;
char unparsbuf[EL_BUFSIZ];
@@ -579,7 +577,7 @@
case XK_STR:
case XK_EXE:
(void) fprintf(el->el_outfile, fmt, key,
- el_key__decode_str(val->str, unparsbuf,
+ key__decode_str(val->str, unparsbuf,
ntype == XK_STR ? "\"\"" : "[]"));
break;
case XK_CMD:
@@ -644,7 +642,7 @@
* Make a printable version of the ey
*/
protected char *
-el_key__decode_str(const char *str, char *buf, const char *sep)
+key__decode_str(const char *str, char *buf, const char *sep)
{
char *b;
const char *p;
--- 1.4/cmd-line-utils/libedit/key.h 2004-09-03 05:47:32 -07:00
+++ 1.5/cmd-line-utils/libedit/key.h 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: key.h,v 1.6 2002/03/18 16:00:55 christos Exp $ */
+/* $OpenBSD: key.h,v 1.7 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -62,19 +59,22 @@
#define XK_NOD 2
#define XK_EXE 3
-protected int el_key_init(EditLine *);
-protected void el_key_end(EditLine *);
-protected key_value_t *el_key_map_cmd(EditLine *, int);
-protected key_value_t *el_key_map_str(EditLine *, char *);
-protected void el_key_reset(EditLine *);
-protected int el_key_get(EditLine *, char *, key_value_t *);
-protected void el_key_add(EditLine *,
- const char *, key_value_t *, int);
-protected void el_key_clear(EditLine *, el_action_t *, const char *);
-protected int el_key_delete(EditLine *, const char *);
-protected void el_key_print(EditLine *, const char *);
-protected void el_key_kprint(EditLine *, const char *, key_value_t *,
+#undef key_end
+#undef key_clear
+#undef key_print
+
+protected int key_init(EditLine *);
+protected void key_end(EditLine *);
+protected key_value_t *key_map_cmd(EditLine *, int);
+protected key_value_t *key_map_str(EditLine *, char *);
+protected void key_reset(EditLine *);
+protected int key_get(EditLine *, char *, key_value_t *);
+protected void key_add(EditLine *, const char *, key_value_t *, int);
+protected void key_clear(EditLine *, el_action_t *, const char *);
+protected int key_delete(EditLine *, const char *);
+protected void key_print(EditLine *, const char *);
+protected void key_kprint(EditLine *, const char *, key_value_t *,
int);
-protected char *el_key__decode_str(const char *, char *, const char *);
+protected char *key__decode_str(const char *, char *, const char *);
#endif /* _h_el_key */
--- 1.6/cmd-line-utils/libedit/map.c 2004-09-03 05:47:32 -07:00
+++ 1.7/cmd-line-utils/libedit/map.c 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: map.c,v 1.18 2002/11/15 14:32:33 christos Exp $ */
+/* $OpenBSD: map.c,v 1.9 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: map.c,v 1.19 2003/08/07 16:44:32 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: map.c,v 1.18 2002/11/15 14:32:33 christos Exp $");
+static const char rcsid[] = "$OpenBSD: map.c,v 1.9 2003/10/31 08:42:24 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -287,7 +284,7 @@
/* 221 */ ED_UNASSIGNED, /* M-] */
/* 222 */ ED_UNASSIGNED, /* M-^ */
/* 223 */ ED_UNASSIGNED, /* M-_ */
- /* 223 */ ED_UNASSIGNED, /* M-` */
+
/* 224 */ ED_UNASSIGNED, /* M-a */
/* 225 */ ED_PREV_WORD, /* M-b */
/* 226 */ EM_CAPITOL_CASE, /* M-c */
@@ -1011,8 +1008,7 @@
break;
default:
buf[1] = i & 0177;
- el_key_add(el, buf,
- el_key_map_cmd(el, (int) map[i]), XK_CMD);
+ key_add(el, buf, key_map_cmd(el, (int) map[i]), XK_CMD);
break;
}
map[(int) buf[0]] = ED_SEQUENCE_LEAD_IN;
@@ -1034,7 +1030,7 @@
el->el_map.type = MAP_VI;
el->el_map.current = el->el_map.key;
- el_key_reset(el);
+ key_reset(el);
for (i = 0; i < N_KEYS; i++) {
key[i] = vii[i];
@@ -1063,7 +1059,7 @@
el->el_map.type = MAP_EMACS;
el->el_map.current = el->el_map.key;
- el_key_reset(el);
+ key_reset(el);
for (i = 0; i < N_KEYS; i++) {
key[i] = emacs[i];
@@ -1076,7 +1072,7 @@
buf[0] = CONTROL('X');
buf[1] = CONTROL('X');
buf[2] = 0;
- el_key_add(el, buf, el_key_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
+ key_add(el, buf, key_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
tty_bind_char(el, 1);
term_bind_arrow(el);
@@ -1133,7 +1129,7 @@
el_bindings_t *bp;
if (in[0] == '\0' || in[1] == '\0') {
- (void) el_key__decode_str(in, outbuf, "");
+ (void) key__decode_str(in, outbuf, "");
for (bp = el->el_map.help; bp->name != NULL; bp++)
if (bp->func == map[(unsigned char) *in]) {
(void) fprintf(el->el_outfile,
@@ -1141,7 +1137,7 @@
return;
}
} else
- el_key_print(el, in);
+ key_print(el, in);
}
@@ -1163,20 +1159,20 @@
if (first == last)
(void) fprintf(el->el_outfile,
"%-15s-> is undefined\n",
- el_key__decode_str(firstbuf, unparsbuf, STRQQ));
+ key__decode_str(firstbuf, unparsbuf, STRQQ));
return;
}
for (bp = el->el_map.help; bp->name != NULL; bp++) {
if (bp->func == map[first]) {
if (first == last) {
(void) fprintf(el->el_outfile, "%-15s-> %s\n",
- el_key__decode_str(firstbuf, unparsbuf, STRQQ),
+ key__decode_str(firstbuf, unparsbuf, STRQQ),
bp->name);
} else {
(void) fprintf(el->el_outfile,
"%-4s to %-7s-> %s\n",
- el_key__decode_str(firstbuf, unparsbuf, STRQQ),
- el_key__decode_str(lastbuf, extrabuf, STRQQ),
+ key__decode_str(firstbuf, unparsbuf, STRQQ),
+ key__decode_str(lastbuf, extrabuf, STRQQ),
bp->name);
}
return;
@@ -1230,7 +1226,7 @@
map_print_some_keys(el, el->el_map.alt, prev, i - 1);
(void) fprintf(el->el_outfile, "Multi-character bindings\n");
- el_key_print(el, "");
+ key_print(el, "");
(void) fprintf(el->el_outfile, "Arrow key bindings\n");
term_print_arrow(el, "");
}
@@ -1323,9 +1319,9 @@
return (-1);
}
if (in[1])
- (void) el_key_delete(el, in);
+ (void) key_delete(el, in);
else if (map[(unsigned char) *in] == ED_SEQUENCE_LEAD_IN)
- (void) el_key_delete(el, in);
+ (void) key_delete(el, in);
else
map[(unsigned char) *in] = ED_UNASSIGNED;
return (0);
@@ -1353,9 +1349,9 @@
return (-1);
}
if (key)
- term_set_arrow(el, in, el_key_map_str(el, out), ntype);
+ term_set_arrow(el, in, key_map_str(el, out), ntype);
else
- el_key_add(el, in, el_key_map_str(el, out), ntype);
+ key_add(el, in, key_map_str(el, out), ntype);
map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
break;
@@ -1366,13 +1362,13 @@
return (-1);
}
if (key)
- term_set_arrow(el, in, el_key_map_str(el, out), ntype);
+ term_set_arrow(el, in, key_map_str(el, out), ntype);
else {
if (in[1]) {
- el_key_add(el, in, el_key_map_cmd(el, cmd), ntype);
+ key_add(el, in, key_map_cmd(el, cmd), ntype);
map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN;
} else {
- el_key_clear(el, map, in);
+ key_clear(el, map, in);
map[(unsigned char) *in] = cmd;
}
}
--- 1.2/cmd-line-utils/libedit/map.h 2004-08-24 08:41:37 -07:00
+++ 1.3/cmd-line-utils/libedit/map.h 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: map.h,v 1.7 2002/03/18 16:00:56 christos Exp $ */
+/* $OpenBSD: map.h,v 1.7 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: map.h,v 1.8 2003/08/07 16:44:32 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
--- 1.4/cmd-line-utils/libedit/parse.c 2005-01-08 12:25:24 -08:00
+++ 1.5/cmd-line-utils/libedit/parse.c 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: parse.c,v 1.16 2003/01/21 18:40:24 christos Exp $ */
+/* $OpenBSD: parse.c,v 1.8 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: parse.c,v 1.19 2003/11/02 20:06:57 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: parse.c,v 1.16 2003/01/21 18:40:24 christos Exp $");
+static const char rcsid[] = "$OpenBSD: parse.c,v 1.8 2003/11/25 20:12:38 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -87,8 +84,7 @@
int argc;
Tokenizer *tok;
- if (!(tok = tok_init(NULL)))
- return -1;
+ tok = tok_init(NULL);
tok_line(tok, line, &argc, &argv);
argc = el_parse(el, argc, argv);
tok_end(tok);
@@ -207,7 +203,7 @@
c = *p;
break;
}
- } else if (*p == '^' && isalpha((unsigned char) p[1])) {
+ } else if (*p == '^') {
p++;
c = (*p == '?') ? '\177' : (*p & 0237);
} else
@@ -215,6 +211,7 @@
*ptr = ++p;
return (c);
}
+
/* parse__string():
* Parse the escapes from in and put the raw string out
*/
@@ -236,6 +233,14 @@
return (NULL);
*out++ = n;
break;
+
+ case 'M':
+ if (in[1] == '-' && in[2] != '\0') {
+ *out++ = '\033';
+ in += 2;
+ break;
+ }
+ /*FALLTHROUGH*/
default:
*out++ = *in++;
--- 1.1/cmd-line-utils/libedit/parse.h 2003-01-18 08:28:16 -08:00
+++ 1.2/cmd-line-utils/libedit/parse.h 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: parse.h,v 1.4 2000/09/04 22:06:31 lukem Exp $ */
+/* $OpenBSD: parse.h,v 1.6 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: parse.h,v 1.5 2003/08/07 16:44:32 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
--- 1.3/cmd-line-utils/libedit/prompt.c 2004-08-24 08:41:37 -07:00
+++ 1.4/cmd-line-utils/libedit/prompt.c 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: prompt.c,v 1.9 2002/03/18 16:00:56 christos Exp $ */
+/* $OpenBSD: prompt.c,v 1.7 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: prompt.c,v 1.9 2002/03/18 16:00:56 christos Exp $");
+static const char rcsid[] = "$OpenBSD: prompt.c,v 1.7 2003/10/31 08:42:24 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -59,7 +56,7 @@
*/
private char *
/*ARGSUSED*/
-prompt_default(EditLine *el __attribute__((unused)))
+prompt_default(EditLine *el __attribute__((__unused__)))
{
static char a[3] = {'?', ' ', '\0'};
@@ -72,7 +69,7 @@
*/
private char *
/*ARGSUSED*/
-prompt_default_r(EditLine *el __attribute__((unused)))
+prompt_default_r(EditLine *el __attribute__((__unused__)))
{
static char a[1] = {'\0'};
@@ -127,7 +124,7 @@
*/
protected void
/*ARGSUSED*/
-prompt_end(EditLine *el __attribute__((unused)))
+prompt_end(EditLine *el __attribute__((__unused__)))
{
}
--- 1.1/cmd-line-utils/libedit/prompt.h 2003-01-18 08:28:16 -08:00
+++ 1.2/cmd-line-utils/libedit/prompt.h 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: prompt.h,v 1.5 2000/09/04 22:06:31 lukem Exp $ */
+/* $OpenBSD: prompt.h,v 1.6 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: prompt.h,v 1.6 2003/08/07 16:44:32 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
--- 1.5/cmd-line-utils/libedit/read.c 2004-09-03 05:47:32 -07:00
+++ 1.6/cmd-line-utils/libedit/read.c 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: read.c,v 1.24 2002/11/20 16:50:08 christos Exp $ */
+/* $OpenBSD: read.c,v 1.11 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: read.c,v 1.30 2003/10/18 23:48:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.24 2002/11/20 16:50:08 christos Exp $");
+static const char rcsid[] = "$OpenBSD: read.c,v 1.11 2003/11/25 20:12:38 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
@@ -50,6 +47,7 @@
* Terminal read functions
*/
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include "el.h"
@@ -97,6 +95,10 @@
}
+#ifndef MIN
+#define MIN(A,B) ((A) < (B) ? (A) : (B))
+#endif
+
#ifdef DEBUG_EDIT
private void
read_debug(EditLine *el)
@@ -121,11 +123,7 @@
*/
/* ARGSUSED */
private int
-read__fixio(int fd
-#if !(defined(TRY_AGAIN) && (defined(FIONBIO) || (defined(F_SETFL) &&
defined(O_NDELAY))))
- __attribute__((unused))
-#endif /* !(defined(TRY_AGAIN) && (defined(FIONBIO) || (defined(F_SETFL)
&& defined(O_NDELAY)))) */
-, int e)
+read__fixio(int fd __attribute__((__unused__)), int e)
{
switch (e) {
@@ -190,18 +188,10 @@
{
int chrs = 0;
- if (el->el_chared.c_macro.nline) {
- el_free((ptr_t) el->el_chared.c_macro.nline);
- el->el_chared.c_macro.nline = NULL;
- }
if (el->el_tty.t_mode == ED_IO)
return (0);
#ifdef FIONREAD
-
-#ifndef MIN // definition of MIN is lacking on hpux..
-#define MIN(x,y) (((x)<(y))?(x):(y))
-#endif
(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
if (chrs > 0) {
char buf[EL_BUFSIZ];
@@ -210,8 +200,7 @@
(size_t) MIN(chrs, EL_BUFSIZ - 1));
if (chrs > 0) {
buf[chrs] = '\0';
- el->el_chared.c_macro.nline = strdup(buf);
- el_push(el, el->el_chared.c_macro.nline);
+ el_push(el, buf);
}
}
#endif /* FIONREAD */
@@ -230,11 +219,12 @@
if (str != NULL && ma->level + 1 < EL_MAXMACRO) {
ma->level++;
- ma->macro[ma->level] = str;
- } else {
- term_beep(el);
- term__flush();
+ if ((ma->macro[ma->level] = el_strdup(str)) != NULL)
+ return;
+ ma->level--;
}
+ term_beep(el);
+ term__flush();
}
@@ -266,7 +256,7 @@
cmd = el->el_map.current[(unsigned char) *ch];
if (cmd == ED_SEQUENCE_LEAD_IN) {
key_value_t val;
- switch (el_key_get(el, ch, &val)) {
+ switch (key_get(el, ch, &val)) {
case XK_CMD:
cmd = val.cmd;
break;
@@ -331,14 +321,16 @@
if (ma->level < 0)
break;
- if (*ma->macro[ma->level] == 0) {
- ma->level--;
+ if (ma->macro[ma->level][ma->offset] == '\0') {
+ el_free(ma->macro[ma->level--]);
+ ma->offset = 0;
continue;
}
- *cp = *ma->macro[ma->level]++ & 0377;
- if (*ma->macro[ma->level] == 0) { /* Needed for QuoteMode
- * On */
- ma->level--;
+ *cp = ma->macro[ma->level][ma->offset++] & 0377;
+ if (ma->macro[ma->level][ma->offset] == '\0') {
+ /* Needed for QuoteMode On */
+ el_free(ma->macro[ma->level--]);
+ ma->offset = 0;
}
return (1);
}
@@ -359,6 +351,32 @@
return (num_read);
}
+protected void
+read_prepare(EditLine *el)
+{
+ if (el->el_flags & HANDLE_SIGNALS)
+ sig_set(el);
+ if (el->el_flags & NO_TTY)
+ return;
+ if ((el->el_flags & (UNBUFFERED|EDIT_DISABLED)) == UNBUFFERED)
+ tty_rawmode(el);
+
+ /* This is relatively cheap, and things go terribly wrong if
+ we have the wrong size. */
+ el_resize(el);
+ re_clear_display(el); /* reset the display stuff */
+ ch_reset(el);
+ re_refresh(el); /* print the prompt */
+}
+
+protected void
+read_finish(EditLine *el)
+{
+ if ((el->el_flags & UNBUFFERED) == 0)
+ (void) tty_cookedmode(el);
+ if (el->el_flags & HANDLE_SIGNALS)
+ sig_clr(el);
+}
public const char *
el_gets(EditLine *el, int *nread)
@@ -367,13 +385,11 @@
el_action_t cmdnum = 0;
int num; /* how many chars we have read at NL */
char ch;
+ int crlf = 0;
#ifdef FIONREAD
c_macro_t *ma = &el->el_chared.c_macro;
#endif /* FIONREAD */
- if (el->el_flags & HANDLE_SIGNALS)
- sig_set(el);
-
if (el->el_flags & NO_TTY) {
char *cp = el->el_line.buffer;
size_t idx;
@@ -387,6 +403,8 @@
cp = &el->el_line.buffer[idx];
}
cp++;
+ if (el->el_flags & UNBUFFERED)
+ break;
if (cp[-1] == '\r' || cp[-1] == '\n')
break;
}
@@ -398,12 +416,6 @@
return (el->el_line.buffer);
}
- /* This is relatively cheap, and things go terribly wrong if
- we have the wrong size. */
- el_resize(el);
-
- re_clear_display(el); /* reset the display stuff */
- ch_reset(el);
#ifdef FIONREAD
if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
@@ -420,7 +432,8 @@
}
#endif /* FIONREAD */
- re_refresh(el); /* print the prompt */
+ if ((el->el_flags & UNBUFFERED) == 0)
+ read_prepare(el);
if (el->el_flags & EDIT_DISABLED) {
char *cp = el->el_line.buffer;
@@ -439,7 +452,10 @@
if (*cp == 4) /* ought to be stty eof */
break;
cp++;
- if (cp[-1] == '\r' || cp[-1] == '\n')
+ crlf = cp[-1] == '\r' || cp[-1] == '\n';
+ if (el->el_flags & UNBUFFERED)
+ break;
+ if (crlf)
break;
}
@@ -463,8 +479,7 @@
#endif /* DEBUG_READ */
break;
}
- if ((unsigned int)cmdnum >= (unsigned int)(el->el_map.nfunc))
- { /* BUG CHECK command */
+ if ((uint)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
#ifdef DEBUG_EDIT
(void) fprintf(el->el_errfile,
"ERROR: illegal command from key 0%o\r\n", ch);
@@ -536,7 +551,13 @@
continue; /* keep going... */
case CC_EOF: /* end of file typed */
- num = 0;
+ if ((el->el_flags & UNBUFFERED) == 0)
+ num = 0;
+ else if (num == -1) {
+ *el->el_line.lastchar++ = CTRL('d');
+ el->el_line.cursor = el->el_line.lastchar;
+ num = 1;
+ }
break;
case CC_NEWLINE: /* normal end of line */
@@ -567,14 +588,19 @@
el->el_state.argument = 1;
el->el_state.doingarg = 0;
el->el_chared.c_vcmd.action = NOP;
+ if (el->el_flags & UNBUFFERED)
+ break;
}
term__flush(); /* flush any buffered output */
/* make sure the tty is set up correctly */
- (void) tty_cookedmode(el);
- if (el->el_flags & HANDLE_SIGNALS)
- sig_clr(el);
- if (nread)
- *nread = num;
+ if ((el->el_flags & UNBUFFERED) == 0) {
+ read_finish(el);
+ if (nread)
+ *nread = num;
+ } else {
+ if (nread)
+ *nread = el->el_line.lastchar - el->el_line.buffer;
+ }
return (num ? el->el_line.buffer : NULL);
}
--- 1.1/cmd-line-utils/libedit/read.h 2004-08-24 09:52:10 -07:00
+++ 1.2/cmd-line-utils/libedit/read.h 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: read.h,v 1.1 2001/09/27 19:29:50 christos Exp $ */
+/* $OpenBSD: read.h,v 1.1 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: read.h,v 1.2 2003/09/26 17:44:51 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -49,6 +50,8 @@
} el_read_t;
protected int read_init(EditLine *);
+protected void read_prepare(EditLine *);
+protected void read_finish(EditLine *);
protected int el_read_setfn(EditLine *, el_rfunc_t);
protected el_rfunc_t el_read_getfn(EditLine *);
--- 1.6/cmd-line-utils/libedit/readline.c 2004-08-31 06:28:58 -07:00
+++ 1.7/cmd-line-utils/libedit/readline.c 2005-04-05 19:43:53 -07:00
@@ -1,4 +1,5 @@
-/* $NetBSD: readline.c,v 1.28 2003/03/10 01:14:54 christos Exp $ */
+/* $OpenBSD: readline.c,v 1.2 2003/11/25 20:12:38 otto Exp $ */
+/* $NetBSD: readline.c,v 1.43 2003/11/03 03:22:55 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +39,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.28 2003/03/10 01:14:54 christos Exp $");
+static const char rcsid[] = "$OpenBSD";
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -51,19 +52,27 @@
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_VIS_H
+#include <vis.h>
+#else
+#include "np/vis.h"
+#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include "histedit.h"
#include "readline/readline.h"
#include "el.h"
+#include "tokenizer.h"
#include "fcns.h" /* for EL_NUM_FCNS */
/* for rl_complete() */
-#define TAB '\r'
+#define TAB '\r'
/* see comment at the #ifdef for sense of this */
-#define GDB_411_HACK
+/* #define GDB_411_HACK */
/* readline compatibility stuff - look at readline sources/documentation */
/* to see what these variables mean */
@@ -78,6 +87,9 @@
int rl_point = 0;
int rl_end = 0;
char *rl_line_buffer = NULL;
+VFunction *rl_linefunc = NULL;
+int rl_done = 0;
+VFunction *rl_event_hook = NULL;
int history_base = 1; /* probably never subject to change */
int history_length = 0;
@@ -86,16 +98,34 @@
char history_subst_char = '^';
char *history_no_expand_chars = expand_chars;
Function *history_inhibit_expansion_function = NULL;
+char *history_arg_extract(int start, int end, const char *str);
int rl_inhibit_completion = 0;
int rl_attempted_completion_over = 0;
char *rl_basic_word_break_characters = break_chars;
char *rl_completer_word_break_characters = NULL;
char *rl_completer_quote_characters = NULL;
-CPFunction *rl_completion_entry_function = NULL;
+Function *rl_completion_entry_function = NULL;
CPPFunction *rl_attempted_completion_function = NULL;
+Function *rl_pre_input_hook = NULL;
+Function *rl_startup1_hook = NULL;
+Function *rl_getc_function = NULL;
+char *rl_terminal_name = NULL;
+int rl_already_prompted = 0;
+int rl_filename_completion_desired = 0;
+int rl_ignore_completion_duplicates = 0;
+int rl_catch_signals = 1;
+VFunction *rl_redisplay_function = NULL;
+Function *rl_startup_hook = NULL;
+VFunction *rl_completion_display_matches_hook = NULL;
+VFunction *rl_prep_term_function = NULL;
+VFunction *rl_deprep_term_function = NULL;
/*
+ * The current prompt string.
+ */
+char *rl_prompt = NULL;
+/*
* This is set to character indicating type of completion being done by
* rl_complete_internal(); this is available for application completion
* functions.
@@ -128,30 +158,28 @@
static History *h = NULL;
static EditLine *e = NULL;
+static Function *map[256];
static int el_rl_complete_cmdnum = 0;
/* internal functions */
static unsigned char _el_rl_complete(EditLine *, int);
static char *_get_prompt(EditLine *);
static HIST_ENTRY *_move_history(int);
-static int _history_search_gen(const char *, int, int);
-static int _history_expand_command(const char *, size_t, char **);
+static int _history_expand_command(const char *, size_t, size_t,
+ char **);
static char *_rl_compat_sub(const char *, const char *,
- const char *, int);
+ const char *, int);
static int rl_complete_internal(int);
static int _rl_qsort_string_compare(const void *, const void *);
-
-/*
- * needed for prompt switching in readline()
- */
-static char *el_rl_prompt = NULL;
+static int _rl_event_read_char(EditLine *, char *);
/* ARGSUSED */
static char *
-_get_prompt(EditLine *el __attribute__((unused)))
+_get_prompt(EditLine *el __attribute__((__unused__)))
{
- return (el_rl_prompt);
+ rl_already_prompted = 1;
+ return (rl_prompt);
}
@@ -168,7 +196,7 @@
return (HIST_ENTRY *) NULL;
rl_he.line = ev.str;
- rl_he.data = "";
+ rl_he.data = NULL;
return (&rl_he);
}
@@ -221,28 +249,31 @@
el_set(e, EL_HIST, history, h);
/* for proper prompt printing in readline() */
- el_rl_prompt = strdup("");
- if (el_rl_prompt == NULL) {
+ rl_prompt = strdup("");
+ if (rl_prompt == NULL) {
history_end(h);
el_end(e);
return -1;
}
el_set(e, EL_PROMPT, _get_prompt);
- el_set(e, EL_SIGNAL, 1);
+ el_set(e, EL_SIGNAL, rl_catch_signals);
/* set default mode to "emacs"-style and read setting afterwards */
/* so this can be overriden */
el_set(e, EL_EDITOR, "emacs");
+ if (rl_terminal_name != NULL)
+ el_set(e, EL_TERMINAL, rl_terminal_name);
+ else
+ el_get(e, EL_TERMINAL, &rl_terminal_name);
/*
- * Word completition - this has to go AFTER rebinding keys
+ * Word completion - this has to go AFTER rebinding keys
* to emacs-style.
*/
el_set(e, EL_ADDFN, "rl_complete",
- "ReadLine compatible completition function",
+ "ReadLine compatible completion function",
_el_rl_complete);
el_set(e, EL_BIND, "^I", "rl_complete", NULL);
-
/*
* Find out where the rl_complete function was added; this is
* used later to detect that lastcmd was also rl_complete.
@@ -266,6 +297,9 @@
rl_line_buffer = memchr(li->buffer, *li->buffer, 1);
rl_point = rl_end = 0;
+ if (rl_startup_hook)
+ (*rl_startup_hook)(NULL, 0);
+
return (0);
}
@@ -281,19 +315,38 @@
int count;
const char *ret;
char *buf;
+ static int used_event_hook;
if (e == NULL || h == NULL)
rl_initialize();
+ rl_done = 0;
+
/* update prompt accordingly to what has been passed */
if (!prompt)
prompt = "";
- if (strcmp(el_rl_prompt, prompt) != 0) {
- free(el_rl_prompt);
- el_rl_prompt = strdup(prompt);
- if (el_rl_prompt == NULL)
+ if (strcmp(rl_prompt, prompt) != 0) {
+ free(rl_prompt);
+ rl_prompt = strdup(prompt);
+ if (rl_prompt == NULL)
return NULL;
}
+
+ if (rl_pre_input_hook)
+ (*rl_pre_input_hook)(NULL, 0);
+
+ if (rl_event_hook && !(e->el_flags&NO_TTY)) {
+ el_set(e, EL_GETCFN, _rl_event_read_char);
+ used_event_hook = 1;
+ }
+
+ if (!rl_event_hook && used_event_hook) {
+ el_set(e, EL_GETCFN, EL_BUILTIN_GETCFN);
+ used_event_hook = 0;
+ }
+
+ rl_already_prompted = 0;
+
/* get one line from input stream */
ret = el_gets(e, &count);
@@ -333,73 +386,180 @@
/*
* substitute ``what'' with ``with'', returning resulting string; if
- * globally == 1, substitutes all occurences of what, otherwise only the
+ * globally == 1, substitutes all occurrences of what, otherwise only the
* first one
*/
static char *
_rl_compat_sub(const char *str, const char *what, const char *with,
int globally)
{
- char *result;
- const char *temp, *new;
- unsigned int len, with_len, what_len, add;
- size_t size, i;
+ const char *s;
+ char *r, *result;
+ size_t len, with_len, what_len;
- result = malloc((size = 16));
- if (result == NULL)
- return NULL;
- temp = str;
+ len = strlen(str);
with_len = strlen(with);
what_len = strlen(what);
- len = 0;
- do {
- new = strstr(temp, what);
- if (new) {
- i = new - temp;
- add = i + with_len;
- if (i + add + 1 >= size) {
- char *nresult;
- size += add + 1;
- nresult = realloc(result, size);
- if (nresult == NULL) {
- free(result);
- return NULL;
- }
- result = nresult;
- }
- (void) strncpy(&result[len], temp, i);
- len += i;
- (void) strcpy(&result[len], with); /* safe */
- len += with_len;
- temp = new + what_len;
- } else {
- add = strlen(temp);
- if (len + add + 1 >= size) {
- char *nresult;
- size += add + 1;
- nresult = realloc(result, size);
- if (nresult == NULL) {
- free(result);
- return NULL;
- }
- result = nresult;
+
+ /* calculate length we need for result */
+ s = str;
+ while (*s) {
+ if (*s == *what && !strncmp(s, what, what_len)) {
+ len += with_len - what_len;
+ if (!globally)
+ break;
+ s += what_len;
+ } else
+ s++;
+ }
+ len++;
+ r = result = malloc(len);
+ if (result == NULL)
+ return NULL;
+ s = str;
+ while (*s) {
+ if (*s == *what && !strncmp(s, what, what_len)) {
+ (void)strncpy(r, with, with_len);
+ r += with_len;
+ len -= with_len;
+ s += what_len;
+ if (!globally) {
+ (void)strlcpy(r, s, len);
+ return(result);
}
- (void) strcpy(&result[len], temp); /* safe */
- len += add;
- temp = NULL;
+ } else
+ *r++ = *s++;
+ }
+ *r = 0;
+ return(result);
+}
+
+static char *last_search_pat; /* last !?pat[?] search pattern */
+static char *last_search_match; /* last !?pat[?] that matched */
+
+const char *
+get_history_event(const char