1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
*** sim/spice/common/src/lib/cp/history.c.orig Sat Jan 29 18:44:09 1994
--- sim/spice/common/src/lib/cp/history.c Sun Dec 12 14:56:43 1999
***************
*** 11,16 ****
--- 11,24 ----
#include "cpdefs.h"
#include "suffix.h"
+ #ifdef HAS_GNUREADLINE
+
+ /* Added GNU Readline Support -- Andrew Veliath <veliaa@rpi.edu> */
+ #include <readline/readline.h>
+ #include <readline/history.h>
+
+ #endif /* HAS_GNUREADLINE */
+
static char *dohs();
static void freehist();
static wordlist *dohmod();
***************
*** 19,24 ****
--- 27,33 ----
static wordlist *hpattern();
static wordlist *hprefix();
+
struct histent *cp_lastone = NULL;
int cp_maxhistlength = 1000;
char cp_hat = '^';
***************
*** 345,352 ****
--- 354,363 ----
cp_lastone->hi_next = NULL;
cp_lastone->hi_event = event;
cp_lastone->hi_wlist = wl_copy(wlist);
+ #ifndef HAS_GNUREADLINE
freehist(histlength - cp_maxhistlength);
histlength++;
+ #endif
return;
}
***************
*** 483,492 ****
--- 494,529 ----
wl = wl->wl_next;
rev = true;
}
+ #ifdef HAS_GNUREADLINE
+ /* Added GNU Readline Support -- Andrew Veliath <veliaa@rpi.edu> */
+ {
+ HIST_ENTRY *he;
+ int i, N;
+
+ N = (wl == NULL) ? history_length : atoi(wl->wl_word);
+
+ if (N < 0) N = 0;
+ if (N > history_length) N = history_length;
+
+ if (rev)
+ for (i = history_length; i > 0 && N; --i, --N) {
+ he = history_get(i);
+ if (!he) return;
+ fprintf(cp_out, "%d\t%s\n", i, he->line);
+ }
+ else
+ for (i = history_length - N + 1; i <= history_length; ++i) {
+ he = history_get(i);
+ if (!he) return;
+ fprintf(cp_out, "%d\t%s\n", i, he->line);
+ }
+ }
+ #else
if (wl == NULL)
cp_hprint(cp_event - 1, cp_event - histlength, rev);
else
cp_hprint(cp_event - 1, cp_event - 1 - atoi(wl->wl_word), rev);
+ #endif /* ifelse HAS_GNUREADLINE */
return;
}
|