summaryrefslogtreecommitdiff
path: root/lib/libedit/history.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-01-30 17:32:53 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-01-30 17:32:53 +0000
commitd1ec769799b45cbcf9aa8e23df4d354dc487625a (patch)
tree4df0e61127ed12979816be824a3d3a38cf556b48 /lib/libedit/history.c
parent6ef516ee5df5d88f456513181817254692408279 (diff)
Fifth step in synching with NetBSD:
Delete the silly ptr_t and ioctl_t typedefs and delete some "#ifdef notdef" code from "sys.h". No functional change. This makes hist.h identical to the NetBSD version. It reduces the remaining diff from +1526 -734 to +1430 -592. OK czarkoff@
Diffstat (limited to 'lib/libedit/history.c')
-rw-r--r--lib/libedit/history.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/libedit/history.c b/lib/libedit/history.c
index d978522d37c..cbe9d0ce33b 100644
--- a/lib/libedit/history.c
+++ b/lib/libedit/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.20 2016/01/30 12:22:20 schwarze Exp $ */
+/* $OpenBSD: history.c,v 1.21 2016/01/30 17:32:52 schwarze Exp $ */
/* $NetBSD: history.c,v 1.37 2010/01/03 18:27:10 christos Exp $ */
/*-
@@ -53,13 +53,13 @@ static const char hist_cookie[] = "_HiStOrY_V2_\n";
#include "histedit.h"
#include "chartype.h"
-typedef int (*history_gfun_t)(ptr_t, TYPE(HistEvent) *);
-typedef int (*history_efun_t)(ptr_t, TYPE(HistEvent) *, const Char *);
-typedef void (*history_vfun_t)(ptr_t, TYPE(HistEvent) *);
-typedef int (*history_sfun_t)(ptr_t, TYPE(HistEvent) *, const int);
+typedef int (*history_gfun_t)(void *, TYPE(HistEvent) *);
+typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *);
+typedef void (*history_vfun_t)(void *, TYPE(HistEvent) *);
+typedef int (*history_sfun_t)(void *, TYPE(HistEvent) *, const int);
struct TYPE(history) {
- ptr_t h_ref; /* Argument for history fcns */
+ void *h_ref; /* Argument for history fcns */
int h_ent; /* Last entry point for history */
history_gfun_t h_first; /* Get the first element */
history_gfun_t h_next; /* Get the next element */
@@ -129,23 +129,23 @@ typedef struct history_t {
#define H_UNIQUE 1 /* Store only unique elements */
} history_t;
-private int history_def_next(ptr_t, TYPE(HistEvent) *);
-private int history_def_first(ptr_t, TYPE(HistEvent) *);
-private int history_def_prev(ptr_t, TYPE(HistEvent) *);
-private int history_def_last(ptr_t, TYPE(HistEvent) *);
-private int history_def_curr(ptr_t, TYPE(HistEvent) *);
-private int history_def_set(ptr_t, TYPE(HistEvent) *, const int);
-private void history_def_clear(ptr_t, TYPE(HistEvent) *);
-private int history_def_enter(ptr_t, TYPE(HistEvent) *, const Char *);
-private int history_def_add(ptr_t, TYPE(HistEvent) *, const Char *);
-private int history_def_del(ptr_t, TYPE(HistEvent) *, const int);
-
-private int history_def_init(ptr_t *, TYPE(HistEvent) *, int);
+private int history_def_next(void *, TYPE(HistEvent) *);
+private int history_def_first(void *, TYPE(HistEvent) *);
+private int history_def_prev(void *, TYPE(HistEvent) *);
+private int history_def_last(void *, TYPE(HistEvent) *);
+private int history_def_curr(void *, TYPE(HistEvent) *);
+private int history_def_set(void *, TYPE(HistEvent) *, const int);
+private void history_def_clear(void *, TYPE(HistEvent) *);
+private int history_def_enter(void *, TYPE(HistEvent) *, const Char *);
+private int history_def_add(void *, TYPE(HistEvent) *, const Char *);
+private int history_def_del(void *, TYPE(HistEvent) *, const int);
+
+private int history_def_init(void **, TYPE(HistEvent) *, int);
private int history_def_insert(history_t *, TYPE(HistEvent) *, const Char *);
private void history_def_delete(history_t *, TYPE(HistEvent) *, hentry_t *);
private int history_deldata_nth(history_t *, TYPE(HistEvent) *, int, void **);
-private int history_set_nth(ptr_t, TYPE(HistEvent) *, int);
+private int history_set_nth(void *, TYPE(HistEvent) *, int);
#define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num))
#define history_def_getsize(p) (((history_t *)p)->cur)
@@ -203,7 +203,7 @@ static const Char *const he_errlist[] = {
* Default function to return the first event in the history.
*/
private int
-history_def_first(ptr_t p, TYPE(HistEvent) *ev)
+history_def_first(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -223,7 +223,7 @@ history_def_first(ptr_t p, TYPE(HistEvent) *ev)
* Default function to return the last event in the history.
*/
private int
-history_def_last(ptr_t p, TYPE(HistEvent) *ev)
+history_def_last(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -243,7 +243,7 @@ history_def_last(ptr_t p, TYPE(HistEvent) *ev)
* Default function to return the next event in the history.
*/
private int
-history_def_next(ptr_t p, TYPE(HistEvent) *ev)
+history_def_next(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -268,7 +268,7 @@ history_def_next(ptr_t p, TYPE(HistEvent) *ev)
* Default function to return the previous event in the history.
*/
private int
-history_def_prev(ptr_t p, TYPE(HistEvent) *ev)
+history_def_prev(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -294,7 +294,7 @@ history_def_prev(ptr_t p, TYPE(HistEvent) *ev)
* Default function to return the current event in the history.
*/
private int
-history_def_curr(ptr_t p, TYPE(HistEvent) *ev)
+history_def_curr(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -315,7 +315,7 @@ history_def_curr(ptr_t p, TYPE(HistEvent) *ev)
* given one.
*/
private int
-history_def_set(ptr_t p, TYPE(HistEvent) *ev, const int n)
+history_def_set(void *p, TYPE(HistEvent) *ev, const int n)
{
history_t *h = (history_t *) p;
@@ -342,7 +342,7 @@ history_def_set(ptr_t p, TYPE(HistEvent) *ev, const int n)
* n-th one.
*/
private int
-history_set_nth(ptr_t p, TYPE(HistEvent) *ev, int n)
+history_set_nth(void *p, TYPE(HistEvent) *ev, int n)
{
history_t *h = (history_t *) p;
@@ -366,7 +366,7 @@ history_set_nth(ptr_t p, TYPE(HistEvent) *ev, int n)
* Append string to element
*/
private int
-history_def_add(ptr_t p, TYPE(HistEvent) *ev, const Char *str)
+history_def_add(void *p, TYPE(HistEvent) *ev, const Char *str)
{
history_t *h = (history_t *) p;
size_t len;
@@ -384,7 +384,7 @@ history_def_add(ptr_t p, TYPE(HistEvent) *ev, const Char *str)
(void) Strncpy(s, h->cursor->ev.str, len);
s[len - 1] = '\0';
(void) Strncat(s, str, len - Strlen(s) - 1);
- free((ptr_t)evp->str);
+ free(evp->str);
evp->str = s;
*ev = h->cursor->ev;
return 0;
@@ -414,7 +414,7 @@ history_deldata_nth(history_t *h, TYPE(HistEvent) *ev,
*/
/* ARGSUSED */
private int
-history_def_del(ptr_t p, TYPE(HistEvent) *ev __attribute__((__unused__)),
+history_def_del(void *p, TYPE(HistEvent) *ev __attribute__((__unused__)),
const int num)
{
history_t *h = (history_t *) p;
@@ -445,7 +445,7 @@ history_def_delete(history_t *h,
}
hp->prev->next = hp->next;
hp->next->prev = hp->prev;
- free((ptr_t) evp->str);
+ free(evp->str);
free(hp);
h->cur--;
}
@@ -462,7 +462,7 @@ history_def_insert(history_t *h, TYPE(HistEvent) *ev, const Char *str)
if (h->cursor == NULL)
goto oomem;
if ((h->cursor->ev.str = h_strdup(str)) == NULL) {
- free((ptr_t)h->cursor);
+ free(h->cursor);
goto oomem;
}
h->cursor->data = NULL;
@@ -485,7 +485,7 @@ oomem:
* Default function to enter an item in the history
*/
private int
-history_def_enter(ptr_t p, TYPE(HistEvent) *ev, const Char *str)
+history_def_enter(void *p, TYPE(HistEvent) *ev, const Char *str)
{
history_t *h = (history_t *) p;
@@ -512,7 +512,7 @@ history_def_enter(ptr_t p, TYPE(HistEvent) *ev, const Char *str)
*/
/* ARGSUSED */
private int
-history_def_init(ptr_t *p, TYPE(HistEvent) *ev __attribute__((__unused__)), int n)
+history_def_init(void **p, TYPE(HistEvent) *ev __attribute__((__unused__)), int n)
{
history_t *h = (history_t *) malloc(sizeof(history_t));
if (h == NULL)
@@ -528,7 +528,7 @@ history_def_init(ptr_t *p, TYPE(HistEvent) *ev __attribute__((__unused__)), int
h->list.ev.num = 0;
h->cursor = &h->list;
h->flags = 0;
- *p = (ptr_t) h;
+ *p = h;
return 0;
}
@@ -537,7 +537,7 @@ history_def_init(ptr_t *p, TYPE(HistEvent) *ev __attribute__((__unused__)), int
* Default history cleanup function
*/
private void
-history_def_clear(ptr_t p, TYPE(HistEvent) *ev)
+history_def_clear(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -564,7 +564,7 @@ FUN(history,init)(void)
return NULL;
if (history_def_init(&h->h_ref, &ev, 0) == -1) {
- free((ptr_t)h);
+ free(h);
return NULL;
}
h->h_ent = -1;
@@ -774,7 +774,7 @@ history_load(TYPE(History) *h, const char *fname)
}
}
oomem:
- free((ptr_t)ptr);
+ free(ptr);
done:
free(lbuf);
(void) fclose(fp);
@@ -822,7 +822,7 @@ history_save_fp(TYPE(History) *h, FILE *fp)
(void) fprintf(fp, "%s\n", ptr);
}
oomem:
- free((ptr_t)ptr);
+ free(ptr);
done:
return i;
}
@@ -1053,7 +1053,7 @@ FUNW(history)(TYPE(History) *h, TYPE(HistEvent) *ev, int fun, ...)
{
TYPE(History) hf;
- hf.h_ref = va_arg(va, ptr_t);
+ hf.h_ref = va_arg(va, void *);
h->h_ent = -1;
hf.h_first = va_arg(va, history_gfun_t);
hf.h_next = va_arg(va, history_gfun_t);