summaryrefslogtreecommitdiff
path: root/pith/hist.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2016-05-13 21:19:43 -0600
committerEduardo Chappa <chappa@washington.edu>2016-05-13 21:19:43 -0600
commitdbb9b8a9c80985dec59650cc9b7a5ec638d4d19a (patch)
treec57cbd37f0e5931b726192caeddedf86339e6ad0 /pith/hist.c
parent398178c265ff68ceeafa6a84089bc01ae949e314 (diff)
downloadalpine-dbb9b8a9c80985dec59650cc9b7a5ec638d4d19a.tar.xz
* Simplify some of the code for the new option for extra directories
for save of attachments or export of files.
Diffstat (limited to 'pith/hist.c')
-rw-r--r--pith/hist.c44
1 files changed, 3 insertions, 41 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)
{