mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-19 16:23:29 +00:00
Merge a small update from NetBSD.
Feb 15 21:55:23 2009 - chared.c chared.h pass lint on _LP64. MFC after: 1 week
This commit is contained in:
parent
f95a30bd6a
commit
a880c5109e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=238178
|
@ -29,7 +29,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $
|
||||
* $NetBSD: chared.c,v 1.27 2009/02/15 21:55:23 christos Exp $
|
||||
*/
|
||||
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
|
@ -59,12 +59,12 @@ cv_undo(EditLine *el)
|
|||
{
|
||||
c_undo_t *vu = &el->el_chared.c_undo;
|
||||
c_redo_t *r = &el->el_chared.c_redo;
|
||||
unsigned int size;
|
||||
size_t 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;
|
||||
vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer);
|
||||
memcpy(vu->buf, el->el_line.buffer, size);
|
||||
|
||||
/* save command info for redo */
|
||||
|
@ -83,7 +83,7 @@ cv_yank(EditLine *el, const char *ptr, int size)
|
|||
{
|
||||
c_kill_t *k = &el->el_chared.c_kill;
|
||||
|
||||
memcpy(k->buf, ptr, size +0u);
|
||||
memcpy(k->buf, ptr, (size_t)size);
|
||||
k->last = k->buf + size;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ c_insert(EditLine *el, int num)
|
|||
char *cp;
|
||||
|
||||
if (el->el_line.lastchar + num >= el->el_line.limit) {
|
||||
if (!ch_enlargebufs(el, num +0u))
|
||||
if (!ch_enlargebufs(el, (size_t)num))
|
||||
return; /* can't go past end of buffer */
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ c_delafter(EditLine *el, int num)
|
|||
{
|
||||
|
||||
if (el->el_line.cursor + num > el->el_line.lastchar)
|
||||
num = el->el_line.lastchar - el->el_line.cursor;
|
||||
num = (int)(el->el_line.lastchar - el->el_line.cursor);
|
||||
|
||||
if (el->el_map.current != el->el_map.emacs) {
|
||||
cv_undo(el);
|
||||
|
@ -159,7 +159,7 @@ c_delbefore(EditLine *el, int num)
|
|||
{
|
||||
|
||||
if (el->el_line.cursor - num < el->el_line.buffer)
|
||||
num = el->el_line.cursor - el->el_line.buffer;
|
||||
num = (int)(el->el_line.cursor - el->el_line.buffer);
|
||||
|
||||
if (el->el_map.current != el->el_map.emacs) {
|
||||
cv_undo(el);
|
||||
|
@ -375,7 +375,7 @@ cv_delfini(EditLine *el)
|
|||
/* sanity */
|
||||
return;
|
||||
|
||||
size = el->el_line.cursor - el->el_chared.c_vcmd.pos;
|
||||
size = (int)(el->el_line.cursor - el->el_chared.c_vcmd.pos);
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
el->el_line.cursor = el->el_chared.c_vcmd.pos;
|
||||
|
@ -529,8 +529,7 @@ ch_reset(EditLine *el, int mclear)
|
|||
}
|
||||
|
||||
private void
|
||||
ch__clearmacro(el)
|
||||
EditLine *el;
|
||||
ch__clearmacro(EditLine *el)
|
||||
{
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
while (ma->level >= 0)
|
||||
|
@ -542,9 +541,7 @@ ch__clearmacro(el)
|
|||
* Returns 1 if successful, 0 if not.
|
||||
*/
|
||||
protected int
|
||||
ch_enlargebufs(el, addlen)
|
||||
EditLine *el;
|
||||
size_t addlen;
|
||||
ch_enlargebufs(EditLine *el, size_t addlen)
|
||||
{
|
||||
size_t sz, newsz;
|
||||
char *newbuffer, *oldbuf, *oldkbuf;
|
||||
|
@ -695,12 +692,12 @@ protected int
|
|||
c_gets(EditLine *el, char *buf, const char *prompt)
|
||||
{
|
||||
char ch;
|
||||
int len;
|
||||
ssize_t len;
|
||||
char *cp = el->el_line.buffer;
|
||||
|
||||
if (prompt) {
|
||||
len = strlen(prompt);
|
||||
memcpy(cp, prompt, len + 0u);
|
||||
memcpy(cp, prompt, (size_t)len);
|
||||
cp += len;
|
||||
}
|
||||
len = 0;
|
||||
|
@ -721,7 +718,7 @@ c_gets(EditLine *el, char *buf, const char *prompt)
|
|||
|
||||
case '\010': /* Delete and backspace */
|
||||
case '\177':
|
||||
if (len <= 0) {
|
||||
if (len == 0) {
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
|
@ -749,7 +746,7 @@ c_gets(EditLine *el, char *buf, const char *prompt)
|
|||
el->el_line.buffer[0] = '\0';
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return len;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
|
||||
|
@ -771,6 +768,6 @@ c_hpos(EditLine *el)
|
|||
ptr >= el->el_line.buffer && *ptr != '\n';
|
||||
ptr--)
|
||||
continue;
|
||||
return (el->el_line.cursor - ptr - 1);
|
||||
return (int)(el->el_line.cursor - ptr - 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)chared.h 8.1 (Berkeley) 6/4/93
|
||||
* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $
|
||||
* $NetBSD: chared.h,v 1.18 2009/02/15 21:55:23 christos Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
@ -70,7 +70,7 @@ typedef struct c_macro_t {
|
|||
* Undo information for vi - no undo in emacs (yet)
|
||||
*/
|
||||
typedef struct c_undo_t {
|
||||
int len; /* length of saved line */
|
||||
ssize_t len; /* length of saved line */
|
||||
int cursor; /* position of saved cursor */
|
||||
char *buf; /* full saved text */
|
||||
} c_undo_t;
|
||||
|
|
Loading…
Reference in a new issue