Make this compile under linux
This commit is contained in:
parent
41c6b0167f
commit
c3f0ff041d
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: readline.c,v 1.5 1998/12/12 19:54:16 christos Exp $ */
|
||||
/* $NetBSD: readline.c,v 1.6 1999/06/12 18:58:05 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: readline.c,v 1.5 1998/12/12 19:54:16 christos Exp $");
|
||||
__RCSID("$NetBSD: readline.c,v 1.6 1999/06/12 18:58:05 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -1169,10 +1169,10 @@ filename_completion_function(text, state)
|
||||
/* otherwise, get first entry where first */
|
||||
/* filename_len characters are equal */
|
||||
if (entry->d_name[0] == filename[0]
|
||||
#ifndef __SVR4
|
||||
&& entry->d_namlen >= filename_len
|
||||
#else
|
||||
#if defined(__SVR4) || defined(__linux__)
|
||||
&& strlen(entry->d_name) >= filename_len
|
||||
#else
|
||||
&& entry->d_namlen >= filename_len
|
||||
#endif
|
||||
&& strncmp(entry->d_name, filename,
|
||||
filename_len) == 0)
|
||||
@ -1182,10 +1182,10 @@ filename_completion_function(text, state)
|
||||
if (entry) { /* match found */
|
||||
|
||||
struct stat stbuf;
|
||||
#ifndef __SVR4
|
||||
len = entry->d_namlen +
|
||||
#else
|
||||
#if defined(__SVR4) || defined(__linux__)
|
||||
len = strlen(entry->d_name) +
|
||||
#else
|
||||
len = entry->d_namlen +
|
||||
#endif
|
||||
((dirname) ? strlen(dirname) : 0) + 1 + 1;
|
||||
temp = malloc(len);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: refresh.c,v 1.6 1999/02/05 20:53:50 christos Exp $ */
|
||||
/* $NetBSD: refresh.c,v 1.7 1999/06/12 18:58:05 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: refresh.c,v 1.6 1999/02/05 20:53:50 christos Exp $");
|
||||
__RCSID("$NetBSD: refresh.c,v 1.7 1999/06/12 18:58:05 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -71,7 +71,7 @@ private void re__copy_and_pad __P((char *, char *, size_t));
|
||||
private void re_printstr __P((EditLine *, char *, char *,
|
||||
char *));
|
||||
# define __F el->el_errfile
|
||||
# define RE_DEBUG(a, b, c) do \
|
||||
# define ELRE_DEBUG(a, b, c) do \
|
||||
if (a) { \
|
||||
(void) fprintf b; \
|
||||
c; \
|
||||
@ -86,13 +86,13 @@ re_printstr(el, str, f, t)
|
||||
char *str;
|
||||
char *f, *t;
|
||||
{
|
||||
RE_DEBUG(1,(__F, "%s:\"", str),);
|
||||
ELRE_DEBUG(1,(__F, "%s:\"", str),);
|
||||
while (f < t)
|
||||
RE_DEBUG(1,(__F, "%c", *f++ & 0177),);
|
||||
RE_DEBUG(1,(__F, "\"\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "%c", *f++ & 0177),);
|
||||
ELRE_DEBUG(1,(__F, "\"\r\n"),);
|
||||
}
|
||||
#else
|
||||
# define RE_DEBUG(a, b, c)
|
||||
# define ELRE_DEBUG(a, b, c)
|
||||
#endif
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ re_putc(el, c)
|
||||
EditLine *el;
|
||||
int c;
|
||||
{
|
||||
RE_DEBUG(1,(__F, "printing %3.3o '%c'\r\n", c, c),);
|
||||
ELRE_DEBUG(1,(__F, "printing %3.3o '%c'\r\n", c, c),);
|
||||
|
||||
el->el_vdisplay[el->el_refresh.r_cursor.v][el->el_refresh.r_cursor.h] = c;
|
||||
el->el_refresh.r_cursor.h++; /* advance to next place */
|
||||
@ -155,7 +155,7 @@ re_putc(el, c)
|
||||
/* assure end of line */
|
||||
el->el_refresh.r_cursor.h = 0; /* reset it. */
|
||||
el->el_refresh.r_cursor.v++;
|
||||
RE_DEBUG(el->el_refresh.r_cursor.v >= el->el_term.t_size.v,
|
||||
ELRE_DEBUG(el->el_refresh.r_cursor.v >= el->el_term.t_size.v,
|
||||
(__F, "\r\nre_putc: overflow! r_cursor.v == %d > %d\r\n",
|
||||
el->el_refresh.r_cursor.v, el->el_term.t_size.v), abort());
|
||||
}
|
||||
@ -176,7 +176,7 @@ re_refresh(el)
|
||||
char *cp;
|
||||
coord_t cur;
|
||||
|
||||
RE_DEBUG(1,(__F, "el->el_line.buffer = :%s:\r\n", el->el_line.buffer),);
|
||||
ELRE_DEBUG(1,(__F, "el->el_line.buffer = :%s:\r\n", el->el_line.buffer),);
|
||||
|
||||
/* reset the Drawing cursor */
|
||||
el->el_refresh.r_cursor.h = 0;
|
||||
@ -204,12 +204,12 @@ re_refresh(el)
|
||||
el->el_refresh.r_newcv = el->el_refresh.r_cursor.v;
|
||||
re_putc(el, '\0'); /* put NUL on end */
|
||||
|
||||
RE_DEBUG(1,(__F,
|
||||
ELRE_DEBUG(1,(__F,
|
||||
"term.h=%d vcur.h=%d vcur.v=%d vdisplay[0]=\r\n:%80.80s:\r\n",
|
||||
el->el_term.t_size.h, el->el_refresh.r_cursor.h,
|
||||
el->el_refresh.r_cursor.v, el->el_vdisplay[0]),);
|
||||
|
||||
RE_DEBUG(1,(__F, "updating %d lines.\r\n", el->el_refresh.r_newcv),);
|
||||
ELRE_DEBUG(1,(__F, "updating %d lines.\r\n", el->el_refresh.r_newcv),);
|
||||
for (i = 0; i <= el->el_refresh.r_newcv; i++) {
|
||||
/* NOTE THAT re_update_line MAY CHANGE el_display[i] */
|
||||
re_update_line(el, el->el_display[i], el->el_vdisplay[i], i);
|
||||
@ -223,7 +223,7 @@ re_refresh(el)
|
||||
re__copy_and_pad(el->el_display[i], el->el_vdisplay[i],
|
||||
(size_t)el->el_term.t_size.h);
|
||||
}
|
||||
RE_DEBUG(1,(__F,
|
||||
ELRE_DEBUG(1,(__F,
|
||||
"\r\nel->el_refresh.r_cursor.v=%d,el->el_refresh.r_oldcv=%d i=%d\r\n",
|
||||
el->el_refresh.r_cursor.v, el->el_refresh.r_oldcv, i),);
|
||||
|
||||
@ -239,7 +239,7 @@ re_refresh(el)
|
||||
}
|
||||
|
||||
el->el_refresh.r_oldcv = el->el_refresh.r_newcv; /* set for next time */
|
||||
RE_DEBUG(1,(__F,
|
||||
ELRE_DEBUG(1,(__F,
|
||||
"\r\ncursor.h = %d, cursor.v = %d, cur.h = %d, cur.v = %d\r\n",
|
||||
el->el_refresh.r_cursor.h, el->el_refresh.r_cursor.v,
|
||||
cur.h, cur.v),);
|
||||
@ -283,9 +283,9 @@ re_insert(el, d, dat, dlen, s, num)
|
||||
if (num > dlen - dat)
|
||||
num = dlen - dat;
|
||||
|
||||
RE_DEBUG(1,(__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
|
||||
ELRE_DEBUG(1,(__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
|
||||
num, dat, dlen, d),);
|
||||
RE_DEBUG(1,(__F, "s == \"%s\"n", s),);
|
||||
ELRE_DEBUG(1,(__F, "s == \"%s\"n", s),);
|
||||
|
||||
/* open up the space for num chars */
|
||||
if (num > 0) {
|
||||
@ -295,18 +295,18 @@ re_insert(el, d, dat, dlen, s, num)
|
||||
*b-- = *a--;
|
||||
d[dlen] = '\0'; /* just in case */
|
||||
}
|
||||
RE_DEBUG(1,(__F,
|
||||
ELRE_DEBUG(1,(__F,
|
||||
"re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
|
||||
num, dat, dlen, d),);
|
||||
RE_DEBUG(1,(__F, "s == \"%s\"n", s),);
|
||||
ELRE_DEBUG(1,(__F, "s == \"%s\"n", s),);
|
||||
|
||||
/* copy the characters */
|
||||
for (a = d + dat; (a < d + dlen) && (num > 0); num--)
|
||||
*a++ = *s++;
|
||||
|
||||
RE_DEBUG(1,(__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n",
|
||||
ELRE_DEBUG(1,(__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n",
|
||||
num, dat, dlen, d, s),);
|
||||
RE_DEBUG(1,(__F, "s == \"%s\"n", s),);
|
||||
ELRE_DEBUG(1,(__F, "s == \"%s\"n", s),);
|
||||
} /* end re_insert */
|
||||
|
||||
|
||||
@ -329,7 +329,7 @@ re_delete(el, d, dat, dlen, num)
|
||||
return;
|
||||
}
|
||||
|
||||
RE_DEBUG(1,(__F, "re_delete() starting: %d at %d max %d, d == \"%s\"\n",
|
||||
ELRE_DEBUG(1,(__F, "re_delete() starting: %d at %d max %d, d == \"%s\"\n",
|
||||
num, dat, dlen, d),);
|
||||
|
||||
/* open up the space for num chars */
|
||||
@ -340,7 +340,7 @@ re_delete(el, d, dat, dlen, num)
|
||||
*b++ = *a++;
|
||||
d[dlen] = '\0'; /* just in case */
|
||||
}
|
||||
RE_DEBUG(1,(__F, "re_delete() after delete: %d at %d max %d, d == \"%s\"\n",
|
||||
ELRE_DEBUG(1,(__F, "re_delete() after delete: %d at %d max %d, d == \"%s\"\n",
|
||||
num, dat, dlen, d),);
|
||||
} /* end re_delete */
|
||||
|
||||
@ -434,7 +434,7 @@ re_update_line(el, old, new, i)
|
||||
* if no diff, continue to next line of redraw
|
||||
*/
|
||||
if (*ofd == '\0' && *nfd == '\0') {
|
||||
RE_DEBUG(1,(__F, "no difference.\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "no difference.\r\n"),);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -575,14 +575,14 @@ re_update_line(el, old, new, i)
|
||||
fx = (nsb - nfd) - (osb - ofd);
|
||||
sx = (nls - nse) - (ols - ose);
|
||||
|
||||
RE_DEBUG(1,(__F, "\n"),);
|
||||
RE_DEBUG(1,(__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
|
||||
ELRE_DEBUG(1,(__F, "\n"),);
|
||||
ELRE_DEBUG(1,(__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
|
||||
ofd - old, osb - old, ose - old, ols - old, oe - old),);
|
||||
RE_DEBUG(1,(__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
|
||||
ELRE_DEBUG(1,(__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
|
||||
nfd - new, nsb - new, nse - new, nls - new, ne - new),);
|
||||
RE_DEBUG(1,(__F,
|
||||
ELRE_DEBUG(1,(__F,
|
||||
"xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n"),);
|
||||
RE_DEBUG(1,(__F,
|
||||
ELRE_DEBUG(1,(__F,
|
||||
"xxx-xxx:\"01234567890123456789012345678901234567890\"\r\n"),);
|
||||
#ifdef DEBUG_REFRESH
|
||||
re_printstr(el, "old- oe", old, oe);
|
||||
@ -646,7 +646,7 @@ re_update_line(el, old, new, i)
|
||||
* We need to delete characters! else No insert or delete
|
||||
*/
|
||||
if ((nsb != nfd) && fx > 0 && ((p - old) + fx <= el->el_term.t_size.h)) {
|
||||
RE_DEBUG(1,(__F, "first diff insert at %d...\r\n", nfd - new),);
|
||||
ELRE_DEBUG(1,(__F, "first diff insert at %d...\r\n", nfd - new),);
|
||||
/*
|
||||
* Move to the first char to insert, where the first diff is.
|
||||
*/
|
||||
@ -655,12 +655,12 @@ re_update_line(el, old, new, i)
|
||||
* Check if we have stuff to keep at end
|
||||
*/
|
||||
if (nsb != ne) {
|
||||
RE_DEBUG(1,(__F, "with stuff to keep at end\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "with stuff to keep at end\r\n"),);
|
||||
/*
|
||||
* insert fx chars of new starting at nfd
|
||||
*/
|
||||
if (fx > 0) {
|
||||
RE_DEBUG(!EL_CAN_INSERT,
|
||||
ELRE_DEBUG(!EL_CAN_INSERT,
|
||||
(__F, "ERROR: cannot insert in early first diff\n"),);
|
||||
term_insertwrite(el, nfd, fx);
|
||||
re_insert(el, old, ofd - old, el->el_term.t_size.h, nfd, fx);
|
||||
@ -672,7 +672,7 @@ re_update_line(el, old, new, i)
|
||||
re__strncopy(ofd + fx, nfd + fx, (size_t)((nsb - nfd) - fx));
|
||||
}
|
||||
else {
|
||||
RE_DEBUG(1,(__F, "without anything to save\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "without anything to save\r\n"),);
|
||||
term_overwrite(el, nfd, (nsb - nfd));
|
||||
re__strncopy(ofd, nfd, (size_t)(nsb - nfd));
|
||||
/*
|
||||
@ -682,7 +682,7 @@ re_update_line(el, old, new, i)
|
||||
}
|
||||
}
|
||||
else if (fx < 0) {
|
||||
RE_DEBUG(1,(__F, "first diff delete at %d...\r\n", ofd - old),);
|
||||
ELRE_DEBUG(1,(__F, "first diff delete at %d...\r\n", ofd - old),);
|
||||
/*
|
||||
* move to the first char to delete where the first diff is
|
||||
*/
|
||||
@ -691,13 +691,13 @@ re_update_line(el, old, new, i)
|
||||
* Check if we have stuff to save
|
||||
*/
|
||||
if (osb != oe) {
|
||||
RE_DEBUG(1,(__F, "with stuff to save at end\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "with stuff to save at end\r\n"),);
|
||||
/*
|
||||
* fx is less than zero *always* here but we check for code
|
||||
* symmetry
|
||||
*/
|
||||
if (fx < 0) {
|
||||
RE_DEBUG(!EL_CAN_DELETE,
|
||||
ELRE_DEBUG(!EL_CAN_DELETE,
|
||||
(__F, "ERROR: cannot delete in first diff\n"),);
|
||||
term_deletechars(el, -fx);
|
||||
re_delete(el, old, ofd - old, el->el_term.t_size.h, -fx);
|
||||
@ -710,12 +710,12 @@ re_update_line(el, old, new, i)
|
||||
|
||||
}
|
||||
else {
|
||||
RE_DEBUG(1,(__F, "but with nothing left to save\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "but with nothing left to save\r\n"),);
|
||||
/*
|
||||
* write (nsb-nfd) chars of new starting at nfd
|
||||
*/
|
||||
term_overwrite(el, nfd, (nsb - nfd));
|
||||
RE_DEBUG(1,(__F, "cleareol %d\n", (oe - old) - (ne - new)),);
|
||||
ELRE_DEBUG(1,(__F, "cleareol %d\n", (oe - old) - (ne - new)),);
|
||||
term_clear_EOL(el, (oe - old) - (ne - new));
|
||||
/*
|
||||
* Done
|
||||
@ -727,7 +727,7 @@ re_update_line(el, old, new, i)
|
||||
fx = 0;
|
||||
|
||||
if (sx < 0) {
|
||||
RE_DEBUG(1,(__F, "second diff delete at %d...\r\n", (ose - old) + fx),);
|
||||
ELRE_DEBUG(1,(__F, "second diff delete at %d...\r\n", (ose - old) + fx),);
|
||||
/*
|
||||
* Check if we have stuff to delete
|
||||
*/
|
||||
@ -740,12 +740,12 @@ re_update_line(el, old, new, i)
|
||||
* Check if we have stuff to save
|
||||
*/
|
||||
if (ols != oe) {
|
||||
RE_DEBUG(1,(__F, "with stuff to save at end\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "with stuff to save at end\r\n"),);
|
||||
/*
|
||||
* Again a duplicate test.
|
||||
*/
|
||||
if (sx < 0) {
|
||||
RE_DEBUG(!EL_CAN_DELETE,
|
||||
ELRE_DEBUG(!EL_CAN_DELETE,
|
||||
(__F, "ERROR: cannot delete in second diff\n"),);
|
||||
term_deletechars(el, -sx);
|
||||
}
|
||||
@ -756,9 +756,9 @@ re_update_line(el, old, new, i)
|
||||
term_overwrite(el, nse, (nls - nse));
|
||||
}
|
||||
else {
|
||||
RE_DEBUG(1,(__F, "but with nothing left to save\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "but with nothing left to save\r\n"),);
|
||||
term_overwrite(el, nse, (nls - nse));
|
||||
RE_DEBUG(1,(__F, "cleareol %d\n", (oe - old) - (ne - new)),);
|
||||
ELRE_DEBUG(1,(__F, "cleareol %d\n", (oe - old) - (ne - new)),);
|
||||
term_clear_EOL(el, (oe - old) - (ne - new));
|
||||
}
|
||||
}
|
||||
@ -767,14 +767,14 @@ re_update_line(el, old, new, i)
|
||||
* if we have a first insert AND WE HAVEN'T ALREADY DONE IT...
|
||||
*/
|
||||
if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) {
|
||||
RE_DEBUG(1,(__F, "late first diff insert at %d...\r\n", nfd - new),);
|
||||
ELRE_DEBUG(1,(__F, "late first diff insert at %d...\r\n", nfd - new),);
|
||||
|
||||
term_move_to_char(el, nfd - new);
|
||||
/*
|
||||
* Check if we have stuff to keep at the end
|
||||
*/
|
||||
if (nsb != ne) {
|
||||
RE_DEBUG(1,(__F, "with stuff to keep at end\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "with stuff to keep at end\r\n"),);
|
||||
/*
|
||||
* We have to recalculate fx here because we set it
|
||||
* to zero above as a flag saying that we hadn't done
|
||||
@ -785,7 +785,7 @@ re_update_line(el, old, new, i)
|
||||
/*
|
||||
* insert fx chars of new starting at nfd
|
||||
*/
|
||||
RE_DEBUG(!EL_CAN_INSERT,
|
||||
ELRE_DEBUG(!EL_CAN_INSERT,
|
||||
(__F, "ERROR: cannot insert in late first diff\n"),);
|
||||
term_insertwrite(el, nfd, fx);
|
||||
re_insert(el, old, ofd - old, el->el_term.t_size.h, nfd, fx);
|
||||
@ -798,7 +798,7 @@ re_update_line(el, old, new, i)
|
||||
re__strncopy(ofd + fx, nfd + fx, (size_t)((nsb - nfd) - fx));
|
||||
}
|
||||
else {
|
||||
RE_DEBUG(1,(__F, "without anything to save\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "without anything to save\r\n"),);
|
||||
term_overwrite(el, nfd, (nsb - nfd));
|
||||
re__strncopy(ofd, nfd, (size_t)(nsb - nfd));
|
||||
}
|
||||
@ -808,13 +808,13 @@ re_update_line(el, old, new, i)
|
||||
* line is now NEW up to nse
|
||||
*/
|
||||
if (sx >= 0) {
|
||||
RE_DEBUG(1,(__F, "second diff insert at %d...\r\n", nse - new),);
|
||||
ELRE_DEBUG(1,(__F, "second diff insert at %d...\r\n", nse - new),);
|
||||
term_move_to_char(el, nse - new);
|
||||
if (ols != oe) {
|
||||
RE_DEBUG(1,(__F, "with stuff to keep at end\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "with stuff to keep at end\r\n"),);
|
||||
if (sx > 0) {
|
||||
/* insert sx chars of new starting at nse */
|
||||
RE_DEBUG(!EL_CAN_INSERT,
|
||||
ELRE_DEBUG(!EL_CAN_INSERT,
|
||||
(__F, "ERROR: cannot insert in second diff\n"),);
|
||||
term_insertwrite(el, nse, sx);
|
||||
}
|
||||
@ -825,7 +825,7 @@ re_update_line(el, old, new, i)
|
||||
term_overwrite(el, nse + sx, (nls - nse) - sx);
|
||||
}
|
||||
else {
|
||||
RE_DEBUG(1,(__F, "without anything to save\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "without anything to save\r\n"),);
|
||||
term_overwrite(el, nse, (nls - nse));
|
||||
|
||||
/*
|
||||
@ -835,7 +835,7 @@ re_update_line(el, old, new, i)
|
||||
*/
|
||||
}
|
||||
}
|
||||
RE_DEBUG(1,(__F, "done.\r\n"),);
|
||||
ELRE_DEBUG(1,(__F, "done.\r\n"),);
|
||||
} /* re_update_line */
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user