Commit ae641bdd authored by unknown's avatar unknown
Browse files

Merge neptunus.(none):/home/msvensson/mysql/mysql-4.1

into neptunus.(none):/home/msvensson/mysql/bug2596

parents e2f56710 6905af20
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1306,7 +1306,7 @@ static void initialize_readline (char *name)
  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;
+37 −18
Original line number Diff line number Diff line
/*	$NetBSD: chared.c,v 1.18 2002/11/20 16:50:08 christos Exp $	*/
/*	$NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $	*/

/*-
 * Copyright (c) 1992, 1993
@@ -15,11 +15,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,14 +32,7 @@
 * SUCH DAMAGE.
 */

#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#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 $");
#endif
#endif /* not lint && not SCCSID */
#include <config.h>

/*
 * chared.c: Character editor utilities
@@ -62,13 +51,13 @@ cv_undo(EditLine *el)
{
	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;
@@ -139,6 +128,21 @@ c_delafter(EditLine *el, int num)
}


/* c_delafter1():
 *	Delete the character after the cursor, do not yank
 */
protected void
c_delafter1(EditLine *el)
{
	char *cp;

	for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
		*cp = cp[1];

	el->el_line.lastchar--;
}


/* c_delbefore():
 *	Delete num characters before the cursor
 */
@@ -167,6 +171,21 @@ c_delbefore(EditLine *el, int num)
}


/* c_delbefore1():
 *	Delete the character before the cursor, do not yank
 */
protected void
c_delbefore1(EditLine *el)
{
	char *cp;

	for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
		*cp = cp[1];

	el->el_line.lastchar--;
}


/* ce__isword():
 *	Return if p is part of a word according to emacs
 */
@@ -460,8 +479,8 @@ ch_init(EditLine *el)
	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 +601,7 @@ ch_enlargebufs(el, addlen)
		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;
}

+5 −7
Original line number Diff line number Diff line
/*	$NetBSD: chared.h,v 1.11 2002/11/20 16:50:08 christos Exp $	*/
/*	$NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp $	*/

/*-
 * Copyright (c) 1992, 1993
@@ -15,11 +15,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 +62,8 @@

typedef struct c_macro_t {
	int	  level;
	int	  offset;
	char	**macro;
	char	 *nline;
} c_macro_t;

/*
@@ -158,7 +154,9 @@ protected char *c__next_word(char *, char *, int, int (*)(int));
protected char	*c__prev_word(char *, char *, int, int (*)(int));
protected void	 c_insert(EditLine *, int);
protected void	 c_delbefore(EditLine *, int);
protected void	 c_delbefore1(EditLine *);
protected void	 c_delafter(EditLine *, int);
protected void	 c_delafter1(EditLine *);
protected int	 c_gets(EditLine *, char *, const char *);
protected int	 c_hpos(EditLine *);

+42 −54
Original line number Diff line number Diff line
/*	$NetBSD: common.c,v 1.14 2002/11/20 16:50:08 christos Exp $	*/
/*	$NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $	*/

/*-
 * Copyright (c) 1992, 1993
@@ -15,11 +15,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,14 +32,7 @@
 * SUCH DAMAGE.
 */

#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#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 $");
#endif
#endif /* not lint && not SCCSID */
#include <config.h>

/*
 * common.c: Common Editor functions
@@ -56,7 +45,7 @@ __RCSID("$NetBSD: common.c,v 1.14 2002/11/20 16:50:08 christos Exp $");
 */
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 +102,7 @@ ed_insert(EditLine *el, int c)
 */
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 +130,7 @@ ed_delete_prev_word(EditLine *el, int c __attribute__((unused)))
 */
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 +181,7 @@ ed_delete_next_char(EditLine *el, int c __attribute__((unused)))
 */
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 +202,7 @@ ed_kill_line(EditLine *el, int c __attribute__((unused)))
 */
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 +225,7 @@ ed_move_to_end(EditLine *el, int c __attribute__((unused)))
 */
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 +274,7 @@ ed_transpose_chars(EditLine *el, int c)
 */
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 +303,7 @@ ed_next_char(EditLine *el, int c __attribute__((unused)))
 */
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 +329,7 @@ ed_prev_word(EditLine *el, int c __attribute__((unused)))
 */
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 +426,7 @@ ed_argument_digit(EditLine *el, int c)
 */
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 +443,8 @@ ed_unassigned(EditLine *el __attribute__((unused)),
 */
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 +457,8 @@ ed_tty_sigint(EditLine *el __attribute__((unused)),
 */
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 +471,8 @@ ed_tty_dsusp(EditLine *el __attribute__((unused)),
 */
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 +485,8 @@ ed_tty_flush_output(EditLine *el __attribute__((unused)),
 */
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 +499,8 @@ ed_tty_sigquit(EditLine *el __attribute__((unused)),
 */
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 +513,8 @@ ed_tty_sigtstp(EditLine *el __attribute__((unused)),
 */
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 +527,8 @@ ed_tty_stop_output(EditLine *el __attribute__((unused)),
 */
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 +541,7 @@ ed_tty_start_output(EditLine *el __attribute__((unused)),
 */
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 +557,7 @@ ed_newline(EditLine *el, int c __attribute__((unused)))
 */
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 +577,7 @@ ed_delete_prev_char(EditLine *el, int c __attribute__((unused)))
 */
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 +592,8 @@ ed_clear_screen(EditLine *el, int c __attribute__((unused)))
 */
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 +606,7 @@ ed_redisplay(EditLine *el __attribute__((unused)),
 */
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 +620,8 @@ ed_start_over(EditLine *el, int c __attribute__((unused)))
 */
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 +634,7 @@ ed_sequence_lead_in(EditLine *el __attribute__((unused)),
 */
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 +672,7 @@ ed_prev_history(EditLine *el, int c __attribute__((unused)))
 */
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 +699,7 @@ ed_next_history(EditLine *el, int c __attribute__((unused)))
 */
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 +767,7 @@ ed_search_prev_history(EditLine *el, int c __attribute__((unused)))
 */
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 +821,7 @@ ed_search_next_history(EditLine *el, int c __attribute__((unused)))
 */
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 +864,7 @@ ed_prev_line(EditLine *el, int c __attribute__((unused)))
 */
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 +898,7 @@ ed_next_line(EditLine *el, int c __attribute__((unused)))
 */
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;
+52 −33
Original line number Diff line number Diff line
/*	$NetBSD: el.c,v 1.30 2002/11/12 00:00:23 thorpej Exp $	*/
/*	$NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp $	*/

/*-
 * Copyright (c) 1992, 1993
@@ -15,11 +15,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,14 +32,7 @@
 * SUCH DAMAGE.
 */

#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#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 $");
#endif
#endif /* not lint && not SCCSID */
#include <config.h>

/*
 * el.c: EditLine interface functions
@@ -72,7 +61,10 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
	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 +72,11 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
	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 +104,7 @@ el_end(EditLine *el)
	el_reset(el);

	term_end(el);
	el_key_end(el);
	key_end(el);
	map_end(el);
	tty_end(el);
	ch_end(el);
@@ -257,6 +249,27 @@ el_set(EditLine *el, int op, ...)
		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)
			(void) tty_rawmode(el);
		else
			(void) tty_cookedmode(el);
		rv = 0;
		break;

	default:
		rv = -1;
		break;
@@ -297,21 +310,22 @@ el_get(EditLine *el, int op, void *ret)
		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 +392,11 @@ el_get(EditLine *el, int op, void *ret)
		rv = 0;
		break;

	case EL_UNBUFFERED:
		*((int *) ret) = (!(el->el_flags & UNBUFFERED));
		rv = 0;
		break;

	default:
		rv = -1;
	}
@@ -409,12 +428,17 @@ el_source(EditLine *el, const char *fname)

	fp = NULL;
	if (fname == NULL) {
#ifdef HAVE_ISSETUGID
		static const char elpath[] = "/.editrc";
#ifdef MAXPATHLEN
		char path[MAXPATHLEN];
#else
		char path[4096];
#endif

#ifdef HAVE_ISSETUGID
		if (issetugid())
			return (-1);
#endif
		if ((ptr = getenv("HOME")) == NULL)
			return (-1);
		if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
@@ -422,14 +446,6 @@ el_source(EditLine *el, const char *fname)
		if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
			return (-1);
		fname = path;
#else
		/*
		 * If issetugid() is missing, always return an error, in order
		 * to keep from inadvertently opening up the user to a security
		 * hole.
		 */
		return (-1);
#endif
	}
	if (fp == NULL)
		fp = fopen(fname, "r");
@@ -496,10 +512,13 @@ el_editmode(EditLine *el, int argc, const char **argv)
		return (-1);

	how = argv[1];
	if (strcmp(how, "on") == 0)
	if (strcmp(how, "on") == 0) {
		el->el_flags &= ~EDIT_DISABLED;
	else if (strcmp(how, "off") == 0)
		tty_rawmode(el);
	} else if (strcmp(how, "off") == 0) {
		tty_cookedmode(el);
		el->el_flags |= EDIT_DISABLED;
	}
	else {
		(void) fprintf(el->el_errfile, "edit: Bad value `%s'.\n", how);
		return (-1);
Loading