summaryrefslogtreecommitdiff
path: root/pith
diff options
context:
space:
mode:
Diffstat (limited to 'pith')
-rw-r--r--pith/hist.c44
-rw-r--r--pith/hist.h2
2 files changed, 3 insertions, 43 deletions
diff --git a/pith/hist.c b/pith/hist.c
index 9d5022c9..0776305f 100644
--- a/pith/hist.c
+++ b/pith/hist.c
@@ -60,55 +60,17 @@ free_hist(HISTORY_S **history)
char *
hist_in_pos(int pos, char **list, int llen, HISTORY_S *hist, int n)
{
- char *p;
- int i;
-
if(pos < 0 || pos > llen + n)
return NULL;
if(pos < llen)
return list[pos];
- hist->curindex = hist->origindex; /* reset history */
- for(i = 0; i < n-1; i++)
- p = get_prev_hist_dir(hist);
- p = get_prev_hist_dir(hist);
- for(i = 0; i < pos - llen; i++)
- p = get_next_hist_dir(hist);
- return p;
-}
-
-
-char *
-get_next_hist_dir(HISTORY_S *history)
-{
- return get_next_hist(history, NULL, 0, NULL);
+ hist->curindex = (hist->origindex + n - pos + llen) % hist->histsize;
+ return((hist->hist[hist->curindex] && hist->hist[hist->curindex]->str)
+ ? hist->hist[hist->curindex]->str : NULL);
}
-
-char *
-get_prev_hist_dir(HISTORY_S *history)
-{
- int nextcurindex;
-
- if(!(history && history->histsize > 0))
- return NULL;
-
- nextcurindex = (history->curindex + 1) % history->histsize;
-
- /* already at start of history */
- if(nextcurindex == history->origindex
- || !(history->hist[nextcurindex] && history->hist[nextcurindex]->str
- && history->hist[nextcurindex]->str[0]))
- return NULL;
-
- history->curindex = nextcurindex;
-
- return((history->hist[history->curindex] && history->hist[history->curindex]->str)
- ? history->hist[history->curindex]->str : NULL);
-}
-
-
char *
get_prev_hist(HISTORY_S *history, char *savethis, unsigned saveflags, void *cntxt)
{
diff --git a/pith/hist.h b/pith/hist.h
index 65082998..d34961f9 100644
--- a/pith/hist.h
+++ b/pith/hist.h
@@ -43,8 +43,6 @@ void init_hist(HISTORY_S **, int);
void free_hist(HISTORY_S **);
char *get_prev_hist(HISTORY_S *, char *, unsigned, void *);
char *get_next_hist(HISTORY_S *, char *, unsigned, void *);
-char *get_prev_hist_dir(HISTORY_S *);
-char *get_next_hist_dir(HISTORY_S *);
char *hist_in_pos(int, char **, int, HISTORY_S *, int);
void save_hist(HISTORY_S *, char *, unsigned, void *);
int items_in_hist(HISTORY_S *);