6 extern char *get_curr_cmd(void);
7 extern void update_curr_cmd(char *);
8 //extern char *get_cmd_str(int);
16 update_cmd_history(char *s
)
18 // reset history pointer
29 if (i
!= j
&& strcmp(s
, buf
[(i
+ N
- 1) % N
]) == 0)
45 // k != i indicates curr cmd is historical
52 // save curr cmd if new input or change to historical input
57 if (k
== i
|| strcmp(s
, buf
[k
]) != 0) {
58 update_cmd_history(s
);
65 // retard history pointer
71 update_curr_cmd(buf
[k
]);
81 // save curr cmd if new input or change to historical input
86 if (k
== i
|| strcmp(s
, buf
[k
]) != 0) {
87 update_cmd_history(s
);
94 // advance history pointer
100 update_curr_cmd(buf
[k
]);
106 get_cmd_history(void)
116 n
+= (int) strlen(buf
[k
]) + 2;
120 s
= (char *) malloc(n
+ 1);