2016-02-24 17:25:38 +03:00
|
|
|
/* $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */
|
1997-01-11 09:47:47 +03:00
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Christos Zoulas of Cornell University.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 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.
|
2003-08-07 20:42:00 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-06 10:01:42 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2002-03-18 19:00:50 +03:00
|
|
|
#include "config.h"
|
1994-05-06 10:01:42 +04:00
|
|
|
#if !defined(lint) && !defined(SCCSID)
|
1997-01-11 09:47:47 +03:00
|
|
|
#if 0
|
1994-05-06 10:01:42 +04:00
|
|
|
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
|
1997-01-11 09:47:47 +03:00
|
|
|
#else
|
2016-02-24 17:25:38 +03:00
|
|
|
__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $");
|
1997-01-11 09:47:47 +03:00
|
|
|
#endif
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif /* not lint && not SCCSID */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* common.c: Common Editor functions
|
|
|
|
*/
|
2016-02-17 01:53:14 +03:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
#include "el.h"
|
2016-02-16 22:08:41 +03:00
|
|
|
#include "common.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "vi.h"
|
1994-05-06 10:01:42 +04:00
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_end_of_file():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Indicate end of file
|
|
|
|
* [^D]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
re_goto_bottom(el);
|
|
|
|
*el->el_line.lastchar = '\0';
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_EOF;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_insert():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Add character to the line
|
|
|
|
* Insert a character [bound to all insert keys]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_insert(EditLine *el, wint_t c)
|
2000-09-05 02:06:28 +04:00
|
|
|
{
|
2002-11-15 17:32:32 +03:00
|
|
|
int count = el->el_state.argument;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (c == '\0')
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_line.lastchar + el->el_state.argument >=
|
2001-01-10 10:45:41 +03:00
|
|
|
el->el_line.limit) {
|
|
|
|
/* end of buffer space, try to allocate more */
|
2002-11-15 17:32:32 +03:00
|
|
|
if (!ch_enlargebufs(el, (size_t) count))
|
2001-01-10 10:45:41 +03:00
|
|
|
return CC_ERROR; /* error allocating more */
|
|
|
|
}
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2002-11-15 17:32:32 +03:00
|
|
|
if (count == 1) {
|
2002-10-28 00:41:50 +03:00
|
|
|
if (el->el_state.inputmode == MODE_INSERT
|
|
|
|
|| el->el_line.cursor >= el->el_line.lastchar)
|
|
|
|
c_insert(el, 1);
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2016-02-11 22:21:04 +03:00
|
|
|
*el->el_line.cursor++ = (Char)c;
|
2000-09-05 02:06:28 +04:00
|
|
|
re_fastaddc(el); /* fast refresh for one char. */
|
|
|
|
} else {
|
2002-10-28 00:41:50 +03:00
|
|
|
if (el->el_state.inputmode != MODE_REPLACE_1)
|
|
|
|
c_insert(el, el->el_state.argument);
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2002-11-15 17:32:32 +03:00
|
|
|
while (count-- && el->el_line.cursor < el->el_line.lastchar)
|
2016-02-11 22:21:04 +03:00
|
|
|
*el->el_line.cursor++ = (Char)c;
|
2000-09-05 02:06:28 +04:00
|
|
|
re_refresh(el);
|
|
|
|
}
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_state.inputmode == MODE_REPLACE_1)
|
2002-10-28 00:41:50 +03:00
|
|
|
return vi_command_mode(el, 0);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_delete_prev_word():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Delete from beginning of current word to cursor
|
|
|
|
* [M-^?] [^W]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
Char *cp, *p, *kp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor == el->el_line.buffer)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
|
|
|
el->el_state.argument, ce__isword);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
|
|
|
|
*kp++ = *p;
|
|
|
|
el->el_chared.c_kill.last = kp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2009-02-16 00:55:23 +03:00
|
|
|
c_delbefore(el, (int)(el->el_line.cursor - cp));/* delete before dot */
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = cp;
|
|
|
|
if (el->el_line.cursor < el->el_line.buffer)
|
|
|
|
el->el_line.cursor = el->el_line.buffer; /* bounds check */
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_delete_next_char():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Delete character under cursor
|
|
|
|
* [^D] [x]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2011-07-29 19:20:39 +04:00
|
|
|
#ifdef DEBUG_EDIT
|
2000-09-05 02:06:28 +04:00
|
|
|
#define EL el->el_line
|
1998-05-20 05:00:33 +04:00
|
|
|
(void) fprintf(el->el_errlfile,
|
1999-07-02 19:14:07 +04:00
|
|
|
"\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n",
|
1998-05-20 05:00:33 +04:00
|
|
|
EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
|
|
|
|
EL.lastchar, EL.limit, EL.limit);
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor == el->el_line.lastchar) {
|
|
|
|
/* if I'm at the end */
|
|
|
|
if (el->el_map.type == MAP_VI) {
|
|
|
|
if (el->el_line.cursor == el->el_line.buffer) {
|
|
|
|
/* if I'm also at the beginning */
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef KSHVI
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
#else
|
2006-03-07 00:11:56 +03:00
|
|
|
/* then do an EOF */
|
2011-07-28 05:05:20 +04:00
|
|
|
terminal_writec(el, c);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_EOF;
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2000-09-05 02:06:28 +04:00
|
|
|
} else {
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef KSHVI
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor--;
|
1994-05-06 10:01:42 +04:00
|
|
|
#else
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2012-03-25 00:08:43 +04:00
|
|
|
} else
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
2000-09-05 02:06:28 +04:00
|
|
|
c_delafter(el, el->el_state.argument); /* delete after dot */
|
2012-03-25 00:08:43 +04:00
|
|
|
if (el->el_map.type == MAP_VI &&
|
|
|
|
el->el_line.cursor >= el->el_line.lastchar &&
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor > el->el_line.buffer)
|
|
|
|
/* bounds check */
|
|
|
|
el->el_line.cursor = el->el_line.lastchar - 1;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_kill_line():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Cut to the end of line
|
|
|
|
* [^K] [^K]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
Char *kp, *cp;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
cp = el->el_line.cursor;
|
|
|
|
kp = el->el_chared.c_kill.buf;
|
|
|
|
while (cp < el->el_line.lastchar)
|
|
|
|
*kp++ = *cp++; /* copy it */
|
|
|
|
el->el_chared.c_kill.last = kp;
|
|
|
|
/* zap! -- delete to end */
|
|
|
|
el->el_line.lastchar = el->el_line.cursor;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_move_to_end():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move cursor to the end of line
|
|
|
|
* [^E] [^E]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_line.cursor = el->el_line.lastchar;
|
|
|
|
if (el->el_map.type == MAP_VI) {
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_chared.c_vcmd.action != NOP) {
|
2000-09-05 02:06:28 +04:00
|
|
|
cv_delfini(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2008-09-30 12:37:42 +04:00
|
|
|
#ifdef VI_MOVE
|
|
|
|
el->el_line.cursor--;
|
|
|
|
#endif
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_move_to_beg():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move cursor to the beginning of line
|
|
|
|
* [^A] [^A]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__)))
|
2000-09-05 02:06:28 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
el->el_line.cursor = el->el_line.buffer;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_map.type == MAP_VI) {
|
|
|
|
/* We want FIRST non space character */
|
2009-12-31 01:37:40 +03:00
|
|
|
while (Isspace(*el->el_line.cursor))
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor++;
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_chared.c_vcmd.action != NOP) {
|
2000-09-05 02:06:28 +04:00
|
|
|
cv_delfini(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_transpose_chars():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Exchange the character to the left of the cursor with the one under it
|
|
|
|
* [^T] [^T]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_transpose_chars(EditLine *el, wint_t c)
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_line.cursor < el->el_line.lastchar) {
|
|
|
|
if (el->el_line.lastchar <= &el->el_line.buffer[1])
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
else
|
|
|
|
el->el_line.cursor++;
|
|
|
|
}
|
|
|
|
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
|
|
|
/* must have at least two chars entered */
|
|
|
|
c = el->el_line.cursor[-2];
|
|
|
|
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
2016-02-11 22:21:04 +03:00
|
|
|
el->el_line.cursor[-1] = (Char)c;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
} else
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_next_char():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move to the right one character
|
|
|
|
* [^F] [^F]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
Char *lim = el->el_line.lastchar;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_line.cursor >= lim ||
|
|
|
|
(el->el_line.cursor == lim - 1 &&
|
|
|
|
el->el_map.type == MAP_VI &&
|
|
|
|
el->el_chared.c_vcmd.action == NOP))
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor += el->el_state.argument;
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_line.cursor > lim)
|
|
|
|
el->el_line.cursor = lim;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_map.type == MAP_VI)
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_chared.c_vcmd.action != NOP) {
|
2000-09-05 02:06:28 +04:00
|
|
|
cv_delfini(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_prev_word():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move to the beginning of the current word
|
|
|
|
* [M-b] [b]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor == el->el_line.buffer)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = c__prev_word(el->el_line.cursor,
|
|
|
|
el->el_line.buffer,
|
|
|
|
el->el_state.argument,
|
|
|
|
ce__isword);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_map.type == MAP_VI)
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_chared.c_vcmd.action != NOP) {
|
2000-09-05 02:06:28 +04:00
|
|
|
cv_delfini(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_prev_char():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move to the left one character
|
|
|
|
* [^B] [^B]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor > el->el_line.buffer) {
|
|
|
|
el->el_line.cursor -= el->el_state.argument;
|
|
|
|
if (el->el_line.cursor < el->el_line.buffer)
|
|
|
|
el->el_line.cursor = el->el_line.buffer;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_map.type == MAP_VI)
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_chared.c_vcmd.action != NOP) {
|
2000-09-05 02:06:28 +04:00
|
|
|
cv_delfini(el);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
2000-09-05 02:06:28 +04:00
|
|
|
} else
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_quoted_insert():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Add the next character typed verbatim
|
|
|
|
* [^V] [^V]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_quoted_insert(EditLine *el, wint_t c)
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
int num;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
tty_quotemode(el);
|
2016-02-24 17:25:38 +03:00
|
|
|
num = el_wgetc(el, &c);
|
2000-09-05 02:06:28 +04:00
|
|
|
tty_noquotemode(el);
|
|
|
|
if (num == 1)
|
2011-07-29 19:16:33 +04:00
|
|
|
return ed_insert(el, c);
|
2000-09-05 02:06:28 +04:00
|
|
|
else
|
2011-07-29 19:16:33 +04:00
|
|
|
return ed_end_of_file(el, 0);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_digit():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Adds to argument or enters a digit
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_digit(EditLine *el, wint_t c)
|
2000-09-05 02:06:28 +04:00
|
|
|
{
|
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
if (!Isdigit(c))
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_state.doingarg) {
|
|
|
|
/* if doing an arg, add this in... */
|
|
|
|
if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
|
|
|
|
el->el_state.argument = c - '0';
|
|
|
|
else {
|
|
|
|
if (el->el_state.argument > 1000000)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_state.argument =
|
|
|
|
(el->el_state.argument * 10) + (c - '0');
|
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ARGHACK;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
2002-10-28 00:41:50 +03:00
|
|
|
|
|
|
|
return ed_insert(el, c);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_argument_digit():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Digit that starts argument
|
|
|
|
* For ESC-n
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_argument_digit(EditLine *el, wint_t c)
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
if (!Isdigit(c))
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
if (el->el_state.doingarg) {
|
|
|
|
if (el->el_state.argument > 1000000)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_state.argument = (el->el_state.argument * 10) +
|
|
|
|
(c - '0');
|
|
|
|
} else { /* else starting an argument */
|
|
|
|
el->el_state.argument = c - '0';
|
|
|
|
el->el_state.doingarg = 1;
|
|
|
|
}
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ARGHACK;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_unassigned():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Indicates unbound character
|
|
|
|
* Bound to keys that are not assigned
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2011-07-30 00:58:07 +04:00
|
|
|
ed_unassigned(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
** TTY key handling.
|
|
|
|
**/
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_sigint():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty interrupt character
|
|
|
|
* [^C]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1999-07-02 19:14:07 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_dsusp():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty delayed suspend character
|
|
|
|
* [^Y]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_flush_output():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty flush output characters
|
|
|
|
* [^O]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_sigquit():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty quit character
|
|
|
|
* [^\]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_sigtstp():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty suspend character
|
|
|
|
* [^Z]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_stop_output():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty disallow output characters
|
|
|
|
* [^S]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_tty_start_output():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Tty allow output characters
|
|
|
|
* [^Q]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_newline():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Execute command
|
|
|
|
* [^J]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_newline(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
re_goto_bottom(el);
|
|
|
|
*el->el_line.lastchar++ = '\n';
|
|
|
|
*el->el_line.lastchar = '\0';
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NEWLINE;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_delete_prev_char():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Delete the character to the left of the cursor
|
|
|
|
* [^?]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_line.cursor <= el->el_line.buffer)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
c_delbefore(el, el->el_state.argument);
|
|
|
|
el->el_line.cursor -= el->el_state.argument;
|
|
|
|
if (el->el_line.cursor < el->el_line.buffer)
|
|
|
|
el->el_line.cursor = el->el_line.buffer;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_clear_screen():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Clear screen leaving current line at the top
|
|
|
|
* [^L]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-28 05:05:20 +04:00
|
|
|
terminal_clear_screen(el); /* clear the whole real screen */
|
2000-09-05 02:06:28 +04:00
|
|
|
re_clear_display(el); /* reset everything */
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_redisplay():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Redisplay everything
|
|
|
|
* ^R
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REDISPLAY;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_start_over():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Erase current line and start from scratch
|
|
|
|
* [^G]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_start_over(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2005-08-02 03:00:15 +04:00
|
|
|
ch_reset(el, 0);
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_sequence_lead_in():
|
1994-05-06 10:01:42 +04:00
|
|
|
* First character in a bound sequence
|
|
|
|
* Placeholder for external keys
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
2016-02-17 22:47:49 +03:00
|
|
|
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_NORM;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_prev_history():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move to the previous history line
|
|
|
|
* [^P] [k]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2000-09-05 02:06:28 +04:00
|
|
|
char beep = 0;
|
2002-11-15 17:32:32 +03:00
|
|
|
int sv_event = el->el_history.eventno;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2002-10-28 00:41:50 +03:00
|
|
|
el->el_chared.c_undo.len = -1;
|
2000-09-05 02:06:28 +04:00
|
|
|
*el->el_line.lastchar = '\0'; /* just in case */
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_history.eventno == 0) { /* save the current buffer
|
|
|
|
* away */
|
2009-12-31 01:37:40 +03:00
|
|
|
(void) Strncpy(el->el_history.buf, el->el_line.buffer,
|
2000-09-05 02:06:28 +04:00
|
|
|
EL_BUFSIZ);
|
|
|
|
el->el_history.last = el->el_history.buf +
|
|
|
|
(el->el_line.lastchar - el->el_line.buffer);
|
|
|
|
}
|
|
|
|
el->el_history.eventno += el->el_state.argument;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (hist_get(el) == CC_ERROR) {
|
2002-11-15 17:32:32 +03:00
|
|
|
if (el->el_map.type == MAP_VI) {
|
|
|
|
el->el_history.eventno = sv_event;
|
|
|
|
}
|
2000-09-05 02:06:28 +04:00
|
|
|
beep = 1;
|
|
|
|
/* el->el_history.eventno was fixed by first call */
|
|
|
|
(void) hist_get(el);
|
|
|
|
}
|
|
|
|
if (beep)
|
2002-11-15 17:32:32 +03:00
|
|
|
return CC_REFRESH_BEEP;
|
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_next_history():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Move to the next history line
|
|
|
|
* [^N] [j]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2002-11-15 17:32:32 +03:00
|
|
|
el_action_t beep = CC_REFRESH, rval;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2002-10-28 00:41:50 +03:00
|
|
|
el->el_chared.c_undo.len = -1;
|
2000-09-05 02:06:28 +04:00
|
|
|
*el->el_line.lastchar = '\0'; /* just in case */
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_history.eventno -= el->el_state.argument;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_history.eventno < 0) {
|
|
|
|
el->el_history.eventno = 0;
|
2002-11-15 17:32:32 +03:00
|
|
|
beep = CC_REFRESH_BEEP;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
2002-11-15 17:32:32 +03:00
|
|
|
rval = hist_get(el);
|
|
|
|
if (rval == CC_REFRESH)
|
|
|
|
return beep;
|
|
|
|
return rval;
|
|
|
|
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_search_prev_history():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Search previous in history for a line matching the current
|
|
|
|
* next search history [M-P] [K]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
2000-09-05 02:06:28 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
const Char *hp;
|
2000-09-05 02:06:28 +04:00
|
|
|
int h;
|
2016-02-16 22:11:25 +03:00
|
|
|
int found = 0;
|
2000-09-05 02:06:28 +04:00
|
|
|
|
|
|
|
el->el_chared.c_vcmd.action = NOP;
|
2002-10-28 00:41:50 +03:00
|
|
|
el->el_chared.c_undo.len = -1;
|
2000-09-05 02:06:28 +04:00
|
|
|
*el->el_line.lastchar = '\0'; /* just in case */
|
|
|
|
if (el->el_history.eventno < 0) {
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef DEBUG_EDIT
|
2000-09-05 02:06:28 +04:00
|
|
|
(void) fprintf(el->el_errfile,
|
|
|
|
"e_prev_search_hist(): eventno < 0;\n");
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_history.eventno = 0;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
|
|
|
if (el->el_history.eventno == 0) {
|
2009-12-31 01:37:40 +03:00
|
|
|
(void) Strncpy(el->el_history.buf, el->el_line.buffer,
|
2000-09-05 02:06:28 +04:00
|
|
|
EL_BUFSIZ);
|
|
|
|
el->el_history.last = el->el_history.buf +
|
|
|
|
(el->el_line.lastchar - el->el_line.buffer);
|
|
|
|
}
|
|
|
|
if (el->el_history.ref == NULL)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
hp = HIST_FIRST(el);
|
|
|
|
if (hp == NULL)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
c_setpat(el); /* Set search pattern !! */
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (h = 1; h <= el->el_history.eventno; h++)
|
|
|
|
hp = HIST_NEXT(el);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
while (hp != NULL) {
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef SDEBUG
|
2000-09-05 02:06:28 +04:00
|
|
|
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2009-12-31 01:37:40 +03:00
|
|
|
if ((Strncmp(hp, el->el_line.buffer, (size_t)
|
2000-09-05 02:06:28 +04:00
|
|
|
(el->el_line.lastchar - el->el_line.buffer)) ||
|
|
|
|
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
|
|
|
c_hmatch(el, hp)) {
|
2016-02-16 22:11:25 +03:00
|
|
|
found = 1;
|
2000-09-05 02:06:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
h++;
|
|
|
|
hp = HIST_NEXT(el);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (!found) {
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef SDEBUG
|
2000-09-05 02:06:28 +04:00
|
|
|
(void) fprintf(el->el_errfile, "not found\n");
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
|
|
|
el->el_history.eventno = h;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return hist_get(el);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_search_next_history():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Search next in history for a line matching the current
|
|
|
|
* [M-N] [J]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
const Char *hp;
|
2000-09-05 02:06:28 +04:00
|
|
|
int h;
|
2016-02-16 22:11:25 +03:00
|
|
|
int found = 0;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_chared.c_vcmd.action = NOP;
|
2002-10-28 00:41:50 +03:00
|
|
|
el->el_chared.c_undo.len = -1;
|
2000-09-05 02:06:28 +04:00
|
|
|
*el->el_line.lastchar = '\0'; /* just in case */
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_history.eventno == 0)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_history.ref == NULL)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
hp = HIST_FIRST(el);
|
|
|
|
if (hp == NULL)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
c_setpat(el); /* Set search pattern !! */
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (h = 1; h < el->el_history.eventno && hp; h++) {
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef SDEBUG
|
2000-09-05 02:06:28 +04:00
|
|
|
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2009-12-31 01:37:40 +03:00
|
|
|
if ((Strncmp(hp, el->el_line.buffer, (size_t)
|
2000-09-05 02:06:28 +04:00
|
|
|
(el->el_line.lastchar - el->el_line.buffer)) ||
|
|
|
|
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
|
|
|
c_hmatch(el, hp))
|
|
|
|
found = h;
|
|
|
|
hp = HIST_NEXT(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) { /* is it the current history number? */
|
|
|
|
if (!c_hmatch(el, el->el_history.buf)) {
|
1994-05-06 10:01:42 +04:00
|
|
|
#ifdef SDEBUG
|
2000-09-05 02:06:28 +04:00
|
|
|
(void) fprintf(el->el_errfile, "not found\n");
|
1994-05-06 10:01:42 +04:00
|
|
|
#endif
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
2000-09-05 02:06:28 +04:00
|
|
|
}
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_history.eventno = found;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2011-07-29 19:16:33 +04:00
|
|
|
return hist_get(el);
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ed_prev_line():
|
|
|
|
* Move up one line
|
|
|
|
* Could be [k] [^p]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
Char *ptr;
|
2000-09-05 02:06:28 +04:00
|
|
|
int nchars = c_hpos(el);
|
1999-07-02 19:14:07 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/*
|
|
|
|
* Move to the line requested
|
|
|
|
*/
|
|
|
|
if (*(ptr = el->el_line.cursor) == '\n')
|
|
|
|
ptr--;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
for (; ptr >= el->el_line.buffer; ptr--)
|
|
|
|
if (*ptr == '\n' && --el->el_state.argument <= 0)
|
|
|
|
break;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_state.argument > 0)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/*
|
|
|
|
* Move to the beginning of the line
|
|
|
|
*/
|
|
|
|
for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
|
|
|
|
continue;
|
1999-07-02 19:14:07 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/*
|
|
|
|
* Move to the character requested
|
|
|
|
*/
|
|
|
|
for (ptr++;
|
|
|
|
nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
|
|
|
|
ptr++)
|
|
|
|
continue;
|
1999-07-02 19:14:07 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = ptr;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ed_next_line():
|
|
|
|
* Move down one line
|
|
|
|
* Could be [j] [^n]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_next_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
1994-05-06 10:01:42 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
Char *ptr;
|
2000-09-05 02:06:28 +04:00
|
|
|
int nchars = c_hpos(el);
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/*
|
|
|
|
* Move to the line requested
|
|
|
|
*/
|
|
|
|
for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
|
|
|
|
if (*ptr == '\n' && --el->el_state.argument <= 0)
|
|
|
|
break;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
if (el->el_state.argument > 0)
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_ERROR;
|
1994-05-06 10:01:42 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
/*
|
|
|
|
* Move to the character requested
|
|
|
|
*/
|
|
|
|
for (ptr++;
|
|
|
|
nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
|
|
|
|
ptr++)
|
|
|
|
continue;
|
1999-07-02 19:14:07 +04:00
|
|
|
|
2000-09-05 02:06:28 +04:00
|
|
|
el->el_line.cursor = ptr;
|
2011-07-29 19:16:33 +04:00
|
|
|
return CC_CURSOR;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-02 19:14:07 +04:00
|
|
|
/* ed_command():
|
1994-05-06 10:01:42 +04:00
|
|
|
* Editline extended command
|
|
|
|
* [M-X] [:]
|
|
|
|
*/
|
|
|
|
protected el_action_t
|
|
|
|
/*ARGSUSED*/
|
From Ingo Schwarze:
As we have seen before, "histedit.h" can never get rid of including
the <wchar.h> header because using the data types defined there is
deeply ingrained in the public interfaces of libedit.
Now POSIX unconditionally requires that <wchar.h> defines the type
wint_t. Consequently, it can be used unconditionally, no matter
whether WIDECHAR is active or not. Consequently, the #define Int
is pointless.
Note that removing it is not gratuitious churn. Auditing for
integer signedness problems is already hard when only fundamental
types like "int" and "unsigned" are involved. It gets very hard
when types come into the picture that have platform-dependent
signedness, like "char" and "wint_t". Adding yet another layer
on top, changing both the signedness and the width in a platform-
dependent way, makes auditing yet harder, which IMHO is really
dangerous. Note that while removing the #define, i already found
one bug caused by this excessive complication - in the function
re_putc() in refresh.c. If WIDECHAR was defined, it printed an
Int = wint_t value with %c. Fortunately, that bug only affects
debugging, not production. The fix is contained in the patch.
With WIDECHAR, this doesn't change anything. For the case without
WIDECHAR, i checked that none of the places wants to store values
that might not fit in wint_t.
This only changes internal interfaces; public ones remain unchanged.
2016-02-14 17:49:34 +03:00
|
|
|
ed_command(EditLine *el, wint_t c __attribute__((__unused__)))
|
2000-09-05 02:06:28 +04:00
|
|
|
{
|
2009-12-31 01:37:40 +03:00
|
|
|
Char tmpbuf[EL_BUFSIZ];
|
2000-09-05 02:06:28 +04:00
|
|
|
int tmplen;
|
|
|
|
|
2009-12-31 01:37:40 +03:00
|
|
|
tmplen = c_gets(el, tmpbuf, STR("\n: "));
|
2011-07-28 05:05:20 +04:00
|
|
|
terminal__putc(el, '\n');
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2002-11-20 19:50:08 +03:00
|
|
|
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
|
2011-07-28 05:05:20 +04:00
|
|
|
terminal_beep(el);
|
2000-09-05 02:06:28 +04:00
|
|
|
|
2002-11-20 19:50:08 +03:00
|
|
|
el->el_map.current = el->el_map.key;
|
|
|
|
re_clear_display(el);
|
|
|
|
return CC_REFRESH;
|
1994-05-06 10:01:42 +04:00
|
|
|
}
|